blib/lib/Bio/Tools/Run/Phylo/Phyml.pm

filter: Statementstmt 27.7% 73 / 263 Branchbran 14.1% 28 / 198 Conditioncond 9.4% 7 / 74 MC/DCmcdc 4.5% 2 / 44 Subroutinesub 39.3% 13 / 33 Podpod 100% 24 / 24 totaltotal 23.1% 147 / 636 CC 129 SCAR 39.0
CC
129
Cov
20%
_setparams
156.0
model
117.0
data_type
90.0
CRAP 49.3
« blib/lib/Bio/Tools/Run/Phylo/Hyphy/Modeltest.pm ↑ Summary blib/lib/Bio/Tools/Run/ERPIN.pm »
1 #
2 # BioPerl module for Bio::Tools::Run::Phylo::Phyml
3 #
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
5 #
6 # Cared for by Heikki Lehvaslaiho
7 #
8 # Copyright Heikki Lehvaslaiho
9 #
10 # You may distribute this module under the same terms as perl itself
11  
12 # POD documentation - main docs before the code
13  
14 =head1 NAME
15  
16 Bio::Tools::Run::Phylo::Phyml - Wrapper for rapid reconstruction of phylogenies using Phyml
17  
18 =head1 SYNOPSIS
19  
20 use Bio::Tools::Run::Phylo::Phyml;
21  
22 # Make a Phyml factory
23 $factory = Bio::Tools::Run::Phylo::Phyml->new(-verbose => 2);
24 # it defaults to protein alignment
25 # change parameters
26 $factory->model('Dayhoff');
27 # Pass the factory an alignment and run
28 $inputfilename = 't/data/protpars.phy';
29 $tree = $factory->run($inputfilename); # $tree is a Bio::Tree::Tree object.
30  
31  
32 # or set parameters at object creation
33 my %args = (
34 -data_type => 'dna',
35 -model => 'HKY',
36 -kappa => 4,
37 -invar => 'e',
38 -category_number => 4,
39 -alpha => 'e',
40 -tree => 'BIONJ',
41 -opt_topology => '0',
42 -opt_lengths => '1',
43 );
44 $factory = Bio::Tools::Run::Phylo::Phyml->new(%args);
45 # if you need the output files do
46 $factory->save_tempfiles(1);
47 $factory->tempdir($workdir);
48  
49 # and get a Bio::Align::AlignI (SimpleAlign) object from somewhere
50 $tree = $factory->run($aln);
51  
52 =head1 DESCRIPTION
53  
54 This is a wrapper for running the phyml application by Stephane
55 Guindon and Olivier Gascuel. You can download it from:
56 http://atgc.lirmm.fr/phyml/
57  
58 =head2 Installing
59  
60 After downloading, you need to rename a the copy of the program that
61 runs under your operating system. I.e. C<phyml_linux> into C<phyml>.
62  
63 You will need to help this Phyml wrapper to find the C<phyml> program.
64 This can be done in (at least) three ways:
65  
66 =over
67  
68 =item 1.
69  
70 Make sure the Phyml executable is in your path. Copy it to, or create
71 a symbolic link from a directory that is in your path.
72  
73 =item 2.
74  
75 Define an environmental variable PHYMLDIR which is a
76 directory which contains the 'phyml' application: In bash:
77  
78 export PHYMLDIR=/home/username/phyml_v2.4.4/exe
79  
80 In csh/tcsh:
81  
82 setenv PHYMLDIR /home/username/phyml_v2.4.4/exe
83  
84 =item 3.
85  
86 Include a definition of an environmental variable PHYMLDIR in
87 every script that will use this Phyml wrapper module, e.g.:
88  
89 BEGIN { $ENV{PHYMLDIR} = '/home/username/phyml_v2.4.4/exe' }
90 use Bio::Tools::Run::Phylo::Phyml;
91  
92 =back
93  
94 =head2 Running
95  
96 This wrapper has been tested with PHYML v2.4.4 and v.3.0
97  
98 In its current state, the wrapper supports only input of one MSA and
99 output of one tree. It can easily be extended to support more advanced
100 capabilities of C<phyml>.
101  
102 Two convienience methods have been added on top of the standard
103 BioPerl WrapperBase ones: stats() and tree_string(). You can call them
104 to after running the phyml program to retrieve into a string the statistics
105 and the tree in Newick format.
106  
107 =head1 FEEDBACK
108  
109 =head2 Mailing Lists
110  
111 User feedback is an integral part of the evolution of this and other
112 Bioperl modules. Send your comments and suggestions preferably to
113 the Bioperl mailing list. Your participation is much appreciated.
114  
115 bioperl-l@bioperl.org - General discussion
116 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
117  
118 =head2 Support
119  
120 Please direct usage questions or support issues to the mailing list:
121  
122 I<bioperl-l@bioperl.org>
123  
124 rather than to the module maintainer directly. Many experienced and
125 reponsive experts will be able look at the problem and quickly
126 address it. Please include a thorough description of the problem
127 with code and data examples if at all possible.
128  
129 =head2 Reporting Bugs
130  
131 Report bugs to the Bioperl bug tracking system to help us keep track
132 of the bugs and their resolution. Bug reports can be submitted via
133 the web:
134  
135 http://redmine.open-bio.org/projects/bioperl/
136  
137 =head1 AUTHOR - Heikki Lehvaslaiho
138  
139 heikki at bioperl dot org
140  
141 =head1 APPENDIX
142  
143 The rest of the documentation details each of the object methods.
144 Internal methods are usually preceded with a _
145  
146 =cut
147  
148 package Bio::Tools::Run::Phylo::Phyml;
149 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
150  
151 1 ▶use Bio::AlignIO;
Subroutine BEGIN: called CC=1 SCAR=0.0
152 1 ▶use File::Copy;
Subroutine BEGIN: called CC=1 SCAR=0.0
153 1 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
154  
155 1 ▶use Bio::TreeIO;
Subroutine BEGIN: called CC=1 SCAR=0.0
156  
157 1 ▶use base qw(Bio::Tools::Run::WrapperBase);
Subroutine BEGIN: called CC=1 SCAR=0.0
158  
159 1 our $PROGRAM_NAME = 'phyml';
160 1 our $PROGRAM_DIR = $ENV{'PHYMLDIR'};
161  
162  
163  
164 # valid substitution model names
165 1 our $models;
166 # DNA
167 1 map { $models->{0}->{$_} = 1 } qw(JC69 K2P F81 HKY F84 TN93 GTR);
168 # protein
169 1 map { $models->{1}->{$_} = 1 } qw(JTT MtREV Dayhoff WAG);
170  
171 1 our $models3;
172 # DNA
173 1 map { $models3->{'nt'}->{$_} = 1 } qw(HKY85 JC69 K80 F81 F84 TN93 GTR );
174 # protein
175 1 map { $models3->{'aa'}->{$_} = 1 }
176 qw(WAG JTT MtREV Dayhoff DCMut RtREV CpREV VT Blosum62 MtMam MtArt HIVw HIVb );
177  
178 =head2 new
179  
180 Title : new
181 Usage : $factory = Bio::Tools::Run::Phylo::Phyml->new(@params)
182 Function: creates a new Phyml factory
183 Returns : Bio::Tools::Run::Phylo::Phyml
184 Args : Optionally, provide any of the following (default in []):
185 -data_type => 'dna' or 'protein', [protein]
186 -dataset_count => 'integer, [1]
187 -model => 'HKY'... , [HKY|JTT]
188 -kappa => 'e' or float, [e]
189 -invar => 'e' or float, [e]
190 -category_number => integer, [1]
191 -alpha => 'e' or float (int v3),[e]
192 -tree => 'BIONJ' or your own, [BION]
193 -opt_topology => boolean [y]
194 -opt_lengths => boolean [y]
195  
196 =cut
197  
198 sub new {
199 1 ▶ my ($class, @args) = @_;
Subroutine new: called CC=20 SCAR=34.7
Pod documented
200 1 my $self = $class->SUPER::new(@args);
201  
202 # for consistency with other run modules, allow params to be dashless
203 1 my %args = @args;
204 1 ▶ while (my ($key, $val) = each %args) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %args) 1 1 2
205 1 ▶ if ($key !~ /^-/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($key =~ /^-/) 0 1 1
206 0 delete $args{$key};
207 0 $args{'-'.$key} = $val;
208 }
209 }
210  
211 1 my ($data_type, $data_format, $dataset_count, $model, $freq, $kappa, $invar,
212 $category_number, $alpha, $tree, $opt_topology,
213 $opt_lengths, $opt, $search, $rand_start, $rand_starts, $rand_seed)
214 = $self->_rearrange([qw( DATA_TYPE
215 DATA_FORMAT
216 DATASET_COUNT
217 MODEL
218 FREQ
219 KAPPA
220 INVAR
221 CATEGORY_NUMBER
222 ALPHA
223 TREE
224 OPT_TOPOLOGY
225 OPT_LENGTHS
226 OPT
227 SEARCH
228 RAND_START
229 RAND_STARTS
230 RAND_SEED
231 )], %args);
232  
233 1 ▶ $self->data_type($data_type) if $data_type;
Branch: 1 branch
BranchTrueFalseTotal
if $data_type 0 1 1
234 1 ▶ $self->data_format($data_format) if $data_format;
Branch: 1 branch
BranchTrueFalseTotal
if $data_format 0 1 1
235 1 ▶ $self->dataset_count($dataset_count) if $dataset_count;
Branch: 1 branch
BranchTrueFalseTotal
if $dataset_count 0 1 1
236 1 ▶ $self->model($model) if $model;
Branch: 1 branch
BranchTrueFalseTotal
if $model 0 1 1
237 1 ▶ $self->freq($freq) if $freq;
Branch: 1 branch
BranchTrueFalseTotal
if $freq 0 1 1
238 1 ▶ $self->kappa($kappa) if $kappa;
Branch: 1 branch
BranchTrueFalseTotal
if $kappa 0 1 1
239 1 ▶ $self->invar($invar) if $invar;
Branch: 1 branch
BranchTrueFalseTotal
if $invar 0 1 1
240 1 ▶ $self->category_number($category_number) if $category_number;
Branch: 1 branch
BranchTrueFalseTotal
if $category_number 0 1 1
241 1 ▶ $self->alpha($alpha) if $alpha;
Branch: 1 branch
BranchTrueFalseTotal
if $alpha 0 1 1
242 1 ▶ $self->tree($tree) if $tree;
Branch: 1 branch
BranchTrueFalseTotal
if $tree 0 1 1
243 1 ▶ $self->opt_topology($opt_topology) if $opt_topology;
Branch: 1 branch
BranchTrueFalseTotal
if $opt_topology 0 1 1
244 1 ▶ $self->opt_lengths($opt_lengths) if $opt_lengths;
Branch: 1 branch
BranchTrueFalseTotal
if $opt_lengths 0 1 1
245 1 ▶ $self->opt($opt) if $opt;
Branch: 1 branch
BranchTrueFalseTotal
if $opt 0 1 1
246 1 ▶ $self->search($search) if $search;
Branch: 1 branch
BranchTrueFalseTotal
if $search 0 1 1
247 1 ▶ $self->rand_start($rand_start) if $rand_start;
Branch: 1 branch
BranchTrueFalseTotal
if $rand_start 0 1 1
248 1 ▶ $self->rand_starts($rand_starts) if $rand_starts;
Branch: 1 branch
BranchTrueFalseTotal
if $rand_starts 0 1 1
249 1 ▶ $self->rand_seed($rand_seed) if $rand_seed;
Branch: 1 branch
BranchTrueFalseTotal
if $rand_seed 0 1 1
250  
251  
252 1 return $self;
253 }
254  
255 =head2 program_name
256  
257 Title : program_name
258 Usage : $factory>program_name()
259 Function: holds the program name
260 Returns : string
261 Args : None
262  
263 =cut
264  
265 sub program_name {
266 7 ▶ return $PROGRAM_NAME;
Subroutine program_name: called CC=1 SCAR=0.0
Pod documented
267 }
268  
269 =head2 program_dir
270  
271 Title : program_dir
272 Usage : $factory->program_dir(@params)
273 Function: returns the program directory, obtained from ENV variable.
274 Returns : string
275 Args : None
276  
277 =cut
278  
279 sub program_dir {
280 4 ▶ return $PROGRAM_DIR;
Subroutine program_dir: called CC=1 SCAR=0.0
Pod documented
281 }
282  
283 =head2 version
284  
285 Title : version
286 Usage : exit if $prog->version < 1.8
287 Function: Determine the version number of the program
288 Example :
289 Returns : float or undef
290 Args : none
291  
292 Phyml before 3.0 did not display the version. Assume 2.44 when can not
293 determine it.
294  
295 =cut
296  
297 sub version {
298 1 ▶ my $self = shift;
Subroutine version: called CC=4 SCAR=22.3
Pod documented
299  
300 1 ▶ return $self->{'_version'} if defined $self->{'_version'};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"_version"} 0 1 1
301 1 ▶ my $exe = $self->executable || return;
Condition0%0/2
$self->executable || (return)
l!l
00
MC/DC0%0/1
$self->executable || (return)
$self->executable
Truth table0%0/2
A
A= $self->executable
Aresult
11
00
302 0 my $string = substr `$exe --help`, 0, 40 ;
303 0 my ($version) = $string =~ /PhyML v([\d+\.]+)/;
304 0 $self->{'_version'} = $version;
305 0 ▶ $version ? (return $version) : return '2.44'
Branch: 1 branch
BranchTrueFalseTotal
$version ? : 0 0 0
306 }
307  
308  
309 =head2 run
310  
311 Title : run
312 Usage : $factory->run($aln_file);
313 $factory->run($align_object);
314 Function: Runs Phyml to generate a tree
315 Returns : Bio::Tree::Tree object
316 Args : file name for your input alignment in a format
317 recognised by AlignIO, OR Bio::Align::AlignI
318 complient object (eg. Bio::SimpleAlign).
319  
320 =cut
321  
322 sub run {
323 0 ▶ my ($self, $in) = @_;
Subroutine run: not called CC=5 SCAR=34.0
Pod documented
324  
325 0 ▶ if (ref $in && $in->isa("Bio::Align::AlignI")) {
Branch: 3 branches
BranchTrueFalseTotal
if (ref $in and $in->isa('Bio::Align::AlignI')) { } 0 0 0
elsif (not -e $in) { } 0 0 0
elsif (-e $in) { } 0 0 0
Condition0%0/3
ref $in and $in->isa("Bio::Align::AlignI")
!ll&&!rl&&r
000
MC/DC0%0/2
ref $in and $in->isa("Bio::Align::AlignI")
ref $in $in->isa("Bio::Align::AlignI")
Truth table0%0/3
A and B
A= ref $inB= $in->isa("Bio::Align::AlignI")
ABresult
0X0
100
111
326 0 $in = $self->_write_phylip_align_file($in);
327 }
328 elsif (! -e $in) {
329 0 $self->throw("When not supplying a Bio::Align::AlignI object, ".
330 "you must supply a readable filename");
331 }
332 elsif (-e $in) {
333 0 copy ($in, $self->tempdir);
334 0 my $name = File::Spec->splitpath($in); # name is the last item in the array
335 0 $in = File::Spec->catfile($self->tempdir, $name);
336 }
337  
338 0 return $self->_run($in);
339 }
340  
341 =head2 stats
342  
343 Title : stats
344 Usage : $factory->stats;
345 Function: Returns the contents of the phyml '_phyml_stat.txt' output file
346 Returns : string with statistics about the run, undef before run()
347 Args : none
348  
349 =cut
350  
351 sub stats {
352 0 ▶ my $self = shift;;
Subroutine stats: not called CC=1 SCAR=6.9
Pod documented
353 0 return $self->{_stats};
354 }
355  
356 =head2 tree_string
357  
358 Title : tree_string
359 Usage : $factory->tree_string;
360 $factory->run($align_object);
361 Function: Returns the contents of the phyml '_phyml_tree.txt' ouput file
362 Returns : string with tree in Newick format, undef before run()
363 Args : none
364  
365 =cut
366  
367 sub tree_string {
368 0 ▶ my $self = shift;;
Subroutine tree_string: not called CC=1 SCAR=6.9
Pod documented
369 0 return $self->{_tree};
370 }
371  
372 =head2 Getsetters
373  
374 These methods are used to set and get program parameters before running.
375  
376 =head2 data_type
377  
378 Title : data_type
379 Usage : $phyml->data_type('nt');
380 Function: Sets sequence alphabet to 'dna' (nt in v3) or 'aa'
381 If leaved unset, will be set automatically
382 Returns : set value, defaults to 'protein'
383 Args : None to get, 'dna' ('nt') or 'aa' to set.
384  
385 =cut
386  
387 sub data_type {
388 0 ▶ my ($self, $value) = @_;
Subroutine data_type: not called CC=9 SCAR=45.0
Pod documented
389 0 ▶ if ($self->version && $self->version >= 3 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->version and $self->version >= 3) { } 0 0 0
Condition0%0/3
$self->version and $self->version >= 3
!ll&&!rl&&r
000
MC/DC0%0/2
$self->version and $self->version >= 3
$self->version $self->version >= 3
Truth table0%0/3
A and B
A= $self->versionB= $self->version >= 3
ABresult
0X0
100
111
390 0 ▶ if (defined $value) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 0 0 0
391 0 ▶ if ($value eq 'nt') {
Branch: 1 branch
BranchTrueFalseTotal
if ($value eq 'nt') { } 0 0 0
392 0 $self->{_data_type} = 'nt';
393 } else {
394 0 $self->{_data_type} = 'aa';
395 }
396 }
397 0 ▶ return 'aa' unless defined $self->{_data_type};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"_data_type"} 0 0 0
398 } else {
399 0 ▶ if (defined $value) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 0 0 0
400 0 ▶ if ($value eq 'dna') {
Branch: 1 branch
BranchTrueFalseTotal
if ($value eq 'dna') { } 0 0 0
401 0 $self->{_data_type} = '0';
402 } else {
403 0 $self->{_data_type} = '1';
404 }
405 }
406 0 ▶ return '1' unless defined $self->{_data_type};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"_data_type"} 0 0 0
407 }
408 0 return $self->{_data_type};
409 }
410  
411  
412 =head2 data_format
413  
414 Title : data_format
415 Usage : $phyml->data_format('s');
416 Function: Sets PHYLIP format to 'i' interleaved or
417 's' sequential
418 Returns : set value, defaults to 'i'
419 Args : None to get, 'i' or 's' to set.
420  
421 =cut
422  
423 sub data_format {
424 3 ▶ my ($self, $value) = @_;
Subroutine data_format: called CC=5 SCAR=16.2
Pod documented
425 3 ▶ if (defined $value) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 2 1 3
426 2 ▶ $self->throw("PHYLIP format must be 'i' or 's'")
Branch: 1 branch
BranchTrueFalseTotal
unless $value eq "i" or $value eq "s" 0 2 2
Condition66%2/3
$value eq "i" or $value eq "s"
l!l&&r!l&&!r
110
MC/DC0%0/2
$value eq "i" or $value eq "s"
$value eq "i" $value eq "s"
Truth table66%2/3
A or B
A= $value eq "i"B= $value eq "s"
ABresult
1X1
011
000
427 unless $value eq 'i' or $value eq 's';
428 2 $self->{_data_format} = $value;
429 }
430 3 ▶ return $self->{_data_format} || 'i';
Condition100%2/2
$self->{'_data_format'} || 'i'
l!l
21
MC/DC100%1/1
$self->{'_data_format'} || 'i'
$self->{'_data_format'}
Truth table100%2/2
A
A= $self->{'_data_format'}
Aresult
11
00
431 }
432  
433 =head2 dataset_count
434  
435 Title : dataset_count
436 Usage : $phyml->dataset_count(3);
437 Function: Sets dataset number to deal with
438 Returns : set value, defaults to 1
439 Args : None to get, positive integer to set.
440  
441 =cut
442  
443 sub dataset_count {
444 2 ▶ my ($self, $value) = @_;
Subroutine dataset_count: called CC=5 SCAR=16.6
Pod documented
445 2 ▶ if (defined $value) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 1 1 2
446 1 ▶ die "Invalid positive integer [$value]"
Branch: 1 branch
BranchTrueFalseTotal
unless $value =~ /^[-+]?\d*$/ and $value > 0 0 1 1
Condition33%1/3
$value =~ /^[-+]?\d*$/ and $value > 0
!ll&&!rl&&r
001
MC/DC0%0/2
$value =~ /^[-+]?\d*$/ and $value > 0
$value =~ /^[-+]?\d*$/ $value > 0
Truth table33%1/3
A and B
A= $value =~ /^[-+]?\d*$/B= $value > 0
ABresult
0X0
100
111
447 unless $value =~ /^[-+]?\d*$/ and $value > 0;
448 1 $self->{_dataset_count} = $value;
449 }
450 2 ▶ return $self->{_dataset_count} || 1;
Condition100%2/2
$self->{'_dataset_count'} || 1
l!l
11
MC/DC100%1/1
$self->{'_dataset_count'} || 1
$self->{'_dataset_count'}
Truth table100%2/2
A
A= $self->{'_dataset_count'}
Aresult
11
00
451 }
452  
453  
454  
455 =head2 model
456  
457 Title : model
458 Usage : $phyml->model('HKY');
459 Function: Choose the substitution model to use. One of
460  
461 JC69 | K2P | F81 | HKY | F84 | TN93 | GTR (DNA)
462 JTT | MtREV | Dayhoff | WAG (amino acids)
463  
464 v3.0:
465 HKY85 (default) | JC69 | K80 | F81 | F84 |
466 TN93 | GTR (DNA)
467 WAG (default) | JTT | MtREV | Dayhoff | DCMut |
468 RtREV | CpREV | VT | Blosum62 | MtMam | MtArt |
469 HIVw | HIVb (amino acids)
470  
471 Returns : Name of the model, defaults to {HKY|JTT}
472 Args : None to get, string to set.
473  
474 =cut
475  
476 sub model {
477 1 ▶ my ($self, $value) = @_;
Subroutine model: called CC=12 SCAR=47.6
Pod documented
478 1 ▶ if (defined ($value)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 1 0 1
479 1 ▶ if ($self->version && $self->version >= 3 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->version and $self->version >= 3) { } 0 0 0
Condition0%0/3
$self->version and $self->version >= 3
!ll&&!rl&&r
000
MC/DC0%0/2
$self->version and $self->version >= 3
$self->version $self->version >= 3
Truth table0%0/3
A and B
A= $self->versionB= $self->version >= 3
ABresult
0X0
100
111
480 0 ▶ unless ($value =~ /\d{6}/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($value =~ /\d{6}/) 0 0 0
481 $self->throw("Not a valid model name [$value] for current data type (alphabet)")
482 0 ▶ unless $models3->{$self->data_type}->{$value};
Branch: 1 branch
BranchTrueFalseTotal
unless $$Bio::Tools::Run::Phylo::Phyml::models3{$self->data_type}{$value} 0 0 0
483 }
484 } else {
485 $self->throw("Not a valid model name [$value] for current data type (alphabet)")
486 0 ▶ unless $models->{$self->data_type}->{$value};
Branch: 1 branch
BranchTrueFalseTotal
unless $$Bio::Tools::Run::Phylo::Phyml::models{$self->data_type}{$value} 0 0 0
487 }
488 0 $self->{_model} = $value;
489 }
490  
491  
492 0 ▶ if ($self->{_model}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_model"}) 0 0 0
493 0 return $self->{_model};
494 }
495  
496 0 ▶ if ($self->version && $self->version >= 3 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->version and $self->version >= 3) { } 0 0 0
Condition0%0/3
$self->version and $self->version >= 3
!ll&&!rl&&r
000
MC/DC0%0/2
$self->version and $self->version >= 3
$self->version $self->version >= 3
Truth table0%0/3
A and B
A= $self->versionB= $self->version >= 3
ABresult
0X0
100
111
497 0 ▶ if ($self->data_type eq 'aa') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->data_type eq 'aa') { } 0 0 0
498 0 return 'WAG'; # protein
499 } else {
500 0 return 'HKY85'; # DNA
501 }
502 } else {
503 0 ▶ if ($self->data_type) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->data_type) { } 0 0 0
504 0 return 'JTT'; # protein
505 } else {
506 0 return 'HKY'; # DNA
507 }
508 }
509 }
510  
511  
512 =head2 kappa
513  
514 Title : kappa
515 Usage : $phyml->kappa(4);
516 Function: Sets transition/transversion ratio, leave unset to estimate
517 Returns : set value, defaults to 'e'
518 Args : None to get, float or integer to set.
519  
520 =cut
521  
522 sub kappa {
523 0 ▶ my ($self, $value) = @_;
Subroutine kappa: not called CC=6 SCAR=37.4
Pod documented
524 0 ▶ if (defined $value) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 0 0 0
525 0 ▶ die "Invalid number [$value]"
Branch: 1 branch
BranchTrueFalseTotal
unless $value =~ /^[-+]?\d*\.?\d*$/ or $value eq "e" 0 0 0
Condition0%0/3
$value =~ /^[-+]?\d*\.?\d*$/ or $value eq "e"
l!l&&r!l&&!r
000
MC/DC0%0/2
$value =~ /^[-+]?\d*\.?\d*$/ or $value eq "e"
$value =~ /^[-+]?\d*\.?\d*$/ $value eq "e"
Truth table0%0/3
A or B
A= $value =~ /^[-+]?\d*\.?\d*$/B= $value eq "e"
ABresult
1X1
011
000
526 unless $value =~ /^[-+]?\d*\.?\d*$/ or $value eq 'e';
527 0 $self->{_kappa} = $value;
528 }
529 0 ▶ return 'e' unless defined $self->{_kappa};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"_kappa"} 0 0 0
530 0 ▶ return 'e' if $self->{_kappa} eq 'e';
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_kappa"} eq "e" 0 0 0
531 0 return sprintf("%.1f", $self->{_kappa});
532 }
533  
534  
535 =head2 invar
536  
537 Title : invar
538 Usage : $phyml->invar(.3);
539 Function: Sets proportion of invariable sites, leave unset to estimate
540 Returns : set value, defaults to 'e'
541 Args : None to get, float or integer to set.
542  
543 =cut
544  
545 sub invar {
546 0 ▶ my ($self, $value) = @_;
Subroutine invar: not called CC=6 SCAR=37.4
Pod documented
547 0 ▶ if (defined $value) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 0 0 0
548 0 ▶ die "Invalid number [$value]"
Branch: 1 branch
BranchTrueFalseTotal
unless $value =~ /^[-+]?\d*\.\d*$/ or $value eq "e" 0 0 0
Condition0%0/3
$value =~ /^[-+]?\d*\.\d*$/ or $value eq "e"
l!l&&r!l&&!r
000
MC/DC0%0/2
$value =~ /^[-+]?\d*\.\d*$/ or $value eq "e"
$value =~ /^[-+]?\d*\.\d*$/ $value eq "e"
Truth table0%0/3
A or B
A= $value =~ /^[-+]?\d*\.\d*$/B= $value eq "e"
ABresult
1X1
011
000
549 unless $value =~ /^[-+]?\d*\.\d*$/ or $value eq 'e';
550 0 $self->{_invar} = $value;
551 }
552 0 ▶ return 'e' unless defined $self->{_invar};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"_invar"} 0 0 0
553 0 ▶ return 'e' if $self->{_invar} eq 'e';
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_invar"} eq "e" 0 0 0
554 0 return sprintf("%.1f", $self->{_invar});
555 }
556  
557  
558 =head2 category_number
559  
560 Title : category_number
561 Usage : $phyml->category_number(4);
562 Function: Sets number of relative substitution rate categories
563 Returns : set value, defaults to 1
564 Args : None to get, integer to set.
565  
566 =cut
567  
568 sub category_number {
569 0 ▶ my ($self, $value) = @_;
Subroutine category_number: not called CC=5 SCAR=34.0
Pod documented
570 0 ▶ if (defined $value) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 0 0 0
571 0 ▶ die "Invalid postive integer [$value]"
Branch: 1 branch
BranchTrueFalseTotal
unless $value =~ /^[+]?\d*$/ and $value > 0 0 0 0
Condition0%0/3
$value =~ /^[+]?\d*$/ and $value > 0
!ll&&!rl&&r
000
MC/DC0%0/2
$value =~ /^[+]?\d*$/ and $value > 0
$value =~ /^[+]?\d*$/ $value > 0
Truth table0%0/3
A and B
A= $value =~ /^[+]?\d*$/B= $value > 0
ABresult
0X0
100
111
572 unless $value =~ /^[+]?\d*$/ and $value > 0;
573 0 $self->{_category_number} = $value;
574 }
575 0 ▶ return $self->{_category_number} || 1;
Condition0%0/2
$self->{'_category_number'} || 1
l!l
00
MC/DC0%0/1
$self->{'_category_number'} || 1
$self->{'_category_number'}
Truth table0%0/2
A
A= $self->{'_category_number'}
Aresult
11
00
576 }
577  
578  
579  
580 =head2 alpha
581  
582 Title : alpha
583 Usage : $phyml->alpha(1.0);
584 Function: Sets gamma distribution parameter, leave unset to estimate
585 Returns : set value, defaults to 'e'
586 Args : None to get, float or integer to set.
587  
588 =cut
589  
590 sub alpha {
591 0 ▶ my ($self, $value) = @_;
Subroutine alpha: not called CC=7 SCAR=40.3
Pod documented
592 0 ▶ if (defined $value) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 0 0 0
593 0 ▶ die "Invalid number [$value]"
Branch: 1 branch
BranchTrueFalseTotal
unless $value =~ /^[-+]?\d*\.?\d*$/ or $value eq "e" 0 0 0
Condition0%0/3
$value =~ /^[-+]?\d*\.?\d*$/ or $value eq "e"
l!l&&r!l&&!r
000
MC/DC0%0/2
$value =~ /^[-+]?\d*\.?\d*$/ or $value eq "e"
$value =~ /^[-+]?\d*\.?\d*$/ $value eq "e"
Truth table0%0/3
A or B
A= $value =~ /^[-+]?\d*\.?\d*$/B= $value eq "e"
ABresult
1X1
011
000
594 unless $value =~ /^[-+]?\d*\.?\d*$/ or $value eq 'e';
595 0 $self->{_alpha} = $value;
596 }
597 0 ▶ return 'e' unless defined $self->{_alpha};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"_alpha"} 0 0 0
598 0 ▶ return 'e' if $self->{_alpha} eq 'e';
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_alpha"} eq "e" 0 0 0
599 0 ▶ return sprintf("%.1f", $self->{_alpha}) || 'e';
Condition0%0/2
sprintf('%.1f', $self->{'_alpha'}) || 'e'
l!l
00
MC/DC0%0/1
sprintf('%.1f', $self->{'_alpha'}) || 'e'
sprintf('%.1f', $self->{'_alpha'})
Truth table0%0/2
A
A= sprintf('%.1f', $self->{'_alpha'})
Aresult
11
00
600 }
601  
602 =head2 tree
603  
604 Title : tree
605 Usage : $phyml->tree('/tmp/tree.nwk');
606 Function: Sets starting tree, leave unset to estimate a distance tree
607 Returns : set value, defaults to 'BIONJ'
608 Args : None to get, newick tree file name to set.
609  
610 =cut
611  
612  
613 sub tree {
614 0 ▶ my ($self, $value) = @_;
Subroutine tree: not called CC=5 SCAR=34.0
Pod documented
615 0 ▶ if (defined $value) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 0 0 0
616 0 ▶ die "Invalid number [$value]"
Branch: 1 branch
BranchTrueFalseTotal
unless -e $value or $value eq "BIONJ" 0 0 0
Condition0%0/3
-e $value or $value eq "BIONJ"
l!l&&r!l&&!r
000
MC/DC0%0/2
-e $value or $value eq "BIONJ"
-e $value $value eq "BIONJ"
Truth table0%0/3
A or B
A= -e $valueB= $value eq "BIONJ"
ABresult
1X1
011
000
617 unless -e $value or $value eq 'BIONJ';
618 0 $self->{_tree} = $value;
619 }
620 0 ▶ return $self->{_tree} || 'BIONJ';
Condition0%0/2
$self->{'_tree'} || 'BIONJ'
l!l
00
MC/DC0%0/1
$self->{'_tree'} || 'BIONJ'
$self->{'_tree'}
Truth table0%0/2
A
A= $self->{'_tree'}
Aresult
11
00
621 }
622  
623 =head2 v2 options
624  
625 These methods can be used with PhyML v2* only.
626  
627 =head2 opt_topology
628  
629 Title : opt_topology
630 Usage : $factory->opt_topology(1);
631 Function: Choose to optimise the tree topology
632 Returns : {y|n} (default y)
633 Args : None to get, boolean to set.
634  
635 v2.* only
636  
637 =cut
638  
639 sub opt_topology {
640 0 ▶ my ($self, $value) = @_;
Subroutine opt_topology: not called CC=6 SCAR=37.4
Pod documented
641 0 ▶ $self->throw("Not a valid parameter [opt_topology] for to PhyML v3") if $self->version && $self->version >= 3;
Branch: 1 branch
BranchTrueFalseTotal
if $self->version and $self->version >= 3 0 0 0
Condition0%0/3
$self->version and $self->version >= 3
!ll&&!rl&&r
000
MC/DC0%0/2
$self->version and $self->version >= 3
$self->version $self->version >= 3
Truth table0%0/3
A and B
A= $self->versionB= $self->version >= 3
ABresult
0X0
100
111
642 0 ▶ if (defined ($value)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 0 0 0
643 0 ▶ if ($value) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value) { } 0 0 0
644 0 $self->{_opt_topology} = 'y';
645 } else {
646 0 $self->{_opt_topology} = 'n';
647 }
648 }
649 0 ▶ return $self->{_opt_topology} || 'y';
Condition0%0/2
$self->{'_opt_topology'} || 'y'
l!l
00
MC/DC0%0/1
$self->{'_opt_topology'} || 'y'
$self->{'_opt_topology'}
Truth table0%0/2
A
A= $self->{'_opt_topology'}
Aresult
11
00
650 }
651  
652 =head2 opt_lengths
653  
654 Title : opt_lengths
655 Usage : $factory->opt_lengths(0);
656 Function: Choose to optimise branch lengths and rate parameters
657 Returns : {y|n} (default y)
658 Args : None to get, boolean to set.
659  
660  
661 v2.* only
662  
663 =cut
664  
665 sub opt_lengths {
666 0 ▶ my ($self, $value) = @_;
Subroutine opt_lengths: not called CC=6 SCAR=37.4
Pod documented
667 0 ▶ $self->throw("Not a valid parameter [opt_lengths] for PhyML v3") if $self->version && $self->version >= 3;
Branch: 1 branch
BranchTrueFalseTotal
if $self->version and $self->version >= 3 0 0 0
Condition0%0/3
$self->version and $self->version >= 3
!ll&&!rl&&r
000
MC/DC0%0/2
$self->version and $self->version >= 3
$self->version $self->version >= 3
Truth table0%0/3
A and B
A= $self->versionB= $self->version >= 3
ABresult
0X0
100
111
668 0 ▶ if (defined ($value)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 0 0 0
669 0 ▶ if ($value) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value) { } 0 0 0
670 0 $self->{_opt_lengths} = 'y';
671 } else {
672 0 $self->{_opt_lengths} = 'n';
673 }
674 }
675 0 ▶ return $self->{_opt_lengths} || 'y';
Condition0%0/2
$self->{'_opt_lengths'} || 'y'
l!l
00
MC/DC0%0/1
$self->{'_opt_lengths'} || 'y'
$self->{'_opt_lengths'}
Truth table0%0/2
A
A= $self->{'_opt_lengths'}
Aresult
11
00
676 }
677  
678 =head2 v3 options
679  
680 These methods can be used with PhyML v3* only.
681  
682 =head2 freq
683  
684 Title : freq
685 Usage : $phyml->freq(e); $phyml->freq("0.2, 0.6, 0.6, 0.2");
686 Function: Sets nucleotide frequences or asks residue to be estimated
687 according to two models: e or d
688 Returns : set value,
689 Args : None to get, string to set.
690  
691 v3 only.
692  
693 =cut
694  
695 sub freq {
696 0 ▶ my ($self, $value) = @_;
Subroutine freq: not called CC=6 SCAR=37.4
Pod documented
697 0 ▶ $self->throw("Not a valid parameter [freq] prior to PhyML v3") if $self->version < 3;
Branch: 1 branch
BranchTrueFalseTotal
if $self->version < 3 0 0 0
698 0 ▶ if (defined $value) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 0 0 0
699 0 ▶ die "Invalid value [$value]"
Branch: 1 branch
BranchTrueFalseTotal
unless $value =~ /^[\d\. ]$/ or $value eq "e" or $value eq "d" 0 0 0
Condition0%0/6
$value =~ /^[\d\. ]$/ or $value eq "e" or $value eq "d"
l!l&&r!l&&!r
000
$value =~ /^[\d\. ]$/ or $value eq "e"
l!l&&r!l&&!r
000
MC/DC0%0/3
$value =~ /^[\d\. ]$/ or $value eq "e" or $value eq "d"
$value =~ /^[\d\. ]$/ $value eq "e" $value eq "d"
Truth table0%0/4
A or B or C
A= $value =~ /^[\d\. ]$/B= $value eq "e"C= $value eq "d"
ABCresult
1XX1
01X1
0011
0000
700 unless $value =~ /^[\d\. ]$/ or $value eq 'e' or $value eq 'd';
701 0 $self->{_freq} = $value;
702 }
703 0 return $self->{_freq};
704 }
705  
706 =head2 opt
707  
708 Title : opt
709 Usage : $factory->opt(1);
710 Function: Optimise tree parameters: tlr|tl|tr|l|n
711 Returns : {value|n} (default n)
712 Args : None to get, string to set.
713  
714 v3.* only
715  
716 =cut
717  
718 sub opt {
719 0 ▶ my ($self, $value) = @_;
Subroutine opt: not called CC=5 SCAR=34.0
Pod documented
720 0 ▶ $self->throw("Not a valid parameter [opt] prior to PhyML v3") if $self->version < 3;
Branch: 1 branch
BranchTrueFalseTotal
if $self->version < 3 0 0 0
721 0 ▶ if (defined ($value)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 0 0 0
722 0 ▶ $self->{_opt} = $value if $value =~ /tlr|tl|tr|l|n/;
Branch: 1 branch
BranchTrueFalseTotal
if $value =~ /tlr|tl|tr|l|n/ 0 0 0
723 }
724 0 ▶ return $self->{_opt} || 'n';
Condition0%0/2
$self->{'_opt'} || 'n'
l!l
00
MC/DC0%0/1
$self->{'_opt'} || 'n'
$self->{'_opt'}
Truth table0%0/2
A
A= $self->{'_opt'}
Aresult
11
00
725 }
726  
727 =head2 search
728  
729 Title : search
730 Usage : $factory->search(SPR);
731 Function: Tree topology search operation algorithm: NNI|SPR|BEST
732 Returns : string (defaults to NNI)
733 Args : None to get, string to set.
734  
735 v3.* only
736  
737 =cut
738  
739 sub search {
740 0 ▶ my ($self, $value) = @_;
Subroutine search: not called CC=5 SCAR=34.0
Pod documented
741 0 ▶ $self->throw("Not a valid parameter [search] prior to PhyML v3") if $self->version < 3;
Branch: 1 branch
BranchTrueFalseTotal
if $self->version < 3 0 0 0
742 0 ▶ if (defined ($value)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 0 0 0
743 0 ▶ $self->{_search} = $value if $value =~ /NNI|SPR|BEST/;
Branch: 1 branch
BranchTrueFalseTotal
if $value =~ /NNI|SPR|BEST/ 0 0 0
744 }
745 0 ▶ return $self->{_search} || 'NNI';
Condition0%0/2
$self->{'_search'} || 'NNI'
l!l
00
MC/DC0%0/1
$self->{'_search'} || 'NNI'
$self->{'_search'}
Truth table0%0/2
A
A= $self->{'_search'}
Aresult
11
00
746 }
747  
748 =head2 rand_start
749  
750 Title : rand_start
751 Usage : $factory->rand_start(1);
752 Function: Sets the initial SPR tree to random.
753 Returns : boolean (defaults to false)
754 Args : None to get, boolean to set.
755  
756 v3.* only; only meaningful if $prog-E<gt>search is 'SPR'
757  
758 =cut
759  
760  
761 sub rand_start {
762 0 ▶ my ($self, $value) = @_;
Subroutine rand_start: not called CC=5 SCAR=34.0
Pod documented
763 0 ▶ $self->throw("Not a valid parameter [rand_start] prior to PhyML v3") if $self->version < 3;
Branch: 1 branch
BranchTrueFalseTotal
if $self->version < 3 0 0 0
764 0 ▶ if (defined ($value)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 0 0 0
765 0 ▶ if ($value) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value) { } 0 0 0
766 0 $self->{_rand_start} = 1;
767 } else {
768 0 $self->{_rand_start} = 0;
769 }
770 }
771 0 ▶ return $self->{_rand_start} || 0;
Condition0%0/2
$self->{'_rand_start'} || 0
l!l
00
MC/DC0%0/1
$self->{'_rand_start'} || 0
$self->{'_rand_start'}
Truth table0%0/2
A
A= $self->{'_rand_start'}
Aresult
11
00
772 }
773  
774  
775 =head2 rand_starts
776  
777 Title : rand_starts
778 Usage : $factory->rand_starts(10);
779 Function: Sets the number of initial random SPR trees
780 Returns : integer (defaults to 1)
781 Args : None to get, integer to set.
782  
783 v3.* only; only valid if $prog-E<gt>search is 'SPR'
784  
785 =cut
786  
787 sub rand_starts {
788 0 ▶ my ($self, $value) = @_;
Subroutine rand_starts: not called CC=5 SCAR=34.0
Pod documented
789 0 ▶ $self->throw("Not a valid parameter [rand_starts] prior to PhyML v3") if $self->version < 3;
Branch: 1 branch
BranchTrueFalseTotal
if $self->version < 3 0 0 0
790 0 ▶ if (defined $value) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 0 0 0
791 0 ▶ die "Invalid number [$value]"
Branch: 1 branch
BranchTrueFalseTotal
unless $value =~ /^[-+]?\d+$/ 0 0 0
792 unless $value =~ /^[-+]?\d+$/;
793 0 $self->{_rand_starts} = $value;
794 }
795 0 ▶ return $self->{_rand_starts} || 1;
Condition0%0/2
$self->{'_rand_starts'} || 1
l!l
00
MC/DC0%0/1
$self->{'_rand_starts'} || 1
$self->{'_rand_starts'}
Truth table0%0/2
A
A= $self->{'_rand_starts'}
Aresult
11
00
796 }
797  
798  
799 =head2 rand_seed
800  
801 Title : rand_seed
802 Usage : $factory->rand_seed(1769876);
803 Function: Seeds the random number generator
804 Returns : random integer
805 Args : None to get, integer to set.
806  
807 v3.* only; only valid if $prog-E<gt>search is 'SPR'
808  
809 Uses perl rand() to initialize if not explicitely set.
810  
811 =cut
812  
813 sub rand_seed {
814 0 ▶ my ($self, $value) = @_;
Subroutine rand_seed: not called CC=5 SCAR=34.0
Pod documented
815 0 ▶ $self->throw("Not a valid parameter [rand_seed] prior to PhyML v3") if $self->version < 3;
Branch: 1 branch
BranchTrueFalseTotal
if $self->version < 3 0 0 0
816 0 ▶ if (defined $value) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 0 0 0
817 0 ▶ die "Invalid number [$value]"
Branch: 1 branch
BranchTrueFalseTotal
unless $value =~ /^[-+]?\d+$/ 0 0 0
818 unless $value =~ /^[-+]?\d+$/;
819 0 $self->{_rand_seed} = $value;
820 }
821 0 ▶ return $self->{_rand_seed} || int rand 1000000;
Condition0%0/3
$self->{'_rand_seed'} || int rand 1000000
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{'_rand_seed'} || int rand 1000000
$self->{'_rand_seed'} int rand 1000000
Truth table0%0/3
A || B
A= $self->{'_rand_seed'}B= int rand 1000000
ABresult
1X1
011
000
822 }
823  
824  
825 =head2 Internal methods
826  
827 These methods are private and should not be called outside this class.
828  
829 =cut
830  
831 sub _run {
832 0 ▶ my ($self, $file)= @_;
Subroutine _run: not called CC=6 SCAR=37.4
833  
834 0 ▶ my $exe = $self->executable || return;
Condition0%0/2
$self->executable || (return)
l!l
00
MC/DC0%0/1
$self->executable || (return)
$self->executable
Truth table0%0/2
A
A= $self->executable
Aresult
11
00
835 0 my $command;
836 my $output_stat_file;
837 0 ▶ if ($self->version >= 3 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->version >= 3) { } 0 0 0
838 0 $command = $exe. " -i $file". $self->_setparams;
839 0 $output_stat_file = '_phyml_stats.txt';
840 } else {
841 0 $command = $exe. " $file ". $self->arguments. $self->_setparams;
842 0 $output_stat_file = '_phyml_stat.txt';
843 }
844  
845 0 $self->debug("Phyml command = $command\n");
846 0 `$command`;
847  
848 # stats
849 {
850 0 my $stat_file = $file. $output_stat_file;
851 0 ▶ open(my $FH_STAT, "<", $stat_file)
Branch: 1 branch
BranchTrueFalseTotal
open my $FH_STAT, "<", $stat_file or $self->throw("Phyml call ($command) did not give an output [$stat_file]: $?") 0 0 0
852 || $self->throw("Phyml call ($command) did not give an output [$stat_file]: $?");
853 0 local $/;
854 0 $self->{_stats} .= <$FH_STAT>;
855 }
856 #print $self->{stats};
857  
858 # tree
859 0 my $tree_file = $file. '_phyml_tree.txt';
860 {
861 0 ▶ open(my $FH_TREE, "<", $tree_file)
Branch: 1 branch
BranchTrueFalseTotal
open my $FH_TREE, "<", $tree_file or $self->throw("Phyml call ($command) did not give an output: $?") 0 0 0
862 || $self->throw("Phyml call ($command) did not give an output: $?");
863 0 local $/;
864 0 $self->{_tree} .= <$FH_TREE>;
865 }
866  
867 0 ▶ open(my $FH_TREE, "<", $tree_file)
Branch: 1 branch
BranchTrueFalseTotal
open my $FH_TREE, "<", $tree_file or $self->throw("Phyml call ($command) did not give an output: $?") 0 0 0
868 || $self->throw("Phyml call ($command) did not give an output: $?");
869  
870 0 my $treeio = Bio::TreeIO->new(-format => 'nhx', -fh => $FH_TREE);
871 0 my $tree = $treeio->next_tree;
872  
873 # could be faster to parse the tree only if needed?
874  
875 0 return $tree;
876 }
877  
878  
879 =head2 _setparams
880  
881 Title : _setparams
882 Usage : Internal function, not to be called directly
883 Function: Creates a string of params to be used in the command string
884 Returns : string of params
885 Args : none
886  
887 =cut
888  
889 sub _setparams {
890 0 ▶ my $self = shift;
Subroutine _setparams: not called CC=12 SCAR=50.5
891 0 my $param_string;
892  
893 0 ▶ if ($self->version >= 3 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->version >= 3) { } 0 0 0
894  
895 0 $param_string = ' -d '. $self->data_type;
896 0 ▶ $param_string .= ' -q' if $self->data_format eq 's';
Branch: 1 branch
BranchTrueFalseTotal
if $self->data_format eq "s" 0 0 0
897 0 ▶ $param_string .= ' -n '. $self->dataset_count if $self->dataset_count > 1;
Branch: 1 branch
BranchTrueFalseTotal
if $self->dataset_count > 1 0 0 0
898  
899 #$param_string .= ' 0'; # no bootstap sets
900  
901 0 $param_string .= ' -m '. $self->model;
902 0 ▶ $param_string .= ' -f '. $self->freq if $self->freq;
Branch: 1 branch
BranchTrueFalseTotal
if $self->freq 0 0 0
903  
904 0 ▶ if ($self->data_type eq 'dna') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->data_type eq "dna") 0 0 0
905 0 $param_string .= ' -t '. $self->kappa;
906 }
907  
908 0 $param_string .= ' -v '. $self->invar;
909 0 $param_string .= ' -c '. $self->category_number;
910 0 $param_string .= ' -a '. $self->alpha;
911 0 ▶ $param_string .= ' -u '. $self->tree if $self->tree ne 'BIONJ';
Branch: 1 branch
BranchTrueFalseTotal
if $self->tree ne "BIONJ" 0 0 0
912 0 ▶ $param_string .= ' -o '. $self->opt if $self->opt;
Branch: 1 branch
BranchTrueFalseTotal
if $self->opt 0 0 0
913 0 $param_string .= ' -s '. $self->search;
914  
915 0 ▶ if ($self->search eq 'SPR' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->search eq "SPR") 0 0 0
916 0 ▶ $param_string .= ' --rand_start ' if $self->rand_start;
Branch: 1 branch
BranchTrueFalseTotal
if $self->rand_start 0 0 0
917 0 ▶ $param_string .= ' --n_rand_starts '. $self->rand_starts
Branch: 1 branch
BranchTrueFalseTotal
if $self->rand_starts 0 0 0
918 if $self->rand_starts;
919 0 $param_string .= ' --r_seed '. $self->rand_seed;
920 }
921  
922 } else {
923  
924 0 $param_string = ' ' . $self->data_type;
925  
926 0 $param_string .= ' '. $self->data_format;
927 0 $param_string .= ' '. $self->dataset_count;
928  
929 0 $param_string .= ' 0'; # no bootstap sets
930  
931 0 $param_string .= ' '. $self->model;
932  
933 0 ▶ unless ($self->data_type) { # only for DNA
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->data_type) 0 0 0
934 0 $param_string .= ' '. $self->kappa;
935 }
936  
937 0 $param_string .= ' '. $self->invar;
938 0 $param_string .= ' '. $self->category_number;
939 0 $param_string .= ' '. $self->alpha;
940 0 $param_string .= ' '. $self->tree;
941 0 $param_string .= ' '. $self->opt_topology;
942 0 $param_string .= ' '. $self->opt_lengths;
943  
944 }
945 0 return $param_string;
946 }
947  
948 =head2 _write_phylip_align_file
949  
950 Title : _write_phylip_align_file
951 Usage : obj->__write_phylip_align_file($aln)
952 Function: Internal (not to be used directly)
953  
954 Writes the alignment into the tmp directory
955 in PHYLIP interlieved format
956  
957 Returns : filename
958 Args : Bio::Align::AlignI
959  
960 =cut
961  
962 sub _write_phylip_align_file {
963 0 ▶ my ($self, $align) = @_;
Subroutine _write_phylip_align_file: not called CC=1 SCAR=6.9
964
965 0 my $tempfile = File::Spec->catfile($self->tempdir, "aln$$.phylip");
966 0 $self->data_format('i');
967 0 my $out = Bio::AlignIO->new('-file' => ">$tempfile",
968 '-format' => 'phylip',
969 '-interleaved' => 0,
970 '-longid' => 1 );
971 0 $out->write_aln($align);
972 0 $out->close();
973 0 $out = undef;
974 0 return $tempfile;
975 }
976  
977 1 1;
« blib/lib/Bio/Tools/Run/Phylo/Hyphy/Modeltest.pm ↑ Summary blib/lib/Bio/Tools/Run/ERPIN.pm »