| 1 |
package Bio::Tools::Run::Phylo::PAML::Evolver; |
| 2 |
$Bio::Tools::Run::Phylo::PAML::Evolver::VERSION = '1.7.3'; |
| 3 |
use utf8; |
| 4 |
use strict; |
| 5 |
use warnings; |
| 6 |
|
| 7 |
use vars qw(@ISA %VALIDVALUES $MINNAMELEN $PROGRAMNAME $PROGRAM); |
| 8 |
use Bio::Root::Root; |
| 9 |
use Bio::AlignIO; |
| 10 |
use Bio::SeqIO; |
| 11 |
use Bio::TreeIO; |
| 12 |
use Bio::Tools::Run::WrapperBase; |
| 13 |
use Bio::Tools::Phylo::PAML; |
| 14 |
use Cwd; |
| 15 |
|
| 16 |
@ISA = qw(Bio::Root::Root Bio::Tools::Run::WrapperBase); |
| 17 |
|
| 18 |
# ABSTRACT: Wrapper aroud the PAML program evolver |
| 19 |
# AUTHOR: Albert Vilella <[email protected]> |
| 20 |
# OWNER: Albert Vilella <[email protected]> |
| 21 |
# LICENSE: Perl_5 |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
BEGIN { |
| 26 |
|
| 27 |
$MINNAMELEN = 25; |
| 28 |
$PROGRAMNAME = 'evolver' . ($^O =~ /mswin/i ?'.exe':''); |
| 29 |
if( defined $ENV{'PAMLDIR'} ) { |
| 30 |
$PROGRAM = Bio::Root::IO->catfile($ENV{'PAMLDIR'},$PROGRAMNAME). ($^O =~ /mswin/i ?'.exe':'');; |
| 31 |
} |
| 32 |
|
| 33 |
# valid values for parameters, the default one is always |
| 34 |
# the first one in the array |
| 35 |
# much of the documentation here is lifted directly from the MCcodon.dat |
| 36 |
# example file provided with the package |
| 37 |
|
| 38 |
# Evolver calls time for seed: SetSeed(i==-1?(int)time(NULL):i); |
| 39 |
my $rand = int(time); |
| 40 |
# my $rand = int(rand(999999)); |
| 41 |
%VALIDVALUES = |
| 42 |
( |
| 43 |
|
| 44 |
# FIXME: there should be a 6-7-8 option that fits MCcodon or MCbase or MCaa |
| 45 |
'outfmt' => [0,1], |
| 46 |
# 0 * 0:paml format (mc.paml); 1:paup format (mc.paup) |
| 47 |
# random number seed (odd number) |
| 48 |
# FIXME: set seed to null here and ask for it later? |
| 49 |
'seed' => "$rand", |
| 50 |
# numseq can actually be calculated from the tree external nodes |
| 51 |
# nucleotide sites |
| 52 |
'nuclsites' => '1000', |
| 53 |
# replicates |
| 54 |
'replicates' => '1', |
| 55 |
# tree length; use -1 if tree has absolute branch lengths |
| 56 |
# Note that tree length and branch lengths under the codon model are |
| 57 |
# measured by the expected number of nucleotide substitutions per codon |
| 58 |
# (see Goldman & Yang 1994). For amino acid models, they are defined as |
| 59 |
# the expected number of amino acid changes per amino acid site. |
| 60 |
'tree_length' => '1.5', |
| 61 |
# omega |
| 62 |
# FIXME: if one wants to call for different omegas (NSsites), |
| 63 |
# right now it has to be done like: |
| 64 |
# $evolver->set_parameter(omega,"3\n0.2\t0.3\t0.5\n0.5\t0.9\t3.2\n"); |
| 65 |
# 3 * number of site classes, followed by frequencies and omega's. |
| 66 |
# 0.6 0.3 0.1 # Freqs |
| 67 |
# 0.1 0.8 3.2 # Omegas |
| 68 |
'omega' => '0.3', |
| 69 |
# kappa |
| 70 |
'kappa' => '5', |
| 71 |
# FIXME: this only for MCbase.dat ? |
| 72 |
# model: 0:JC69, 1:K80, 2:F81, 3:F84, 4:HKY85, 5:T92, 6:TN93, 7:REV |
| 73 |
# FIXME: this applies to only some models? |
| 74 |
# 10 5 1 2 3 * kappa or rate parameters in model |
| 75 |
# FIXME: this applies to only MCbase.dat ? |
| 76 |
# 0.5 4 * <alpha> <#categories for discrete gamma> |
| 77 |
); # end of validvalues |
| 78 |
} |
| 79 |
|
| 80 |
|
| 81 |
sub program_name { |
| 82 |
return 'evolver'; |
| 83 |
} |
| 84 |
|
| 85 |
|
| 86 |
sub program_dir { |
| 87 |
return Bio::Root::IO->catfile($ENV{PAMLDIR}) if $ENV{PAMLDIR}; |
| 88 |
} |
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
sub new { |
| 93 |
my($class,@args) = @_; |
| 94 |
|
| 95 |
my $self = $class->SUPER::new(@args); |
| 96 |
# $self->{'_branchLengths'} = 0; |
| 97 |
my ($tree, $st, $params, $exe) |
| 98 |
= $self->_rearrange([qw(TREE SAVE_TEMPFILES PARAMS EXECUTABLE)], |
| 99 |
@args); |
| 100 |
defined $tree && $self->tree($tree); |
| 101 |
defined $st && $self->save_tempfiles($st); |
| 102 |
defined $exe && $self->executable($exe); |
| 103 |
|
| 104 |
$self->set_default_parameters(); |
| 105 |
if( defined $params ) { |
| 106 |
if( ref($params) !~ /HASH/i ) { |
| 107 |
$self->warn("Must provide a valid hash ref for parameter -FLAGS"); |
| 108 |
} else { |
| 109 |
map { $self->set_parameter($_, $$params{$_}) } keys %$params; |
| 110 |
} |
| 111 |
} |
| 112 |
return $self; |
| 113 |
} |
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
sub prepare { |
| 118 |
my ($self,$aln,$tree) = @_; |
| 119 |
# FIXME: To consider: to have save_tempfiles always TRUE by default |
| 120 |
# or simply never delete |
| 121 |
unless ( $self->save_tempfiles ) { |
| 122 |
# brush so we don't get plaque buildup ;) |
| 123 |
$self->cleanup(); |
| 124 |
} |
| 125 |
$tree = $self->tree unless $tree; |
| 126 |
my ($tempdir) = $self->tempdir(); |
| 127 |
|
| 128 |
# FIXME: |
| 129 |
# If multiple replicates, evolver gives: |
| 130 |
# A file with a concatenation of sequential phylips separated by a |
| 131 |
# double return which gets correctly parsed by AlignIO next_aln |
| 132 |
|
| 133 |
# Or a concatenation of paup entries with tags separating them which |
| 134 |
# wont get correctly parsed with current AlignIO (failed with |
| 135 |
# nexus) |
| 136 |
|
| 137 |
# FIXME: To consider: force phylip outfmt and split the files if |
| 138 |
# replicates > 1 |
| 139 |
|
| 140 |
# if( ! ref($aln) && -e $aln ) { |
| 141 |
# $tempseqfile = $aln; |
| 142 |
# } else { |
| 143 |
# ($tempseqFH,$tempseqfile) = $self->io->tempfile |
| 144 |
# ('-dir' => $tempdir, |
| 145 |
# UNLINK => ($self->save_tempfiles ? 0 : 1)); |
| 146 |
# my $alnout = Bio::AlignIO->new('-format' => 'phylip', |
| 147 |
# '-fh' => $tempseqFH, |
| 148 |
# '-interleaved' => 0, |
| 149 |
# '-idlength' => $MINNAMELEN > $aln->maxdisplayname_length() ? $MINNAMELEN : $aln->maxdisplayname_length() +1); |
| 150 |
# $alnout->write_aln($aln); |
| 151 |
# $alnout->close(); |
| 152 |
# undef $alnout; |
| 153 |
# close($tempseqFH); |
| 154 |
# } |
| 155 |
# now let's print the MCcodon.dat file. |
| 156 |
# many of the these programs are finicky about what the filename is |
| 157 |
# and won't even run without the properly named file. Ack |
| 158 |
|
| 159 |
# FIXME: we should do the appropriate here if we are simulating codons, nts o aa. |
| 160 |
my $evolver_ctl = "$tempdir/MCcodon.dat"; |
| 161 |
my $evolverfh; |
| 162 |
open($evolverfh, ">$evolver_ctl") or $self->throw("cannot open $evolver_ctl for writing"); |
| 163 |
# FIXME: params follow an order in the control file, they are not a hash. Do we have an |
| 164 |
# clean example of this in bioperl-run? |
| 165 |
my %params = $self->get_parameters; |
| 166 |
print $evolverfh "$params{outfmt}\n"; |
| 167 |
print $evolverfh "$params{seed}\n"; |
| 168 |
# FIXME: call get_leaf_nodes to count only leafs - relates to newick onlyleafids bug |
| 169 |
# my $numseq = scalar($tree->get_nodes); |
| 170 |
my $numseq = scalar($tree->get_leaf_nodes); |
| 171 |
print $evolverfh "$numseq "; |
| 172 |
print $evolverfh "$params{nuclsites} "; |
| 173 |
print $evolverfh "$params{replicates}\n\n"; |
| 174 |
print $evolverfh "$params{tree_length}\n"; |
| 175 |
# FIXME: do #1:#n branch tagging magic here |
| 176 |
# FIXME: this pre flush stuff is for appending mode |
| 177 |
my $treeout = Bio::TreeIO->new |
| 178 |
('-format' => 'newick', |
| 179 |
'-fh' => $evolverfh, |
| 180 |
-PRE =>'>>', |
| 181 |
'-flush', |
| 182 |
); |
| 183 |
# $treeout->bootstrap_style('nointernalids'); |
| 184 |
$treeout->write_tree($tree); |
| 185 |
# Appending mode to add more control file contents here |
| 186 |
open($evolverfh, ">>$evolver_ctl") or $self->throw("cannot open $evolver_ctl for writing"); |
| 187 |
print $evolverfh "\n$params{omega}\n"; |
| 188 |
print $evolverfh "$params{kappa}\n"; |
| 189 |
# Print codon freqs here or defaults (below) |
| 190 |
my @codon_freqs = $self->get_CodonFreqs(); |
| 191 |
foreach my $firstbase (@codon_freqs) { |
| 192 |
foreach my $element (@$firstbase) { |
| 193 |
print $evolverfh " $element"; |
| 194 |
} |
| 195 |
print $evolverfh "\n"; |
| 196 |
} |
| 197 |
|
| 198 |
# FIXME: codon freqs or nt freqs should always come from an object? |
| 199 |
# Silly printing the default codonfreqs in the default |
| 200 |
# MCcodon.dat provided by PAML |
| 201 |
unless (@codon_freqs) { |
| 202 |
print $evolverfh |
| 203 |
"0.00983798 0.01745548 0.00222048 0.01443315\n", |
| 204 |
"0.00844604 0.01498576 0.00190632 0.01239105\n", |
| 205 |
"0.01064012 0.01887870 0 0\n", |
| 206 |
"0.00469486 0.00833007 0 0.00688776\n", |
| 207 |
"0.01592816 0.02826125 0.00359507 0.02336796\n", |
| 208 |
"0.01367453 0.02426265 0.00308642 0.02006170\n", |
| 209 |
"0.01722686 0.03056552 0.00388819 0.02527326\n", |
| 210 |
"0.00760121 0.01348678 0.00171563 0.01115161\n", |
| 211 |
"0.01574077 0.02792876 0.00355278 0.02309304\n", |
| 212 |
"0.01351366 0.02397721 0.00305010 0.01982568\n", |
| 213 |
"0.01702419 0.03020593 0.00384245 0.02497593\n", |
| 214 |
"0.00751178 0.01332811 0.00169545 0.01102042\n", |
| 215 |
"0.02525082 0.04480239 0.00569924 0.03704508\n", |
| 216 |
"0.02167816 0.03846344 0.00489288 0.03180369\n", |
| 217 |
"0.02730964 0.04845534 0.00616393 0.04006555\n", |
| 218 |
"0.01205015 0.02138052 0.00271978 0.01767859\n"; |
| 219 |
} |
| 220 |
print $evolverfh "\n// end of file.\n"; |
| 221 |
close($evolverfh); |
| 222 |
# FIXME: what do we return in prepare? |
| 223 |
# return |
| 224 |
} |
| 225 |
|
| 226 |
|
| 227 |
|
| 228 |
|
| 229 |
sub run { |
| 230 |
|
| 231 |
my $self = shift; |
| 232 |
# FIXME: We should look for the stuff we prepared in the prepare method here |
| 233 |
my $rc = (1); |
| 234 |
{ |
| 235 |
my $exit_status; |
| 236 |
my ($tmpdir) = $self->tempdir(); |
| 237 |
chdir($tmpdir); |
| 238 |
my $evolverexe = $self->executable(); |
| 239 |
$self->throw("unable to find or run executable for 'evolver'") unless $evolverexe && -e $evolverexe && -x _; |
| 240 |
open(RUN, "$evolverexe 6 MCcodon.dat |") or $self->throw("Cannot open exe $evolverexe"); |
| 241 |
my @output = <RUN>; |
| 242 |
$exit_status = close(RUN); |
| 243 |
$self->error_string(join('',@output)); |
| 244 |
if ( (grep { /\berr(or)?: /io } @output) || !$exit_status) { |
| 245 |
$self->warn("There was an error - see error_string for the program output"); |
| 246 |
$rc = 0; |
| 247 |
} |
| 248 |
# FIXME - hardcoded mc.paml |
| 249 |
unless ($self->indel) { |
| 250 |
my $in = Bio::AlignIO->new('-file' => "$tmpdir/mc.paml", |
| 251 |
'-format' => 'phylip'); |
| 252 |
my $aln = $in->next_aln(); |
| 253 |
$self->alignment($aln); |
| 254 |
} |
| 255 |
} |
| 256 |
return $rc; |
| 257 |
} |
| 258 |
|
| 259 |
|
| 260 |
sub error_string{ |
| 261 |
my ($self,$value) = @_; |
| 262 |
if( defined $value) { |
| 263 |
$self->{'error_string'} = $value; |
| 264 |
} |
| 265 |
return $self->{'error_string'}; |
| 266 |
|
| 267 |
} |
| 268 |
|
| 269 |
|
| 270 |
sub alignment{ |
| 271 |
my ($self,$aln) = @_; |
| 272 |
|
| 273 |
if( defined $aln ) { |
| 274 |
if( -e $aln ) { |
| 275 |
$self->{'_alignment'} = $aln; |
| 276 |
} elsif( !ref($aln) || ! $aln->isa('Bio::Align::AlignI') ) { |
| 277 |
$self->warn("Must specify a valid Bio::Align::AlignI object to the alignment function not $aln"); |
| 278 |
return undef; |
| 279 |
} else { |
| 280 |
$self->{'_alignment'} = $aln; |
| 281 |
} |
| 282 |
} |
| 283 |
return $self->{'_alignment'}; |
| 284 |
} |
| 285 |
|
| 286 |
|
| 287 |
|
| 288 |
sub tree { |
| 289 |
my ($self, $tree, %params) = @_; |
| 290 |
if( defined $tree ) { |
| 291 |
if( ! ref($tree) || ! $tree->isa('Bio::Tree::TreeI') ) { |
| 292 |
$self->warn("Must specify a valid Bio::Tree::TreeI object to the alignment function"); |
| 293 |
} |
| 294 |
$self->{'_tree'} = $tree; |
| 295 |
# FIXME: I think we dont need this in Evolver |
| 296 |
# if ( defined $params{'_branchLengths'} ) { |
| 297 |
# my $ubl = $params{'_branchLengths'}; |
| 298 |
# if ($ubl !~ m/^(0|1|2)$/) { |
| 299 |
# $self->throw("The branchLengths parameter to tree() must be 0 (ignore), 1 (initial values) or 2 (fixed values) only"); |
| 300 |
# } |
| 301 |
# $self->{'_branchLengths'} = $ubl; |
| 302 |
# } |
| 303 |
} |
| 304 |
return $self->{'_tree'}; |
| 305 |
} |
| 306 |
|
| 307 |
|
| 308 |
sub get_parameters{ |
| 309 |
my ($self) = @_; |
| 310 |
# we're returning a copy of this |
| 311 |
return %{ $self->{'_evolverparams'} }; |
| 312 |
} |
| 313 |
|
| 314 |
|
| 315 |
|
| 316 |
sub set_parameter{ |
| 317 |
my ($self,$param,$value) = @_; |
| 318 |
unless ($self->{'no_param_checks'} == 1) { |
| 319 |
if ( ! defined $VALIDVALUES{$param} ) { |
| 320 |
$self->warn("unknown parameter $param will not be set unless you force by setting no_param_checks to true"); |
| 321 |
return 0; |
| 322 |
} |
| 323 |
if ( ref( $VALIDVALUES{$param}) =~ /ARRAY/i && |
| 324 |
scalar @{$VALIDVALUES{$param}} > 0 ) { |
| 325 |
|
| 326 |
unless ( grep { $value eq $_ } @{ $VALIDVALUES{$param} } ) { |
| 327 |
$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"); |
| 328 |
return 0; |
| 329 |
} |
| 330 |
} |
| 331 |
} |
| 332 |
$self->{'_evolverparams'}->{$param} = $value; |
| 333 |
return 1; |
| 334 |
} |
| 335 |
|
| 336 |
|
| 337 |
sub set_default_parameters{ |
| 338 |
my ($self,$keepold) = @_; |
| 339 |
$keepold = 0 unless defined $keepold; |
| 340 |
|
| 341 |
while( my ($param,$val) = each %VALIDVALUES ) { |
| 342 |
# skip if we want to keep old values and it is already set |
| 343 |
next if( defined $self->{'_evolverparams'}->{$param} && $keepold); |
| 344 |
if(ref($val)=~/ARRAY/i ) { |
| 345 |
$self->{'_evolverparams'}->{$param} = $val->[0]; |
| 346 |
} else { |
| 347 |
$self->{'_evolverparams'}->{$param} = $val; |
| 348 |
} |
| 349 |
} |
| 350 |
} |
| 351 |
|
| 352 |
|
| 353 |
|
| 354 |
|
| 355 |
sub no_param_checks{ |
| 356 |
my ($self,$value) = @_; |
| 357 |
if( defined $value) { |
| 358 |
$self->{'no_param_checks'} = $value; |
| 359 |
} |
| 360 |
return $self->{'no_param_checks'}; |
| 361 |
} |
| 362 |
|
| 363 |
|
| 364 |
sub set_CodonFreqs{ |
| 365 |
my $self = shift; |
| 366 |
|
| 367 |
return $self->{'_codonfreqs'} = shift if @_; |
| 368 |
return $self->{'_codonfreqs'}; |
| 369 |
} |
| 370 |
|
| 371 |
|
| 372 |
sub get_CodonFreqs{ |
| 373 |
my ($self) = @_; |
| 374 |
return @{$self->{'_codonfreqs'} || []}; |
| 375 |
} |
| 376 |
|
| 377 |
|
| 378 |
|
| 379 |
|
| 380 |
|
| 381 |
|
| 382 |
|
| 383 |
|
| 384 |
sub DESTROY { |
| 385 |
my $self= shift; |
| 386 |
unless ( $self->save_tempfiles ) { |
| 387 |
$self->cleanup(); |
| 388 |
} |
| 389 |
$self->SUPER::DESTROY(); |
| 390 |
} |
| 391 |
|
| 392 |
|
| 393 |
|
| 394 |
sub indel{ |
| 395 |
my $self = shift; |
| 396 |
|
| 397 |
return $self->{'indel'} = shift if @_; |
| 398 |
return $self->{'indel'}; |
| 399 |
} |
| 400 |
|
| 401 |
|
| 402 |
1; |
| 403 |
|
| 404 |
__END__ |
| 405 |
|
| 406 |
=pod |
| 407 |
|
| 408 |
=encoding UTF-8 |
| 409 |
|
| 410 |
=head1 NAME |
| 411 |
|
| 412 |
Bio::Tools::Run::Phylo::PAML::Evolver - Wrapper aroud the PAML program evolver |
| 413 |
|
| 414 |
=head1 VERSION |
| 415 |
|
| 416 |
version 1.7.3 |
| 417 |
|
| 418 |
=head1 SYNOPSIS |
| 419 |
|
| 420 |
use Bio::Tools::Run::Phylo::PAML::Evolver; |
| 421 |
|
| 422 |
my $evolver = Bio::Tools::Run::Phylo::PAML::Evolver->new(); |
| 423 |
|
| 424 |
# Get a $tree object somehow |
| 425 |
$evolver->tree($tree); |
| 426 |
|
| 427 |
# FIXME: evolver generates a tree (first run with option 1 or 2)? |
| 428 |
|
| 429 |
# One or more alns are created |
| 430 |
my @alns = $evolver->run(); |
| 431 |
|
| 432 |
#### |
| 433 |
|
| 434 |
# Or with all the data coming from a previous PAML run |
| 435 |
my $parser = Bio::Tools::Phylo::PAML->new |
| 436 |
( |
| 437 |
-file => "$inputfile", |
| 438 |
); |
| 439 |
my $result = $parser->next_result(); |
| 440 |
my $tree = $result->next_tree; |
| 441 |
$evolver->tree($tree); |
| 442 |
my @codon_freqs = $result->get_CodonFreqs(); |
| 443 |
$evolver->set_CodonFreqs(\@codon_freqs); |
| 444 |
|
| 445 |
my $val = $evolver->prepare(); |
| 446 |
|
| 447 |
# FIXME: something similar for nucleotide frequencies: |
| 448 |
# Option (5) Simulate nucleotide data sets (use MCbase.dat)? |
| 449 |
|
| 450 |
# FIXME: something similar for aa parameters: |
| 451 |
# Option (7) Simulate amino acid data sets (use MCaa.dat)? |
| 452 |
|
| 453 |
# FIXME: With an initial RootSeq.txt |
| 454 |
|
| 455 |
=head1 DESCRIPTION |
| 456 |
|
| 457 |
This is a wrapper around the evolver program of PAML (Phylogenetic |
| 458 |
Analysis by Maximum Likelihood) package of Ziheng Yang. See |
| 459 |
http://abacus.gene.ucl.ac.uk/software/paml.html for more information. |
| 460 |
|
| 461 |
This module is more about generating the properl MCmodel.ctl file and |
| 462 |
will run the program in a separate temporary directory to avoid |
| 463 |
creating temp files all over the place. |
| 464 |
|
| 465 |
=head2 Default Values |
| 466 |
|
| 467 |
Valid and default values for evolver programs are listed below. The |
| 468 |
default values are always the first one listed. These descriptions |
| 469 |
are essentially lifted from the example MCcodon.dat file and pamlDOC |
| 470 |
documentation provided by the author. |
| 471 |
|
| 472 |
Stub: |
| 473 |
|
| 474 |
B<option1> specifies something. |
| 475 |
|
| 476 |
B<option2> specifies something else. |
| 477 |
|
| 478 |
INCOMPLETE DOCUMENTATION OF ALL METHODS |
| 479 |
|
| 480 |
=head1 ATTRIBUTES |
| 481 |
|
| 482 |
=head2 program_name |
| 483 |
|
| 484 |
Title : program_name |
| 485 |
Usage : $factory->program_name() |
| 486 |
Function: holds the program name |
| 487 |
Returns: string |
| 488 |
Args : None |
| 489 |
|
| 490 |
=head2 program_dir |
| 491 |
|
| 492 |
Title : program_dir |
| 493 |
Usage : ->program_dir() |
| 494 |
Function: returns the program directory, obtained from ENV variable. |
| 495 |
Returns: string |
| 496 |
Args : |
| 497 |
|
| 498 |
=head2 error_string |
| 499 |
|
| 500 |
Title : error_string |
| 501 |
Usage : $obj->error_string($newval) |
| 502 |
Function: Where the output from the last analysis run is stored. |
| 503 |
Returns : value of error_string |
| 504 |
Args : newvalue (optional) |
| 505 |
|
| 506 |
=head2 alignment |
| 507 |
|
| 508 |
Title : alignment |
| 509 |
Usage : $evolver->align($aln); |
| 510 |
Function: Get/Set the L<Bio::Align::AlignI> object |
| 511 |
Returns : L<Bio::Align::AlignI> object |
| 512 |
Args : [optional] L<Bio::Align::AlignI> |
| 513 |
Comment : We could potentially add support for running directly on a file |
| 514 |
but we shall keep it simple |
| 515 |
See also: L<Bio::SimpleAlign> |
| 516 |
|
| 517 |
=head2 tree |
| 518 |
|
| 519 |
Title : tree |
| 520 |
Usage : $evolver->tree($tree, %params); |
| 521 |
Function: Get/Set the L<Bio::Tree::TreeI> object |
| 522 |
Returns : L<Bio::Tree::TreeI> |
| 523 |
Args : [optional] $tree => L<Bio::Tree::TreeI>, |
| 524 |
[optional] %parameters => hash of tree-specific parameters: |
| 525 |
branchLengths: 0, 1 or 2 |
| 526 |
out |
| 527 |
|
| 528 |
Comment : We could potentially add support for running directly on a file |
| 529 |
but we shall keep it simple |
| 530 |
See also: L<Bio::Tree::Tree> |
| 531 |
|
| 532 |
=head2 no_param_checks |
| 533 |
|
| 534 |
Title : no_param_checks |
| 535 |
Usage : $obj->no_param_checks($newval) |
| 536 |
Function: Boolean flag as to whether or not we should |
| 537 |
trust the sanity checks for parameter values |
| 538 |
Returns : value of no_param_checks |
| 539 |
Args : newvalue (optional) |
| 540 |
|
| 541 |
=head2 save_tempfiles |
| 542 |
|
| 543 |
Title : save_tempfiles |
| 544 |
Usage : $obj->save_tempfiles($newval) |
| 545 |
Function: |
| 546 |
Returns : value of save_tempfiles |
| 547 |
Args : newvalue (optional) |
| 548 |
|
| 549 |
=head2 outfile_name |
| 550 |
|
| 551 |
Title : outfile_name |
| 552 |
Usage : my $outfile = $evolver->outfile_name(); |
| 553 |
Function: Get/Set the name of the output file for this run |
| 554 |
(if you wanted to do something special) |
| 555 |
Returns : string |
| 556 |
Args : [optional] string to set value to |
| 557 |
|
| 558 |
=head2 tempdir |
| 559 |
|
| 560 |
Title : tempdir |
| 561 |
Usage : my $tmpdir = $self->tempdir(); |
| 562 |
Function: Retrieve a temporary directory name (which is created) |
| 563 |
Returns : string which is the name of the temporary directory |
| 564 |
Args : none |
| 565 |
|
| 566 |
=head2 indel |
| 567 |
|
| 568 |
Title : indel |
| 569 |
Usage : $obj->indel($newval) |
| 570 |
Function: this is only useful if using evolver_indel instead of main |
| 571 |
evolver package: |
| 572 |
Exploring the Relationship between Sequence Similarity and |
| 573 |
Accurate Phylogenetic Trees Brandi L. Cantarel, Hilary |
| 574 |
G. Morrison and William Pearson |
| 575 |
Example : |
| 576 |
Returns : value of indel (a scalar) |
| 577 |
Args : on set, new value (a scalar or undef, optional) |
| 578 |
|
| 579 |
=head1 METHODS |
| 580 |
|
| 581 |
=head2 new |
| 582 |
|
| 583 |
Title : new |
| 584 |
Usage : my $obj = Bio::Tools::Run::Phylo::PAML::Evolver->new(); |
| 585 |
Function: Builds a new Bio::Tools::Run::Phylo::PAML::Evolver object |
| 586 |
Returns : Bio::Tools::Run::Phylo::PAML::Evolver |
| 587 |
-save_tempfiles => boolean to save the generated tempfiles and |
| 588 |
NOT cleanup after onesself (default FALSE) |
| 589 |
-tree => the Bio::Tree::TreeI object (FIXME: optional if this is done in a first run) |
| 590 |
-params => a hashref of PAML parameters (all passed to set_parameter) |
| 591 |
-executable => where the evolver executable resides |
| 592 |
|
| 593 |
See also: L<Bio::Tree::TreeI> |
| 594 |
|
| 595 |
=head2 prepare |
| 596 |
|
| 597 |
Title : prepare |
| 598 |
Usage : my $rundir = $evolver->prepare($aln); |
| 599 |
Function: prepare the evolver analysis using the default or updated parameters |
| 600 |
the alignment parameter must have been set |
| 601 |
Returns : value of rundir |
| 602 |
Args : L<Bio::Align::AlignI> object, |
| 603 |
L<Bio::Tree::TreeI> object [optional] |
| 604 |
|
| 605 |
=head2 run |
| 606 |
|
| 607 |
Title : run |
| 608 |
Usage : my ($rc,$parser) = $evolver->run(); |
| 609 |
Function: run the evolver analysis using the default or updated parameters |
| 610 |
the alignment parameter must have been set |
| 611 |
Returns : Return code, L<Bio::Tools::Phylo::PAML> |
| 612 |
Args : L<Bio::Align::AlignI> object, |
| 613 |
L<Bio::Tree::TreeI> object [optional] |
| 614 |
|
| 615 |
=head2 get_parameters |
| 616 |
|
| 617 |
Title : get_parameters |
| 618 |
Usage : my %params = $self->get_parameters(); |
| 619 |
Function: returns the list of parameters as a hash |
| 620 |
Returns : associative array keyed on parameter names |
| 621 |
Args : none |
| 622 |
|
| 623 |
=head2 set_parameter |
| 624 |
|
| 625 |
Title : set_parameter |
| 626 |
Usage : $evolver->set_parameter($param,$val); |
| 627 |
Function: Sets a evolver parameter, will be validated against |
| 628 |
the valid values as set in the %VALIDVALUES class variable. |
| 629 |
The checks can be ignored if one turns off param checks like this: |
| 630 |
$evolver->no_param_checks(1) |
| 631 |
Returns : boolean if set was success, if verbose is set to -1 |
| 632 |
then no warning will be reported |
| 633 |
Args : $param => name of the parameter |
| 634 |
$value => value to set the parameter to |
| 635 |
See also: L<no_param_checks()> |
| 636 |
|
| 637 |
=head2 set_default_parameters |
| 638 |
|
| 639 |
Title : set_default_parameters |
| 640 |
Usage : $evolver->set_default_parameters(0); |
| 641 |
Function: (Re)set the default parameters from the defaults |
| 642 |
(the first value in each array in the |
| 643 |
%VALIDVALUES class variable) |
| 644 |
Returns : none |
| 645 |
Args : boolean: keep existing parameter values |
| 646 |
|
| 647 |
=head2 set_CodonFreqs |
| 648 |
|
| 649 |
Title : set_CodonFreqs |
| 650 |
Usage : $obj->set_CodonFreqs($newval) |
| 651 |
Function: Get/Set the Codon Frequence table |
| 652 |
Returns : value of set_CodonFreqs (a scalar) |
| 653 |
Args : on set, new value (a scalar or undef, optional) |
| 654 |
|
| 655 |
=head2 get_CodonFreqs |
| 656 |
|
| 657 |
Title : get_CodonFreqs |
| 658 |
Usage : my @codon_freqs = $evolver->get_CodonFreqs() |
| 659 |
Function: Get the Codon freqs |
| 660 |
Returns : Array |
| 661 |
Args : none |
| 662 |
|
| 663 |
=head2 cleanup |
| 664 |
|
| 665 |
Title : cleanup |
| 666 |
Usage : $evolver->cleanup(); |
| 667 |
Function: Will cleanup the tempdir directory after a PAML run |
| 668 |
Returns : none |
| 669 |
Args : none |
| 670 |
|
| 671 |
=head2 io |
| 672 |
|
| 673 |
Title : io |
| 674 |
Usage : $obj->io($newval) |
| 675 |
Function: Gets a L<Bio::Root::IO> object |
| 676 |
Returns : L<Bio::Root::IO> |
| 677 |
Args : none |
| 678 |
|
| 679 |
=head1 Bio::Tools::Run::WrapperBase methods |
| 680 |
|
| 681 |
=head1 FEEDBACK |
| 682 |
|
| 683 |
=head2 Mailing lists |
| 684 |
|
| 685 |
User feedback is an integral part of the evolution of this and other |
| 686 |
Bioperl modules. Send your comments and suggestions preferably to |
| 687 |
the Bioperl mailing list. Your participation is much appreciated. |
| 688 |
|
| 689 |
[email protected] - General discussion |
| 690 |
http://bioperl.org/Support.html - About the mailing lists |
| 691 |
|
| 692 |
=head2 Support |
| 693 |
|
| 694 |
Please direct usage questions or support issues to the mailing list: |
| 695 |
I<[email protected]> |
| 696 |
|
| 697 |
rather than to the module maintainer directly. Many experienced and |
| 698 |
reponsive experts will be able look at the problem and quickly |
| 699 |
address it. Please include a thorough description of the problem |
| 700 |
with code and data examples if at all possible. |
| 701 |
|
| 702 |
=head2 Reporting bugs |
| 703 |
|
| 704 |
Report bugs to the Bioperl bug tracking system to help us keep track |
| 705 |
of the bugs and their resolution. Bug reports can be submitted via the |
| 706 |
web: |
| 707 |
|
| 708 |
https://github.com/bioperl/bio-tools-phylo-paml/issues |
| 709 |
|
| 710 |
=head1 AUTHOR |
| 711 |
|
| 712 |
Albert Vilella <[email protected]> |
| 713 |
|
| 714 |
=head1 COPYRIGHT |
| 715 |
|
| 716 |
This software is copyright (c) by Albert Vilella <[email protected]>. |
| 717 |
|
| 718 |
This software is available under the same terms as the perl 5 programming language system itself. |
| 719 |
|
| 720 |
=cut |