blib/lib/Bio/Tools/Run/Phylo/Molphy/ProtML.pm

filter: Statementstmt 42.2% 71 / 168 Branchbran 25.6% 19 / 74 Conditioncond 13.3% 4 / 30 MC/DCmcdc 0.0% 0 / 19 Subroutinesub 61.9% 13 / 21 Podpod 100% 10 / 10 totaltotal 36.3% 117 / 322 CC 53 SCAR 41.0
CC
53
Cov
35%
run
240.0
__ANON__
20.0
alignment
20.0
CRAP 60.2
« blib/lib/Bio/Tools/Run/Phylo/Njtree/Best.pm ↑ Summary blib/lib/Bio/Tools/Run/Phylo/Hyphy/Base.pm »
1 # $Id$
2 #
3 # BioPerl module for Bio::Tools::Run::Phylo::Molphy::ProtML
4 #
5 # Please direct questions and support issues to <bioperl-l@bioperl.org>
6 #
7 # Cared for by Jason Stajich <jason-AT-bioperl_DOT_org>
8 #
9 # Copyright Jason Stajich
10 #
11 # You may distribute this module under the same terms as perl itself
12  
13 # POD documentation - main docs before the code
14  
15 =head1 NAME
16  
17 Bio::Tools::Run::Phylo::Molphy::ProtML - A wrapper for the Molphy pkg app ProtML
18  
19 =head1 SYNOPSIS
20  
21 use Bio::AlignIO;
22 use Bio::TreeIO;
23 use Bio::Tools::Run::Phylo::Molphy::ProtML;
24  
25 my %args = ( 'models' => 'jtt',
26 'search' => 'quick',
27 'other' => [ '-information', '-w'] );
28 my $verbose = 0; # change to 1 if you want some debugging output
29 my $protml = Bio::Tools::Run::Phylo::Molphy::ProtML->new(-verbose => $verbose,
30 -flags => \%args);
31  
32 die("cannot find the protml executable") unless $protml->executable;
33  
34 # read in a previously built protein alignment
35 my $in = Bio::AlignIO->new(-format => 'clustalw',
36 -file => 't/data/cel-cbr-fam.aln');
37 my $aln = $in->next_aln;
38 $protml->alignment($aln);
39  
40 my ($rc,$results) = $protml->run();
41  
42 # This may be a bit of overkill, but it is possible we could
43 # have a bunch of results and $results is a
44 # Bio::Tools::Phylo::Molphy object
45  
46 my $r = $results->next_result;
47 # $r is a Bio::Tools::Phylo::Molphy::Result object
48  
49 my @trees;
50 while( my $t = $r->next_tree ) {
51 push @trees, $t;
52 }
53  
54 print "search space is ", $r->search_space, "\n";
55 "1st tree score is ", $tree[0]->score, "\n";
56  
57 my $out = Bio::TreeIO->new(-file => ">saved_MLtrees.tre",
58 -format => "newick");
59 $out->write_tree($tree[0]);
60 $out = undef;
61  
62 =head1 DESCRIPTION
63  
64 This is a wrapper for the exe from the Molphy (MOLecular
65 PHYlogenetics) package by Jun Adachi & Masami Hasegawa. The software
66 can be downloaded from L<http://www.ism.ac.jp/ismlib/softother.e.html>.
67 Note that PHYLIP (Joe Felsenstein) also provides a version of protml
68 which this module is currently NOT prepared to handle. Use the package
69 available directly from MOLPHY authors if you want to use the module
70 in its present implementation (extensions are welcomed!).
71  
72 The main components are the protml and nucml executables which are
73 used to build maximum likelihood (ML) phylogenetic trees based on
74 either protein or nucleotide sequences.
75  
76 Here are the valid input parameters, we have added a longhand version
77 of the parameters to help you understand what each one does. Either
78 the longhand or the original Molphy parameter will work.
79  
80 Bioperl Molphy Description
81 Longhand parameter
82 Model (one of these):
83 ---------------
84 jtt j Jones, Taylor & Thornton (1992)
85 jtt-f jf JTT w/ frequencies
86 dayhoff d Dahoff et al. (1978)
87 dayhoff-f d dayhoff w/ frequencies
88 mtrev24 m mtREV24 Adachi & Hasegwa (1995)
89 mtrev24-f mf mtREV24 w/ frequencies
90 poisson p Poisson
91 proportional pf Proportional
92 rsr r Relative Substitution Rate
93 rsr-f rf RSR w/ frequencies
94 frequencies f data frequencies
95  
96 Search Strategy (one of these):
97 ----------------
98 usertrees u User trees (must also supply a tree)
99 rearrangement R Local rearrangement
100 lbp RX Local boostrap prob
101 exhaustive e Exhaustive search
102 star s Star decomposition search (may not be ML)
103 quick q Quick Add OTU search (may not be ML)
104 distance D ML Distance matrix --> NJDIST (need to supply
105 NJDIST tree)
106  
107 Others (can be some or all of these):
108 ---------------
109 norell-bp b No RELL-BP
110 minimumevolution M Minimum evolution
111  
112 sequential S Sequence is in Sequential format
113 _OR_
114 interleaved I Sequence is in Interleaved format
115  
116 verbose v Verbose messages directed to STDERR
117 information i Output some information (tree vals)
118 w More some extra information (transition
119 matricies, etc)
120  
121  
122 =head1 FEEDBACK
123  
124 =head2 Mailing Lists
125  
126 User feedback is an integral part of the evolution of this and other
127 Bioperl modules. Send your comments and suggestions preferably to
128 the Bioperl mailing list. Your participation is much appreciated.
129  
130 bioperl-l@bioperl.org - General discussion
131 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
132  
133 =head2 Support
134  
135 Please direct usage questions or support issues to the mailing list:
136  
137 I<bioperl-l@bioperl.org>
138  
139 rather than to the module maintainer directly. Many experienced and
140 reponsive experts will be able look at the problem and quickly
141 address it. Please include a thorough description of the problem
142 with code and data examples if at all possible.
143  
144 =head2 Reporting Bugs
145  
146 Report bugs to the Bioperl bug tracking system to help us keep track
147 of the bugs and their resolution. Bug reports can be submitted via the
148 web:
149  
150 http://redmine.open-bio.org/projects/bioperl/
151  
152 =head1 AUTHOR - Jason Stajich
153  
154 Email jason-AT-bioperl_DOT_org
155  
156 =head1 CONTRIBUTORS
157  
158 Additional contributors names and emails here
159  
160 =head1 APPENDIX
161  
162 The rest of the documentation details each of the object methods.
163 Internal methods are usually preceded with a _
164  
165 =cut
166  
167  
168 # Let the code begin...
169  
170  
171 package Bio::Tools::Run::Phylo::Molphy::ProtML;
172 1 ▶use vars qw(@ISA $PROGRAMNAME $PROGRAM $MINNAMELEN %VALIDVALUES %VALIDFLAGS);
Subroutine BEGIN: called CC=1 SCAR=0.0
173 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
174 1 ▶use Bio::Tools::Run::WrapperBase;
Subroutine BEGIN: called CC=1 SCAR=0.0
175 1 ▶use Bio::Tools::Phylo::Molphy;
Subroutine BEGIN: called CC=1 SCAR=0.0
176 1 ▶use Bio::AlignIO;
Subroutine BEGIN: called CC=1 SCAR=0.0
177 1 ▶use Bio::TreeIO;
Subroutine BEGIN: called CC=1 SCAR=0.0
178 1 ▶use Bio::Root::Root;
Subroutine BEGIN: called CC=1 SCAR=0.0
179  
180 1 @ISA = qw(Bio::Root::Root Bio::Tools::Run::WrapperBase );
181  
182 BEGIN {
183 1 ▶ $MINNAMELEN = 25;
Subroutine BEGIN: called CC=3 SCAR=16.3
184  
185 1 %VALIDFLAGS = (
186 'models' => { # models
187 jtt => 'j', # Jones, Taylor & Thornton (1992)
188 'jtt-f' => 'jf', # jtt w/ frequencies
189 dayhoff => 'd', # Dahoff et al. (1978)
190 'dayhoff-f' => 'df', # dayhoff w/ frequencies
191 mtrev24 => 'm', # Adachi & Hasegwa (1995)
192 'mtrev24-f' => 'mf', # mtREV24 w/ frequencies
193 poisson => 'p', # Poisson
194 proportional => 'pf', # Proportional
195 rsr => 'r', # Relative Substitution Rate
196 'rsr-f' => 'rf', # RSR w/ frequencies
197 frequencies => 'f', # data frequencies
198 },
199 'search' => { # search strategy
200 usertrees => 'u', # must also supply tree
201 rearrangement => 'R', # local rearrangement
202 lbp => 'RX', # local boostrap prob
203 exhaustive => 'e', # exhaustive
204 star => 's', # star decomposition search (may not be ML)
205 quick => 'q', # quick add OTU search (may not be ML)
206 distance => 'D', # ML Distance matrix --> NJDIST
207 },
208 'others' => { # others
209 'norell-bp' => 'b',
210 sequential => 'S', # sequential format
211 interleaved => 'I', # interleaved format
212 minimumevolution => 'M', # minimum evolution
213 verbose => 'v', # verbose to stderr
214 information => 'i', # output some information
215 w => 'w', # some extra information
216 }
217 );
218 # this will allow for each of the parameters to also accept the original
219 # protML params
220 1 my @toadd;
221 1 foreach my $type ( keys %VALIDFLAGS ) {
222 3 my @keys = keys %{ $VALIDFLAGS{$type} };
223 3 for my $k ( @keys ) {
224 25 my $v = $VALIDFLAGS{$type}->{$k};
225 25 $VALIDFLAGS{$type}->{$v} = $v;
226 }
227 }
228 0 ▶ %VALIDVALUES = (num_retained => sub { my $a = shift;
Subroutine __ANON__: not called CC=2 SCAR=17.9
229 0 ▶ if( $a =~ /^\d+$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($a =~ /^\d+$/) 0 0 0
230 0 return 'n';
231 }}, # should be a number
232 0 ▶ percent_retained => sub { my $a = shift;
Subroutine __ANON__: not called CC=4 SCAR=30.0
233 0 ▶ if( $a =~ /^\d+$/ &&
Branch: 1 branch
BranchTrueFalseTotal
if ($a =~ /^\d+$/ and $a >= 0 and $a <= 100) 0 0 0
Condition0%0/6
$a =~ /^\d+$/ and $a >= 0 and $a <= 100
!ll&&!rl&&r
000
$a =~ /^\d+$/ and $a >= 0
!ll&&!rl&&r
000
MC/DC0%0/3
$a =~ /^\d+$/ and $a >= 0 and $a <= 100
$a =~ /^\d+$/ $a >= 0 $a <= 100
Truth table0%0/4
A and B and C
A= $a =~ /^\d+$/B= $a >= 0C= $a <= 100
ABCresult
0XX0
10X0
1100
1111
234 $a >= 0 && $a <= 100) {
235 0 return 'P';
236 }}
237 1 );
238  
239  
240 }
241  
242 =head2 program_name
243  
244 Title : program_name
245 Usage : >program_name()
246 Function: holds the program name
247 Returns: string
248 Args : None
249  
250 =cut
251  
252 sub program_name {
253 6 ▶ return 'protml';
Subroutine program_name: called CC=1 SCAR=0.0
Pod documented
254 }
255  
256 =head2 program_dir
257  
258 Title : program_dir
259 Usage : ->program_dir()
260 Function: returns the program directory, obtained from ENV variable.
261 Returns: string
262 Args :
263  
264 =cut
265  
266 sub program_dir {
267 3 ▶ return Bio::Root::IO->catfile($ENV{MOLPHYDIR}) if $ENV{MOLPHYDIR};
Subroutine program_dir: called CC=2 SCAR=7.6
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"MOLPHYDIR"} 0 3 3
268 }
269  
270 =head2 new
271  
272 Title : new
273 Usage : my $obj = Bio::Tools::Run::Phylo::Molphy::ProtML->new();
274 Function: Builds a new Bio::Tools::Run::Phylo::Molphy::ProtML object
275 Returns : Bio::Tools::Run::Phylo::Molphy::ProtML
276 Args : -alignment => the Bio::Align::AlignI object
277 -save_tempfiles => boolean to save the generated tempfiles and
278 NOT cleanup after onesself (default FALSE)
279 -tree => the Bio::Tree::TreeI object
280 -params => a hashref of PAML parameters (all passed to
281 set_parameter)
282 -executable => where the protml executable resides
283  
284 See also: L<Bio::Tree::TreeI>, L<Bio::Align::AlignI>
285  
286  
287 =cut
288  
289 sub new {
290 1 ▶ my($class,@args) = @_;
Subroutine new: called CC=12 SCAR=28.5
Pod documented
291  
292 1 my $self = $class->SUPER::new(@args);
293 1 $self->{'_protmlparams'} = {};
294 1 $self->{'_protmlflags'} = {};
295  
296 1 my ($aln, $tree, $st, $flags, $params,
297 $exe) = $self->_rearrange([qw(ALIGNMENT TREE SAVE_TEMPFILES
298 FLAGS PARAMS EXECUTABLE)],
299 @args);
300 1 ▶ defined $aln && $self->alignment($aln);
Branch: 1 branch
BranchTrueFalseTotal
defined $aln and $self->alignment($aln) 0 1 1
301 1 ▶ defined $tree && $self->tree($tree );
Branch: 1 branch
BranchTrueFalseTotal
defined $tree and $self->tree($tree) 0 1 1
302 1 ▶ defined $st && $self->save_tempfiles($st);
Branch: 1 branch
BranchTrueFalseTotal
defined $st and $self->save_tempfiles($st) 0 1 1
303 1 ▶ defined $exe && $self->executable($exe);
Branch: 1 branch
BranchTrueFalseTotal
defined $exe and $self->executable($exe) 0 1 1
304 1 ▶ if( defined $flags ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $flags) 1 0 1
305 1 ▶ if( ref($flags) !~ /HASH/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not ref($flags) =~ /HASH/i) { } 0 1 1
306 0 $self->warn("Must provide a valid hash ref for parameter -FLAGS");
307 } else {
308 1 foreach my $type ( keys %$flags ) {
309 3 ▶ if( $type =~ /other/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type =~ /other/i) { } 1 2 3
310 1 foreach my $flag ( @{$flags->{$type}} ) {
311 2 $self->set_flag('others', $flag) ;
312 }
313 } else {
314 2 $self->set_flag($type, $flags->{$type}) ;
315 }
316 }
317 }
318 }
319 1 ▶ if( defined $params ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $params) 0 1 1
320 0 ▶ if( ref($flags) !~ /HASH/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not ref($flags) =~ /HASH/i) { } 0 0 0
321 0 $self->warn("Must provide a valid hash ref for parameter -FLAGS");
322 } else {
323 0 map { $self->set_parameter($_, $$params{$_}) } keys %$params;
324 }
325 }
326 1 return $self;
327 }
328  
329  
330 =head2 run
331  
332 Title : run
333 Usage : $protml->run();
334 Function: run the protml analysis using the default or updated parameters
335 the alignment parameter must have been set
336 Returns : Bio::Tools::Phylo::Molphy
337 Args :
338  
339  
340 =cut
341  
342 sub run {
343 0 ▶ my ($self) = @_;
Subroutine run: not called CC=15 SCAR=54.8
Pod documented
344  
345 0 ▶ unless ( $self->save_tempfiles ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->save_tempfiles) 0 0 0
346 0 $self->cleanup();
347 }
348  
349 0 my $align = $self->alignment();
350 0 ▶ if( ! $align ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($align) 0 0 0
351 0 $self->warn("must have provided a valid alignment object");
352 0 return -1;
353 }
354 0 ▶ if( $align->get_seq_by_pos(1)->alphabet ne 'protein' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($align->get_seq_by_pos(1)->alphabet ne "protein") 0 0 0
355 0 $self->warn("Must have provided a valid protein alignment");
356 0 return -1;
357 }
358  
359 0 my %params = $self->get_parameters;
360 0 my %flags = $self->get_flags();
361 0 my $cmdstring = $self->executable;
362  
363 0 ▶ if( ! defined $flags{'search'} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $flags{"search"}) 0 0 0
364 0 $self->warn("Must have set a valid 'search' flag to run protml this is one of ".join(",", keys %{$VALIDFLAGS{'search'}}));
365 0 return;
366 }
367 0 my $tree = $self->tree;
368  
369 0 for my $t ( keys %flags ) {
370 0 ▶ if( $t eq 'others' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t eq 'others') { } 0 0 0
371 0 $cmdstring .= " " . join(" ", map { '-'.$_ } keys %{$flags{$t}});
372 } else {
373 0 ▶ next if $flags{$t} eq 'u';
Branch: 1 branch
BranchTrueFalseTotal
if $flags{$t} eq "u" 0 0 0
374 0 $cmdstring .= " -".$flags{$t};
375 }
376 }
377  
378 0 ▶ while( my ($param,$val) = each %params ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %params) 0 0 0
379 0 $cmdstring .= " \-$param $val";
380 }
381 0 my ($tmpdir) = $self->tempdir();
382 0 ▶ my ($tempseqFH,$tempseqfile) = $self->io->tempfile
Branch: 1 branch
BranchTrueFalseTotal
$self->save_tempfiles ? : 0 0 0
383 ('DIR' => $tmpdir,
384 UNLINK => ($self->save_tempfiles ? 0 : 1));
385
386 0 ▶ my $alnout = Bio::AlignIO->new('-format' => 'phylip',
Branch: 1 branch
BranchTrueFalseTotal
$Bio::Tools::Run::Phylo::Molphy::ProtML::MINNAMELEN > $align->maxdisplayname_length ? : 0 0 0
387 '-fh' => $tempseqFH,
388 '-interleaved' => 0,
389 '-idlinebreak' => 1,
390 '-idlength' => $MINNAMELEN > $align->maxdisplayname_length() ? $MINNAMELEN : $align->maxdisplayname_length() +1);
391  
392 0 $alnout->write_aln($align);
393 0 $alnout->close();
394 0 $alnout = undef;
395 0 close($tempseqFH);
396 0 $tempseqFH = undef;
397 0 $cmdstring .= " $tempseqfile";
398 0 ▶ if( $tree && defined $flags{'search'} eq 'u' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tree and defined $flags{"search"} eq "u") 0 0 0
Condition0%0/3
$tree and defined $flags{"search"} eq "u"
!ll&&!rl&&r
000
MC/DC0%0/2
$tree and defined $flags{"search"} eq "u"
$tree defined $flags{"search"} eq "u"
Truth table0%0/3
A and B
A= $treeB= defined $flags{"search"} eq "u"
ABresult
0X0
100
111
399 0 ▶ my ($temptreeFH,$temptreefile) = $self->io->tempfile
Branch: 1 branch
BranchTrueFalseTotal
$self->save_tempfiles ? : 0 0 0
400 ('DIR' => $tmpdir,
401 UNLINK => ($self->save_tempfiles ? 0 : 1));
402 0 my $treeout = Bio::TreeIO->new('-format' => 'newick',
403 '-fh' => $temptreeFH);
404 0 $treeout->write_tree($tree);
405 0 $treeout->close();
406 0 close($temptreeFH);
407 0 $cmdstring .= " $temptreefile";
408 }
409 0 $self->debug( "cmdstring is $cmdstring\n");
410  
411 0 ▶ unless( open(PROTML, "$cmdstring |") ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (open PROTML, "$cmdstring |") 0 0 0
412 0 $self->warn("Cannot run $cmdstring");
413 0 return undef;
414 }
415 0 my $parser= Bio::Tools::Phylo::Molphy->new(-fh => \*PROTML);
416 0 return (1,$parser);
417 }
418  
419 =head2 alignment
420  
421 Title : alignment
422 Usage : $protml->align($aln);
423 Function: Get/Set the Bio::Align::AlignI object
424 Returns : Bio::Align::AlignI object
425 Args : [optional] Bio::Align::AlignI
426 Comment : We could potentially add support for running directly on a file
427 but we shall keep it simple
428 See also : L<Bio::SimpleAlign>, L<Bio::Align::AlignI>
429  
430 =cut
431  
432 sub alignment{
433 0 ▶ my ($self,$aln) = @_;
Subroutine alignment: not called CC=4 SCAR=30.0
Pod documented
434 0 ▶ if( defined $aln ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $aln) 0 0 0
435 0 ▶ if( !ref($aln) || ! $aln->isa('Bio::Align::AlignI') ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $aln and $aln->isa("Bio::Align::AlignI")) 0 0 0
Condition0%0/3
ref $aln and $aln->isa("Bio::Align::AlignI")
!ll&&!rl&&r
000
MC/DC0%0/2
ref $aln and $aln->isa("Bio::Align::AlignI")
ref $aln $aln->isa("Bio::Align::AlignI")
Truth table0%0/3
A and B
A= ref $alnB= $aln->isa("Bio::Align::AlignI")
ABresult
0X0
100
111
436 0 $self->warn("Must specify a valid Bio::Align::AlignI object to the alignment function");
437 0 return undef;
438 }
439 0 $self->{'_alignment'} = $aln;
440 }
441 0 return $self->{'_alignment'};
442 }
443  
444 =head2 tree
445  
446 Title : tree
447 Usage : $protml->tree($tree, %params);
448 Function: Get/Set the Bio::Tree::TreeI object
449 Returns : Bio::Tree::TreeI
450 Args : [optional] $tree => Bio::Tree::TreeI,
451  
452 Comment : We could potentially add support for running directly on a file
453 but we shall keep it simple
454 See also : L<Bio::Tree::Tree>
455  
456 =cut
457  
458 sub tree {
459 0 ▶ my ($self, $tree, %params) = @_;
Subroutine tree: not called CC=4 SCAR=30.0
Pod documented
460 0 ▶ if( defined $tree ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $tree) 0 0 0
461 0 ▶ if( ! ref($tree) || ! $tree->isa('Bio::Tree::TreeI') ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $tree and $tree->isa("Bio::Tree::TreeI")) 0 0 0
Condition0%0/3
ref $tree and $tree->isa("Bio::Tree::TreeI")
!ll&&!rl&&r
000
MC/DC0%0/2
ref $tree and $tree->isa("Bio::Tree::TreeI")
ref $tree $tree->isa("Bio::Tree::TreeI")
Truth table0%0/3
A and B
A= ref $treeB= $tree->isa("Bio::Tree::TreeI")
ABresult
0X0
100
111
462 0 $self->warn("Must specify a valid Bio::Tree::TreeI object to the alignment function");
463 }
464 0 $self->{'_tree'} = $tree;
465 }
466 0 return $self->{'_tree'};
467 }
468  
469 =head2 get_flags
470  
471 Title : get_flags
472 Usage : my @params = $protml->get_flags();
473 Function: returns the list of flags
474 Returns : array of flag names coded in the way that
475 Args : none
476  
477  
478 =cut
479  
480 sub get_flags{
481 0 ▶ my ($self) = @_;
Subroutine get_flags: not called CC=1 SCAR=6.9
Pod documented
482 # we're returning a copy of this
483 0 return %{ $self->{'_protmlflags'} };
484 }
485  
486  
487 =head2 set_flag
488  
489 Title : set_flag
490 Usage : $protml->set_parameter($type,$val);
491 Function: Sets a protml parameter, will be validated against
492 the valid values as set in the %VALIDVALUES class variable.
493 The checks can be ignored if one turns off param checks like this:
494 $protml->no_param_checks(1)
495 Returns : boolean if set was success, if verbose is set to -1
496 then no warning will be reported
497 Args : $type => name of the parameter
498 This can be one of 'search', 'model', 'other'
499 $value => flag value
500 See also: L<no_param_checks()>
501  
502 =cut
503  
504 sub set_flag{
505 4 ▶ my ($self,$type,$param) = @_;
Subroutine set_flag: called CC=11 SCAR=29.9
Pod documented
506 4 $type = lc($type);
507 4 ▶ while( substr($type,0,1) eq '-') { # handle multiple '-'
Branch: 1 branch
BranchTrueFalseTotal
if (substr($type, 0, 1) eq "-") 0 4 4
508 0 substr($type,0,1,'');
509 }
510  
511 4 ▶ if( ! defined $type ||
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $type and defined $param) 0 4 4
Condition33%1/3
defined $type and defined $param
!ll&&!rl&&r
004
MC/DC0%0/2
defined $type and defined $param
defined $type defined $param
Truth table33%1/3
A and B
A= defined $typeB= defined $param
ABresult
0X0
100
111
512 ! defined $param ) {
513 0 $self->debug("Must supply a type and param when setting flag");
514 0 return 0;
515 }
516  
517 4 ▶ if( ! $VALIDFLAGS{$type} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($Bio::Tools::Run::Phylo::Molphy::ProtML::VALIDFLAGS{$type}) 0 4 4
518 0 $self->warn("$type is an unrecognized type");
519 }
520 4 $param = lc($param);
521  
522 4 ▶ while( substr($param,0,1) eq '-') { # handle multiple '-'
Branch: 1 branch
BranchTrueFalseTotal
if (substr($param, 0, 1) eq "-") 2 4 6
523 2 substr($param,0,1,'');
524 }
525  
526 4 ▶ if(! $self->no_param_checks && ! defined $VALIDFLAGS{$type}->{$param} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->no_param_checks or defined $Bio::Tools::Run::Phylo::Molphy::ProtML::VALIDFLAGS{$type}{$param}) 0 4 4
Condition33%1/3
$self->no_param_checks or defined $Bio::Tools::Run::Phylo::Molphy::ProtML::VALIDFLAGS{$type}{$param}
l!l&&r!l&&!r
040
MC/DC0%0/2
$self->no_param_checks or defined $Bio::Tools::Run::Phylo::Molphy::ProtML::VALIDFLAGS{$type}{$param}
$self->no_param_checks defined $Bio::Tools::Run::Phylo::Molphy::ProtML::VALIDFLAGS{$type}{$param}
Truth table33%1/3
A or B
A= $self->no_param_checksB= defined $Bio::Tools::Run::Phylo::Molphy::ProtML::VALIDFLAGS{$type}{$param}
ABresult
1X1
011
000
527 0 $self->warn("unknown flag ($type) $param will not be set unless you force by setting no_param_checks to true");
528 0 return 0;
529 }
530 4 ▶ if($type eq 'others' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq 'others') { } 2 2 4
531 2 ▶ $self->{'_protmlflags'}->{$type}->{$VALIDFLAGS{$type}->{$param} || $param} = 1;
Condition33%1/3
$Bio::Tools::Run::Phylo::Molphy::ProtML::VALIDFLAGS{$type}{$param} || $param
l!l&&r!l&&!r
200
MC/DC0%0/2
$Bio::Tools::Run::Phylo::Molphy::ProtML::VALIDFLAGS{$type}{$param} || $param
$Bio::Tools::Run::Phylo::Molphy::ProtML::VALIDFLAGS{$type}{$param} $param
Truth table33%1/3
A || B
A= $Bio::Tools::Run::Phylo::Molphy::ProtML::VALIDFLAGS{$type}{$param}B= $param
ABresult
1X1
011
000
532 } else {
533 2 ▶ $self->{'_protmlflags'}->{$type} = $VALIDFLAGS{$type}->{$param} || $param;
Condition33%1/3
$Bio::Tools::Run::Phylo::Molphy::ProtML::VALIDFLAGS{$type}{$param} || $param
l!l&&r!l&&!r
200
MC/DC0%0/2
$Bio::Tools::Run::Phylo::Molphy::ProtML::VALIDFLAGS{$type}{$param} || $param
$Bio::Tools::Run::Phylo::Molphy::ProtML::VALIDFLAGS{$type}{$param} $param
Truth table33%1/3
A || B
A= $Bio::Tools::Run::Phylo::Molphy::ProtML::VALIDFLAGS{$type}{$param}B= $param
ABresult
1X1
011
000
534 }
535 4 return 1;
536 }
537  
538  
539 =head2 get_parameters
540  
541 Title : get_parameters
542 Usage : my %params = $protml->get_parameters();
543 Function: returns the list of parameters as a hash
544 Returns : associative array keyed on parameter names
545 Args : none
546  
547  
548 =cut
549  
550 sub get_parameters{
551 0 ▶ my ($self) = @_;
Subroutine get_parameters: not called CC=1 SCAR=6.9
Pod documented
552 # we're returning a copy of this
553 0 return %{ $self->{'_protmlparams'} };
554 }
555  
556  
557 =head2 set_parameter
558  
559 Title : set_parameter
560 Usage : $protml->set_parameter($param,$val);
561 Function: Sets a protml parameter, will be validated against
562 the valid values as set in the %VALIDVALUES class variable.
563 The checks can be ignored if one turns off param checks like this:
564 $protml->no_param_checks(1)
565 Returns : boolean if set was success, if verbose is set to -1
566 then no warning will be reported
567 Args : $param => name of the parameter
568 $value => value to set the parameter to
569 See also: L<no_param_checks()>
570  
571 =cut
572  
573 sub set_parameter{
574 0 ▶ my ($self,$param,$value) = @_;
Subroutine set_parameter: not called CC=4 SCAR=30.0
Pod documented
575 0 $param = lc($param);
576 0 $param =~ s/^\-//;
577 0 ▶ if(! $self->no_param_checks && ! defined $VALIDVALUES{$param} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->no_param_checks or defined $Bio::Tools::Run::Phylo::Molphy::ProtML::VALIDVALUES{$param}) 0 0 0
Condition0%0/3
$self->no_param_checks or defined $Bio::Tools::Run::Phylo::Molphy::ProtML::VALIDVALUES{$param}
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->no_param_checks or defined $Bio::Tools::Run::Phylo::Molphy::ProtML::VALIDVALUES{$param}
$self->no_param_checks defined $Bio::Tools::Run::Phylo::Molphy::ProtML::VALIDVALUES{$param}
Truth table0%0/3
A or B
A= $self->no_param_checksB= defined $Bio::Tools::Run::Phylo::Molphy::ProtML::VALIDVALUES{$param}
ABresult
1X1
011
000
578 0 $self->warn("unknown parameter $param will not be set unless you force by setting no_param_checks to true");
579 0 return 0;
580 }
581  
582 0 my $paramflag = $VALIDVALUES{$param}->($value);
583 0 ▶ if( $paramflag ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($paramflag) { } 0 0 0
584 0 $self->{'_protmlparams'}->{$paramflag} = $value;
585 } else {
586 0 print "value $value was not valid for param $param\n";
587 0 return 0;
588 }
589 0 return 1;
590 }
591  
592 =head1 Bio::Tools::Run::WrapperBase methods
593  
594 =cut
595  
596 =head2 no_param_checks
597  
598 Title : no_param_checks
599 Usage : $obj->no_param_checks($newval)
600 Function: Boolean flag as to whether or not we should
601 trust the sanity checks for parameter values
602 Returns : value of no_param_checks
603 Args : newvalue (optional)
604  
605  
606 =cut
607  
608 =head2 save_tempfiles
609  
610 Title : save_tempfiles
611 Usage : $obj->save_tempfiles($newval)
612 Function:
613 Returns : value of save_tempfiles
614 Args : newvalue (optional)
615  
616  
617 =cut
618  
619 =head2 outfile_name
620  
621 Title : outfile_name
622 Usage : my $outfile = $protml->outfile_name();
623 Function: Get/Set the name of the output file for this run
624 (if you wanted to do something special)
625 Returns : string
626 Args : [optional] string to set value to
627  
628  
629 =cut
630  
631  
632 =head2 tempdir
633  
634 Title : tempdir
635 Usage : my $tmpdir = $self->tempdir();
636 Function: Retrieve a temporary directory name (which is created)
637 Returns : string which is the name of the temporary directory
638 Args : none
639  
640  
641 =cut
642  
643 =head2 cleanup
644  
645 Title : cleanup
646 Usage : $protml->cleanup();
647 Function: Will cleanup the tempdir directory after a PAML run
648 Returns : none
649 Args : none
650  
651  
652 =cut
653  
654 =head2 io
655  
656 Title : io
657 Usage : $obj->io($newval)
658 Function: Gets a L<Bio::Root::IO> object
659 Returns : L<Bio::Root::IO>
660 Args : none
661  
662  
663 =cut
664  
665  
666 sub DESTROY {
667 1 ▶ my $self= shift;
Subroutine DESTROY: called CC=2 SCAR=7.0
668 1 ▶ unless ( $self->save_tempfiles ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->save_tempfiles) 1 0 1
669 1 $self->cleanup();
670 }
671 1 $self->SUPER::DESTROY();
672 }
673 1 1;
« blib/lib/Bio/Tools/Run/Phylo/Njtree/Best.pm ↑ Summary blib/lib/Bio/Tools/Run/Phylo/Hyphy/Base.pm »