Tools/Run/Phylo/Phyml.pm

filter: Statementstmt 34.8% 103 / 296 Branchbran 23.7% 55 / 232 Conditioncond 24.0% 19 / 79 MC/DCmcdc 8.5% 4 / 47 Subroutinesub 44.4% 16 / 36 Podpod 100% 26 / 26 totaltotal 31.1% 223 / 716 CC 148 SCAR 39.3
CC
148
Cov
29%
_setparams
210.0
model
156.0
data_type
90.0
CRAP 51.0
« Tools/Run/RNAMotif.pm ↑ Summary Tools/Run/Phylo/Hyphy/Base.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. It may work with
97 recent Phyml releases using a date format for the format, but the wrapper
98 hasn't been extensively tested in these cases, so for the moment only the
99 simpler numbered versions are supported.
100  
101 In its current state, the wrapper supports only input of one MSA and
102 output of one tree. It can easily be extended to support more advanced
103 capabilities of C<phyml>.
104  
105 Two convienience methods have been added on top of the standard
106 BioPerl WrapperBase ones: stats() and tree_string(). You can call them
107 to after running the phyml program to retrieve into a string the statistics
108 and the tree in Newick format.
109  
110 =head1 FEEDBACK
111  
112 =head2 Mailing Lists
113  
114 User feedback is an integral part of the evolution of this and other
115 Bioperl modules. Send your comments and suggestions preferably to
116 the Bioperl mailing list. Your participation is much appreciated.
117  
118 bioperl-l@bioperl.org - General discussion
119 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
120  
121 =head2 Support
122  
123 Please direct usage questions or support issues to the mailing list:
124  
125 I<bioperl-l@bioperl.org>
126  
127 rather than to the module maintainer directly. Many experienced and
128 reponsive experts will be able look at the problem and quickly
129 address it. Please include a thorough description of the problem
130 with code and data examples if at all possible.
131  
132 =head2 Reporting Bugs
133  
134 Report bugs to the Bioperl bug tracking system to help us keep track
135 of the bugs and their resolution. Bug reports can be submitted via
136 the web:
137  
138 http://bugzilla.open-bio.org/
139  
140 =head1 AUTHOR - Heikki Lehvaslaiho
141  
142 heikki at bioperl dot org
143  
144 =head1 APPENDIX
145  
146 The rest of the documentation details each of the object methods.
147 Internal methods are usually preceded with a _
148  
149 =cut
150  
151 package Bio::Tools::Run::Phylo::Phyml;
152 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
153  
154 1 ▶use Bio::AlignIO;
Subroutine BEGIN: called CC=1 SCAR=0.0
155 1 ▶use File::Copy;
Subroutine BEGIN: called CC=1 SCAR=0.0
156 1 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
157 1 ▶use Bio::TreeIO;
Subroutine BEGIN: called CC=1 SCAR=0.0
158  
159 1 ▶use base qw(Bio::Tools::Run::WrapperBase);
Subroutine BEGIN: called CC=1 SCAR=0.0
160  
161 1 our $PROGRAM_NAME = 'phyml';
162 1 our $PROGRAM_DIR = $ENV{'PHYMLDIR'};
163  
164 # valid substitution model names
165 1 our $models;
166  
167 # DNA
168 1 map { $models->{0}->{$_} = 1 } qw(JC69 K2P F81 HKY F84 TN93 GTR);
169  
170 # protein
171 1 map { $models->{1}->{$_} = 1 } qw(JTT MtREV Dayhoff WAG);
172  
173 1 our $models3;
174  
175 # DNA
176 1 map { $models3->{'nt'}->{$_} = 1 } qw(HKY85 JC69 K80 F81 F84 TN93 GTR );
177  
178 # protein
179 1 map { $models3->{'aa'}->{$_} = 1 }
180 qw(LG WAG JTT MtREV Dayhoff DCMut RtREV CpREV VT Blosum62 MtMam MtArt HIVw HIVb );
181  
182 =head2 new
183  
184 Title : new
185 Usage : $factory = Bio::Tools::Run::Phylo::Phyml->new(@params)
186 Function: creates a new Phyml factory
187 Returns : Bio::Tools::Run::Phylo::Phyml
188 Args : Optionally, provide any of the following (default in []):
189 -data_type => 'dna' or 'protein', [protein]
190 -dataset_count => integer, [1]
191 -model => 'HKY'... , [HKY|JTT]
192 -kappa => 'e' or float, [e]
193 -invar => 'e' or float, [e]
194 -category_number => integer, [1]
195 -alpha => 'e' or float (int v3),[e]
196 -tree => 'BIONJ' or your own, [BION]
197 -bootstrap => integer [123]
198 -opt_topology => boolean [1]
199 -opt_lengths => boolean [1]
200 -no_memory_check => boolean [1]
201 -program_name => string
202  
203 =cut
204  
205 1 ▶sub new {
Subroutine new: called CC=23 SCAR=36.8
Pod documented
206 1 my ( $class, @args ) = @_;
207 1 my $self = $class->SUPER::new(@args);
208  
209 # for consistency with other run modules, allow params to be dashless
210 1 my %args = @args;
211 1 ▶ while ( my ( $key, $val ) = each %args ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %args) 1 1 2
212 1 ▶ if ( $key !~ /^-/ ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($key =~ /^-/) 0 1 1
213 0 delete $args{$key};
214 0 $args{ '-' . $key } = $val;
215 }
216 }
217  
218 my (
219 1 $data_type, $data_format, $dataset_count, $model,
220 $freq, $kappa, $invar, $category_number,
221 $alpha, $tree, $opt_topology, $opt_lengths,
222 $opt, $search, $rand_start, $rand_starts,
223 $rand_seed, $no_memory_check, $bootstrap, $program_name
224 )
225 = $self->_rearrange(
226 [
227 qw( DATA_TYPE
228 DATA_FORMAT
229 DATASET_COUNT
230 MODEL
231 FREQ
232 KAPPA
233 INVAR
234 CATEGORY_NUMBER
235 ALPHA
236 TREE
237 OPT_TOPOLOGY
238 OPT_LENGTHS
239 OPT
240 SEARCH
241 RAND_START
242 RAND_STARTS
243 RAND_SEED
244 NO_MEMORY_CHECK
245 BOOTSTRAP
246 PROGRAM_NAME
247 )
248 ],
249 %args
250 );
251  
252 1 ▶ $self->data_type($data_type) if $data_type;
Branch: 1 branch
BranchTrueFalseTotal
if $data_type 0 1 1
253 1 ▶ $self->data_format($data_format) if $data_format;
Branch: 1 branch
BranchTrueFalseTotal
if $data_format 0 1 1
254 1 ▶ $self->dataset_count($dataset_count) if $dataset_count;
Branch: 1 branch
BranchTrueFalseTotal
if $dataset_count 0 1 1
255 1 ▶ $self->model($model) if $model;
Branch: 1 branch
BranchTrueFalseTotal
if $model 0 1 1
256 1 ▶ $self->freq($freq) if $freq;
Branch: 1 branch
BranchTrueFalseTotal
if $freq 0 1 1
257 1 ▶ $self->kappa($kappa) if $kappa;
Branch: 1 branch
BranchTrueFalseTotal
if $kappa 0 1 1
258 1 ▶ $self->invar($invar) if $invar;
Branch: 1 branch
BranchTrueFalseTotal
if $invar 0 1 1
259 1 ▶ $self->category_number($category_number) if $category_number;
Branch: 1 branch
BranchTrueFalseTotal
if $category_number 0 1 1
260 1 ▶ $self->alpha($alpha) if $alpha;
Branch: 1 branch
BranchTrueFalseTotal
if $alpha 0 1 1
261 1 ▶ $self->tree($tree) if $tree;
Branch: 1 branch
BranchTrueFalseTotal
if $tree 0 1 1
262 1 ▶ $self->opt_topology($opt_topology) if $opt_topology;
Branch: 1 branch
BranchTrueFalseTotal
if $opt_topology 0 1 1
263 1 ▶ $self->opt_lengths($opt_lengths) if $opt_lengths;
Branch: 1 branch
BranchTrueFalseTotal
if $opt_lengths 0 1 1
264 1 ▶ $self->opt($opt) if $opt;
Branch: 1 branch
BranchTrueFalseTotal
if $opt 0 1 1
265 1 ▶ $self->search($search) if $search;
Branch: 1 branch
BranchTrueFalseTotal
if $search 0 1 1
266 1 ▶ $self->rand_start($rand_start) if $rand_start;
Branch: 1 branch
BranchTrueFalseTotal
if $rand_start 0 1 1
267 1 ▶ $self->rand_starts($rand_starts) if $rand_starts;
Branch: 1 branch
BranchTrueFalseTotal
if $rand_starts 0 1 1
268 1 ▶ $self->rand_seed($rand_seed) if $rand_seed;
Branch: 1 branch
BranchTrueFalseTotal
if $rand_seed 0 1 1
269 1 ▶ $self->no_memory_check($no_memory_check) if $no_memory_check;
Branch: 1 branch
BranchTrueFalseTotal
if $no_memory_check 0 1 1
270 1 ▶ $self->bootstrap($bootstrap) if $bootstrap;
Branch: 1 branch
BranchTrueFalseTotal
if $bootstrap 0 1 1
271 1 ▶ $self->program_name($program_name) if $program_name;
Branch: 1 branch
BranchTrueFalseTotal
if $program_name 0 1 1
272  
273 1 return $self;
274 }
275  
276 =head2 program_name
277  
278 Title : program_name
279 Usage : $factory>program_name()
280 Function: holds the program name
281 Returns : string
282 Args : None
283  
284 =cut
285  
286 7 ▶sub program_name {
Subroutine program_name: called CC=3 SCAR=16.0
Pod documented
287 7 my ( $self, $value ) = @_;
288  
289 7 ▶ if ( defined($value) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 0 7 7
290 0 ▶ if ( $value =~ /^$PROGRAM_NAME[-a-z]*$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value =~ /^$Bio::Tools::Run::Phylo::Phyml::PROGRAM_NAME[-a-z]*$/) { } 0 0 0
291 0 $PROGRAM_NAME = $value;
292 } else {
293 0 $self->throw("$value is not a valid program name");
294 }
295 }
296  
297 7 $PROGRAM_NAME;
298 }
299  
300 =head2 program_dir
301  
302 Title : program_dir
303 Usage : $factory->program_dir(@params)
304 Function: returns the program directory, obtained from ENV variable.
305 Returns : string
306 Args : None
307  
308 =cut
309  
310 4 ▶sub program_dir {
Subroutine program_dir: called CC=1 SCAR=0.0
Pod documented
311 4 return $PROGRAM_DIR;
312 }
313  
314 =head2 version
315  
316 Title : version
317 Usage : exit if $prog->version < 1.8
318 Function: Determine the version number of the program
319 Example :
320 Returns : float or undef
321 Args : none
322  
323 Phyml before 3.0 did not display the version. Assume 2.44 when can not
324 determine it.
325  
326 Some releases do not state version number, only date, so the
327 version might have to be inferred from this date.
328  
329 =cut
330  
331 0 ▶sub version {
Subroutine version: not called CC=7 SCAR=40.3
Pod documented
332 0 my $self = shift;
333  
334 0 ▶ return $self->{'_version'} if defined $self->{'_version'};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"_version"} 0 0 0
335 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
336 0 my $string = substr `$exe -h`, 0, 40;
337 0 my ($version) = $string =~ /PhyML v([\d+\.]+)/;
338 0 ▶ if ( !$version ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($version) 0 0 0
339 0 $string =~ /PhyML\s+(\d{8})/;
340  
341 # 3 was released August 2008
342 0 ▶ $version = 3 if ( $1 && $1 >= 20080801 );
Branch: 1 branch
BranchTrueFalseTotal
if $1 and $1 >= 20080801 0 0 0
Condition0%0/3
$1 and $1 >= 20080801
!ll&&!rl&&r
000
MC/DC0%0/2
$1 and $1 >= 20080801
$1 $1 >= 20080801
Truth table0%0/3
A and B
A= $1B= $1 >= 20080801
ABresult
0X0
100
111
343 }
344 0 $self->{'_version'} = $version;
345 0 ▶ $version ? ( return $version ) : return '2.44';
Branch: 1 branch
BranchTrueFalseTotal
$version ? : 0 0 0
346 }
347  
348 =head2 run
349  
350 Title : run
351 Usage : $factory->run($aln_file);
352 $factory->run($align_object);
353 Function: Runs Phyml to generate a tree
354 Returns : Bio::Tree::Tree object
355 Args : file name for your input alignment in a format
356 recognised by AlignIO, OR Bio::Align::AlignI
357 compliant object (eg. Bio::SimpleAlign).
358  
359 =cut
360  
361 0 ▶sub run {
Subroutine run: not called CC=5 SCAR=34.0
Pod documented
362 0 my ( $self, $in ) = @_;
363  
364 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
365 0 $in = $self->_write_phylip_align_file($in);
366 }
367 elsif ( !-e $in ) {
368 0 $self->throw( "When not supplying a Bio::Align::AlignI object, "
369 . "you must supply a readable filename" );
370 }
371 elsif ( -e $in ) {
372 0 copy( $in, $self->tempdir );
373 0 my $name =
374 File::Spec->splitpath($in); # name is the last item in the array
375 0 $in = File::Spec->catfile( $self->tempdir, $name );
376 }
377  
378 0 return $self->_run($in);
379 }
380  
381 =head2 stats
382  
383 Title : stats
384 Usage : $factory->stats;
385 Function: Returns the contents of the phyml '_phyml_stat.txt' output file
386 Returns : string with statistics about the run, undef before run()
387 Args : none
388  
389 =cut
390  
391 0 ▶sub stats {
Subroutine stats: not called CC=1 SCAR=6.9
Pod documented
392 0 my $self = shift;
393 0 return $self->{_stats};
394 }
395  
396 =head2 tree_string
397  
398 Title : tree_string
399 Usage : $factory->tree_string;
400 $factory->run($align_object);
401 Function: Returns the contents of the phyml '_phyml_tree.txt' output file
402 Returns : string with tree in Newick format, undef before run()
403 Args : none
404  
405 =cut
406  
407 0 ▶sub tree_string {
Subroutine tree_string: not called CC=1 SCAR=6.9
Pod documented
408 0 my $self = shift;
409 0 return $self->{_tree};
410 }
411  
412 =head2 Getsetters
413  
414 These methods are used to set and get program parameters before running.
415  
416 =head2 data_type
417  
418 Title : data_type
419 Usage : $phyml->data_type('nt');
420 Function: Sets sequence alphabet to 'dna' (nt in v3) or 'aa'
421 If leaved unset, will be set automatically
422 Returns : set value, defaults to 'protein'
423 Args : None to get, 'dna' ('nt') or 'aa' to set.
424  
425 =cut
426  
427 0 ▶sub data_type {
Subroutine data_type: not called CC=9 SCAR=45.0
Pod documented
428 0 my ( $self, $value ) = @_;
429 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
430 0 ▶ if ( defined $value ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 0 0 0
431 0 ▶ if ( $value eq 'nt' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value eq 'nt') { } 0 0 0
432 0 $self->{_data_type} = 'nt';
433 }
434 else {
435 0 $self->{_data_type} = 'aa';
436 }
437 }
438 0 ▶ return 'aa' unless defined $self->{_data_type};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"_data_type"} 0 0 0
439 }
440 else {
441 0 ▶ if ( defined $value ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 0 0 0
442 0 ▶ if ( $value eq 'dna' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value eq 'dna') { } 0 0 0
443 0 $self->{_data_type} = '0';
444 }
445 else {
446 0 $self->{_data_type} = '1';
447 }
448 }
449 0 ▶ return '1' unless defined $self->{_data_type};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"_data_type"} 0 0 0
450 }
451 0 return $self->{_data_type};
452 }
453  
454 =head2 data_format
455  
456 Title : data_format
457 Usage : $phyml->data_format('s');
458 Function: Sets PHYLIP format to 'i' interleaved or
459 's' sequential
460 Returns : set value, defaults to 'i'
461 Args : None to get, 'i' or 's' to set.
462  
463 =cut
464  
465 3 ▶sub data_format {
Subroutine data_format: called CC=5 SCAR=16.2
Pod documented
466 3 my ( $self, $value ) = @_;
467 3 ▶ if ( defined $value ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 2 1 3
468 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
469 unless $value eq 'i'
470 or $value eq 's';
471 2 $self->{_data_format} = $value;
472 }
473 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
474 }
475  
476 =head2 dataset_count
477  
478 Title : dataset_count
479 Usage : $phyml->dataset_count(3);
480 Function: Sets dataset number to deal with
481 Returns : set value, defaults to 1
482 Args : None to get, positive integer to set.
483  
484 =cut
485  
486 2 ▶sub dataset_count {
Subroutine dataset_count: called CC=5 SCAR=16.6
Pod documented
487 2 my ( $self, $value ) = @_;
488 2 ▶ if ( defined $value ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 1 1 2
489 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
490 unless $value =~ /^[-+]?\d*$/ and $value > 0;
491 1 $self->{_dataset_count} = $value;
492 }
493 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
494 }
495  
496 =head2 model
497  
498 Title : model
499 Usage : $phyml->model('HKY');
500 Function: Choose the substitution model to use. One of
501  
502 JC69 | K2P | F81 | HKY | F84 | TN93 | GTR (DNA)
503 JTT | MtREV | Dayhoff | WAG (amino acids)
504  
505 v3.0:
506 HKY85 (default) | JC69 | K80 | F81 | F84 |
507 TN93 | GTR (DNA)
508 LG (default) | WAG | JTT | MtREV | Dayhoff | DCMut |
509 RtREV | CpREV | VT | Blosum62 | MtMam | MtArt |
510 HIVw | HIVb (amino acids)
511  
512 Returns : Name of the model, v2.4.4 defaults to {HKY|JTT}
513 Args : None to get, string to set.
514  
515 =cut
516  
517 0 ▶sub model {
Subroutine model: not called CC=12 SCAR=50.5
Pod documented
518 0 my ( $self, $value ) = @_;
519 0 ▶ if ( defined($value) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 0 0 0
520 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
521 0 ▶ unless ( $value =~ /\d{6}/ ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($value =~ /\d{6}/) 0 0 0
522 $self->throw(
523 "Not a valid model name [$value] for current data type (alphabet)"
524 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
525 }
526 }
527 else {
528 $self->throw(
529 "Not a valid model name [$value] for current data type (alphabet)"
530 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
531 }
532 0 $self->{_model} = $value;
533 }
534  
535 0 ▶ if ( $self->{_model} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_model"}) 0 0 0
536 0 return $self->{_model};
537 }
538  
539 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
540 0 ▶ if ( $self->data_type eq 'aa' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->data_type eq 'aa') { } 0 0 0
541 0 return 'LG'; # protein
542 }
543 else {
544 0 return 'HKY85'; # DNA
545 }
546 }
547 else {
548 0 ▶ if ( $self->data_type ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->data_type) { } 0 0 0
549 0 return 'JTT'; # protein
550 }
551 else {
552 0 return 'HKY'; # DNA
553 }
554 }
555 }
556  
557 =head2 kappa
558  
559 Title : kappa
560 Usage : $phyml->kappa(4);
561 Function: Sets transition/transversion ratio, leave unset to estimate
562 Returns : set value, defaults to 'e'
563 Args : None to get, float or integer to set.
564  
565 =cut
566  
567 2 ▶sub kappa {
Subroutine kappa: called CC=6 SCAR=18.6
Pod documented
568 2 my ( $self, $value ) = @_;
569 2 ▶ if ( defined $value ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 1 1 2
570 1 ▶ die "Invalid number [$value]"
Branch: 1 branch
BranchTrueFalseTotal
unless $value =~ /^[-+]?\d*\.?\d*$/ or $value eq "e" 0 1 1
Condition33%1/3
$value =~ /^[-+]?\d*\.?\d*$/ or $value eq "e"
l!l&&r!l&&!r
100
MC/DC0%0/2
$value =~ /^[-+]?\d*\.?\d*$/ or $value eq "e"
$value =~ /^[-+]?\d*\.?\d*$/ $value eq "e"
Truth table33%1/3
A or B
A= $value =~ /^[-+]?\d*\.?\d*$/B= $value eq "e"
ABresult
1X1
011
000
571 unless $value =~ /^[-+]?\d*\.?\d*$/
572 or $value eq 'e';
573 1 $self->{_kappa} = $value;
574 }
575 2 ▶ return 'e' unless defined $self->{_kappa};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"_kappa"} 1 1 2
576 1 ▶ return 'e' if $self->{_kappa} eq 'e';
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_kappa"} eq "e" 0 1 1
577 1 return sprintf( "%.1f", $self->{_kappa} );
578 }
579  
580 =head2 invar
581  
582 Title : invar
583 Usage : $phyml->invar(.3);
584 Function: Sets proportion of invariable sites, 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 2 ▶sub invar {
Subroutine invar: called CC=6 SCAR=18.6
Pod documented
591 2 my ( $self, $value ) = @_;
592 2 ▶ if ( defined $value ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 1 1 2
593 1 ▶ die "Invalid number [$value]"
Branch: 1 branch
BranchTrueFalseTotal
unless $value =~ /^[-+]?\d*\.\d*$/ or $value eq "e" 0 1 1
Condition33%1/3
$value =~ /^[-+]?\d*\.\d*$/ or $value eq "e"
l!l&&r!l&&!r
100
MC/DC0%0/2
$value =~ /^[-+]?\d*\.\d*$/ or $value eq "e"
$value =~ /^[-+]?\d*\.\d*$/ $value eq "e"
Truth table33%1/3
A or B
A= $value =~ /^[-+]?\d*\.\d*$/B= $value eq "e"
ABresult
1X1
011
000
594 unless $value =~ /^[-+]?\d*\.\d*$/
595 or $value eq 'e';
596 1 $self->{_invar} = $value;
597 }
598 2 ▶ return 'e' unless defined $self->{_invar};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"_invar"} 1 1 2
599 1 ▶ return 'e' if $self->{_invar} eq 'e';
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_invar"} eq "e" 0 1 1
600 1 return sprintf( "%.1f", $self->{_invar} );
601 }
602  
603 =head2 category_number
604  
605 Title : category_number
606 Usage : $phyml->category_number(4);
607 Function: Sets number of relative substitution rate categories
608 Returns : set value, defaults to 1
609 Args : None to get, integer to set.
610  
611 =cut
612  
613 2 ▶sub category_number {
Subroutine category_number: called CC=5 SCAR=16.6
Pod documented
614 2 my ( $self, $value ) = @_;
615 2 ▶ if ( defined $value ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 1 1 2
616 1 ▶ die "Invalid postive 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
617 unless $value =~ /^[+]?\d*$/ and $value > 0;
618 1 $self->{_category_number} = $value;
619 }
620 2 ▶ return $self->{_category_number} || 1;
Condition100%2/2
$self->{'_category_number'} || 1
l!l
11
MC/DC100%1/1
$self->{'_category_number'} || 1
$self->{'_category_number'}
Truth table100%2/2
A
A= $self->{'_category_number'}
Aresult
11
00
621 }
622  
623 =head2 alpha
624  
625 Title : alpha
626 Usage : $phyml->alpha(1.0);
627 Function: Sets gamma distribution parameter, leave unset to estimate
628 Returns : set value, defaults to 'e'
629 Args : None to get, float or integer to set.
630  
631 =cut
632  
633 3 ▶sub alpha {
Subroutine alpha: called CC=7 SCAR=19.7
Pod documented
634 3 my ( $self, $value ) = @_;
635 3 ▶ if ( defined $value ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 2 1 3
636 2 ▶ die "Invalid number [$value]"
Branch: 1 branch
BranchTrueFalseTotal
unless $value =~ /^[-+]?\d*\.?\d*$/ or $value eq "e" 0 2 2
Condition66%2/3
$value =~ /^[-+]?\d*\.?\d*$/ or $value eq "e"
l!l&&r!l&&!r
110
MC/DC0%0/2
$value =~ /^[-+]?\d*\.?\d*$/ or $value eq "e"
$value =~ /^[-+]?\d*\.?\d*$/ $value eq "e"
Truth table66%2/3
A or B
A= $value =~ /^[-+]?\d*\.?\d*$/B= $value eq "e"
ABresult
1X1
011
000
637 unless $value =~ /^[-+]?\d*\.?\d*$/
638 or $value eq 'e';
639 2 $self->{_alpha} = $value;
640 }
641 3 ▶ return 'e' unless defined $self->{_alpha};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"_alpha"} 1 2 3
642 2 ▶ return 'e' if $self->{_alpha} eq 'e';
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_alpha"} eq "e" 1 1 2
643 1 ▶ return sprintf( "%.1f", $self->{_alpha} ) || 'e';
Condition50%1/2
sprintf('%.1f', $self->{'_alpha'}) || 'e'
l!l
10
MC/DC0%0/1
sprintf('%.1f', $self->{'_alpha'}) || 'e'
sprintf('%.1f', $self->{'_alpha'})
Truth table50%1/2
A
A= sprintf('%.1f', $self->{'_alpha'})
Aresult
11
00
644 }
645  
646 =head2 tree
647  
648 Title : tree
649 Usage : $phyml->tree('/tmp/tree.nwk');
650 Function: Sets starting tree, leave unset to estimate a distance tree
651 Returns : set value, defaults to 'BIONJ'
652 Args : None to get, newick tree file name to set.
653  
654 =cut
655  
656 3 ▶sub tree {
Subroutine tree: called CC=5 SCAR=16.2
Pod documented
657 3 my ( $self, $value ) = @_;
658 3 ▶ if ( defined $value ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 2 1 3
659 2 ▶ die "Invalid number [$value]"
Branch: 1 branch
BranchTrueFalseTotal
unless -e $value or $value eq "BIONJ" 0 2 2
Condition66%2/3
-e $value or $value eq "BIONJ"
l!l&&r!l&&!r
110
MC/DC0%0/2
-e $value or $value eq "BIONJ"
-e $value $value eq "BIONJ"
Truth table66%2/3
A or B
A= -e $valueB= $value eq "BIONJ"
ABresult
1X1
011
000
660 unless -e $value or $value eq 'BIONJ';
661 2 $self->{_tree} = $value;
662 }
663 3 ▶ return $self->{_tree} || 'BIONJ';
Condition100%2/2
$self->{'_tree'} || 'BIONJ'
l!l
21
MC/DC100%1/1
$self->{'_tree'} || 'BIONJ'
$self->{'_tree'}
Truth table100%2/2
A
A= $self->{'_tree'}
Aresult
11
00
664 }
665  
666 =head2 v2 options
667  
668 These methods can be used with PhyML v2* only.
669  
670 =head2 opt_topology
671  
672 Title : opt_topology
673 Usage : $factory->opt_topology(1);
674 Function: Choose to optimise the tree topology
675 Returns : 1 or 0. Default is 1.
676 Args : None to get, boolean to set.
677  
678 v2.* only
679  
680 =cut
681  
682 0 ▶sub opt_topology {
Subroutine opt_topology: not called CC=6 SCAR=37.4
Pod documented
683 0 my ( $self, $value ) = @_;
684 0 ▶ $self->throw("Not a valid parameter [opt_topology] for to PhyML v3")
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
685 if $self->version && $self->version >= 3;
686 0 ▶ if ( defined($value) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 0 0 0
687 0 ▶ if ($value) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value) { } 0 0 0
688 0 $self->{_opt_topology} = 1;
689 }
690 else {
691 0 $self->{_opt_topology} = 0;
692 }
693 }
694 0 ▶ return $self->{_opt_topology} || 1;
Condition0%0/2
$self->{'_opt_topology'} || 1
l!l
00
MC/DC0%0/1
$self->{'_opt_topology'} || 1
$self->{'_opt_topology'}
Truth table0%0/2
A
A= $self->{'_opt_topology'}
Aresult
11
00
695 }
696  
697 =head2 opt_lengths
698  
699 Title : opt_lengths
700 Usage : $factory->opt_lengths(0);
701 Function: Choose to optimise branch lengths and rate parameters
702 Returns : 1 or 0. Default is 1.
703 Args : None to get, boolean to set.
704  
705  
706 v2.* only
707  
708 =cut
709  
710 0 ▶sub opt_lengths {
Subroutine opt_lengths: not called CC=6 SCAR=37.4
Pod documented
711 0 my ( $self, $value ) = @_;
712 0 ▶ $self->throw("Not a valid parameter [opt_lengths] for PhyML v3")
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
713 if $self->version && $self->version >= 3;
714 0 ▶ if ( defined($value) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 0 0 0
715 0 ▶ if ($value) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value) { } 0 0 0
716 0 $self->{_opt_lengths} = 1;
717 }
718 else {
719 0 $self->{_opt_lengths} = 0;
720 }
721 }
722 0 ▶ return $self->{_opt_lengths} || 1;
Condition0%0/2
$self->{'_opt_lengths'} || 1
l!l
00
MC/DC0%0/1
$self->{'_opt_lengths'} || 1
$self->{'_opt_lengths'}
Truth table0%0/2
A
A= $self->{'_opt_lengths'}
Aresult
11
00
723 }
724  
725 =head2 v3 options
726  
727 These methods can be used with PhyML v3* only.
728  
729 =head2 freq
730  
731 Title : freq
732 Usage : $phyml->freq(e); $phyml->freq("0.2, 0.6, 0.6, 0.2");
733 Function: Sets nucleotide frequences or asks residue to be estimated
734 according to two models: e or d
735 Returns : set value,
736 Args : None to get, string to set.
737  
738 v3 only.
739  
740 =cut
741  
742 0 ▶sub freq {
Subroutine freq: not called CC=6 SCAR=37.4
Pod documented
743 0 my ( $self, $value ) = @_;
744 0 ▶ $self->throw("Not a valid parameter [freq] prior to PhyML v3")
Branch: 1 branch
BranchTrueFalseTotal
if $self->version < 3 0 0 0
745 if $self->version < 3;
746 0 ▶ if ( defined $value ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 0 0 0
747 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
748 unless $value =~ /^[\d\. ]$/
749 or $value eq 'e'
750 or $value eq 'd';
751 0 $self->{_freq} = $value;
752 }
753 0 return $self->{_freq};
754 }
755  
756 =head2 opt
757  
758 Title : opt
759 Usage : $factory->opt(1);
760 Function: Optimise tree parameters: tlr|tl|tr|l|n
761 Returns : {value|n} (default n)
762 Args : None to get, string to set.
763  
764 v3.* only
765  
766 =cut
767  
768 0 ▶sub opt {
Subroutine opt: not called CC=5 SCAR=34.0
Pod documented
769 0 my ( $self, $value ) = @_;
770 0 ▶ $self->throw("Not a valid parameter [opt] prior to PhyML v3")
Branch: 1 branch
BranchTrueFalseTotal
if $self->version < 3 0 0 0
771 if $self->version < 3;
772 0 ▶ if ( defined($value) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 0 0 0
773 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
774 }
775 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
776 }
777  
778 =head2 search
779  
780 Title : search
781 Usage : $factory->search(SPR);
782 Function: Tree topology search operation algorithm: NNI|SPR|BEST
783 Returns : string (defaults to NNI)
784 Args : None to get, string to set.
785  
786 v3.* only
787  
788 =cut
789  
790 0 ▶sub search {
Subroutine search: not called CC=5 SCAR=34.0
Pod documented
791 0 my ( $self, $value ) = @_;
792 0 ▶ $self->throw("Not a valid parameter [search] prior to PhyML v3")
Branch: 1 branch
BranchTrueFalseTotal
if $self->version < 3 0 0 0
793 if $self->version < 3;
794 0 ▶ if ( defined($value) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 0 0 0
795 0 ▶ $self->{_search} = $value if $value =~ /NNI|SPR|BEST/;
Branch: 1 branch
BranchTrueFalseTotal
if $value =~ /NNI|SPR|BEST/ 0 0 0
796 }
797 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
798 }
799  
800 =head2 rand_start
801  
802 Title : rand_start
803 Usage : $factory->rand_start(1);
804 Function: Sets the initial SPR tree to random.
805 Returns : boolean (defaults to false)
806 Args : None to get, boolean to set.
807  
808 v3.* only; only meaningful if $prog-E<gt>search is 'SPR'
809  
810 =cut
811  
812 0 ▶sub rand_start {
Subroutine rand_start: not called CC=4 SCAR=30.0
Pod documented
813 0 my ( $self, $value ) = @_;
814 0 ▶ $self->throw("Not a valid parameter [rand_start] prior to PhyML v3")
Branch: 1 branch
BranchTrueFalseTotal
if $self->version < 3 0 0 0
815 if $self->version < 3;
816 0 ▶ if ( defined($value) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 0 0 0
817 0 ▶ if ($value) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value) { } 0 0 0
818 0 $self->{_rand_start} = 1;
819 }
820 else {
821 0 $self->{_rand_start} = 0;
822 }
823 }
824 0 return $self->{_rand_start};
825 }
826  
827 =head2 rand_starts
828  
829 Title : rand_starts
830 Usage : $factory->rand_starts(10);
831 Function: Sets the number of initial random SPR trees
832 Returns : integer (defaults to 1)
833 Args : None to get, integer to set.
834  
835 v3.* only; only valid if $prog-E<gt>search is 'SPR'
836  
837 =cut
838  
839 0 ▶sub rand_starts {
Subroutine rand_starts: not called CC=5 SCAR=34.0
Pod documented
840 0 my ( $self, $value ) = @_;
841 0 ▶ $self->throw("Not a valid parameter [rand_starts] prior to PhyML v3")
Branch: 1 branch
BranchTrueFalseTotal
if $self->version < 3 0 0 0
842 if $self->version < 3;
843 0 ▶ if ( defined $value ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 0 0 0
844 0 ▶ die "Invalid number [$value]"
Branch: 1 branch
BranchTrueFalseTotal
unless $value =~ /^[-+]?\d+$/ 0 0 0
845 unless $value =~ /^[-+]?\d+$/;
846 0 $self->{_rand_starts} = $value;
847 }
848 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
849 }
850  
851 =head2 rand_seed
852  
853 Title : rand_seed
854 Usage : $factory->rand_seed(1769876);
855 Function: Seeds the random number generator
856 Returns : random integer
857 Args : None to get, integer to set.
858  
859 v3.* only; only valid if $prog-E<gt>search is 'SPR'
860  
861 Uses perl rand() to initialize if not explicitely set.
862  
863 =cut
864  
865 0 ▶sub rand_seed {
Subroutine rand_seed: not called CC=5 SCAR=34.0
Pod documented
866 0 my ( $self, $value ) = @_;
867 0 ▶ $self->throw("Not a valid parameter [rand_seed] prior to PhyML v3")
Branch: 1 branch
BranchTrueFalseTotal
if $self->version < 3 0 0 0
868 if $self->version < 3;
869 0 ▶ if ( defined $value ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 0 0 0
870 0 ▶ die "Invalid number [$value]"
Branch: 1 branch
BranchTrueFalseTotal
unless $value =~ /^[-+]?\d+$/ 0 0 0
871 unless $value =~ /^[-+]?\d+$/;
872 0 $self->{_rand_seed} = $value;
873 }
874 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
875 }
876  
877 =head2 no_memory_check
878  
879 Title : no_memory_check
880 Usage : $factory->no_memory_check(1);
881 Function:
882 Returns : boolean (defaults to false)
883 Args : None to get, integer to set.
884  
885 =cut
886  
887 0 ▶sub no_memory_check {
Subroutine no_memory_check: not called CC=5 SCAR=34.0
Pod documented
888 0 my ( $self, $value ) = @_;
889 0 ▶ $self->throw("Not a valid parameter [no_memory_check] prior to PhyML v3")
Branch: 1 branch
BranchTrueFalseTotal
if $self->version < 3 0 0 0
890 if $self->version < 3;
891 0 ▶ if ( defined($value) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 0 0 0
892 0 ▶ if ($value) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value) { } 0 0 0
893 0 $self->{_no_memory_check} = 1;
894 }
895 else {
896 0 $self->{_no_memory_check} = 0;
897 }
898 }
899 0 ▶ return $self->{_no_memory_check} || 0;
Condition0%0/2
$self->{'_no_memory_check'} || 0
l!l
00
MC/DC0%0/1
$self->{'_no_memory_check'} || 0
$self->{'_no_memory_check'}
Truth table0%0/2
A
A= $self->{'_no_memory_check'}
Aresult
11
00
900 }
901  
902 =head2 bootstrap
903  
904 Title : bootstrap
905 Usage : $factory->bootstrap(100);
906 Function: Set number of bootstraps
907 Returns :
908 Args : None to get, integer to set.
909  
910 =cut
911  
912 0 ▶sub bootstrap {
Subroutine bootstrap: not called CC=4 SCAR=30.0
913 0 my ( $self, $value ) = @_;
914 0 ▶ $self->throw("Not a valid parameter [bootstrap] prior to PhyML v3")
Branch: 1 branch
BranchTrueFalseTotal
if $self->version < 3 0 0 0
915 if $self->version < 3;
916 0 ▶ if ( defined $value ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 0 0 0
917 0 ▶ die "Invalid number [$value]" unless $value =~ /^\d+$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $value =~ /^\d+$/ 0 0 0
918 0 $self->{_bootstrap} = $value;
919 }
920 0 return $self->{_bootstrap};
921 }
922  
923 =head2 command
924  
925 Title : command
926 Usage : $factory->command(...);
927 Function:
928 Returns : string
929 Args : None to get, integer to set.
930  
931 =cut
932  
933 0 ▶sub command {
Subroutine command: not called CC=4 SCAR=30.0
Pod documented
934 0 my ( $self, $value ) = @_;
935 0 ▶ if ( defined($value) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 0 0 0
936 0 ▶ if ($value =~ /$PROGRAM_NAME/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value =~ /$Bio::Tools::Run::Phylo::Phyml::PROGRAM_NAME/) { } 0 0 0
937 0 $self->{_command} = $value;
938 }
939 else {
940 0 $self->throw("$value is not a $PROGRAM_NAME command");
941 }
942 }
943 0 ▶ return $self->{_command} || '';
Condition0%0/2
$self->{'_command'} || ''
l!l
00
MC/DC0%0/1
$self->{'_command'} || ''
$self->{'_command'}
Truth table0%0/2
A
A= $self->{'_command'}
Aresult
11
00
944 }
945  
946 =head2 Internal methods
947  
948 These methods are private and should not be called outside this class.
949  
950 =cut
951  
952 0 ▶sub _run {
Subroutine _run: not called CC=6 SCAR=37.4
953 0 my ( $self, $file ) = @_;
954  
955 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
956  
957 0 my $command;
958 my $output_stat_file;
959 0 ▶ if ( $self->version >= 3 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->version >= 3) { } 0 0 0
960 0 $command = $exe . " -i $file" . $self->_setparams;
961 0 $output_stat_file = '_phyml_stats.txt';
962 }
963 else {
964 0 $command = $exe . " $file " . $self->arguments . $self->_setparams;
965 0 $output_stat_file = '_phyml_stat.txt';
966 }
967  
968 0 $self->command($command);
969 0 $self->debug("Phyml command = $command\n");
970 0 `$command`;
971  
972 # stats
973 {
974 0 my $stat_file = $file . $output_stat_file;
975 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
976 || $self->throw(
977 "Phyml call ($command) did not give an output [$stat_file]: $?");
978 0 local $/;
979 0 $self->{_stats} .= <$FH_STAT>;
980 }
981  
982 #print $self->{stats};
983  
984 # tree
985 0 my $tree_file = $file . '_phyml_tree.txt';
986 {
987 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
988 || $self->throw("Phyml call ($command) did not give an output: $?");
989 0 local $/;
990 0 $self->{_tree} .= <$FH_TREE>;
991 }
992  
993 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
994 || $self->throw("Phyml call ($command) did not give an output: $?");
995  
996 0 my $treeio = Bio::TreeIO->new( -format => 'nhx', -fh => $FH_TREE );
997 0 my $tree = $treeio->next_tree;
998  
999 # could be faster to parse the tree only if needed?
1000  
1001 0 return $tree;
1002 }
1003  
1004 =head2 _setparams
1005  
1006 Title : _setparams
1007 Usage : Internal function, not to be called directly
1008 Function: Creates a string of params to be used in the command string
1009 Returns : string of params
1010 Args : none
1011  
1012 =cut
1013  
1014 0 ▶sub _setparams {
Subroutine _setparams: not called CC=14 SCAR=53.5
1015 0 my $self = shift;
1016 0 my $param_string;
1017  
1018 0 ▶ if ( $self->version >= 3 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->version >= 3) { } 0 0 0
1019  
1020 # version 3 or higher
1021 0 $param_string = ' -d ' . $self->data_type;
1022  
1023 0 ▶ $param_string .= ' -q ' if $self->data_format eq 's';
Branch: 1 branch
BranchTrueFalseTotal
if $self->data_format eq "s" 0 0 0
1024 0 ▶ $param_string .= ' -n ' . $self->dataset_count
Branch: 1 branch
BranchTrueFalseTotal
if $self->dataset_count > 1 0 0 0
1025 if $self->dataset_count > 1;
1026 0 ▶ $param_string .= ' -b ' . $self->bootstrap if $self->bootstrap;
Branch: 1 branch
BranchTrueFalseTotal
if $self->bootstrap 0 0 0
1027  
1028 # $param_string .= ' 0'; # no bootstrap sets
1029 0 $param_string .= ' -m ' . $self->model;
1030 0 ▶ $param_string .= ' -f ' . $self->freq if $self->freq;
Branch: 1 branch
BranchTrueFalseTotal
if $self->freq 0 0 0
1031  
1032 0 ▶ if ( $self->data_type eq 'dna' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->data_type eq "dna") 0 0 0
1033 0 $param_string .= ' -t ' . $self->kappa;
1034 }
1035  
1036 0 $param_string .= ' -v ' . $self->invar;
1037 0 $param_string .= ' -c ' . $self->category_number;
1038 0 $param_string .= ' -a ' . $self->alpha;
1039 0 ▶ $param_string .= ' -u ' . $self->tree if $self->tree ne 'BIONJ';
Branch: 1 branch
BranchTrueFalseTotal
if $self->tree ne "BIONJ" 0 0 0
1040 0 ▶ $param_string .= ' -o ' . $self->opt if $self->opt;
Branch: 1 branch
BranchTrueFalseTotal
if $self->opt 0 0 0
1041 0 $param_string .= ' -s ' . $self->search;
1042  
1043 0 ▶ if ( $self->search eq 'SPR' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->search eq "SPR") 0 0 0
1044 0 ▶ $param_string .= ' --rand_start ' if $self->rand_start;
Branch: 1 branch
BranchTrueFalseTotal
if $self->rand_start 0 0 0
1045 0 ▶ $param_string .= ' --n_rand_starts ' . $self->rand_starts
Branch: 1 branch
BranchTrueFalseTotal
if $self->rand_starts 0 0 0
1046 if $self->rand_starts;
1047 0 $param_string .= ' --r_seed ' . $self->rand_seed;
1048 }
1049  
1050 0 ▶ $param_string .= ' --no_memory_check '
Branch: 1 branch
BranchTrueFalseTotal
if $self->no_memory_check 0 0 0
1051 if $self->no_memory_check;
1052  
1053 }
1054 else {
1055  
1056 # version 2
1057 0 $param_string = ' ' . $self->data_type;
1058 0 $param_string .= ' ' . $self->data_format;
1059 0 $param_string .= ' ' . $self->dataset_count;
1060 0 $param_string .= ' 0'; # no bootstrap sets
1061 0 $param_string .= ' ' . $self->model;
1062  
1063 0 ▶ unless ( $self->data_type ) { # only for DNA
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->data_type) 0 0 0
1064 0 $param_string .= ' ' . $self->kappa;
1065 }
1066  
1067 0 $param_string .= ' ' . $self->invar;
1068 0 $param_string .= ' ' . $self->category_number;
1069 0 $param_string .= ' ' . $self->alpha;
1070 0 $param_string .= ' ' . $self->tree;
1071 0 $param_string .= ' ' . $self->opt_topology;
1072 0 $param_string .= ' ' . $self->opt_lengths;
1073  
1074 }
1075 0 return $param_string;
1076 }
1077  
1078 =head2 _write_phylip_align_file
1079  
1080 Title : _write_phylip_align_file
1081 Usage : obj->__write_phylip_align_file($aln)
1082 Function: Internal (not to be used directly)
1083  
1084 Writes the alignment into the tmp directory
1085 in PHYLIP interlieved format
1086  
1087 Returns : filename
1088 Args : Bio::Align::AlignI
1089  
1090 =cut
1091  
1092 0 ▶sub _write_phylip_align_file {
Subroutine _write_phylip_align_file: not called CC=1 SCAR=6.9
1093 0 my ( $self, $align ) = @_;
1094  
1095 0 my $tempfile = File::Spec->catfile( $self->tempdir, "aln$$.phylip" );
1096 0 $self->data_format('i');
1097 0 my $out = Bio::AlignIO->new(
1098 -file => ">$tempfile",
1099 -format => 'phylip',
1100 -interleaved => 1,
1101 -longid => 1
1102 );
1103 0 $out->write_aln($align);
1104 0 $out->close();
1105 0 $out = undef;
1106 0 return $tempfile;
1107 }
1108  
1109 1 1;
« Tools/Run/RNAMotif.pm ↑ Summary Tools/Run/Phylo/Hyphy/Base.pm »