« blib/lib/Bio/Tools/Run/Phylo/Molphy/ProtML.pm
↑ Summary
blib/lib/Bio/Tools/Run/Phylo/Hyphy/REL.pm »
| 1 | # $Id$ | ||||||||||||||||||||||||||||
| 2 | # | ||||||||||||||||||||||||||||
| 3 | # BioPerl module for Bio::Tools::Run::Phylo::Hyphy::Base | ||||||||||||||||||||||||||||
| 4 | # | ||||||||||||||||||||||||||||
| 5 | # Please direct questions and support issues to <bioperl-l@bioperl.org> | ||||||||||||||||||||||||||||
| 6 | # | ||||||||||||||||||||||||||||
| 7 | # Cared for by Albert Vilella <avilella-at-gmail-dot-com> | ||||||||||||||||||||||||||||
| 8 | # | ||||||||||||||||||||||||||||
| 9 | # Copyright Albert Vilella | ||||||||||||||||||||||||||||
| 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::Hyphy::Base - Hyphy wrapping base methods | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | FIXME | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | HyPhy ([Hy]pothesis Testing Using [Phy]logenies) package of Sergei | ||||||||||||||||||||||||||||
| 26 | Kosakowsky Pond, Spencer V. Muse, Simon D.W. Frost and Art Poon. See | ||||||||||||||||||||||||||||
| 27 | http://www.hyphy.org for more information. | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | =head1 FEEDBACK | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | =head2 Mailing Lists | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | User feedback is an integral part of the evolution of this and other | ||||||||||||||||||||||||||||
| 34 | Bioperl modules. Send your comments and suggestions preferably to | ||||||||||||||||||||||||||||
| 35 | the Bioperl mailing list. Your participation is much appreciated. | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | bioperl-l@bioperl.org - General discussion | ||||||||||||||||||||||||||||
| 38 | http://bioperl.org/wiki/Mailing_lists - About the mailing lists | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | =head2 Support | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | Please direct usage questions or support issues to the mailing list: | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | I<bioperl-l@bioperl.org> | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | rather than to the module maintainer directly. Many experienced and | ||||||||||||||||||||||||||||
| 47 | reponsive experts will be able look at the problem and quickly | ||||||||||||||||||||||||||||
| 48 | address it. Please include a thorough description of the problem | ||||||||||||||||||||||||||||
| 49 | with code and data examples if at all possible. | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | =head2 Reporting Bugs | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | Report bugs to the Bioperl bug tracking system to help us keep track | ||||||||||||||||||||||||||||
| 54 | of the bugs and their resolution. Bug reports can be submitted via the | ||||||||||||||||||||||||||||
| 55 | web: | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | http://redmine.open-bio.org/projects/bioperl/ | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | =head1 AUTHOR - Albert Vilella | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | Email avilella-at-gmail-dot-com | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | =head1 CONTRIBUTORS | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | Additional contributors names and emails here | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | =head1 APPENDIX | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | The rest of the documentation details each of the object methods. | ||||||||||||||||||||||||||||
| 70 | Internal methods are usually preceded with a _ | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | =cut | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | # Let the code begin... | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | package Bio::Tools::Run::Phylo::Hyphy::Base; | ||||||||||||||||||||||||||||
| 79 | 1 | ▶ | use vars qw(@ISA @VALIDVALUES $PROGRAMNAME $PROGRAM); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 80 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 81 | 1 | ▶ | use Bio::Root::Root; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 82 | 1 | ▶ | use Bio::AlignIO; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 83 | 1 | ▶ | use Bio::TreeIO; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 84 | 1 | ▶ | use Bio::Tools::Run::WrapperBase; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | 1 | @ISA = qw(Bio::Root::Root Bio::Tools::Run::WrapperBase); | |||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | =head2 Default Values | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | Valid and default values are listed below. The default | ||||||||||||||||||||||||||||
| 91 | values are always the first one listed. These descriptions are | ||||||||||||||||||||||||||||
| 92 | essentially lifted from the python wrapper or provided by the author. | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | INCOMPLETE DOCUMENTATION OF ALL METHODS | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | =cut | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | BEGIN { | ||||||||||||||||||||||||||||
| 99 | 1 | ▶ | $PROGRAMNAME = 'HYPHYMP' . ($^O =~ /mswin/i ?'.exe':''); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=4 SCAR=19.1
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 100 | 1 | ▶ | if( defined $ENV{'HYPHYDIR'} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 101 | 0 | ▶ | $PROGRAM = Bio::Root::IO->catfile($ENV{'HYPHYDIR'},$PROGRAMNAME). ($^O =~ /mswin/i ?'.exe':'');; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | =head2 program_name | ||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | Title : program_name | ||||||||||||||||||||||||||||
| 108 | Usage : $factory->program_name() | ||||||||||||||||||||||||||||
| 109 | Function: holds the program name | ||||||||||||||||||||||||||||
| 110 | Returns: string | ||||||||||||||||||||||||||||
| 111 | Args : None | ||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | =cut | ||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | sub program_name { | ||||||||||||||||||||||||||||
| 116 | 6 | ▶ | return 'HYPHYMP'; | ||||||||||||||||||||||||||
|
Subroutine
program_name: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | =head2 program_dir | ||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | Title : program_dir | ||||||||||||||||||||||||||||
| 122 | Usage : ->program_dir() | ||||||||||||||||||||||||||||
| 123 | Function: returns the program directory, obtained from ENV variable. | ||||||||||||||||||||||||||||
| 124 | Returns: string | ||||||||||||||||||||||||||||
| 125 | Args : | ||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | =cut | ||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | sub program_dir { | ||||||||||||||||||||||||||||
| 130 | 3 | ▶ | return Bio::Root::IO->catfile($ENV{HYPHYDIR}) if $ENV{HYPHYDIR}; | ||||||||||||||||||||||||||
|
Subroutine
program_dir: called CC=2 SCAR=7.6
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | =head2 new | ||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | Title : new | ||||||||||||||||||||||||||||
| 137 | Usage : my $obj = Bio::Tools::Run::Phylo::Hyphy->new(); | ||||||||||||||||||||||||||||
| 138 | Function: Builds a new Bio::Tools::Run::Phylo::Hyphy object | ||||||||||||||||||||||||||||
| 139 | Returns : Bio::Tools::Run::Phylo::Hyphy | ||||||||||||||||||||||||||||
| 140 | Args : -alignment => the Bio::Align::AlignI object | ||||||||||||||||||||||||||||
| 141 | -save_tempfiles => boolean to save the generated tempfiles and | ||||||||||||||||||||||||||||
| 142 | NOT cleanup after onesself (default FALSE) | ||||||||||||||||||||||||||||
| 143 | -tree => the Bio::Tree::TreeI object | ||||||||||||||||||||||||||||
| 144 | -params => a hashref of parameters (all passed to set_parameter) | ||||||||||||||||||||||||||||
| 145 | -executable => where the hyphy executable resides | ||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | See also: L<Bio::Tree::TreeI>, L<Bio::Align::AlignI> | ||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | =cut | ||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | sub new { | ||||||||||||||||||||||||||||
| 152 | 2 | ▶ | my($class,@args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | 2 | my $self = $class->SUPER::new(@args); | |||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||
| 156 | 2 | return $self; | |||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||
| 160 | =head2 prepare | ||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | Title : prepare | ||||||||||||||||||||||||||||
| 163 | Usage : my $rundir = $hyphy->prepare($aln); | ||||||||||||||||||||||||||||
| 164 | Function: prepare the analysis using the default or updated parameters | ||||||||||||||||||||||||||||
| 165 | the alignment parameter must have been set | ||||||||||||||||||||||||||||
| 166 | Returns : value of rundir | ||||||||||||||||||||||||||||
| 167 | Args : L<Bio::Align::AlignI> object, | ||||||||||||||||||||||||||||
| 168 | L<Bio::Tree::TreeI> object [optional] | ||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||
| 170 | =cut | ||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | sub prepare { | ||||||||||||||||||||||||||||
| 173 | 0 | ▶ | my ($self,$aln,$tree) = @_; | ||||||||||||||||||||||||||
|
Subroutine
prepare: not called CC=12 SCAR=50.5
Pod
documented
| |||||||||||||||||||||||||||||
| 174 | 0 | ▶ | unless ( $self->save_tempfiles ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 175 | # brush so we don't get plaque buildup ;) | ||||||||||||||||||||||||||||
| 176 | 0 | $self->cleanup(); | |||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||
| 178 | 0 | ▶ | $tree = $self->tree unless $tree; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 179 | 0 | ▶ | $aln = $self->alignment unless $aln; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 180 | 0 | ▶ | if( ! $aln ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 181 | 0 | $self->warn("must have supplied a valid alignment file in order to run hyphy"); | |||||||||||||||||||||||||||
| 182 | 0 | return 0; | |||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||
| 184 | 0 | my ($tempdir) = $self->tempdir(); | |||||||||||||||||||||||||||
| 185 | 0 | my ($tempseqFH,$tempalnfile); | |||||||||||||||||||||||||||
| 186 | 0 | ▶ | if( ! ref($aln) && -e $aln ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not ref $aln and -e $aln
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
| |||||||||||||||||||||||||||||
| 187 | 0 | $tempalnfile = $aln; | |||||||||||||||||||||||||||
| 188 | } else { | ||||||||||||||||||||||||||||
| 189 | 0 | ▶ | ($tempseqFH,$tempalnfile) = $self->io->tempfile | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 190 | ('-dir' => $tempdir, | ||||||||||||||||||||||||||||
| 191 | UNLINK => ($self->save_tempfiles ? 0 : 1)); | ||||||||||||||||||||||||||||
| 192 | 0 | $aln->set_displayname_flat(1); | |||||||||||||||||||||||||||
| 193 | 0 | my $alnout = Bio::AlignIO->new('-format' => 'fasta', | |||||||||||||||||||||||||||
| 194 | '-fh' => $tempseqFH); | ||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||
| 196 | 0 | $alnout->write_aln($aln); | |||||||||||||||||||||||||||
| 197 | 0 | $alnout->close(); | |||||||||||||||||||||||||||
| 198 | 0 | undef $alnout; | |||||||||||||||||||||||||||
| 199 | 0 | close($tempseqFH); | |||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||
| 201 | 0 | $self->{'_params'}{'tempalnfile'} = $tempalnfile; | |||||||||||||||||||||||||||
| 202 | 0 | ▶ | my $outfile = $self->outfile_name || "$tempdir/results.tsv"; | ||||||||||||||||||||||||||
|
Condition0%0/2
$self->outfile_name || "$tempdir/results.tsv"
MC/DC0%0/1
$self->outfile_name || "$tempdir/results.tsv"
$self->outfile_name
Truth table0%0/2
A
A= $self->outfile_name
| |||||||||||||||||||||||||||||
| 203 | 0 | $self->{'_params'}{'outfile'} = $outfile; | |||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||
| 205 | 0 | my ($temptreeFH,$temptreefile); | |||||||||||||||||||||||||||
| 206 | 0 | ▶ | if( ! ref($tree) && -e $tree ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not ref $tree and -e $tree
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
| |||||||||||||||||||||||||||||
| 207 | 0 | $temptreefile = $tree; | |||||||||||||||||||||||||||
| 208 | } else { | ||||||||||||||||||||||||||||
| 209 | 0 | ▶ | ($temptreeFH,$temptreefile) = $self->io->tempfile | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 210 | ('-dir' => $tempdir, | ||||||||||||||||||||||||||||
| 211 | UNLINK => ($self->save_tempfiles ? 0 : 1)); | ||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||
| 213 | 0 | my $treeout = Bio::TreeIO->new('-format' => 'newick', | |||||||||||||||||||||||||||
| 214 | '-fh' => $temptreeFH); | ||||||||||||||||||||||||||||
| 215 | 0 | $treeout->write_tree($tree); | |||||||||||||||||||||||||||
| 216 | 0 | $treeout->close(); | |||||||||||||||||||||||||||
| 217 | 0 | close($temptreeFH); | |||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||
| 219 | 0 | $self->{'_params'}{'temptreefile'} = $temptreefile; | |||||||||||||||||||||||||||
| 220 | 0 | $self->create_wrapper; | |||||||||||||||||||||||||||
| 221 | 0 | $self->{_prepared} = 1; | |||||||||||||||||||||||||||
| 222 | 0 | return $tempdir; | |||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||
| 226 | =head2 create_wrapper | ||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||
| 228 | Title : create_wrapper | ||||||||||||||||||||||||||||
| 229 | Usage : $self->create_wrapper | ||||||||||||||||||||||||||||
| 230 | Function: It will create the wrapper file that interfaces with the analysis bf file | ||||||||||||||||||||||||||||
| 231 | Example : | ||||||||||||||||||||||||||||
| 232 | Returns : | ||||||||||||||||||||||||||||
| 233 | Args : | ||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||
| 236 | =cut | ||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||
| 238 | sub create_wrapper { | ||||||||||||||||||||||||||||
| 239 | 0 | ▶ | my ($self,$batchfile) = @_; | ||||||||||||||||||||||||||
|
Subroutine
create_wrapper: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||
| 241 | 0 | my $tempdir = $self->tempdir; | |||||||||||||||||||||||||||
| 242 | 0 | $self->update_ordered_parameters; | |||||||||||||||||||||||||||
| 243 | 0 | my $wrapper = "$tempdir/wrapper.bf"; | |||||||||||||||||||||||||||
| 244 | 0 | ▶ | open(WRAPPER, ">$wrapper") or $self->throw("cannot open $wrapper for writing"); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||
| 246 | 0 | print WRAPPER "stdinRedirect"," = ", "\{", "\};", "\n\n"; | |||||||||||||||||||||||||||
| 247 | 0 | my $counter = sprintf("%02d", 0); | |||||||||||||||||||||||||||
| 248 | 0 | foreach my $elem (@{ $self->{'_updatedorderedparams'} }) { | |||||||||||||||||||||||||||
| 249 | 0 | my ($param,$val) = each %$elem; | |||||||||||||||||||||||||||
| 250 | 0 | print WRAPPER 'stdinRedirect ["'; | |||||||||||||||||||||||||||
| 251 | 0 | print WRAPPER "$counter"; | |||||||||||||||||||||||||||
| 252 | 0 | print WRAPPER '"] = "'; | |||||||||||||||||||||||||||
| 253 | 0 | print WRAPPER "$val"; | |||||||||||||||||||||||||||
| 254 | 0 | print WRAPPER '"',";\n"; | |||||||||||||||||||||||||||
| 255 | 0 | $counter = sprintf("%02d",$counter+1); | |||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||
| 257 | 0 | print WRAPPER "\n",'ExecuteAFile (HYPHY_BASE_DIRECTORY + "TemplateBatchFiles" + DIRECTORY_SEPARATOR + "', $batchfile ,'", stdinRedirect);', "\n"; | |||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||
| 259 | 0 | close(WRAPPER); | |||||||||||||||||||||||||||
| 260 | 0 | $self->{'_wrapper'} = $wrapper; | |||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||
| 264 | =head2 error_string | ||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||
| 266 | Title : error_string | ||||||||||||||||||||||||||||
| 267 | Usage : $obj->error_string($newval) | ||||||||||||||||||||||||||||
| 268 | Function: Where the output from the last analysus run is stored. | ||||||||||||||||||||||||||||
| 269 | Returns : value of error_string | ||||||||||||||||||||||||||||
| 270 | Args : newvalue (optional) | ||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||
| 273 | =cut | ||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||
| 275 | sub error_string { | ||||||||||||||||||||||||||||
| 276 | 0 | ▶ | my ($self,$value) = @_; | ||||||||||||||||||||||||||
|
Subroutine
error_string: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 277 | 0 | ▶ | if( defined $value) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 278 | 0 | $self->{'error_string'} = $value; | |||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||
| 280 | 0 | return $self->{'error_string'}; | |||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||
| 284 | =head2 alignment | ||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||
| 286 | Title : alignment | ||||||||||||||||||||||||||||
| 287 | Usage : $hyphy->align($aln); | ||||||||||||||||||||||||||||
| 288 | Function: Get/Set the L<Bio::Align::AlignI> object | ||||||||||||||||||||||||||||
| 289 | Returns : L<Bio::Align::AlignI> object | ||||||||||||||||||||||||||||
| 290 | Args : [optional] L<Bio::Align::AlignI> | ||||||||||||||||||||||||||||
| 291 | Comment : We could potentially add support for running directly on a file | ||||||||||||||||||||||||||||
| 292 | but we shall keep it simple | ||||||||||||||||||||||||||||
| 293 | See also: L<Bio::SimpleAlign> | ||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||
| 295 | =cut | ||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||
| 297 | sub alignment { | ||||||||||||||||||||||||||||
| 298 | 0 | ▶ | my ($self,$aln) = @_; | ||||||||||||||||||||||||||
|
Subroutine
alignment: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||
| 300 | 0 | ▶ | if( defined $aln ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 301 | 0 | ▶ | if( -e $aln ) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 302 | 0 | $self->{'_alignment'} = $aln; | |||||||||||||||||||||||||||
| 303 | ▶ | } elsif( !ref($aln) || ! $aln->isa('Bio::Align::AlignI') ) { | |||||||||||||||||||||||||||
|
Condition0%0/3
ref $aln && $aln->isa('Bio::Align::AlignI')
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')
| |||||||||||||||||||||||||||||
| 304 | 0 | $self->warn("Must specify a valid Bio::Align::AlignI object to the alignment function not $aln"); | |||||||||||||||||||||||||||
| 305 | 0 | return undef; | |||||||||||||||||||||||||||
| 306 | } else { | ||||||||||||||||||||||||||||
| 307 | 0 | $self->{'_alignment'} = $aln; | |||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||
| 310 | 0 | return $self->{'_alignment'}; | |||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||
| 313 | =head2 tree | ||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||
| 315 | Title : tree | ||||||||||||||||||||||||||||
| 316 | Usage : $hyphy->tree($tree, %params); | ||||||||||||||||||||||||||||
| 317 | Function: Get/Set the L<Bio::Tree::TreeI> object | ||||||||||||||||||||||||||||
| 318 | Returns : L<Bio::Tree::TreeI> | ||||||||||||||||||||||||||||
| 319 | Args : [optional] $tree => L<Bio::Tree::TreeI>, | ||||||||||||||||||||||||||||
| 320 | [optional] %parameters => hash of tree-specific parameters: | ||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||
| 322 | Comment : We could potentially add support for running directly on a file | ||||||||||||||||||||||||||||
| 323 | but we shall keep it simple | ||||||||||||||||||||||||||||
| 324 | See also: L<Bio::Tree::Tree> | ||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||
| 326 | =cut | ||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||
| 328 | sub tree { | ||||||||||||||||||||||||||||
| 329 | 0 | ▶ | my ($self, $tree, %params) = @_; | ||||||||||||||||||||||||||
|
Subroutine
tree: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 330 | 0 | ▶ | if( defined $tree ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 331 | 0 | ▶ | if( ! ref($tree) || ! $tree->isa('Bio::Tree::TreeI') ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $tree and $tree->isa("Bio::Tree::TreeI")
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")
| |||||||||||||||||||||||||||||
| 332 | 0 | $self->warn("Must specify a valid Bio::Tree::TreeI object to the alignment function"); | |||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||
| 334 | 0 | $self->{'_tree'} = $tree; | |||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||
| 336 | 0 | return $self->{'_tree'}; | |||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||
| 339 | =head2 get_parameters | ||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||
| 341 | Title : get_parameters | ||||||||||||||||||||||||||||
| 342 | Usage : my %params = $self->get_parameters(); | ||||||||||||||||||||||||||||
| 343 | Function: returns the list of parameters as a hash | ||||||||||||||||||||||||||||
| 344 | Returns : associative array keyed on parameter names | ||||||||||||||||||||||||||||
| 345 | Args : none | ||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||
| 348 | =cut | ||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||
| 350 | sub get_parameters { | ||||||||||||||||||||||||||||
| 351 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
get_parameters: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 352 | # we're returning a copy of this | ||||||||||||||||||||||||||||
| 353 | 0 | return @{ $self->{'_hyphyparams'} }; | |||||||||||||||||||||||||||
| 354 | } | ||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||
| 357 | =head2 set_parameter | ||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||
| 359 | Title : set_parameter | ||||||||||||||||||||||||||||
| 360 | Usage : $hyphy->set_parameter($param,$val); | ||||||||||||||||||||||||||||
| 361 | Function: Sets a hyphy parameter, will be validated against | ||||||||||||||||||||||||||||
| 362 | the valid values as set in the %VALIDVALUES class variable. | ||||||||||||||||||||||||||||
| 363 | The checks can be ignored if one turns off param checks like this: | ||||||||||||||||||||||||||||
| 364 | $hyphy->no_param_checks(1) | ||||||||||||||||||||||||||||
| 365 | Returns : boolean if set was success, if verbose is set to -1 | ||||||||||||||||||||||||||||
| 366 | then no warning will be reported | ||||||||||||||||||||||||||||
| 367 | Args : $param => name of the parameter | ||||||||||||||||||||||||||||
| 368 | $value => value to set the parameter to | ||||||||||||||||||||||||||||
| 369 | See also: L<no_param_checks()> | ||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||
| 371 | =cut | ||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||
| 375 | sub set_parameter { | ||||||||||||||||||||||||||||
| 376 | 0 | ▶ | my ($self,$param,$value) = @_; | ||||||||||||||||||||||||||
|
Subroutine
set_parameter: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||
| 378 | # FIXME - add validparams checking | ||||||||||||||||||||||||||||
| 379 | 0 | $self->{'_hyphyparams'}{$param} = $value; | |||||||||||||||||||||||||||
| 380 | 0 | return 1; | |||||||||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||
| 383 | =head2 update_ordered_parameters | ||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||
| 385 | Title : update_ordered_parameters | ||||||||||||||||||||||||||||
| 386 | Usage : $hyphy->update_ordered_parameters(0); | ||||||||||||||||||||||||||||
| 387 | Function: (Re)set the default parameters from the defaults | ||||||||||||||||||||||||||||
| 388 | (the first value in each array in the | ||||||||||||||||||||||||||||
| 389 | %VALIDVALUES class variable) | ||||||||||||||||||||||||||||
| 390 | Returns : none | ||||||||||||||||||||||||||||
| 391 | Args : boolean: keep existing parameter values | ||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||
| 394 | =cut | ||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||
| 396 | sub update_ordered_parameters { | ||||||||||||||||||||||||||||
| 397 | 0 | ▶ | my ($self,$keepold) = @_; | ||||||||||||||||||||||||||
|
Subroutine
update_ordered_parameters: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||||||||||||
| 398 | 0 | ▶ | $keepold = 0 unless defined $keepold; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 399 | 0 | foreach my $elem (@{$self->{'_orderedparams'}}) { | |||||||||||||||||||||||||||
| 400 | 0 | my ($param,$val) = each %$elem; | |||||||||||||||||||||||||||
| 401 | 0 | my $composite_param = $param; | |||||||||||||||||||||||||||
| 402 | # skip if we want to keep old values and it is already set | ||||||||||||||||||||||||||||
| 403 | 0 | ▶ | if (ref($param) =~ /ARRAY/i ) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 404 | 0 | ▶ | push @{ $self->{'_updatedorderedsparams'} }, {$param, $self->{_params}{$param} || $val}; | ||||||||||||||||||||||||||
|
Condition0%0/3
$self->{'_params'}{$param} || $val
MC/DC0%0/2
$self->{'_params'}{$param} || $val
$self->{'_params'}{$param}
$val
Truth table0%0/3
A || B
A= $self->{'_params'}{$param}B= $val
| |||||||||||||||||||||||||||||
| 405 | } elsif ( ref($val) =~ /HASH/i ) { | ||||||||||||||||||||||||||||
| 406 | 0 | ▶ | while (defined($val)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 407 | 0 | ▶ | last unless (ref($val) =~ /HASH/i); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 408 | 0 | my ($param,$val) = each %{$val}; | |||||||||||||||||||||||||||
| 409 | 0 | $composite_param .= $param; | |||||||||||||||||||||||||||
| 410 | } | ||||||||||||||||||||||||||||
| 411 | 0 | ▶ | push @{ $self->{'_updatedorderedparams'} }, {$param, $self->{_params}{$composite_param} || $val}; | ||||||||||||||||||||||||||
|
Condition0%0/3
$self->{'_params'}{$composite_param} || $val
MC/DC0%0/2
$self->{'_params'}{$composite_param} || $val
$self->{'_params'}{$composite_param}
$val
Truth table0%0/3
A || B
A= $self->{'_params'}{$composite_param}B= $val
| |||||||||||||||||||||||||||||
| 412 | } else { | ||||||||||||||||||||||||||||
| 413 | 0 | ▶ | push @{ $self->{'_updatedorderedparams'} }, {$param, $self->{_params}{$param} || $val}; | ||||||||||||||||||||||||||
|
Condition0%0/3
$self->{'_params'}{$param} || $val
MC/DC0%0/2
$self->{'_params'}{$param} || $val
$self->{'_params'}{$param}
$val
Truth table0%0/3
A || B
A= $self->{'_params'}{$param}B= $val
| |||||||||||||||||||||||||||||
| 414 | } | ||||||||||||||||||||||||||||
| 415 | } | ||||||||||||||||||||||||||||
| 416 | } | ||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||
| 419 | =head1 Bio::Tools::Run::WrapperBase methods | ||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||
| 421 | =cut | ||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||
| 423 | =head2 no_param_checks | ||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||
| 425 | Title : no_param_checks | ||||||||||||||||||||||||||||
| 426 | Usage : $obj->no_param_checks($newval) | ||||||||||||||||||||||||||||
| 427 | Function: Boolean flag as to whether or not we should | ||||||||||||||||||||||||||||
| 428 | trust the sanity checks for parameter values | ||||||||||||||||||||||||||||
| 429 | Returns : value of no_param_checks | ||||||||||||||||||||||||||||
| 430 | Args : newvalue (optional) | ||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||
| 433 | =cut | ||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||
| 435 | sub no_param_checks { | ||||||||||||||||||||||||||||
| 436 | 0 | ▶ | my ($self,$value) = @_; | ||||||||||||||||||||||||||
|
Subroutine
no_param_checks: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 437 | 0 | ▶ | if( defined $value) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 438 | 0 | $self->{'no_param_checks'} = $value; | |||||||||||||||||||||||||||
| 439 | } | ||||||||||||||||||||||||||||
| 440 | 0 | return $self->{'no_param_checks'}; | |||||||||||||||||||||||||||
| 441 | } | ||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||
| 444 | =head2 save_tempfiles | ||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||
| 446 | Title : save_tempfiles | ||||||||||||||||||||||||||||
| 447 | Usage : $obj->save_tempfiles($newval) | ||||||||||||||||||||||||||||
| 448 | Function: | ||||||||||||||||||||||||||||
| 449 | Returns : value of save_tempfiles | ||||||||||||||||||||||||||||
| 450 | Args : newvalue (optional) | ||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||
| 453 | =cut | ||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||
| 455 | =head2 outfile_name | ||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||
| 457 | Title : outfile_name | ||||||||||||||||||||||||||||
| 458 | Usage : my $outfile = $hyphy->outfile_name(); | ||||||||||||||||||||||||||||
| 459 | Function: Get/Set the name of the output file for this run | ||||||||||||||||||||||||||||
| 460 | (if you wanted to do something special) | ||||||||||||||||||||||||||||
| 461 | Returns : string | ||||||||||||||||||||||||||||
| 462 | Args : [optional] string to set value to | ||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||
| 465 | =cut | ||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||
| 467 | sub outfile_name { | ||||||||||||||||||||||||||||
| 468 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
outfile_name: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 469 | 0 | ▶ | if( @_ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 470 | 0 | return $self->{'_params'}->{'outfile'} = shift @_; | |||||||||||||||||||||||||||
| 471 | } | ||||||||||||||||||||||||||||
| 472 | 0 | return $self->{'_params'}->{'outfile'}; | |||||||||||||||||||||||||||
| 473 | } | ||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||
| 475 | =head2 no_param_checks | ||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||
| 477 | Title : no_param_checks | ||||||||||||||||||||||||||||
| 478 | Usage : $obj->no_param_checks($newval) | ||||||||||||||||||||||||||||
| 479 | Function: Boolean flag as to whether or not we should | ||||||||||||||||||||||||||||
| 480 | trust the sanity checks for parameter values | ||||||||||||||||||||||||||||
| 481 | Returns : value of no_param_checks | ||||||||||||||||||||||||||||
| 482 | Args : newvalue (optional) | ||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||
| 485 | =cut | ||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||
| 487 | # sub no_param_checks { | ||||||||||||||||||||||||||||
| 488 | # my ($self,$value) = @_; | ||||||||||||||||||||||||||||
| 489 | # if( defined $value) { | ||||||||||||||||||||||||||||
| 490 | # $self->{'no_param_checks'} = $value; | ||||||||||||||||||||||||||||
| 491 | # } | ||||||||||||||||||||||||||||
| 492 | # return $self->{'no_param_checks'}; | ||||||||||||||||||||||||||||
| 493 | # } | ||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||
| 495 | =head2 tempdir | ||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||
| 497 | Title : tempdir | ||||||||||||||||||||||||||||
| 498 | Usage : my $tmpdir = $self->tempdir(); | ||||||||||||||||||||||||||||
| 499 | Function: Retrieve a temporary directory name (which is created) | ||||||||||||||||||||||||||||
| 500 | Returns : string which is the name of the temporary directory | ||||||||||||||||||||||||||||
| 501 | Args : none | ||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||
| 504 | =cut | ||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||
| 506 | =head2 cleanup | ||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||
| 508 | Title : cleanup | ||||||||||||||||||||||||||||
| 509 | Usage : $hyphy->cleanup(); | ||||||||||||||||||||||||||||
| 510 | Function: Will cleanup the tempdir directory after a run | ||||||||||||||||||||||||||||
| 511 | Returns : none | ||||||||||||||||||||||||||||
| 512 | Args : none | ||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||
| 515 | =cut | ||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||
| 517 | =head2 io | ||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||
| 519 | Title : io | ||||||||||||||||||||||||||||
| 520 | Usage : $obj->io($newval) | ||||||||||||||||||||||||||||
| 521 | Function: Gets a L<Bio::Root::IO> object | ||||||||||||||||||||||||||||
| 522 | Returns : L<Bio::Root::IO> | ||||||||||||||||||||||||||||
| 523 | Args : none | ||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||
| 525 | |||||||||||||||||||||||||||||
| 526 | =cut | ||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||
| 528 | sub DESTROY { | ||||||||||||||||||||||||||||
| 529 | 2 | ▶ | my $self= shift; | ||||||||||||||||||||||||||
|
Subroutine
DESTROY: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||
| 530 | 2 | ▶ | unless ( $self->save_tempfiles ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 531 | 2 | $self->cleanup(); | |||||||||||||||||||||||||||
| 532 | } | ||||||||||||||||||||||||||||
| 533 | 2 | $self->SUPER::DESTROY(); | |||||||||||||||||||||||||||
| 534 | } | ||||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||
| 536 | 1 | 1; | |||||||||||||||||||||||||||