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