File Coverage

lib/Bio/MLST/ProcessFasta.pm
Criterion Covered Total %
statement 33 37 89.1
branch n/a
condition n/a
subroutine 12 12 100.0
pod n/a
total 45 49 91.8


line stmt bran cond sub pod time code
1             package Bio::MLST::ProcessFasta;
2             # ABSTRACT: Take in a fasta file, lookup the MLST database and create relevant files.
3             $Bio::MLST::ProcessFasta::VERSION = '2.1.1706216';
4              
5              
6 9     9   34 use Moose;
  9         11  
  9         40  
7 9     9   42358 use Bio::MLST::SearchForFiles;
  9         20  
  9         302  
8 9     9   4291 use Bio::MLST::CompareAlleles;
  9         18  
  9         325  
9 9     9   67 use Bio::MLST::SequenceType;
  9         11  
  9         142  
10 9     9   4230 use Bio::MLST::OutputFasta;
  9         25  
  9         329  
11 9     9   4624 use Bio::MLST::Spreadsheet::Row;
  9         20  
  9         332  
12 9     9   62 use Bio::MLST::Types;
  9         16  
  9         2776  
13              
14             has 'species' => ( is => 'ro', isa => 'Str', required => 1 );
15             has 'base_directory' => ( is => 'ro', isa => 'Str', required => 1 );
16             has 'fasta_file' => ( is => 'ro', isa => 'Bio::MLST::File', required => 1 );
17             has 'makeblastdb_exec' => ( is => 'ro', isa => 'Str', required => 1 );
18             has 'blastn_exec' => ( is => 'ro', isa => 'Str', required => 1 );
19             has 'output_directory' => ( is => 'ro', isa => 'Str', required => 1 );
20             has 'output_fasta_files' => ( is => 'ro', isa => 'Bool', default => 0 );
21             has 'show_contamination_instead_of_alt_matches' => ( is => 'ro', isa => 'Bool', default => 1 );
22             has 'report_lowest_st' => ( is => 'ro', isa => 'Bool', default => 0 );
23              
24             has '_search_results' => ( is => 'ro', isa => 'Bio::MLST::SearchForFiles', lazy => 1, builder => '_build__search_results' );
25             has '_compare_alleles' => ( is => 'ro', isa => 'Bio::MLST::CompareAlleles', lazy => 1, builder => '_build__compare_alleles' );
26             has '_sequence_type_obj' => ( is => 'ro', isa => 'Bio::MLST::SequenceType', lazy => 1, builder => '_build__sequence_type_obj' );
27             has '_spreadsheet_row_obj' => ( is => 'ro', isa => 'Bio::MLST::Spreadsheet::Row', lazy => 1, builder => '_build__spreadsheet_row_obj' );
28              
29             has 'concat_name' => ( is => 'rw', isa => 'Maybe[Str]' );
30             has 'concat_sequence' => ( is => 'rw', isa => 'Maybe[Str]' );
31              
32             sub _build__search_results
33             {
34 4     4   25 my($self) = @_;
35 4         149 Bio::MLST::SearchForFiles->new(
36             species_name => $self->species,
37             base_directory => $self->base_directory
38             );
39             }
40              
41             sub _build__compare_alleles
42             {
43 4     4   9 my($self) = @_;
44 4         124 my $compare_alleles = Bio::MLST::CompareAlleles->new(
45             sequence_filename => $self->fasta_file,
46             allele_filenames => $self->_search_results->allele_filenames(),
47             makeblastdb_exec => $self->makeblastdb_exec,
48             blastn_exec => $self->blastn_exec,
49             profiles_filename => $self->_search_results->profiles_filename()
50             );
51            
52 4         152 my $output_fasta = Bio::MLST::OutputFasta->new(
53             matching_sequences => $compare_alleles->matching_sequences,
54             non_matching_sequences => $compare_alleles->non_matching_sequences,
55             output_directory => $self->output_directory,
56             input_fasta_file => $self->fasta_file
57             );
58 0         0 $output_fasta->create_files();
59 0         0 $self->concat_name($output_fasta->_fasta_filename);
60 0         0 $self->concat_sequence($output_fasta->concat_sequence);
61 0         0 return $compare_alleles;
62             }
63              
64             sub _build__sequence_type_obj
65             {
66 4     4   11 my($self) = @_;
67 4         100 my $sequence_type_obj = Bio::MLST::SequenceType->new(
68             profiles_filename => $self->_search_results->profiles_filename(),
69             matching_names => $self->_compare_alleles->found_sequence_names,
70             non_matching_names => $self->_compare_alleles->found_non_matching_sequence_names,
71             report_lowest_st => $self->report_lowest_st
72             );
73             }
74              
75             sub _build__spreadsheet_row_obj
76             {
77 4     4   17 my($self) = @_;
78 4         147 Bio::MLST::Spreadsheet::Row->new(
79             sequence_type_obj => $self->_sequence_type_obj,
80             compare_alleles => $self->_compare_alleles,
81             show_contamination_instead_of_alt_matches => $self->show_contamination_instead_of_alt_matches
82             );
83             }
84              
85 9     9   45 no Moose;
  9         13  
  9         50  
86             __PACKAGE__->meta->make_immutable;
87             1;
88              
89             __END__
90              
91             =pod
92              
93             =encoding UTF-8
94              
95             =head1 NAME
96              
97             Bio::MLST::ProcessFasta - Take in a fasta file, lookup the MLST database and create relevant files.
98              
99             =head1 VERSION
100              
101             version 2.1.1706216
102              
103             =head1 SYNOPSIS
104              
105             Take in a fasta file, lookup the MLST database and create relevant files.
106              
107             use Bio::MLST::ProcessFasta;
108             Bio::MLST::ProcessFasta->new(
109             'species' => 'E.coli',
110             'base_directory' => '/path/to/dir',
111             'fasta_file' => 'myfasta.fa',
112             'makeblastdb_exec' => 'makeblastdb',
113             'blastn_exec' => 'blastn',
114             'output_directory' => '/path/to/output',
115             'output_fasta_files'=> 1,
116             );
117              
118             =head1 METHODS
119              
120             =head2 concat_name
121              
122             Output the name of the concatinated multifasta file
123              
124             =head2 concat_sequence
125              
126             Output the sequences of the concatinated multifasta file
127              
128             =head2 _spreadsheet_row_obj
129              
130             A row in the output spreadsheet
131              
132             =head1 SEE ALSO
133              
134             =over 4
135              
136             =item *
137              
138             L<Bio::MLST::Check>
139              
140             =back
141              
142             =head1 AUTHOR
143              
144             Andrew J. Page <ap13@sanger.ac.uk>
145              
146             =head1 COPYRIGHT AND LICENSE
147              
148             This software is Copyright (c) 2012 by Wellcome Trust Sanger Institute.
149              
150             This is free software, licensed under:
151              
152             The GNU General Public License, Version 3, June 2007
153              
154             =cut