| 1 | # | ||||||||||||||||||||||||||||||||
| 2 | # BioPerl module for Bio::Tools::Run::Phylo::FastTree | ||||||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||||||
| 4 | # Please direct questions and support issues to <bioperl-l@bioperl.org> | ||||||||||||||||||||||||||||||||
| 5 | # | ||||||||||||||||||||||||||||||||
| 6 | # Copyright Brian Osborne | ||||||||||||||||||||||||||||||||
| 7 | # | ||||||||||||||||||||||||||||||||
| 8 | # You may distribute this module under the same terms as perl itself | ||||||||||||||||||||||||||||||||
| 9 | # | ||||||||||||||||||||||||||||||||
| 10 | # POD documentation - main docs before the code | ||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||
| 12 | =head1 NAME | ||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||
| 14 | Bio::Tools::Run::Phylo::FastTree | ||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||
| 16 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||
| 18 | # Build a FastTree factory | ||||||||||||||||||||||||||||||||
| 19 | $factory = Bio::Tools::Run::Phylo::FastTree->new(-quiet => 1, | ||||||||||||||||||||||||||||||||
| 20 | -fastest => 1); | ||||||||||||||||||||||||||||||||
| 21 | # Get an alignment | ||||||||||||||||||||||||||||||||
| 22 | my $alignio = Bio::AlignIO->new( | ||||||||||||||||||||||||||||||||
| 23 | -format => 'fasta', | ||||||||||||||||||||||||||||||||
| 24 | -file => '219877.cdna.fasta'); | ||||||||||||||||||||||||||||||||
| 25 | my $alnobj = $alignio->next_aln; | ||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||
| 27 | # Analyze the aligment and get a Tree | ||||||||||||||||||||||||||||||||
| 28 | my $tree = $factory->run($alnobj); | ||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||
| 30 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||
| 32 | Get a Bio::Tree object given a protein or DNA alignment. | ||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||
| 34 | =head1 FEEDBACK | ||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||
| 36 | =head2 Mailing Lists | ||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||
| 38 | User feedback is an integral part of the evolution of this and other | ||||||||||||||||||||||||||||||||
| 39 | Bioperl modules. Send your comments and suggestions preferably to one | ||||||||||||||||||||||||||||||||
| 40 | of the Bioperl mailing lists. Your participation is much appreciated. | ||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||
| 42 | bioperl-l@bioperl.org - General discussion | ||||||||||||||||||||||||||||||||
| 43 | http://bioperl.org/wiki/Mailing_lists - About the mailing lists | ||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||
| 45 | =head2 Support | ||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||
| 47 | Please direct usage questions or support issues to the mailing list: | ||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||
| 49 | I<bioperl-l@bioperl.org> | ||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||
| 51 | Do not contact the module maintainer directly. Many experienced experts | ||||||||||||||||||||||||||||||||
| 52 | at bioperl-l will be able look at the problem and quickly | ||||||||||||||||||||||||||||||||
| 53 | address it. Please include a thorough description of the problem | ||||||||||||||||||||||||||||||||
| 54 | with code and data examples if at all possible. | ||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||
| 56 | =head2 Reporting Bugs | ||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||
| 58 | Report bugs to the Bioperl bug tracking system to help us keep track | ||||||||||||||||||||||||||||||||
| 59 | the bugs and their resolution. Bug reports can be submitted via the web: | ||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||
| 61 | http://redmine.open-bio.org/projects/bioperl/ | ||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||
| 63 | =head1 AUTHOR - Brian Osborne | ||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||
| 65 | Email briano@bioteam.net | ||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||
| 67 | =head1 APPENDIX | ||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||
| 69 | The rest of the documentation details each of the object | ||||||||||||||||||||||||||||||||
| 70 | methods. Internal methods are usually preceded with a _ | ||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||
| 72 | =cut | ||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||
| 74 | package Bio::Tools::Run::Phylo::FastTree; | ||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||
| 76 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 77 | 1 | ▶ | use Bio::Seq; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 78 | 1 | ▶ | use Bio::SeqIO; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 79 | 1 | ▶ | use Bio::TreeIO; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 80 | 1 | ▶ | use Bio::AlignIO; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 81 | 1 | ▶ | use Bio::Root::IO; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||
| 83 | 1 | ▶ | use base qw(Bio::Root::Root Bio::Tools::Run::WrapperBase); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||
| 85 | 1 | our @FastTree_PARAMS = | |||||||||||||||||||||||||||||||
| 86 | qw(log cat n intree intree1 constraints sprlength topm close | ||||||||||||||||||||||||||||||||
| 87 | refresh constraintWeight spr mlacc nni mlnni seed matrix gtrrates gtrfreq makematrix ); | ||||||||||||||||||||||||||||||||
| 88 | 1 | our @FastTree_SWITCHES = | |||||||||||||||||||||||||||||||
| 89 | qw(quiet nopr nt fastest slow nosupport gtr wag quote noml | ||||||||||||||||||||||||||||||||
| 90 | nome gamma mllen slownni nocat notoo 2nd no2nd nj bionj top notop | ||||||||||||||||||||||||||||||||
| 91 | nomatrix rawdist ); | ||||||||||||||||||||||||||||||||
| 92 | 1 | our $PROGRAM_NAME = 'FastTree'; | |||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||
| 94 | =head2 new | ||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||
| 96 | Title : new | ||||||||||||||||||||||||||||||||
| 97 | Usage : my $treebuilder = Bio::Tools::Run::Phylo::FastTree->new(); | ||||||||||||||||||||||||||||||||
| 98 | Function: Constructor | ||||||||||||||||||||||||||||||||
| 99 | Returns : Bio::Tools::Run::Phylo::FastTree | ||||||||||||||||||||||||||||||||
| 100 | Args : -outfile_name => $outname | ||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||
| 102 | =cut | ||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||
| 104 | 1 | ▶ | sub new { | ||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 105 | 1 | my ( $class, @args ) = @_; | |||||||||||||||||||||||||||||||
| 106 | 1 | my $self = $class->SUPER::new(@args); | |||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||
| 108 | 1 | $self->_set_from_args( | |||||||||||||||||||||||||||||||
| 109 | \@args, | ||||||||||||||||||||||||||||||||
| 110 | -methods => [ @FastTree_PARAMS, @FastTree_SWITCHES ], | ||||||||||||||||||||||||||||||||
| 111 | -create => 1 | ||||||||||||||||||||||||||||||||
| 112 | ); | ||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||
| 114 | 1 | my ($out) = $self->SUPER::_rearrange( [qw(OUTFILE_NAME)], @args ); | |||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||
| 116 | 1 | ▶ | $self->outfile_name( $out || '' ); | ||||||||||||||||||||||||||||||
|
Condition50%1/2
$out || ''
MC/DC0%0/1
$out || ''
$out
Truth table50%1/2
A
A= $out
| |||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||
| 118 | 1 | $self; | |||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||
| 121 | =head2 program_name | ||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||
| 123 | Title : program_name | ||||||||||||||||||||||||||||||||
| 124 | Usage : $factory->program_name() | ||||||||||||||||||||||||||||||||
| 125 | Function: holds the program name | ||||||||||||||||||||||||||||||||
| 126 | Returns: string | ||||||||||||||||||||||||||||||||
| 127 | Args : None | ||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||
| 129 | =cut | ||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||
| 131 | 6 | ▶ | sub program_name { | ||||||||||||||||||||||||||||||
|
Subroutine
program_name: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 132 | 6 | $PROGRAM_NAME; | |||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||
| 135 | =head2 program_dir | ||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||
| 137 | Title : program_dir | ||||||||||||||||||||||||||||||||
| 138 | Usage : $factory->program_dir(@params) | ||||||||||||||||||||||||||||||||
| 139 | Function: returns the program directory | ||||||||||||||||||||||||||||||||
| 140 | Returns: string | ||||||||||||||||||||||||||||||||
| 141 | Args : | ||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||
| 143 | =cut | ||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||
| 145 | 3 | ▶ | sub program_dir { | ||||||||||||||||||||||||||||||
|
Subroutine
program_dir: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 146 | 3 | undef; | |||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||
| 149 | =head2 error_string | ||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||
| 151 | Title : error_string | ||||||||||||||||||||||||||||||||
| 152 | Usage : $obj->error_string($newval) | ||||||||||||||||||||||||||||||||
| 153 | Function: Where the output from the last analysus run is stored. | ||||||||||||||||||||||||||||||||
| 154 | Returns : value of error_string | ||||||||||||||||||||||||||||||||
| 155 | Args : newvalue (optional) | ||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||
| 157 | =cut | ||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||
| 159 | 0 | ▶ | sub error_string { | ||||||||||||||||||||||||||||||
|
Subroutine
error_string: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 160 | 0 | my ( $self, $value ) = @_; | |||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||
| 162 | 0 | ▶ | $self->{'error_string'} = $value if ( defined $value ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 163 | 0 | $self->{'error_string'}; | |||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||
| 166 | =head2 version | ||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||
| 168 | Title : version | ||||||||||||||||||||||||||||||||
| 169 | Usage : exit if $prog->version() < 1.8 | ||||||||||||||||||||||||||||||||
| 170 | Function: Determine the version number of the program | ||||||||||||||||||||||||||||||||
| 171 | Example : | ||||||||||||||||||||||||||||||||
| 172 | Returns : float or undef | ||||||||||||||||||||||||||||||||
| 173 | Args : none | ||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||
| 175 | =cut | ||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||
| 177 | 0 | ▶ | sub version { | ||||||||||||||||||||||||||||||
|
Subroutine
version: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||
| 178 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||
| 179 | 0 | my $exe; | |||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||
| 181 | 0 | ▶ | return undef unless $exe = $self->executable; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 182 | 0 | my $string = `$exe 2>&1`; | |||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||
| 184 | 0 | $string =~ /FastTree\s+version\s+([\d\.]+)/; | |||||||||||||||||||||||||||||||
| 185 | 0 | ▶ | return $1 || undef; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
$1 || undef
MC/DC0%0/1
$1 || undef
$1
Truth table0%0/2
A
A= $1
| |||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||
| 188 | =head2 run | ||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||
| 190 | Title : run | ||||||||||||||||||||||||||||||||
| 191 | Usage : $factory->run($stockholm_file) OR | ||||||||||||||||||||||||||||||||
| 192 | $factory->run($align_object) | ||||||||||||||||||||||||||||||||
| 193 | Function: Runs FastTree to generate a tree | ||||||||||||||||||||||||||||||||
| 194 | Returns : Bio::Tree::Tree object | ||||||||||||||||||||||||||||||||
| 195 | Args : File name for your input alignment in stockholm format, OR | ||||||||||||||||||||||||||||||||
| 196 | Bio::Align::AlignI compliant object (eg. Bio::SimpleAlign). | ||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||
| 198 | =cut | ||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||
| 200 | 0 | ▶ | sub run { | ||||||||||||||||||||||||||||||
|
Subroutine
run: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 201 | 0 | my ($self, $in) = @_; | |||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||
| 203 | 0 | ▶ | if (ref $in && $in->isa("Bio::Align::AlignI")) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
ref $in and $in->isa("Bio::Align::AlignI")
MC/DC0%0/2
ref $in and $in->isa("Bio::Align::AlignI")
ref $in
$in->isa("Bio::Align::AlignI")
Truth table0%0/3
A and B
A= ref $inB= $in->isa("Bio::Align::AlignI")
| |||||||||||||||||||||||||||||||||
| 204 | 0 | $in = $self->_write_alignfile($in); | |||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||
| 206 | elsif (! -e $in) { | ||||||||||||||||||||||||||||||||
| 207 | 0 | $self->throw("When not supplying a Bio::Align::AlignI object, you must supply a readable filename"); | |||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||
| 210 | 0 | $self->_run($in); | |||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||
| 213 | =head2 _run | ||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||
| 215 | Title : _run | ||||||||||||||||||||||||||||||||
| 216 | Usage : Internal function, not to be called directly | ||||||||||||||||||||||||||||||||
| 217 | Function: Runs the application | ||||||||||||||||||||||||||||||||
| 218 | Returns : Tree object | ||||||||||||||||||||||||||||||||
| 219 | Args : Alignment file name | ||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||
| 221 | =cut | ||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||
| 223 | 0 | ▶ | sub _run { | ||||||||||||||||||||||||||||||
|
Subroutine
_run: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||
| 224 | 0 | my ( $self, $file ) = @_; | |||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||
| 226 | # If -nt is not set check the alphabet of the input | ||||||||||||||||||||||||||||||||
| 227 | 0 | ▶ | $self->_alphabet($file) if ( ! $self->nt ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||
| 229 | 0 | ▶ | my $exe = $self->executable || return; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->executable || (return)
MC/DC0%0/1
$self->executable || (return)
$self->executable
Truth table0%0/2
A
A= $self->executable
| |||||||||||||||||||||||||||||||||
| 230 | 0 | my $param_str = $self->arguments . " " . $self->_setparams($file); | |||||||||||||||||||||||||||||||
| 231 | 0 | my $command = "$exe $param_str"; | |||||||||||||||||||||||||||||||
| 232 | 0 | $self->debug("FastTree command = $command"); | |||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||
| 234 | 0 | my $status = system($command); | |||||||||||||||||||||||||||||||
| 235 | 0 | my $outfile = $self->outfile_name(); | |||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||
| 237 | 0 | ▶ | if ( !-e $outfile || -z $outfile ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not -e $outfile or -z $outfile
MC/DC0%0/2
not -e $outfile or -z $outfile
not -e $outfile
-z $outfile
Truth table0%0/3
not(A) or B
A= not -e $outfileB= -z $outfile
| |||||||||||||||||||||||||||||||||
| 238 | 0 | $self->warn("FastTree call had status of $status: $? [command $command]\n"); | |||||||||||||||||||||||||||||||
| 239 | 0 | return undef; | |||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||
| 242 | 0 | my $treeio = Bio::TreeIO->new( -format => 'newick', -file => $outfile ); | |||||||||||||||||||||||||||||||
| 243 | 0 | my $tree = $treeio->next_tree; | |||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||
| 245 | # if bootstraps were enabled, the bootstraps are the ids; convert to | ||||||||||||||||||||||||||||||||
| 246 | # bootstrap and no id | ||||||||||||||||||||||||||||||||
| 247 | # if ($self->boot) { | ||||||||||||||||||||||||||||||||
| 248 | # my @nodes = $tree->get_nodes; | ||||||||||||||||||||||||||||||||
| 249 | # my %non_internal = map { $_ => 1 } ($tree->get_leaf_nodes, $tree->get_root_node); | ||||||||||||||||||||||||||||||||
| 250 | # foreach my $node (@nodes) { | ||||||||||||||||||||||||||||||||
| 251 | # next if exists $non_internal{$node}; | ||||||||||||||||||||||||||||||||
| 252 | # $node->bootstrap && next; # protect ourselves incase the parser improves | ||||||||||||||||||||||||||||||||
| 253 | # $node->bootstrap($node->id); | ||||||||||||||||||||||||||||||||
| 254 | # $node->id(''); | ||||||||||||||||||||||||||||||||
| 255 | # } | ||||||||||||||||||||||||||||||||
| 256 | # } | ||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||
| 258 | 0 | $tree; | |||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||
| 261 | =head2 _write_alignfile | ||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||
| 263 | Title : _write_alignfile | ||||||||||||||||||||||||||||||||
| 264 | Usage : Internal function, not to be called directly | ||||||||||||||||||||||||||||||||
| 265 | Function: Create an alignment file | ||||||||||||||||||||||||||||||||
| 266 | Returns : filename | ||||||||||||||||||||||||||||||||
| 267 | Args : Bio::Align::AlignI | ||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||
| 269 | =cut | ||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||
| 271 | 0 | ▶ | sub _write_alignfile { | ||||||||||||||||||||||||||||||
|
Subroutine
_write_alignfile: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||
| 272 | 0 | my ( $self, $align ) = @_; | |||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||
| 274 | 0 | my ( $tfh, $tempfile ) = $self->io->tempfile( -dir => $self->tempdir ); | |||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||
| 276 | 0 | my $out = Bio::AlignIO->new( | |||||||||||||||||||||||||||||||
| 277 | -file => ">$tempfile", | ||||||||||||||||||||||||||||||||
| 278 | -format => 'phylip' | ||||||||||||||||||||||||||||||||
| 279 | ); | ||||||||||||||||||||||||||||||||
| 280 | 0 | $out->write_aln($align); | |||||||||||||||||||||||||||||||
| 281 | 0 | $out->close(); | |||||||||||||||||||||||||||||||
| 282 | 0 | undef($out); | |||||||||||||||||||||||||||||||
| 283 | 0 | close($tfh); | |||||||||||||||||||||||||||||||
| 284 | 0 | undef($tfh); | |||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||
| 286 | 0 | ▶ | die "Alignment file $tempfile was not created" if ( ! -e $tempfile ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||
| 288 | 0 | $tempfile; | |||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||
| 291 | =head2 _alphabet | ||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||
| 293 | Title : _alphabet | ||||||||||||||||||||||||||||||||
| 294 | Usage : my $alphabet = $self->_alphabet; | ||||||||||||||||||||||||||||||||
| 295 | Function: Get the alphabet of the input alignment, defaults to 'dna' | ||||||||||||||||||||||||||||||||
| 296 | Returns : 'dna' or 'protein' | ||||||||||||||||||||||||||||||||
| 297 | Args : Alignment file | ||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||
| 299 | =cut | ||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||
| 301 | 0 | ▶ | sub _alphabet { | ||||||||||||||||||||||||||||||
|
Subroutine
_alphabet: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||
| 302 | 0 | my ($self,$file) = @_; | |||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||
| 304 | 0 | ▶ | if ( $file ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 305 | 0 | ▶ | if ( -e $file ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 306 | 0 | my $in = Bio::AlignIO->new(-file => $file); | |||||||||||||||||||||||||||||||
| 307 | 0 | my $aln = $in->next_aln; | |||||||||||||||||||||||||||||||
| 308 | # arbitrary, the first one | ||||||||||||||||||||||||||||||||
| 309 | 0 | my $seq = $aln->get_seq_by_pos(1); | |||||||||||||||||||||||||||||||
| 310 | 0 | my $alphabet = $seq->alphabet; | |||||||||||||||||||||||||||||||
| 311 | 0 | $self->{_alphabet} = $alphabet; | |||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||
| 313 | 0 | ▶ | $self->nt(1) if ( $alphabet eq 'dna' ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 314 | } else { | ||||||||||||||||||||||||||||||||
| 315 | 0 | die "File $file can not be found"; | |||||||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||
| 319 | # default is 'dna' | ||||||||||||||||||||||||||||||||
| 320 | 0 | ▶ | return $self->{'_alphabet'} || 'dna'; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{'_alphabet'} || 'dna'
MC/DC0%0/1
$self->{'_alphabet'} || 'dna'
$self->{'_alphabet'}
Truth table0%0/2
A
A= $self->{'_alphabet'}
| |||||||||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||
| 323 | =head2 _setparams | ||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||
| 325 | Title : _setparams | ||||||||||||||||||||||||||||||||
| 326 | Usage : Internal function, not to be called directly | ||||||||||||||||||||||||||||||||
| 327 | Function: Create parameter inputs for FastTree program | ||||||||||||||||||||||||||||||||
| 328 | Example : | ||||||||||||||||||||||||||||||||
| 329 | Returns : parameter string to be passed to FastTree | ||||||||||||||||||||||||||||||||
| 330 | Args : name of calling object | ||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||
| 332 | =cut | ||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||
| 334 | 0 | ▶ | sub _setparams { | ||||||||||||||||||||||||||||||
|
Subroutine
_setparams: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||||||||||||
| 335 | 0 | my ($self,$infile) = @_; | |||||||||||||||||||||||||||||||
| 336 | 0 | my ( $attr, $value, $param_string ); | |||||||||||||||||||||||||||||||
| 337 | 0 | $param_string = ''; | |||||||||||||||||||||||||||||||
| 338 | 0 | my $laststr; | |||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||
| 340 | 0 | for $attr (@FastTree_PARAMS) { | |||||||||||||||||||||||||||||||
| 341 | 0 | $value = $self->$attr(); | |||||||||||||||||||||||||||||||
| 342 | 0 | ▶ | next unless ( defined $value ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 343 | 0 | my $attr_key = lc $attr; | |||||||||||||||||||||||||||||||
| 344 | 0 | $attr_key = ' -' . $attr_key; | |||||||||||||||||||||||||||||||
| 345 | 0 | $param_string .= $attr_key . ' ' . $value; | |||||||||||||||||||||||||||||||
| 346 | } | ||||||||||||||||||||||||||||||||
| 347 | 0 | for $attr (@FastTree_SWITCHES) { | |||||||||||||||||||||||||||||||
| 348 | 0 | $value = $self->$attr(); | |||||||||||||||||||||||||||||||
| 349 | 0 | ▶ | next unless ($value); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 350 | 0 | my $attr_key = lc $attr; | |||||||||||||||||||||||||||||||
| 351 | 0 | $attr_key = ' -' . $attr_key; | |||||||||||||||||||||||||||||||
| 352 | 0 | $param_string .= $attr_key; | |||||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||
| 355 | # Set default output file if no explicit output file has been given | ||||||||||||||||||||||||||||||||
| 356 | 0 | ▶ | if ( ! $self->outfile_name ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 357 | 0 | my ( $tfh, $outfile ) = $self->io->tempfile( -dir => $self->tempdir() ); | |||||||||||||||||||||||||||||||
| 358 | 0 | close($tfh); | |||||||||||||||||||||||||||||||
| 359 | 0 | undef $tfh; | |||||||||||||||||||||||||||||||
| 360 | 0 | $self->outfile_name($outfile); | |||||||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||||||
| 362 | 0 | $param_string .= " $infile > " . $self->outfile_name; | |||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||
| 364 | 0 | ▶ | my $null = ($^O =~ m/mswin/i) ? 'NUL' : '/dev/null'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 365 | 0 | ▶ | $param_string .= " 2> $null" if ( $self->quiet() || $self->verbose < 0 ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->quiet or $self->verbose < 0
MC/DC0%0/2
$self->quiet or $self->verbose < 0
$self->quiet
$self->verbose < 0
Truth table0%0/3
A or B
A= $self->quietB= $self->verbose < 0
| |||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||
| 367 | 0 | $param_string; | |||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||
| 370 | =head1 Bio::Tools::Run::BaseWrapper methods | ||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||
| 372 | =cut | ||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||
| 374 | =head2 no_param_checks | ||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||
| 376 | Title : no_param_checks | ||||||||||||||||||||||||||||||||
| 377 | Usage : $obj->no_param_checks($newval) | ||||||||||||||||||||||||||||||||
| 378 | Function: Boolean flag as to whether or not we should | ||||||||||||||||||||||||||||||||
| 379 | trust the sanity checks for parameter values | ||||||||||||||||||||||||||||||||
| 380 | Returns : value of no_param_checks | ||||||||||||||||||||||||||||||||
| 381 | Args : newvalue (optional) | ||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||
| 383 | =cut | ||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||
| 385 | =head2 save_tempfiles | ||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||
| 387 | Title : save_tempfiles | ||||||||||||||||||||||||||||||||
| 388 | Usage : $obj->save_tempfiles($newval) | ||||||||||||||||||||||||||||||||
| 389 | Function: | ||||||||||||||||||||||||||||||||
| 390 | Returns : value of save_tempfiles | ||||||||||||||||||||||||||||||||
| 391 | Args : newvalue (optional) | ||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||
| 393 | =cut | ||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||
| 395 | =head2 outfile_name | ||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||
| 397 | Title : outfile_name | ||||||||||||||||||||||||||||||||
| 398 | Usage : my $outfile = $FastTree->outfile_name(); | ||||||||||||||||||||||||||||||||
| 399 | Function: Get/Set the name of the output file for this run | ||||||||||||||||||||||||||||||||
| 400 | (if you wanted to do something special) | ||||||||||||||||||||||||||||||||
| 401 | Returns : string | ||||||||||||||||||||||||||||||||
| 402 | Args : [optional] string to set value to | ||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||
| 404 | =cut | ||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||
| 406 | =head2 tempdir | ||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||
| 408 | Title : tempdir | ||||||||||||||||||||||||||||||||
| 409 | Usage : my $tmpdir = $self->tempdir(); | ||||||||||||||||||||||||||||||||
| 410 | Function: Retrieve a temporary directory name (which is created) | ||||||||||||||||||||||||||||||||
| 411 | Returns : string which is the name of the temporary directory | ||||||||||||||||||||||||||||||||
| 412 | Args : none | ||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||
| 414 | =cut | ||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||
| 416 | =head2 cleanup | ||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||
| 418 | Title : cleanup | ||||||||||||||||||||||||||||||||
| 419 | Usage : $FastTree->cleanup(); | ||||||||||||||||||||||||||||||||
| 420 | Function: Will cleanup the tempdir directory | ||||||||||||||||||||||||||||||||
| 421 | Returns : none | ||||||||||||||||||||||||||||||||
| 422 | Args : none | ||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||
| 424 | =cut | ||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||
| 426 | =head2 io | ||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||
| 428 | Title : io | ||||||||||||||||||||||||||||||||
| 429 | Usage : $obj->io($newval) | ||||||||||||||||||||||||||||||||
| 430 | Function: Gets a L<Bio::Root::IO> object | ||||||||||||||||||||||||||||||||
| 431 | Returns : L<Bio::Root::IO> | ||||||||||||||||||||||||||||||||
| 432 | Args : none | ||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||
| 434 | =cut | ||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||
| 436 | 1 | 1; # Needed to keep compiler happy | |||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||
| 438 | __END__ | ||||||||||||||||||||||||||||||||