Tools/Run/Phylo/Njtree/Best.pm

filter: Statementstmt 23.7% 44 / 185 Branchbran 8.1% 6 / 74 Conditioncond 0.0% 0 / 23 MC/DCmcdc 0.0% 0 / 14 Subroutinesub 59.0% 13 / 22 Podpod 100% 10 / 10 totaltotal 22.2% 73 / 328 CC 52 SCAR 41.0
CC
52
Cov
18%
prepare
156.0
run
132.0
check_names
72.0
CRAP 60.4
« Tools/Run/Primate.pm ↑ Summary Tools/Run/Phylo/Molphy/ProtML.pm »
1 #
2 # BioPerl module for Bio::Tools::Run::Phylo::Njtree::Best
3 #
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
5 #
6 # Cared for by Albert Vilella <avilella-at-gmail-dot-com>
7 #
8 # Copyright Albert Vilella
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::Njtree::Best - Wrapper around the Njtree (Njtree/phyml) best program.
17  
18 =head1 SYNOPSIS
19  
20 use Bio::Tools::Run::Phylo::Njtree::Best;
21 use Bio::AlignIO;
22 use Bio::TreeIO;
23  
24 my $alignio = Bio::AlignIO->new(-format => 'fasta',
25 -file => 't/data/njtree_aln2.nucl.mfa');
26  
27 my $aln = $alignio->next_aln;
28  
29 my $treeio = Bio::TreeIO->new(
30 -format => 'nhx', -file => 't/data/species_tree_njtree.nh');
31  
32 my $tree = $treeio->next_tree;
33  
34 my $njtree_best = Bio::Tools::Run::Phylo::Njtree::Best->new();
35 $njtree_best->alignment($aln);
36 $njtree_best->tree($tree);
37 my $nhx_tree = $njtree_best->run();
38  
39 =head1 DESCRIPTION
40  
41 This is a wrapper around the best program of Njtree by Li Heng. See
42 http://treesoft.sourceforge.net/njtree.shtml for more information.
43  
44 Wrapper for the calculation of a reconciled phylogenetic tree with
45 inferred duplication tags from amultiple sequence alignment and a
46 species tree using NJTREE.
47  
48 =head2 Helping the module find your executable
49  
50 You will need to enable NJTREEDIR to find the njtree program. This can be
51 done in (at least) three ways:
52  
53 1. Make sure the njtree executable is in your path (i.e.
54 'which njtree' returns a valid program
55 2. define an environmental variable NJTREEDIR which points to a
56 directory containing the 'njtree' app:
57 In bash
58 export NJTREEDIR=/home/progs/treesoft/njtree or
59 In csh/tcsh
60 setenv NJTREEDIR /home/progs/treesoft/njtree
61  
62 3. include a definition of an environmental variable NJTREEDIR
63 in every script that will
64 BEGIN {$ENV{NJTREEDIR} = '/home/progs/treesoft/njtree'; }
65 use Bio::Tools::Run::Phylo::Njtree::Best;
66  
67 =head1 FEEDBACK
68  
69 =head2 Mailing Lists
70  
71 User feedback is an integral part of the evolution of this and other
72 Bioperl modules. Send your comments and suggestions preferably to one
73 of the Bioperl mailing lists. Your participation is much appreciated.
74  
75 bioperl-l@bioperl.org - General discussion
76 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
77  
78 =head2 Support
79  
80 Please direct usage questions or support issues to the mailing list:
81  
82 I<bioperl-l@bioperl.org>
83  
84 rather than to the module maintainer directly. Many experienced and
85 reponsive experts will be able look at the problem and quickly
86 address it. Please include a thorough description of the problem
87 with code and data examples if at all possible.
88  
89 =head2 Reporting Bugs
90  
91 Report bugs to the Bioperl bug tracking system to help us keep track
92 the bugs and their resolution. Bug reports can be submitted via the web:
93  
94 http://redmine.open-bio.org/projects/bioperl/
95  
96 =head1 AUTHOR - Albert Vilella
97  
98 Email avilella-at-gmail-dot-com
99  
100 =head1 APPENDIX
101  
102 The rest of the documentation details each of the object
103 methods. Internal methods are usually preceded with a _
104  
105 =cut
106  
107 package Bio::Tools::Run::Phylo::Njtree::Best;
108  
109 1 ▶use vars qw($AUTOLOAD @ISA $PROGRAMNAME $PROGRAM
Subroutine BEGIN: called CC=1 SCAR=0.0
110 1 @NJTREE_BEST_PARAMS @NJTREE_BEST_SWITCHES %OK_FIELD);
111  
112 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
113 1 ▶use Bio::SimpleAlign;
Subroutine BEGIN: called CC=1 SCAR=0.0
114 1 ▶use Bio::AlignIO;
Subroutine BEGIN: called CC=1 SCAR=0.0
115 1 ▶use Bio::TreeIO;
Subroutine BEGIN: called CC=1 SCAR=0.0
116 1 ▶use Bio::Root::Root;
Subroutine BEGIN: called CC=1 SCAR=0.0
117 1 ▶use Bio::Root::IO;
Subroutine BEGIN: called CC=1 SCAR=0.0
118 1 ▶use Bio::Tools::Run::WrapperBase;
Subroutine BEGIN: called CC=1 SCAR=0.0
119 1 @ISA = qw(Bio::Root::Root Bio::Tools::Run::WrapperBase);
120  
121 1 ▶BEGIN {
Subroutine BEGIN: called CC=2 SCAR=6.9
122
123 1 @NJTREE_BEST_PARAMS = qw(C p F c k a d l L b);
124 1 @NJTREE_BEST_SWITCHES = qw(P S A r D s g N);
125 # Authorize attribute fields
126 1 foreach my $attr ( @NJTREE_BEST_PARAMS, @NJTREE_BEST_SWITCHES ) {
127 18 $OK_FIELD{$attr}++; }
128  
129 }
130  
131 =head2 program_name
132  
133 Title : program_name
134 Usage : $factory->program_name()
135 Function: holds the program name
136 Returns: string
137 Args : None
138  
139 =cut
140  
141 6 ▶sub program_name {
Subroutine program_name: called CC=1 SCAR=0.0
Pod documented
142 6 return 'njtree';
143 }
144  
145 =head2 program_dir
146  
147 Title : program_dir
148 Usage : $factory->program_dir(@params)
149 Function: returns the program directory, obtained from ENV variable.
150 Returns: string
151 Args :
152  
153 =cut
154  
155 3 ▶sub program_dir {
Subroutine program_dir: called CC=2 SCAR=7.6
Pod documented
156 3 ▶ return Bio::Root::IO->catfile($ENV{NJTREEDIR}) if $ENV{NJTREEDIR};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"NJTREEDIR"} 0 3 3
157 }
158  
159  
160 =head2 new
161  
162 Title : new
163 Usage : my $njtree_best = Bio::Tools::Run::Phylo::Njtree::Best->new();
164 Function: Builds a new Bio::Tools::Run::Phylo::Njtree::Best
165 Returns : Bio::Tools::Run::Phylo::Njtree::Best
166 Args : -alignment => the Bio::Align::AlignI object
167 -tree => the Bio::Tree::TreeI object
168 -save_tempfiles => boolean to save the generated tempfiles and
169 NOT cleanup after onesself (default FALSE)
170 -executable => where the njtree executable resides
171  
172 See also: L<Bio::Tree::TreeI>, L<Bio::Align::AlignI>
173  
174 =cut
175  
176 1 ▶sub new {
Subroutine new: called CC=5 SCAR=16.8
Pod documented
177 1 my($class,@args) = @_;
178  
179 1 my $self = $class->SUPER::new(@args);
180 1 my ($aln, $tree, $st, $exe,
181 $ubl) = $self->_rearrange([qw(ALIGNMENT TREE SAVE_TEMPFILES
182 EXECUTABLE)],
183 @args);
184 1 ▶ defined $aln && $self->alignment($aln);
Branch: 1 branch
BranchTrueFalseTotal
defined $aln and $self->alignment($aln) 0 1 1
185 1 ▶ defined $tree && $self->tree($tree);
Branch: 1 branch
BranchTrueFalseTotal
defined $tree and $self->tree($tree) 0 1 1
186 1 ▶ defined $st && $self->save_tempfiles($st);
Branch: 1 branch
BranchTrueFalseTotal
defined $st and $self->save_tempfiles($st) 0 1 1
187 1 ▶ defined $exe && $self->executable($exe);
Branch: 1 branch
BranchTrueFalseTotal
defined $exe and $self->executable($exe) 0 1 1
188  
189 1 return $self;
190 }
191  
192 =head2 prepare
193  
194 Title : prepare
195 Usage : my $rundir = $njtree_best->prepare();
196 Function: prepare the njtree_best analysis using the default or updated parameters
197 the alignment parameter and species tree must have been set
198 Returns : value of rundir
199 Args : L<Bio::Align::AlignI> object,
200 L<Bio::Tree::TreeI> object [optional]
201  
202 =cut
203  
204 0 ▶sub prepare {
Subroutine prepare: not called CC=12 SCAR=50.5
Pod documented
205 0 my ($self,$aln,$tree) = @_;
206  
207 0 ▶ unless ( $self->save_tempfiles ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->save_tempfiles) 0 0 0
208 # brush so we don't get plaque buildup ;)
209 0 $self->cleanup();
210 }
211 0 ▶ $tree = $self->tree unless $tree;
Branch: 1 branch
BranchTrueFalseTotal
unless $tree 0 0 0
212 0 ▶ $aln = $self->alignment unless $aln;
Branch: 1 branch
BranchTrueFalseTotal
unless $aln 0 0 0
213 0 ▶ if( ! $aln ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($aln) 0 0 0
214 0 $self->warn("Must have supplied a valid alignment file in order to run njtree_best");
215 0 return 0;
216 }
217 0 ▶ if( ! $tree ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($tree) 0 0 0
218 0 $self->warn("Must have supplied a valid species tree file in order to run njtree_best");
219 0 return 0;
220 }
221 0 my ($tempdir) = $self->tempdir();
222 0 my $tempalnFH;
223 0 ▶ if( ! ref($aln) && -e $aln ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not ref $aln and -e $aln) { } 0 0 0
Condition0%0/3
not ref $aln and -e $aln
!ll&&!rl&&r
000
MC/DC0%0/2
not ref $aln and -e $aln
not ref $aln -e $aln
Truth table0%0/3
not(A) and B
A= not ref $alnB= -e $aln
ABresult
0X0
100
111
224 0 $self->{_tempalnfile} = $aln;
225 } else {
226 0 ▶ ($tempalnFH,$self->{_tempalnfile}) = $self->io->tempfile
Branch: 1 branch
BranchTrueFalseTotal
$self->save_tempfiles ? : 0 0 0
227 ('-dir' => $tempdir,
228 UNLINK => ($self->save_tempfiles ? 0 : 1));
229 0 my $alnout = Bio::AlignIO->new('-format' => 'fasta',
230 '-fh' => $tempalnFH);
231 0 $aln->set_displayname_flat(1);
232 0 $alnout->write_aln($aln);
233 0 $alnout->close();
234 0 undef $alnout;
235 0 close($tempalnFH);
236 }
237  
238 0 my ($temptreeFH);
239 0 ▶ if( ! ref($tree) && -e $tree ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not ref $tree and -e $tree) { } 0 0 0
Condition0%0/3
not ref $tree and -e $tree
!ll&&!rl&&r
000
MC/DC0%0/2
not ref $tree and -e $tree
not ref $tree -e $tree
Truth table0%0/3
not(A) and B
A= not ref $treeB= -e $tree
ABresult
0X0
100
111
240 0 $self->{_temptreefile} = $tree;
241 } else {
242 0 ▶ ($temptreeFH,$self->{_temptreefile}) = $self->io->tempfile
Branch: 1 branch
BranchTrueFalseTotal
$self->save_tempfiles ? : 0 0 0
243 ('-dir' => $tempdir,
244 UNLINK => ($self->save_tempfiles ? 0 : 1));
245  
246 0 my $treeout = Bio::TreeIO->new('-format' => 'newick',
247 '-fh' => $temptreeFH);
248 0 $treeout->write_tree($tree);
249 0 $treeout->close();
250 0 close($temptreeFH);
251 }
252 0 $self->{_prepared} = 1;
253 0 $self->{_njtree_best_params} = $self->_setparams();
254  
255 0 return $tempdir;
256 }
257  
258  
259 =head2 run
260  
261 Title : run
262 Usage : my $nhx_tree = $njtree_best->run();
263 Function: run the njtree_best analysis using the default or updated parameters
264 the alignment parameter must have been set
265 Returns : L<Bio::Tree::TreeI> object [optional]
266 Args : L<Bio::Align::AlignI> object
267 L<Bio::Tree::TreeI> object
268  
269  
270 =cut
271  
272 0 ▶sub run {
Subroutine run: not called CC=11 SCAR=48.8
Pod documented
273 0 my ($self,$aln,$tree) = @_;
274  
275 0 ▶ $self->prepare($aln,$tree) unless (defined($self->{_prepared}));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"_prepared"} 0 0 0
276 0 my ($rc,$nhx_tree) = (1);
277 0 my ($tmpdir) = $self->tempdir();
278 0 my $outfile = $self->outfile_name;
279 {
280 0 my $commandstring;
281 my $exit_status;
282 #./njtree best [other_params] -f species_file.nh -p tree -o inputfile.best.nhx inputfile.nucl.mfa
283 0 my $njtree_executable = $self->executable;
284 0 $commandstring = $njtree_executable." best ";
285 0 $commandstring .= $self->{_njtree_best_params};
286 0 $commandstring .= " -f $self->{_temptreefile} -p tree -o ";
287 0 ▶ unless ($self->outfile_name ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->outfile_name) 0 0 0
288 0 my ($tfh, $outfile) = $self->io->tempfile(-dir=>$self->tempdir());
289 0 close($tfh);
290 0 undef $tfh;
291 0 $self->outfile_name($outfile);
292 }
293 0 $commandstring .= $self->outfile_name;
294 0 $commandstring .= " $self->{_tempalnfile} ";
295  
296 0 ▶ $self->throw("unable to find or run executable for 'njtree'")
Branch: 1 branch
BranchTrueFalseTotal
unless $njtree_executable and -e $njtree_executable and -x _ 0 0 0
Condition0%0/6
$njtree_executable and -e $njtree_executable and -x _
!ll&&!rl&&r
000
$njtree_executable and -e $njtree_executable
!ll&&!rl&&r
000
MC/DC0%0/3
$njtree_executable and -e $njtree_executable and -x _
$njtree_executable -e $njtree_executable -x _
Truth table0%0/4
A and B and C
A= $njtree_executableB= -e $njtree_executableC= -x _
ABCresult
0XX0
10X0
1100
1111
297 unless $njtree_executable && -e $njtree_executable && -x _;
298  
299 0 ▶ open(RUN, "$commandstring |")
Branch: 1 branch
BranchTrueFalseTotal
open RUN, "$commandstring |" or $self->throw("Cannot run $commandstring") 0 0 0
300 or $self->throw("Cannot run $commandstring");
301  
302 0 my @output = <RUN>;
303 0 $exit_status = close(RUN);
304 0 $self->error_string(join('',@output));
305 0 ▶ if( (grep { /^\[ /io } @output) || !$exit_status) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep {/^\[ /io;} @output or not $exit_status) 0 0 0
Condition0%0/3
grep {/^\[ /io;} @output or not $exit_status
l!l&&r!l&&!r
000
MC/DC0%0/2
grep {/^\[ /io;} @output or not $exit_status
grep {/^\[ /io;} @output not $exit_status
Truth table0%0/3
A or not(B)
A= grep {/^\[ /io;} @outputB= not $exit_status
ABresult
1X1
011
000
306 0 $self->warn("There was an error - see error_string for the program output");
307 0 $rc = 0;
308 }
309 0 eval {
310 0 $nhx_tree = Bio::TreeIO->new(-file => "$tmpdir/$outfile",
311 -format => 'nhx');
312 };
313 0 ▶ if( $@ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
314 0 $self->warn($self->error_string);
315 }
316 }
317 0 ▶ unless ( $self->save_tempfiles ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->save_tempfiles) 0 0 0
318 0 $self->cleanup();
319 }
320 0 return ($rc,$nhx_tree);
321 }
322  
323  
324 0 ▶sub AUTOLOAD {
Subroutine AUTOLOAD: not called CC=3 SCAR=24.8
325 0 my $self = shift;
326 0 my $attr = $AUTOLOAD;
327 0 $attr =~ s/.*:://;
328 0 $attr = $attr;
329 # aliasing
330 0 ▶ $self->throw("Unallowed parameter: $attr !") unless $OK_FIELD{$attr};
Branch: 1 branch
BranchTrueFalseTotal
unless $Bio::Tools::Run::Phylo::Njtree::Best::OK_FIELD{$attr} 0 0 0
331  
332 0 ▶ $self->{$attr} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
333 0 return $self->{$attr};
334 }
335  
336 =head2 error_string
337  
338 Title : error_string
339 Usage : $obj->error_string($newval)
340 Function: Where the output from the last analysus run is stored.
341 Returns : value of error_string
342 Args : newvalue (optional)
343  
344  
345 =cut
346  
347 0 ▶sub error_string {
Subroutine error_string: not called CC=2 SCAR=17.9
Pod documented
348 0 my ($self,$value) = @_;
349 0 ▶ if( defined $value) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 0 0 0
350 0 $self->{'error_string'} = $value;
351 }
352 0 return $self->{'error_string'};
353  
354 }
355  
356  
357 =head2 version
358  
359 Title : version
360 Usage : exit if $prog->version() < 1.8
361 Function: Determine the version number of the program
362 Example :
363 Returns : float or undef
364 Args : none
365  
366 =cut
367  
368 0 ▶sub version {
Subroutine version: not called CC=3 SCAR=24.8
Pod documented
369 0 my ($self) = @_;
370 0 my $exe;
371 0 ▶ return undef unless $exe = $self->executable;
Branch: 1 branch
BranchTrueFalseTotal
unless $exe = $self->executable 0 0 0
372 0 my $string = `$exe 2>&1` ;
373  
374 0 $string =~ /Version\:\s+(\d+.\d+.\d+)/m;
375 0 ▶ return $1 || undef;
Condition0%0/2
$1 || undef
l!l
00
MC/DC0%0/1
$1 || undef
$1
Truth table0%0/2
A
A= $1
Aresult
11
00
376 }
377  
378  
379 =head2 alignment
380  
381 Title : alignment
382 Usage : $njtree_best->align($aln);
383 Function: Get/Set the L<Bio::Align::AlignI> object
384 Returns : L<Bio::Align::AlignI> object
385 Args : [optional] L<Bio::Align::AlignI>
386 Comment : We could potentially add support for running directly on a file
387 but we shall keep it simple
388 See also: L<Bio::SimpleAlign>
389  
390 =cut
391  
392 0 ▶sub alignment {
Subroutine alignment: not called CC=5 SCAR=34.0
Pod documented
393 0 my ($self,$aln) = @_;
394  
395 0 ▶ if( defined $aln ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $aln) 0 0 0
396 0 ▶ if( -e $aln ) {
Branch: 2 branches
BranchTrueFalseTotal
if (-e $aln) { } 0 0 0
elsif (not ref $aln && $aln->isa('Bio::Align::AlignI')) { } 0 0 0
397 0 $self->{'_alignment'} = $aln;
398 ▶ } elsif( !ref($aln) || ! $aln->isa('Bio::Align::AlignI') ) {
Condition0%0/3
ref $aln && $aln->isa('Bio::Align::AlignI')
!ll&&!rl&&r
000
MC/DC0%0/2
ref $aln && $aln->isa('Bio::Align::AlignI')
ref $aln $aln->isa('Bio::Align::AlignI')
Truth table0%0/3
A && B
A= ref $alnB= $aln->isa('Bio::Align::AlignI')
ABresult
0X0
100
111
399 0 $self->warn("Must specify a valid Bio::Align::AlignI object to the alignment function not $aln");
400 0 return undef;
401 } else {
402 0 $self->{'_alignment'} = $aln;
403 }
404 }
405 0 return $self->{'_alignment'};
406 }
407  
408 =head2 tree
409  
410 Title : tree
411 Usage : $njtree_best->tree($tree, %params);
412 Function: Get/Set the L<Bio::Tree::TreeI> object
413 Returns : L<Bio::Tree::TreeI>
414 Args : [optional] $tree => L<Bio::Tree::TreeI>,
415 [optional] %parameters => hash of tree-specific parameters
416  
417 Comment : We could potentially add support for running directly on a file
418 but we shall keep it simple
419 See also: L<Bio::Tree::Tree>
420  
421 =cut
422  
423 0 ▶sub tree {
Subroutine tree: not called CC=4 SCAR=30.0
Pod documented
424 0 my ($self, $tree, %params) = @_;
425 0 ▶ if( defined $tree ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $tree) 0 0 0
426 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
427 0 $self->warn("Must specify a valid Bio::Tree::TreeI object to the alignment function");
428 }
429 0 $self->{'_tree'} = $tree;
430 }
431 0 return $self->{'_tree'};
432 }
433  
434 =head2 check_names
435  
436 Title : check_names
437 Usage :
438 Function:
439 Example :
440 Returns :
441 Args :
442  
443  
444 =cut
445  
446 0 ▶sub check_names {
Subroutine check_names: not called CC=8 SCAR=42.8
Pod documented
447 0 my $self = shift;
448  
449 0 my $tree = $self->tree;
450 0 my $aln = $self->alignment;
451 0 ▶ if( ! $aln ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($aln) 0 0 0
452 0 $self->warn("must have supplied a valid alignment file in order to run njtree_best");
453 0 return 0;
454 }
455 0 ▶ if( ! $tree ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($tree) 0 0 0
456 0 $self->warn("must have supplied a valid species tree file in order to run njtree_best");
457 0 return 0;
458 }
459 0 foreach my $leaf ($tree->get_leaf_nodes) {
460 0 my $id = $leaf->id;
461 0 $id =~ s/\-\*.+//; # njtree does not consider anything after a \-\*
462 0 $self->{_treeids}{$id} = 1;
463 }
464 0 foreach my $seq ($aln->each_seq) {
465 0 my $id = $seq->id;
466 0 $id =~ s/.+\_//; # njtree only looks at the right side of the \_
467 0 $self->{_alnids}{$id} = 1;
468 }
469 0 foreach my $alnid (keys %{$self->{_alnids}}) {
470 0 ▶ $self->{_unmappedids}{$alnid} = 1 unless (defined($self->{_treeids}{$alnid}));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"_treeids"}{$alnid} 0 0 0
471 }
472 0 ▶ if (defined($self->{_unmappedids})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"_unmappedids"}) 0 0 0
473 0 my $count = scalar(keys%{$self->{_unmappedids}});
474 0 my $unmapped = join(",",keys %{$self->{_unmappedids}});
475 0 $self->warn("$count unmapped ids between the aln and the tree $unmapped");
476 }
477 }
478  
479  
480  
481 =head2 _setparams
482  
483 Title : _setparams
484 Usage : Internal function, not to be called directly
485 Function: Create parameter inputs for njtree_best program
486 Example :
487 Returns : parameter string to be passed to njtree_best
488 during align or profile_align
489 Args : name of calling object
490  
491 =cut
492  
493 0 ▶sub _setparams {
Subroutine _setparams: not called CC=5 SCAR=34.0
494 0 my ($self) = @_;
495 0 my ($attr, $value,$param_string);
496 0 $param_string = '';
497 0 my $laststr;
498 0 for $attr ( @NJTREE_BEST_PARAMS ) {
499 0 $value = $self->$attr();
500 0 ▶ next unless (defined $value);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 0 0 0
501 0 my $attr_key = $attr;
502 0 $attr_key = ' -'.$attr_key;
503 0 $param_string .= $attr_key .' '.$value;
504  
505 }
506 0 for $attr ( @NJTREE_BEST_SWITCHES) {
507 0 $value = $self->$attr();
508 0 ▶ next unless ($value);
Branch: 1 branch
BranchTrueFalseTotal
unless $value 0 0 0
509 0 my $attr_key = $attr;
510 0 $attr_key = ' -'.$attr_key;
511 0 $param_string .= $attr_key ;
512 }
513  
514 0 return $param_string;
515 }
516  
517  
518 =head1 Bio::Tools::Run::BaseWrapper methods
519  
520 =cut
521  
522 =head2 save_tempfiles
523  
524 Title : save_tempfiles
525 Usage : $obj->save_tempfiles($newval)
526 Function:
527 Returns : value of save_tempfiles
528 Args : newvalue (optional)
529  
530  
531 =cut
532  
533 =head2 outfile_name
534  
535 Title : outfile_name
536 Usage : my $outfile = $njtree_best->outfile_name();
537 Function: Get/Set the name of the output file for this run
538 (if you wanted to do something special)
539 Returns : string
540 Args : [optional] string to set value to
541  
542  
543 =cut
544  
545  
546 =head2 tempdir
547  
548 Title : tempdir
549 Usage : my $tmpdir = $self->tempdir();
550 Function: Retrieve a temporary directory name (which is created)
551 Returns : string which is the name of the temporary directory
552 Args : none
553  
554  
555 =cut
556  
557 =head2 cleanup
558  
559 Title : cleanup
560 Usage : $njtree_best->cleanup();
561 Function: Will cleanup the tempdir directory
562 Returns : none
563 Args : none
564  
565  
566 =cut
567  
568 =head2 io
569  
570 Title : io
571 Usage : $obj->io($newval)
572 Function: Gets a L<Bio::Root::IO> object
573 Returns : L<Bio::Root::IO>
574 Args : none
575  
576  
577 =cut
578  
579 1 ▶sub DESTROY {
Subroutine DESTROY: called CC=2 SCAR=7.0
580 1 my $self= shift;
581 1 ▶ unless ( $self->save_tempfiles ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->save_tempfiles) 1 0 1
582 1 $self->cleanup();
583 }
584 1 $self->SUPER::DESTROY();
585 }
586  
587 1 1; # Needed to keep compiler happy
« Tools/Run/Primate.pm ↑ Summary Tools/Run/Phylo/Molphy/ProtML.pm »