lib/Bio/Roary/CommandLine/RoaryPostAnalysis.pm

filter: Statementstmt 44.8% 52 / 116 Branchbran 0.0% 0 / 56 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 57.1% 8 / 14 Podpod 0.0% 0 / 3 totaltotal 30.1% 60 / 199 CC 31 SCAR 54.6
CC
31
Cov
29%
BUILD
462.0
run
72.0
_is_lsf_job_runner_available
12.0
CRAP 235.0
↑ Summary lib/Bio/Roary/CommandLine/Roary.pm »
1 1 undef $VERSION;
2 package Bio::Roary::CommandLine::RoaryPostAnalysis;
3 1 $Bio::Roary::CommandLine::RoaryPostAnalysis::VERSION = '3.13.0';
4 # ABSTRACT: Perform the post analysis on the pan genome
5  
6  
7 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Getopt::Long qw(GetOptionsFromArray);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Bio::Roary::PostAnalysis;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use File::Find::Rule;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use Bio::Roary::External::GeneAlignmentFromNucleotides;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use File::Path qw(remove_tree);
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use Bio::Roary::External::Fasttree;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 extends 'Bio::Roary::CommandLine::Common';
15  
16 1 has 'args' => ( is => 'ro', isa => 'ArrayRef', required => 1 );
17 1 has 'script_name' => ( is => 'ro', isa => 'Str', required => 1 );
18 1 has 'help' => ( is => 'rw', isa => 'Bool', default => 0 );
19 1 has '_error_message' => ( is => 'rw', isa => 'Str' );
20  
21 1 has 'fasta_files' => ( is => 'rw', isa => 'Str', default => '_fasta_files' );
22 1 has 'input_files' => ( is => 'rw', isa => 'Str', default => '_gff_files');
23 1 has 'output_filename' => ( is => 'rw', isa => 'Str', default => 'clustered_proteins' );
24 1 has 'output_pan_geneome_filename' => ( is => 'rw', isa => 'Str', default => 'pan_genome.fa' );
25 1 has 'output_statistics_filename' => ( is => 'rw', isa => 'Str', default => 'gene_presence_absence.csv' );
26 1 has 'output_multifasta_files' => ( is => 'rw', isa => 'Bool', default => 0 );
27 1 has 'clusters_filename' => ( is => 'rw', isa => 'Str', default => '_clustered.clstr' );
28 1 has 'job_runner' => ( is => 'rw', isa => 'Str', default => 'Local' );
29 1 has 'cpus' => ( is => 'rw', isa => 'Int', default => 1 );
30 1 has 'dont_delete_files' => ( is => 'rw', isa => 'Bool', default => 0 );
31 1 has 'dont_create_rplots' => ( is => 'rw', isa => 'Bool', default => 0 );
32 1 has 'dont_split_groups' => ( is => 'rw', isa => 'Bool', default => 0 );
33 1 has 'verbose_stats' => ( is => 'rw', isa => 'Bool', default => 0 );
34 1 has 'translation_table' => ( is => 'rw', isa => 'Int', default => 11 );
35 1 has 'group_limit' => ( is => 'rw', isa => 'Num', default => 50000 );
36 1 has 'core_definition' => ( is => 'rw', isa => 'Num', default => 0.99 );
37 1 has 'verbose' => ( is => 'rw', isa => 'Bool', default => 0 );
38 1 has 'mafft' => ( is => 'rw', isa => 'Bool', default => 0 );
39 1 has 'allow_paralogs' => ( is => 'rw', isa => 'Bool', default => 0 );
40  
41 0 ▶sub BUILD {
Subroutine BUILD: not called CC=21 SCAR=61.4
Pod undocumented
42 0 my ($self) = @_;
43  
44 my (
45 0 $output_filename, $dont_create_rplots, $dont_delete_files, $dont_split_groups, $output_pan_geneome_filename,
46 $job_runner, $output_statistics_filename, $output_multifasta_files, $clusters_filename, $core_definition,
47 $fasta_files, $input_files, $verbose_stats, $translation_table, $help, $cpus,$group_limit,$verbose,$mafft, $allow_paralogs
48 );
49  
50  
51 0 GetOptionsFromArray(
52 $self->args,
53 'o|output=s' => \$output_filename,
54 'j|job_runner=s' => \$job_runner,
55 'm|output_multifasta_files' => \$output_multifasta_files,
56 'p=s' => \$output_pan_geneome_filename,
57 's=s' => \$output_statistics_filename,
58 'c=s' => \$clusters_filename,
59 'f=s' => \$fasta_files,
60 'i=s' => \$input_files,
61 'a|dont_delete_files' => \$dont_delete_files,
62 'b|dont_create_rplots' => \$dont_create_rplots,
63 'd|dont_split_groups' => \$dont_split_groups,
64 'e|verbose_stats' => \$verbose_stats,
65 'z|processors=i' => \$cpus,
66 't|translation_table=i' => \$translation_table,
67 'g|group_limit=i' => \$group_limit,
68 'cd|core_definition=f' => \$core_definition,
69 'v|verbose' => \$verbose,
70 'n|mafft' => \$mafft,
71 'q|allow_paralogs' => \$allow_paralogs,
72 'h|help' => \$help,
73 );
74
75 0 ▶ $self->help($help) if(defined($help));
Branch: 1 branch
BranchTrueFalseTotal
if defined $help 0 0 0
76 0 ▶ $self->job_runner($job_runner) if ( defined($job_runner) );
Branch: 1 branch
BranchTrueFalseTotal
if defined $job_runner 0 0 0
77 0 ▶ $self->fasta_files($fasta_files) if ( defined($fasta_files) );
Branch: 1 branch
BranchTrueFalseTotal
if defined $fasta_files 0 0 0
78 0 ▶ $self->input_files($input_files) if ( defined($input_files) );
Branch: 1 branch
BranchTrueFalseTotal
if defined $input_files 0 0 0
79 0 ▶ $self->output_filename($output_filename) if ( defined($output_filename) );
Branch: 1 branch
BranchTrueFalseTotal
if defined $output_filename 0 0 0
80 0 ▶ $self->output_pan_geneome_filename($output_pan_geneome_filename) if ( defined($output_pan_geneome_filename) );
Branch: 1 branch
BranchTrueFalseTotal
if defined $output_pan_geneome_filename 0 0 0
81 0 ▶ $self->output_statistics_filename($output_statistics_filename) if ( defined($output_statistics_filename) );
Branch: 1 branch
BranchTrueFalseTotal
if defined $output_statistics_filename 0 0 0
82 0 ▶ $self->output_multifasta_files($output_multifasta_files) if ( defined($output_multifasta_files) );
Branch: 1 branch
BranchTrueFalseTotal
if defined $output_multifasta_files 0 0 0
83 0 ▶ $self->clusters_filename($clusters_filename) if ( defined($clusters_filename) );
Branch: 1 branch
BranchTrueFalseTotal
if defined $clusters_filename 0 0 0
84 0 ▶ $self->dont_delete_files($dont_delete_files) if ( defined($dont_delete_files) );
Branch: 1 branch
BranchTrueFalseTotal
if defined $dont_delete_files 0 0 0
85 0 ▶ $self->dont_create_rplots($dont_create_rplots) if ( defined($dont_create_rplots) );
Branch: 1 branch
BranchTrueFalseTotal
if defined $dont_create_rplots 0 0 0
86 0 ▶ $self->dont_split_groups($dont_split_groups) if ( defined($dont_split_groups) );
Branch: 1 branch
BranchTrueFalseTotal
if defined $dont_split_groups 0 0 0
87 0 ▶ $self->verbose_stats($verbose_stats) if ( defined($verbose_stats));
Branch: 1 branch
BranchTrueFalseTotal
if defined $verbose_stats 0 0 0
88 0 ▶ $self->translation_table($translation_table) if ( defined($translation_table) );
Branch: 1 branch
BranchTrueFalseTotal
if defined $translation_table 0 0 0
89 0 ▶ $self->cpus($cpus) if ( defined($cpus) );
Branch: 1 branch
BranchTrueFalseTotal
if defined $cpus 0 0 0
90 0 ▶ $self->group_limit($group_limit) if ( defined($group_limit) );
Branch: 1 branch
BranchTrueFalseTotal
if defined $group_limit 0 0 0
91 0 ▶ $self->core_definition( $core_definition/100 ) if ( defined($core_definition) );
Branch: 1 branch
BranchTrueFalseTotal
if defined $core_definition 0 0 0
92 0 ▶ $self->mafft($mafft) if ( defined($mafft) );
Branch: 1 branch
BranchTrueFalseTotal
if defined $mafft 0 0 0
93 0 ▶ $self->allow_paralogs($allow_paralogs) if ( defined($allow_paralogs) );
Branch: 1 branch
BranchTrueFalseTotal
if defined $allow_paralogs 0 0 0
94 0 ▶ if ( defined($verbose) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $verbose) 0 0 0
95 0 $self->verbose($verbose);
96 0 $self->logger->level(10000);
97 }
98 }
99  
100 0 ▶sub run {
Subroutine run: not called CC=8 SCAR=42.8
Pod undocumented
101 0 my ($self) = @_;
102  
103 0 ▶ ( !$self->help ) or die $self->usage_text;
Branch: 1 branch
BranchTrueFalseTotal
$self->help and die $self->usage_text 0 0 0
104 0 ▶ if ( defined( $self->_error_message ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->_error_message) 0 0 0
105 0 print $self->_error_message . "\n";
106 0 die $self->usage_text;
107 }
108  
109 0 my $input_files = $self->_read_file_into_array($self->input_files);
110 0 my $obj = Bio::Roary::PostAnalysis->new(
111 fasta_files => $self->_read_file_into_array($self->fasta_files) ,
112 input_files => $input_files ,
113 output_filename => $self->output_filename ,
114 output_pan_geneome_filename => $self->output_pan_geneome_filename,
115 output_statistics_filename => $self->output_statistics_filename ,
116 output_multifasta_files => $self->output_multifasta_files ,
117 clusters_filename => $self->clusters_filename ,
118 dont_delete_files => $self->dont_delete_files,
119 dont_create_rplots => $self->dont_create_rplots,
120 dont_split_groups => $self->dont_split_groups,
121 verbose_stats => $self->verbose_stats,
122 group_limit => $self->group_limit,
123 verbose => $self->verbose,
124 cpus => $self->cpus,
125 logger => $self->logger,
126 core_definition => $self->core_definition,
127 );
128 0 $obj->run();
129
130 0 ▶ if($self->dont_delete_files == 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($self->dont_delete_files == 0) 0 0 0
131 {
132 0 unlink('_inflated_unsplit_mcl_groups');
133 0 remove_tree('split_groups');
134 }
135  
136 0 ▶ if($self->output_multifasta_files == 1)
Branch: 1 branch
BranchTrueFalseTotal
if ($self->output_multifasta_files == 1) 0 0 0
137 {
138 0 ▶ print "Aligning each cluster\n" if($self->verbose);
Branch: 1 branch
BranchTrueFalseTotal
if $self->verbose 0 0 0
139
140 0 my $job_runner_to_use = $self->job_runner;
141 0 ▶ if($self->_is_lsf_job_runner_available && $self->job_runner eq "LSF")
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_is_lsf_job_runner_available and $self->job_runner eq 'LSF') { } 0 0 0
Condition0%0/3
$self->_is_lsf_job_runner_available and $self->job_runner eq "LSF"
!ll&&!rl&&r
000
MC/DC0%0/2
$self->_is_lsf_job_runner_available and $self->job_runner eq "LSF"
$self->_is_lsf_job_runner_available $self->job_runner eq "LSF"
Truth table0%0/3
A and B
A= $self->_is_lsf_job_runner_availableB= $self->job_runner eq "LSF"
ABresult
0X0
100
111
142 {
143 0 $job_runner_to_use = $self->job_runner;
144 }
145 else
146 {
147 0 $job_runner_to_use = 'Parallel';
148 }
149
150 0 my $output_gene_files = $self->_find_input_files;
151 my $seg = Bio::Roary::External::GeneAlignmentFromNucleotides->new(
152 fasta_files => $output_gene_files,
153 job_runner => $job_runner_to_use,
154 translation_table => $self->translation_table,
155 core_definition => $self->core_definition,
156 cpus => $self->cpus,
157 verbose => $self->verbose,
158 mafft => $self->mafft,
159 allow_paralogs => $self->allow_paralogs,
160 dont_delete_files => $self->dont_delete_files,
161 0 num_input_files => $#{$input_files},
162 );
163 0 $seg->run();
164 }
165 }
166  
167 sub _is_lsf_job_runner_available
168 0 ▶{
Subroutine _is_lsf_job_runner_available: not called CC=3 SCAR=24.8
169 0 my ($self) = @_;
170 0 my $rc = eval "require Bio::Roary::JobRunner::LSF; 1;";
171 0 ▶ if(defined($rc) && $rc == 1)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $rc and $rc == 1) { } 0 0 0
Condition0%0/3
defined $rc and $rc == 1
!ll&&!rl&&r
000
MC/DC0%0/2
defined $rc and $rc == 1
defined $rc $rc == 1
Truth table0%0/3
A and B
A= defined $rcB= $rc == 1
ABresult
0X0
100
111
172 {
173 0 return 1;
174 }
175 else
176 {
177 0 return 0;
178 }
179 }
180  
181 sub _find_input_files
182 0 ▶{
Subroutine _find_input_files: not called CC=1 SCAR=6.9
183 0 my ($self) = @_;
184 0 my @files = File::Find::Rule->file()
185 ->name( '*.fa' )
186 ->in('pan_genome_sequences' );
187 0 return \@files;
188 }
189  
190 sub _read_file_into_array
191 0 ▶{
Subroutine _read_file_into_array: not called CC=2 SCAR=17.9
192 0 my ($self, $filename) = @_;
193 0 open(my $in_fh, $filename);
194
195 0 my @filenames;
196 0 ▶ while(<$in_fh>){
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $in_fh)) 0 0 0
197 0 chomp;
198 0 my $line = $_;
199 0 push(@filenames, $line);
200 }
201 0 return \@filenames;
202 }
203  
204 0 ▶sub usage_text {
Subroutine usage_text: not called CC=1 SCAR=6.9
Pod undocumented
205 0 my ($self) = @_;
206  
207 0 return <<USAGE;
208 Usage: pan_genome_post_analysis [options]
209 Perform the post analysis on the pan genome. This script is usally only called by another script.
210  
211 Options: -a dont delete intermediate files
212 -b dont create R plots
213 -c STR clusters filename [_clustered.clstr]
214 -cd FLOAT percentage of isolates a gene must be in to be core [0.99]
215 -d dont split groups
216 -e add inference values to gene presence and absence spreadsheet
217 -f STR file of protein filenames [_fasta_files]
218 -g INT maximum number of clusters [50000]
219 -i STR file of GFF filenames [_gff_files]
220 -m core gene alignement with PRANK
221 -n fast core gene alignement with MAFFT instead of PRANK
222 -o STR clusters output filename [clustered_proteins]
223 -p STR output pan genome filename [pan_genome.fa]
224 -q allow paralogs in core alignment
225 -s STR output gene presence and absence filename [gene_presence_absence.csv]
226 -t INT translation table [11]
227 -z INT number of threads [1]
228 -v verbose output to STDOUT
229 -h this help message
230
231 For further info see: http://sanger-pathogens.github.io/Roary/
232 USAGE
233 }
234  
235 1 __PACKAGE__->meta->make_immutable;
236 1 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
237 1 1;
238  
239 __END__
↑ Summary lib/Bio/Roary/CommandLine/Roary.pm »