lib/Bio/Roary/External/PostAnalysis.pm

filter: Statementstmt 38.3% 38 / 99 Branchbran 0.0% 0 / 22 Conditioncond 0.0% 0 / 24 MC/DCmcdc 0.0% 0 / 16 Subroutinesub 25.0% 3 / 12 Podpod 0.0% 0 / 1 totaltotal 23.5% 41 / 174 CC 22 SCAR 50.8
CC
22
Cov
26%
_command_to_run
306.0
_build__queue
12.0
_build_memory_in_mb
6.0
CRAP 160.1
« lib/Bio/Roary/CommandLine/Roary.pm ↑ Summary blib/lib/Bio/Roary/CommandLine/AssemblyStatistics.pm »
1 package Bio::Roary::External::PostAnalysis;
2 1 $Bio::Roary::External::PostAnalysis::VERSION = '3.13.0';
3 # ABSTRACT: Perform the post analysis
4  
5  
6 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Cwd qw(getcwd);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 with 'Bio::Roary::JobRunner::Role';
9  
10 1 has 'input_files' => ( is => 'ro', isa => 'ArrayRef', required => 1 );
11 1 has 'exec' => ( is => 'ro', isa => 'Str', default => 'pan_genome_post_analysis' );
12 1 has 'fasta_files' => ( is => 'ro', isa => 'ArrayRef', required => 1 );
13 1 has 'output_filename' => ( is => 'ro', isa => 'Str', required => 1 );
14 1 has 'output_pan_geneome_filename' => ( is => 'ro', isa => 'Str', required => 1 );
15 1 has 'output_statistics_filename' => ( is => 'ro', isa => 'Str', required => 1 );
16 1 has 'clusters_filename' => ( is => 'ro', isa => 'Str', required => 1 );
17 1 has 'output_multifasta_files' => ( is => 'ro', isa => 'Bool', required => 1 );
18 1 has 'dont_delete_files' => ( is => 'ro', isa => 'Bool', default => 0 );
19 1 has 'dont_create_rplots' => ( is => 'rw', isa => 'Bool', default => 0 );
20 1 has 'dont_split_groups' => ( is => 'rw', isa => 'Bool', default => 0 );
21 1 has 'verbose_stats' => ( is => 'rw', isa => 'Bool', default => 0 );
22 1 has 'translation_table' => ( is => 'rw', isa => 'Int', default => 11 );
23 1 has 'group_limit' => ( is => 'rw', isa => 'Num', default => 50000 );
24 1 has 'core_definition' => ( is => 'ro', isa => 'Num', default => 1.0 );
25 1 has 'verbose' => ( is => 'rw', isa => 'Bool', default => 0 );
26 1 has 'mafft' => ( is => 'ro', isa => 'Bool', default => 0 );
27 1 has 'allow_paralogs' => ( is => 'ro', isa => 'Bool', default => 0 );
28 0 ▶has '_working_directory' => ( is => 'ro', isa => 'File::Temp::Dir', default => sub { File::Temp->newdir( DIR => getcwd, CLEANUP => 1 ); } );
Subroutine __ANON__: not called CC=1 SCAR=1.2
29 1 has '_gff_fofn' => ( is => 'ro', isa => 'Str', lazy => 1, builder => '_build__gff_fofn' );
30 1 has '_fasta_fofn' => ( is => 'ro', isa => 'Str', lazy => 1, builder => '_build__fasta_fofn' );
31  
32 # Overload Role
33 1 has 'memory_in_mb' => ( is => 'ro', isa => 'Int', lazy => 1, builder => '_build_memory_in_mb' );
34 1 has '_minimum_memory_mb' => ( is => 'ro', isa => 'Int', default => 4000 );
35 1 has '_memory_per_sample_mb' => ( is => 'ro', isa => 'Int', default => 30 );
36 1 has '_queue' => ( is => 'rw', isa => 'Str', lazy => 1, builder => '_build__queue');
37  
38  
39 0 ▶sub _build__queue {
Subroutine _build__queue: not called CC=3 SCAR=24.8
40 0 my ($self) = @_;
41 0 my $queue = 'normal';
42 0 my $num_samples = @{ $self->input_files };
43 0 ▶ if($num_samples > 200)
Branch: 2 branches
BranchTrueFalseTotal
if ($num_samples > 200) { } 0 0 0
elsif ($num_samples > 600) { } 0 0 0
44 {
45 0 $queue = 'long';
46 }
47 elsif($num_samples > 600)
48 {
49 0 $queue = 'basement';
50 }
51 0 return $queue;
52 }
53  
54  
55 0 ▶sub _build_memory_in_mb {
Subroutine _build_memory_in_mb: not called CC=2 SCAR=17.9
56 0 my ($self) = @_;
57 0 my $num_samples = @{ $self->input_files };
58  
59 0 my $memory_required = $num_samples * $self->_memory_per_sample_mb;
60 0 ▶ if ( $memory_required < $self->_minimum_memory_mb ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($memory_required < $self->_minimum_memory_mb) 0 0 0
61 0 $memory_required = $self->_minimum_memory_mb;
62 }
63  
64 0 return $memory_required;
65 }
66  
67 sub _build__gff_fofn
68 0 ▶{
Subroutine _build__gff_fofn: not called CC=1 SCAR=6.9
69 0 my ($self) = @_;
70 0 return join('/', ($self->_working_directory, '/_gff_files'));
71 }
72  
73 sub _build__fasta_fofn
74 0 ▶{
Subroutine _build__fasta_fofn: not called CC=1 SCAR=6.9
75 0 my ($self) = @_;
76 0 return join('/', ($self->_working_directory, '/_fasta_files'));
77 }
78  
79  
80 sub _output_gff_files
81 0 ▶{
Subroutine _output_gff_files: not called CC=2 SCAR=17.9
82 0 my ($self) = @_;
83 0 open(my $out_fh, '>', $self->_gff_fofn);
84 0 for my $filename (@{$self->input_files})
85 {
86 0 print {$out_fh} $filename."\n";
87 }
88 0 close($out_fh);
89 }
90  
91 sub _output_fasta_files
92 0 ▶{
Subroutine _output_fasta_files: not called CC=2 SCAR=17.9
93 0 my ($self) = @_;
94 0 open(my $out_fh, '>', $self->_fasta_fofn);
95 0 for my $filename (@{$self->fasta_files})
96 {
97 0 print {$out_fh} $filename."\n";
98 }
99 0 close($out_fh);
100 }
101  
102 0 ▶sub _command_to_run {
Subroutine _command_to_run: not called CC=17 SCAR=57.2
103 0 my ($self) = @_;
104
105 0 $self->_output_fasta_files;
106 0 $self->_output_gff_files;
107
108 0 my $output_multifasta_files_flag = '';
109 0 ▶ $output_multifasta_files_flag = '--output_multifasta_files' if(defined($self->output_multifasta_files) && $self->output_multifasta_files == 1);
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->output_multifasta_files and $self->output_multifasta_files == 1 0 0 0
Condition0%0/3
defined $self->output_multifasta_files and $self->output_multifasta_files == 1
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->output_multifasta_files and $self->output_multifasta_files == 1
defined $self->output_multifasta_files $self->output_multifasta_files == 1
Truth table0%0/3
A and B
A= defined $self->output_multifasta_filesB= $self->output_multifasta_files == 1
ABresult
0X0
100
111
110  
111 0 my $dont_delete_files_flag = '';
112 0 ▶ $dont_delete_files_flag = '--dont_delete_files' if(defined($self->dont_delete_files) && $self->dont_delete_files == 1);
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->dont_delete_files and $self->dont_delete_files == 1 0 0 0
Condition0%0/3
defined $self->dont_delete_files and $self->dont_delete_files == 1
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->dont_delete_files and $self->dont_delete_files == 1
defined $self->dont_delete_files $self->dont_delete_files == 1
Truth table0%0/3
A and B
A= defined $self->dont_delete_filesB= $self->dont_delete_files == 1
ABresult
0X0
100
111
113
114 0 my $dont_create_rplots_flag = '';
115 0 ▶ $dont_create_rplots_flag = '--dont_create_rplots' if(defined($self->dont_create_rplots) && $self->dont_create_rplots == 1);
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->dont_create_rplots and $self->dont_create_rplots == 1 0 0 0
Condition0%0/3
defined $self->dont_create_rplots and $self->dont_create_rplots == 1
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->dont_create_rplots and $self->dont_create_rplots == 1
defined $self->dont_create_rplots $self->dont_create_rplots == 1
Truth table0%0/3
A and B
A= defined $self->dont_create_rplotsB= $self->dont_create_rplots == 1
ABresult
0X0
100
111
116
117 0 my $dont_split_groups_flag = '';
118 0 ▶ $dont_split_groups_flag = '--dont_split_groups' if ( defined $self->dont_split_groups && $self->dont_split_groups == 1 );
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->dont_split_groups and $self->dont_split_groups == 1 0 0 0
Condition0%0/3
defined $self->dont_split_groups and $self->dont_split_groups == 1
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->dont_split_groups and $self->dont_split_groups == 1
defined $self->dont_split_groups $self->dont_split_groups == 1
Truth table0%0/3
A and B
A= defined $self->dont_split_groupsB= $self->dont_split_groups == 1
ABresult
0X0
100
111
119  
120 0 my $verbose_stats_flag = '';
121 0 ▶ $verbose_stats_flag = '--verbose_stats' if ( defined($self->verbose_stats) && $self->verbose_stats == 1 );
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->verbose_stats and $self->verbose_stats == 1 0 0 0
Condition0%0/3
defined $self->verbose_stats and $self->verbose_stats == 1
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->verbose_stats and $self->verbose_stats == 1
defined $self->verbose_stats $self->verbose_stats == 1
Truth table0%0/3
A and B
A= defined $self->verbose_statsB= $self->verbose_stats == 1
ABresult
0X0
100
111
122
123 0 my $mafft_flag = '';
124 0 ▶ $mafft_flag = '--mafft' if ( defined($self->mafft) && $self->mafft == 1 );
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->mafft and $self->mafft == 1 0 0 0
Condition0%0/3
defined $self->mafft and $self->mafft == 1
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->mafft and $self->mafft == 1
defined $self->mafft $self->mafft == 1
Truth table0%0/3
A and B
A= defined $self->mafftB= $self->mafft == 1
ABresult
0X0
100
111
125
126 0 my $verbose_flag = '';
127 0 ▶ $verbose_flag = '-v' if ( defined($self->verbose) && $self->verbose == 1 );
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->verbose and $self->verbose == 1 0 0 0
Condition0%0/3
defined $self->verbose and $self->verbose == 1
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->verbose and $self->verbose == 1
defined $self->verbose $self->verbose == 1
Truth table0%0/3
A and B
A= defined $self->verboseB= $self->verbose == 1
ABresult
0X0
100
111
128
129 0 my $allow_paralogs_flag = '';
130 0 ▶ $allow_paralogs_flag = '--allow_paralogs' if ( defined($self->allow_paralogs) && $self->allow_paralogs == 1 );
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->allow_paralogs and $self->allow_paralogs == 1 0 0 0
Condition0%0/3
defined $self->allow_paralogs and $self->allow_paralogs == 1
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->allow_paralogs and $self->allow_paralogs == 1
defined $self->allow_paralogs $self->allow_paralogs == 1
Truth table0%0/3
A and B
A= defined $self->allow_paralogsB= $self->allow_paralogs == 1
ABresult
0X0
100
111
131
132 0 return join(
133 " ",
134 (
135 $self->exec,
136 '-o', $self->output_filename,
137 '-p', $self->output_pan_geneome_filename,
138 '-s', $self->output_statistics_filename,
139 '-c', $self->clusters_filename,
140 $output_multifasta_files_flag,
141 '-i', $self->_gff_fofn,
142 '-f', $self->_fasta_fofn,
143 '-t', $self->translation_table,
144 $dont_delete_files_flag,
145 $dont_create_rplots_flag,
146 $dont_split_groups_flag,
147 $verbose_stats_flag,
148 $verbose_flag,
149 $mafft_flag,
150 $allow_paralogs_flag,
151 '-j', $self->job_runner,
152 '--processors', $self->cpus,
153 '--group_limit', $self->group_limit,
154 '-cd', ($self->core_definition*100)
155 )
156 );
157 }
158  
159 0 ▶sub run {
Subroutine run: not called CC=1 SCAR=6.9
Pod undocumented
160 0 my ($self) = @_;
161  
162 0 my @commands_to_run;
163 0 push( @commands_to_run, $self->_command_to_run );
164 0 $self->logger->info( "Running command: " . $self->_command_to_run() );
165 0 my $job_runner_obj = $self->_job_runner_class->new(
166 commands_to_run => \@commands_to_run,
167 memory_in_mb => $self->memory_in_mb,
168 queue => $self->_queue,
169 dont_wait => $self->dont_wait,
170 cpus => $self->cpus
171 );
172 0 $job_runner_obj->run();
173  
174 0 1;
175 }
176  
177 1 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
178 1 __PACKAGE__->meta->make_immutable;
179 1 1;
180  
181 __END__
« lib/Bio/Roary/CommandLine/Roary.pm ↑ Summary blib/lib/Bio/Roary/CommandLine/AssemblyStatistics.pm »