Tools/Run/Simprot.pm

filter: Statementstmt 33.3% 52 / 156 Branchbran 17.6% 12 / 68 Conditioncond 3.4% 1 / 29 MC/DCmcdc 0.0% 0 / 18 Subroutinesub 65.2% 15 / 23 Podpod 91.6% 11 / 12 totaltotal 29.7% 91 / 306 CC 45 SCAR 36.0
CC
45
Cov
26%
run
110.0
prepare
72.0
set_parameter
56.0
CRAP 36.7
« Tools/Run/Alignment/Proda.pm ↑ Summary DB/SoapEUtilities/FetchAdaptor/species.pm »
1 #
2 # BioPerl module for Bio::Tools::Run::Simprot
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::Simprot - Wrapper around the Simprot program. Wrapper for the calculation of a multiple sequence alignment from a phylogenetic tree
17  
18 =head1 SYNOPSIS
19  
20 use Bio::Tools::Run::Simprot;
21 use Bio::TreeIO;
22  
23 my $treeio = Bio::TreeIO->new(
24 -format => 'nh', -file => 't/data/tree.nh');
25  
26 my $tree = $treeio->next_tree;
27  
28 my $simprot = Bio::Tools::Run::Simprot->new();
29 $simprot->tree($tree);
30 my ($rc,$aln,$seq) = $simprot->run();
31  
32 =head1 DESCRIPTION
33  
34 This is a wrapper around the Simprot program by Andy Pang, Andrew D
35 Smith, Paulo AS Nuin and Elisabeth RM Tillier.
36  
37 Simprot allows for several models of amino acid substitution (PAM, JTT
38 and PMB), allows for gamma distributed sites rates according to Yang's
39 model, and implements a parameterised Qian and Goldstein distribution
40 model for insertion and deletion.
41  
42 See http://www.uhnres.utoronto.ca/labs/tillier/software.htm for more
43 information.
44  
45  
46 =head2 Helping the module find your executable
47  
48 You will need to enable SIMPROTDIR to find the simprot program. This can be
49 done in (at least) three ways:
50  
51 1. Make sure the simprot executable is in your path (i.e.
52 'which simprot' returns a valid program
53 2. define an environmental variable SIMPROTDIR which points to a
54 directory containing the 'simprot' app:
55 In bash
56 export SIMPROTDIR=/home/progs/simprot or
57 In csh/tcsh
58 setenv SIMPROTDIR /home/progs/simprot
59  
60 3. include a definition of an environmental variable SIMPROTDIR
61 in every script that will
62 BEGIN {$ENV{SIMPROTDIR} = '/home/progs/simprot'; }
63 use Bio::Tools::Run::Simprot;
64  
65 =head1 FEEDBACK
66  
67 =head2 Mailing Lists
68  
69 User feedback is an integral part of the evolution of this and other
70 Bioperl modules. Send your comments and suggestions preferably to one
71 of the Bioperl mailing lists. Your participation is much appreciated.
72  
73 bioperl-l@bioperl.org - General discussion
74 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
75  
76 =head2 Support
77  
78 Please direct usage questions or support issues to the mailing list:
79  
80 I<bioperl-l@bioperl.org>
81  
82 rather than to the module maintainer directly. Many experienced and
83 reponsive experts will be able look at the problem and quickly
84 address it. Please include a thorough description of the problem
85 with code and data examples if at all possible.
86  
87 =head2 Reporting Bugs
88  
89 Report bugs to the Bioperl bug tracking system to help us keep track
90 the bugs and their resolution. Bug reports can be submitted via the web:
91  
92 http://redmine.open-bio.org/projects/bioperl/
93  
94 =head1 AUTHOR - Albert Vilella
95  
96 Email avilella-at-gmail-dot-com
97  
98 =head1 APPENDIX
99  
100 The rest of the documentation details each of the object
101 methods. Internal methods are usually preceded with a _
102  
103 =cut
104  
105 package Bio::Tools::Run::Simprot;
106  
107 1 ▶use vars qw(@ISA %VALIDVALUES $PROGRAMNAME $PROGRAM);
Subroutine BEGIN: called CC=1 SCAR=0.0
108  
109 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
110 1 ▶use Bio::SimpleAlign;
Subroutine BEGIN: called CC=1 SCAR=0.0
111 1 ▶use Bio::AlignIO;
Subroutine BEGIN: called CC=1 SCAR=0.0
112 1 ▶use Bio::SeqIO;
Subroutine BEGIN: called CC=1 SCAR=0.0
113 1 ▶use Bio::TreeIO;
Subroutine BEGIN: called CC=1 SCAR=0.0
114 1 ▶use Bio::Root::Root;
Subroutine BEGIN: called CC=1 SCAR=0.0
115 1 ▶use Bio::Root::IO;
Subroutine BEGIN: called CC=1 SCAR=0.0
116 1 ▶use Bio::Tools::Run::WrapperBase;
Subroutine BEGIN: called CC=1 SCAR=0.0
117 1 @ISA = qw(Bio::Root::Root Bio::Tools::Run::WrapperBase);
118  
119 # valid values for parameters, the default one is always
120 # the first one in the array
121 1 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
122 1 %VALIDVALUES = (
123 'branch' => '1',
124 'eFactor' => '3',
125 'indelFrequncy' => '0.03',
126 'maxIndel' => '2048',
127 'subModel' => [ 2,0,1], # 0:PAM, 1:JTT, 2:PMB
128 'rootLength' => '50',
129 'alpha' => '1',
130 'Benner' => '0',
131 'interleaved' => '1',
132 'variablegamma' => '0',
133 'bennerk' => '-2',
134 );
135 }
136  
137 =head2 program_name
138  
139 Title : program_name
140 Usage : $factory->program_name()
141 Function: holds the program name
142 Returns: string
143 Args : None
144  
145 =cut
146  
147 6 ▶sub program_name {
Subroutine program_name: called CC=1 SCAR=0.0
Pod documented
148 6 return 'simprot';
149 }
150  
151 =head2 program_dir
152  
153 Title : program_dir
154 Usage : $factory->program_dir(@params)
155 Function: returns the program directory, obtained from ENV variable.
156 Returns: string
157 Args :
158  
159 =cut
160  
161 3 ▶sub program_dir {
Subroutine program_dir: called CC=2 SCAR=7.6
Pod documented
162 3 ▶ return Bio::Root::IO->catfile($ENV{SIMPROTDIR}) if $ENV{SIMPROTDIR};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"SIMPROTDIR"} 0 3 3
163 }
164  
165  
166 =head2 new
167  
168 Title : new
169 Usage : my $simprot = Bio::Tools::Run::Simprot->new();
170 Function: Builds a new Bio::Tools::Run::Simprot
171 Returns : Bio::Tools::Run::Simprot
172 Args : -alignment => the Bio::Align::AlignI object
173 -tree => the Bio::Tree::TreeI object
174 -save_tempfiles => boolean to save the generated tempfiles and
175 NOT cleanup after onesself (default FALSE)
176 -executable => where the simprot executable resides
177 -params => A reference to a hash where keys are parameter names
178 and hash values are the associated parameter values
179  
180 See also: L<Bio::Tree::TreeI>, L<Bio::Align::AlignI>
181  
182 =cut
183  
184 1 ▶sub new {
Subroutine new: called CC=6 SCAR=21.9
Pod documented
185 1 my($class,@args) = @_;
186  
187 1 my $self = $class->SUPER::new(@args);
188 1 my ($aln, $tree, $st, $params, $exe,
189 $ubl) = $self->_rearrange([qw(TREE SAVE_TEMPFILES PARAMS EXECUTABLE)],
190 @args);
191 1 ▶ defined $tree && $self->tree($tree);
Branch: 1 branch
BranchTrueFalseTotal
defined $tree and $self->tree($tree) 0 1 1
192 1 ▶ defined $st && $self->save_tempfiles($st);
Branch: 1 branch
BranchTrueFalseTotal
defined $st and $self->save_tempfiles($st) 0 1 1
193 1 ▶ defined $exe && $self->executable($exe);
Branch: 1 branch
BranchTrueFalseTotal
defined $exe and $self->executable($exe) 0 1 1
194  
195 1 $self->set_default_parameters();
196 1 ▶ if( defined $params ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $params) 0 1 1
197 0 ▶ if( ref($params) !~ /HASH/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not ref($params) =~ /HASH/i) { } 0 0 0
198 0 $self->warn("Must provide a valid hash ref for parameter -FLAGS");
199 } else {
200 0 map { $self->set_parameter($_, $$params{$_}) } keys %$params;
201 }
202 }
203 1 return $self;
204 }
205  
206 =head2 set_parameters
207  
208 Title : set_parameters
209 Usage : $codeml->set_parameters($parameter, $value);
210 Function: (Re)set the SimProt parameters
211 Returns : none
212 Args : First argument is the parameter name
213 Second argument is the parameter value
214  
215 =cut
216  
217 0 ▶sub set_parameter{
Subroutine set_parameter: not called CC=7 SCAR=40.3
Pod undocumented
218 0 my ($self,$param,$value) = @_;
219 0 ▶ unless (defined $self->{'no_param_checks'} && $self->{'no_param_checks'} == 1) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"no_param_checks"} and $self->{"no_param_checks"} == 1) 0 0 0
Condition0%0/3
defined $self->{"no_param_checks"} and $self->{"no_param_checks"} == 1
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->{"no_param_checks"} and $self->{"no_param_checks"} == 1
defined $self->{"no_param_checks"} $self->{"no_param_checks"} == 1
Truth table0%0/3
A and B
A= defined $self->{"no_param_checks"}B= $self->{"no_param_checks"} == 1
ABresult
0X0
100
111
220 0 ▶ if ( ! defined $VALIDVALUES{$param} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $Bio::Tools::Run::Simprot::VALIDVALUES{$param}) 0 0 0
221 0 $self->warn("unknown parameter $param will not be set unless you force by setting no_param_checks to true");
222 0 return 0;
223 }
224 0 ▶ if ( ref( $VALIDVALUES{$param}) =~ /ARRAY/i &&
Branch: 1 branch
BranchTrueFalseTotal
if (ref($Bio::Tools::Run::Simprot::VALIDVALUES{$param}) =~ /ARRAY/i and scalar @{$Bio::Tools::Run::Simprot::VALIDVALUES{$param};} > 0) 0 0 0
Condition0%0/3
ref($Bio::Tools::Run::Simprot::VALIDVALUES{$param}) =~ /ARRAY/i and scalar @{$Bio::Tools::Run::Simprot::VALIDVALUES{$param};} > 0
!ll&&!rl&&r
000
MC/DC0%0/2
ref($Bio::Tools::Run::Simprot::VALIDVALUES{$param}) =~ /ARRAY/i and scalar @{$Bio::Tools::Run::Simprot::VALIDVALUES{$param};} > 0
ref($Bio::Tools::Run::Simprot::VALIDVALUES{$param}) =~ /ARRAY/i scalar @{$Bio::Tools::Run::Simprot::VALIDVALUES{$param};} > 0
Truth table0%0/3
A and B
A= ref($Bio::Tools::Run::Simprot::VALIDVALUES{$param}) =~ /ARRAY/iB= scalar @{$Bio::Tools::Run::Simprot::VALIDVALUES{$param};} > 0
ABresult
0X0
100
111
225 0 scalar @{$VALIDVALUES{$param}} > 0 ) {
226
227 0 ▶ unless ( grep { $value eq $_ } @{ $VALIDVALUES{$param} } ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (grep {$value eq $_;} @{$Bio::Tools::Run::Simprot::VALIDVALUES{$param};}) 0 0 0
228 0 $self->warn("parameter $param specified value $value is not recognized, please see the documentation and the code for this module or set the no_param_checks to a true value");
229 0 return 0;
230 }
231 }
232 }
233 0 $self->{'_simprotparams'}->{$param} = $value;
234 0 return 1;
235 }
236  
237  
238  
239 =head2 set_default_parameters
240  
241 Title : set_default_parameters
242 Usage : $codeml->set_default_parameters(0);
243 Function: (Re)set the default parameters from the defaults
244 (the first value in each array in the
245 %VALIDVALUES class variable)
246 Returns : none
247 Args : boolean: keep existing parameter values
248  
249  
250 =cut
251  
252 1 ▶sub set_default_parameters{
Subroutine set_default_parameters: called CC=6 SCAR=18.6
Pod documented
253 1 my ($self,$keepold) = @_;
254 1 ▶ $keepold = 0 unless defined $keepold;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $keepold 1 0 1
255
256 1 ▶ while( my ($param,$val) = each %VALIDVALUES ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %Bio::Tools::Run::Simprot::VALIDVALUES) 11 1 12
257 # skip if we want to keep old values and it is already set
258 11 ▶ next if( defined $self->{'_simprotparams'}->{$param} && $keepold);
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"_simprotparams"}{$param} and $keepold 0 11 11
Condition33%1/3
defined $self->{"_simprotparams"}{$param} and $keepold
!ll&&!rl&&r
1100
MC/DC0%0/2
defined $self->{"_simprotparams"}{$param} and $keepold
defined $self->{"_simprotparams"}{$param} $keepold
Truth table33%1/3
A and B
A= defined $self->{"_simprotparams"}{$param}B= $keepold
ABresult
0X0
100
111
259 11 ▶ if(ref($val)=~/ARRAY/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref($val) =~ /ARRAY/i) { } 1 10 11
260 1 $self->{'_simprotparams'}->{$param} = $val->[0];
261 } else {
262 10 $self->{'_simprotparams'}->{$param} = $val;
263 }
264 }
265 }
266  
267  
268 =head2 get_parameters
269  
270 Title : get_parameters
271 Usage : my %params = $self->get_parameters();
272 Function: returns the list of parameters as a hash
273 Returns : associative array keyed on parameter names
274 Args : none
275  
276  
277 =cut
278  
279 0 ▶sub get_parameters{
Subroutine get_parameters: not called CC=1 SCAR=6.9
Pod documented
280 0 my ($self) = @_;
281 # we're returning a copy of this
282 0 return %{ $self->{'_simprotparams'} };
283 }
284  
285  
286  
287 =head2 prepare
288  
289 Title : prepare
290 Usage : my $rundir = $simprot->prepare();
291 Function: prepare the simprot analysis using the default or updated parameters
292 the alignment parameter and species tree must have been set
293 Returns : value of rundir
294 Args : L<Bio::Align::AlignI> object,
295 L<Bio::Tree::TreeI> object [optional]
296  
297 =cut
298  
299 0 ▶sub prepare {
Subroutine prepare: not called CC=8 SCAR=42.8
Pod documented
300 0 my ($self,$tree) = @_;
301  
302 0 ▶ unless ( $self->save_tempfiles ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->save_tempfiles) 0 0 0
303 # brush so we don't get plaque buildup ;)
304 0 $self->cleanup();
305 }
306 0 ▶ $tree = $self->tree unless $tree;
Branch: 1 branch
BranchTrueFalseTotal
unless $tree 0 0 0
307 0 ▶ if( ! $tree ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($tree) 0 0 0
308 0 $self->warn("must have supplied a valid species tree file in order to run simprot");
309 0 return 0;
310 }
311 0 my ($tempdir) = $self->tempdir();
312  
313 0 my ($temptreeFH);
314 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
315 0 $self->{_temptreefile} = $tree;
316 } else {
317 0 ▶ ($temptreeFH,$self->{_temptreefile}) = $self->io->tempfile
Branch: 1 branch
BranchTrueFalseTotal
$self->save_tempfiles ? : 0 0 0
318 ('-dir' => $tempdir,
319 UNLINK => ($self->save_tempfiles ? 0 : 1));
320  
321 0 my $treeout = Bio::TreeIO->new('-format' => 'newick',
322 '-fh' => $temptreeFH);
323 0 $treeout->write_tree($tree);
324 0 $treeout->close();
325 0 close($temptreeFH);
326 }
327 0 $self->{_prepared} = 1;
328  
329 0 my %params = $self->get_parameters;
330 0 ▶ while( my ($param,$val) = each %params ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %params) 0 0 0
331 0 $self->{_simprot_params} .=" \-\-$param\=$val";
332 }
333  
334 0 return $tempdir;
335 }
336  
337  
338 =head2 run
339  
340 Title : run
341 Usage : my $nhx_tree = $simprot->run();
342 Function: run the simprot analysis using the default or updated parameters
343 the alignment parameter must have been set
344 Returns : L<Bio::Tree::TreeI> object [optional]
345 Args : L<Bio::Align::AlignI> object
346 L<Bio::Tree::TreeI> object
347  
348  
349 =cut
350  
351 0 ▶sub run {
Subroutine run: not called CC=10 SCAR=47.0
Pod documented
352 0 my ($self,$tree) = @_;
353  
354 0 ▶ $self->prepare($tree) unless (defined($self->{_prepared}));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"_prepared"} 0 0 0
355 0 my ($rc,$aln,$seq) = (1);
356 0 my ($tmpdir) = $self->tempdir();
357 0 my $outfile;
358 {
359 0 my $commandstring;
360 my $exit_status;
361 0 my $simprot_executable = $self->executable;
362 0 $commandstring .= $simprot_executable;
363 0 $commandstring .= $self->{_simprot_params};
364 0 $commandstring .= " --tree=". $self->{_temptreefile} . " ";
365 0 my ($tfh, $outfile) = $self->io->tempfile(-dir=>$self->tempdir());
366 0 close($tfh);
367 0 undef $tfh;
368 0 $self->outfile_name($outfile);
369 0 my $seqfile;
370 0 ($tfh, $seqfile) = $self->io->tempfile(-dir=>$self->tempdir());
371 0 close($tfh);
372 0 undef $tfh;
373  
374 0 $commandstring .= "--alignment=". $self->outfile_name . " ";
375 0 $commandstring .= "--sequence=". $seqfile . " ";
376  
377 0 ▶ $self->throw("unable to find or run executable for 'simprot'")
Branch: 1 branch
BranchTrueFalseTotal
unless $simprot_executable and -e $simprot_executable and -x _ 0 0 0
Condition0%0/6
$simprot_executable and -e $simprot_executable and -x _
!ll&&!rl&&r
000
$simprot_executable and -e $simprot_executable
!ll&&!rl&&r
000
MC/DC0%0/3
$simprot_executable and -e $simprot_executable and -x _
$simprot_executable -e $simprot_executable -x _
Truth table0%0/4
A and B and C
A= $simprot_executableB= -e $simprot_executableC= -x _
ABCresult
0XX0
10X0
1100
1111
378 unless $simprot_executable && -e $simprot_executable && -x _;
379  
380 0 ▶ open(RUN, "$commandstring |")
Branch: 1 branch
BranchTrueFalseTotal
open RUN, "$commandstring |" or $self->throw("Cannot run $commandstring") 0 0 0
381 or $self->throw("Cannot run $commandstring");
382  
383 0 my @output = <RUN>;
384 0 $exit_status = close(RUN);
385 0 $self->error_string(join('',@output));
386 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
387 0 $self->warn("There was an error - see error_string for the program output");
388 0 $rc = 0;
389 }
390 0 eval {
391 0 $aln = Bio::AlignIO->new(-file => "$outfile",-format => 'fasta');
392 0 $seq = Bio::SeqIO->new(-file => "$seqfile", -format => 'fasta');
393 };
394 0 ▶ if( $@ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
395 0 $self->warn($self->error_string);
396 }
397 }
398 0 ▶ unless ( $self->save_tempfiles ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->save_tempfiles) 0 0 0
399 0 $self->cleanup();
400 }
401 0 return ($rc,$aln,$seq);
402 }
403  
404  
405 =head2 error_string
406  
407 Title : error_string
408 Usage : $obj->error_string($newval)
409 Function: Where the output from the last analysus run is stored.
410 Returns : value of error_string
411 Args : newvalue (optional)
412  
413  
414 =cut
415  
416 0 ▶sub error_string {
Subroutine error_string: not called CC=2 SCAR=17.9
Pod documented
417 0 my ($self,$value) = @_;
418 0 ▶ if( defined $value) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 0 0 0
419 0 $self->{'error_string'} = $value;
420 }
421 0 return $self->{'error_string'};
422  
423 }
424  
425  
426 =head2 version
427  
428 Title : version
429 Usage : exit if $prog->version() < 1.8
430 Function: Determine the version number of the program
431 Example :
432 Returns : float or undef
433 Args : none
434  
435 =cut
436  
437 0 ▶sub version {
Subroutine version: not called CC=3 SCAR=24.8
Pod documented
438 0 my ($self) = @_;
439 0 my $exe;
440 0 ▶ return undef unless $exe = $self->executable;
Branch: 1 branch
BranchTrueFalseTotal
unless $exe = $self->executable 0 0 0
441 0 my $string = `$exe 2>&1` ;
442  
443 0 $string =~ /Version\:\s+(\d+.\d+.\d+)/m;
444 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
445 }
446  
447  
448 =head2 alignment
449  
450 Title : alignment
451 Usage : $simprot->align($aln);
452 Function: Get/Set the L<Bio::Align::AlignI> object
453 Returns : L<Bio::Align::AlignI> object
454 Args : [optional] L<Bio::Align::AlignI>
455 Comment : We could potentially add support for running directly on a file
456 but we shall keep it simple
457 See also: L<Bio::SimpleAlign>
458  
459 =cut
460  
461 0 ▶sub alignment {
Subroutine alignment: not called CC=5 SCAR=34.0
Pod documented
462 0 my ($self,$aln) = @_;
463  
464 0 ▶ if( defined $aln ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $aln) 0 0 0
465 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
466 0 $self->{'_alignment'} = $aln;
467 ▶ } 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
468 0 $self->warn("Must specify a valid Bio::Align::AlignI object to the alignment function not $aln");
469 0 return undef;
470 } else {
471 0 $self->{'_alignment'} = $aln;
472 }
473 }
474 0 return $self->{'_alignment'};
475 }
476  
477 =head2 tree
478  
479 Title : tree
480 Usage : $simprot->tree($tree, %params);
481 Function: Get/Set the L<Bio::Tree::TreeI> object
482 Returns : L<Bio::Tree::TreeI>
483 Args : [optional] $tree => L<Bio::Tree::TreeI>,
484 [optional] %parameters => hash of tree-specific parameters
485  
486 Comment : We could potentially add support for running directly on a file
487 but we shall keep it simple
488 See also: L<Bio::Tree::Tree>
489  
490 =cut
491  
492 0 ▶sub tree {
Subroutine tree: not called CC=4 SCAR=30.0
Pod documented
493 0 my ($self, $tree, %params) = @_;
494 0 ▶ if( defined $tree ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $tree) 0 0 0
495 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
496 0 $self->warn("Must specify a valid Bio::Tree::TreeI object to the alignment function");
497 }
498 0 $self->{'_tree'} = $tree;
499 }
500 0 return $self->{'_tree'};
501 }
502  
503  
504  
505 =head1 Bio::Tools::Run::BaseWrapper methods
506  
507 =cut
508  
509 =head2 save_tempfiles
510  
511 Title : save_tempfiles
512 Usage : $obj->save_tempfiles($newval)
513 Function:
514 Returns : value of save_tempfiles
515 Args : newvalue (optional)
516  
517  
518 =cut
519  
520 =head2 outfile_name
521  
522 Title : outfile_name
523 Usage : my $outfile = $simprot->outfile_name();
524 Function: Get/Set the name of the output file for this run
525 (if you wanted to do something special)
526 Returns : string
527 Args : [optional] string to set value to
528  
529  
530 =cut
531  
532  
533 =head2 tempdir
534  
535 Title : tempdir
536 Usage : my $tmpdir = $self->tempdir();
537 Function: Retrieve a temporary directory name (which is created)
538 Returns : string which is the name of the temporary directory
539 Args : none
540  
541  
542 =cut
543  
544 =head2 cleanup
545  
546 Title : cleanup
547 Usage : $simprot->cleanup();
548 Function: Will cleanup the tempdir directory
549 Returns : none
550 Args : none
551  
552  
553 =cut
554  
555 =head2 io
556  
557 Title : io
558 Usage : $obj->io($newval)
559 Function: Gets a L<Bio::Root::IO> object
560 Returns : L<Bio::Root::IO>
561 Args : none
562  
563  
564 =cut
565  
566 1 ▶sub DESTROY {
Subroutine DESTROY: called CC=2 SCAR=7.0
567 1 my $self= shift;
568 1 ▶ unless ( $self->save_tempfiles ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->save_tempfiles) 1 0 1
569 1 $self->cleanup();
570 }
571 1 $self->SUPER::DESTROY();
572 }
573  
574 1 1; # Needed to keep compiler happy
« Tools/Run/Alignment/Proda.pm ↑ Summary DB/SoapEUtilities/FetchAdaptor/species.pm »