lib/Bio/Roary/PrepareInputFiles.pm

filter: Statementstmt 94.3% 83 / 88 Branchbran 70.0% 7 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 94.4% 17 / 18 Podpod 0.0% 0 / 2 totaltotal 90.6% 107 / 118 CC 8 SCAR 6.6
CC
8
Cov
92%
_build__input_fasta_files
4.0
lookup_fasta_files_from_unknown_input_files
3.0
_build__input_fasta_files_filtered
2.0
CRAP 1.9
« lib/Bio/Roary/SampleOrder.pm ↑ Summary lib/Bio/Roary/External/Mcl.pm »
1 package Bio::Roary::PrepareInputFiles;
2 4 $Bio::Roary::PrepareInputFiles::VERSION = '3.13.0';
3 # ABSTRACT: Take in a mixture of FASTA and GFF input files and output FASTA proteomes only
4  
5  
6 4 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 ▶use Bio::Roary::Exceptions;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 4 ▶use Bio::Roary::ExtractProteomeFromGFFs;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 4 ▶use Bio::Roary::FilterUnknownsFromFasta;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 4 ▶use Cwd qw(getcwd);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 4 ▶use File::Temp;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 4 ▶use Log::Log4perl qw(:easy);
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 4 has 'input_files' => ( is => 'ro', isa => 'ArrayRef', required => 1 );
15 4 has 'job_runner' => ( is => 'ro', isa => 'Str', default => 'Local' );
16 4 has 'cpus' => ( is => 'ro', isa => 'Int', default => 1 );
17 4 has '_input_gff_files' => ( is => 'ro', isa => 'Maybe[ArrayRef]', lazy => 1, builder => '_build__input_gff_files' );
18 4 has '_input_fasta_files' => ( is => 'ro', isa => 'Maybe[ArrayRef]', lazy => 1, builder => '_build__input_fasta_files' );
19 4 has '_input_fasta_files_filtered' => ( is => 'ro', isa => 'Maybe[ArrayRef]', lazy => 1, builder => '_build__input_fasta_files_filtered' );
20 4 has '_input_fasta_files_filtered_obj' =>
21 ( is => 'ro', isa => 'Bio::Roary::FilterUnknownsFromFasta', lazy => 1, builder => '_build__input_fasta_files_filtered_obj' );
22  
23 4 has '_derived_fasta_files' => ( is => 'ro', isa => 'Maybe[ArrayRef]', lazy => 1, builder => '_build__derived_fasta_files' );
24 4 has '_extract_proteome_obj' => (
25 is => 'ro',
26 isa => 'Bio::Roary::ExtractProteomeFromGFFs',
27 lazy => 1,
28 builder => '_build__extract_proteome_obj'
29 );
30 4 has 'apply_unknowns_filter' => ( is => 'rw', isa => 'Bool', default => 1 );
31 4 has 'translation_table' => ( is => 'rw', isa => 'Int', default => 11 );
32 4 has 'verbose' => ( is => 'rw', isa => 'Bool', default => 0 );
33 4 has '_fasta_filter_obj' => ( is => 'ro', isa => 'Bio::Roary::FilterUnknowsFromFasta', lazy => 1, builder => '_fasta_filter_obj' );
34 20 ▶has 'working_directory' => ( is => 'ro', isa => 'File::Temp::Dir', default => sub { File::Temp->newdir( DIR => getcwd, CLEANUP => 1 ); } );
Subroutine __ANON__: called CC=1 SCAR=0.0
35 4 has 'logger' => ( is => 'ro', lazy => 1, builder => '_build_logger' );
36  
37 0 ▶sub _build_logger {
Subroutine _build_logger: not called CC=1 SCAR=6.9
38 0 my ($self) = @_;
39 0 Log::Log4perl->easy_init($ERROR);
40 0 my $logger = get_logger();
41 0 return $logger;
42 }
43  
44 19 ▶sub _build__input_gff_files {
Subroutine _build__input_gff_files: called CC=1 SCAR=0.0
45 19 my ($self) = @_;
46 19 my @gff_files = grep( /\.gff$/, @{ $self->input_files } );
47 19 return \@gff_files;
48 }
49  
50 19 ▶sub _build__input_fasta_files {
Subroutine _build__input_fasta_files: called CC=4 SCAR=13.9
51 19 my ($self) = @_;
52 19 my @fasta_files = grep( !/\.gff$/, @{ $self->input_files } );
53  
54 19 my @validated_fasta_files;
55  
56 19 for my $fasta_file (@fasta_files) {
57 44 eval {
58 44 my $inseq = Bio::SeqIO->new(
59 -file => $fasta_file,
60 -format => 'fasta',
61 -alphabet => 'protein'
62 );
63 44 ▶ while ( my $seq = $inseq->next_seq ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $seq = $inseq->next_seq) 183 44 227
64  
65 # do something to force the reading.
66 183 $seq->seq;
67 }
68 };
69 44 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) { } 0 44 44
70 0 $self->logger->warn(
71 "Input file doesnt have a .gff extension and isnt a protein FASTA file so excluding it from further analysis: $fasta_file"
72 );
73 }
74 else {
75 44 push( @validated_fasta_files, $fasta_file );
76 }
77  
78 }
79  
80 19 return \@fasta_files;
81 }
82  
83 19 ▶sub _build__input_fasta_files_filtered_obj {
Subroutine _build__input_fasta_files_filtered_obj: called CC=1 SCAR=0.0
84 19 my ($self) = @_;
85 19 return Bio::Roary::FilterUnknownsFromFasta->new( fasta_files => $self->_input_fasta_files );
86 }
87  
88 19 ▶sub _build__input_fasta_files_filtered {
Subroutine _build__input_fasta_files_filtered: called CC=2 SCAR=7.1
89 19 my ($self) = @_;
90 19 ▶ return undef if ( !defined( $self->_input_fasta_files ) );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->_input_fasta_files 0 19 19
91 19 return $self->_input_fasta_files_filtered_obj->filtered_fasta_files();
92 }
93  
94 19 ▶sub _build__extract_proteome_obj {
Subroutine _build__extract_proteome_obj: called CC=1 SCAR=0.0
95 19 my ($self) = @_;
96 19 return Bio::Roary::ExtractProteomeFromGFFs->new(
97 gff_files => $self->_input_gff_files,
98 job_runner => $self->job_runner,
99 apply_unknowns_filter => $self->apply_unknowns_filter,
100 translation_table => $self->translation_table,
101 cpus => $self->cpus,
102 verbose => $self->verbose,
103 working_directory => $self->working_directory,
104 );
105 }
106  
107 19 ▶sub _build__derived_fasta_files {
Subroutine _build__derived_fasta_files: called CC=2 SCAR=7.1
108 19 my ($self) = @_;
109 19 ▶ return undef if ( !defined( $self->_input_gff_files ) );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->_input_gff_files 0 19 19
110 19 return $self->_extract_proteome_obj->fasta_files();
111 }
112  
113 59 ▶sub fasta_files {
Subroutine fasta_files: called CC=1 SCAR=0.0
Pod undocumented
114 59 my ($self) = @_;
115 59 my @output_fasta_files = ( @{ $self->_input_fasta_files_filtered }, @{ $self->_derived_fasta_files } );
116 59 return \@output_fasta_files;
117 }
118  
119 15 ▶sub lookup_fasta_files_from_unknown_input_files {
Subroutine lookup_fasta_files_from_unknown_input_files: called CC=3 SCAR=11.0
Pod undocumented
120 15 my ( $self, $input_files ) = @_;
121 15 $self->fasta_files;
122  
123 15 my @output_fasta_files;
124 15 for my $input_file ( @{$input_files} ) {
125 23 ▶ if ( defined( $self->_extract_proteome_obj->fasta_files_to_gff_files->{$input_file} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->_extract_proteome_obj->fasta_files_to_gff_files->{$input_file}) { } 4 19 23
126 4 push( @output_fasta_files, $self->_extract_proteome_obj->fasta_files_to_gff_files->{$input_file} );
127 }
128 else {
129 19 push( @output_fasta_files, $self->_input_fasta_files_filtered_obj->input_fasta_to_output_fasta->{$input_file} );
130 }
131 }
132 15 return \@output_fasta_files;
133 }
134  
135 4 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
136 4 __PACKAGE__->meta->make_immutable;
137  
138 4 1;
139  
140 __END__
« lib/Bio/Roary/SampleOrder.pm ↑ Summary lib/Bio/Roary/External/Mcl.pm »