| 1 | # $Id $ | ||||||||||||||||||||||||||||
| 2 | # | ||||||||||||||||||||||||||||
| 3 | # BioPerl module for Bio::Tools::Run::Phylo::Phylip::DrawGram | ||||||||||||||||||||||||||||
| 4 | # | ||||||||||||||||||||||||||||
| 5 | # Please direct questions and support issues to <bioperl-l@bioperl.org> | ||||||||||||||||||||||||||||
| 6 | # | ||||||||||||||||||||||||||||
| 7 | # Cared for by Jason Stajich <jason-AT-bioperl_DOT_org> | ||||||||||||||||||||||||||||
| 8 | # | ||||||||||||||||||||||||||||
| 9 | # Copyright Jason Stajich | ||||||||||||||||||||||||||||
| 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::Phylip::DrawGram - use Phylip DrawTree program to draw phylograms or phenograms | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | use Bio::Tools::Run::Phylo::Phylip::DrawGram; | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | my $drawfact = Bio::Tools::Run::Phylo::Phylip::DrawGram->new(); | ||||||||||||||||||||||||||||
| 24 | my $treeimage = $drawfact->run($tree); | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | This is a module for automating drawing of trees through Joe | ||||||||||||||||||||||||||||
| 29 | Felsenstein's Phylip suite. | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | =head1 FEEDBACK | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | =head2 Mailing Lists | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | User feedback is an integral part of the evolution of this and other | ||||||||||||||||||||||||||||
| 36 | Bioperl modules. Send your comments and suggestions preferably to | ||||||||||||||||||||||||||||
| 37 | the Bioperl mailing list. Your participation is much appreciated. | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | bioperl-l@bioperl.org - General discussion | ||||||||||||||||||||||||||||
| 40 | http://bioperl.org/wiki/Mailing_lists - About the mailing lists | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | =head2 Support | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | Please direct usage questions or support issues to the mailing list: | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | I<bioperl-l@bioperl.org> | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | rather than to the module maintainer directly. Many experienced and | ||||||||||||||||||||||||||||
| 49 | reponsive experts will be able look at the problem and quickly | ||||||||||||||||||||||||||||
| 50 | address it. Please include a thorough description of the problem | ||||||||||||||||||||||||||||
| 51 | with code and data examples if at all possible. | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | =head2 Reporting Bugs | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | Report bugs to the Bioperl bug tracking system to help us keep track | ||||||||||||||||||||||||||||
| 56 | of the bugs and their resolution. Bug reports can be submitted via the | ||||||||||||||||||||||||||||
| 57 | web: | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | http://redmine.open-bio.org/projects/bioperl/ | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | =head1 AUTHOR - Jason Stajich | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | Email jason-at-bioperl.org | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | =head1 APPENDIX | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | The rest of the documentation details each of the object methods. | ||||||||||||||||||||||||||||
| 68 | Internal methods are usually preceded with a _ | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | =cut | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | # Let the code begin... | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | package Bio::Tools::Run::Phylo::Phylip::DrawGram; | ||||||||||||||||||||||||||||
| 77 | 1 | ▶ | use vars qw($AUTOLOAD @ISA $PROGRAM $PROGRAMDIR $PROGRAMNAME | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 78 | $FONTFILE @DRAW_PARAMS @OTHER_SWITCHES | ||||||||||||||||||||||||||||
| 79 | 1 | %OK_FIELD %DEFAULT); | |||||||||||||||||||||||||||
| 80 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 81 | 1 | ▶ | use Bio::Tools::Run::Phylo::Phylip::Base; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 82 | 1 | ▶ | use Bio::Tools::Run::Phylo::Phylip::PhylipConf qw(%Menu); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 83 | 1 | ▶ | use Cwd; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 84 | # inherit from Phylip::Base which has some methods for dealing with | ||||||||||||||||||||||||||||
| 85 | # Phylip specifics | ||||||||||||||||||||||||||||
| 86 | 1 | @ISA = qw(Bio::Tools::Run::Phylo::Phylip::Base); | |||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | # You will need to enable the neighbor program. This | ||||||||||||||||||||||||||||
| 89 | # can be done in (at least) 3 ways: | ||||||||||||||||||||||||||||
| 90 | # | ||||||||||||||||||||||||||||
| 91 | # 1. define an environmental variable PHYLIPDIR: | ||||||||||||||||||||||||||||
| 92 | # export PHYLIPDIR=/home/shawnh/PHYLIP/bin | ||||||||||||||||||||||||||||
| 93 | # | ||||||||||||||||||||||||||||
| 94 | # 2. include a definition of an environmental variable PHYLIPDIR in | ||||||||||||||||||||||||||||
| 95 | # every script that will use DrawGram.pm. | ||||||||||||||||||||||||||||
| 96 | # $ENV{PHYLIPDIR} = '/home/shawnh/PHYLIP/bin'; | ||||||||||||||||||||||||||||
| 97 | # | ||||||||||||||||||||||||||||
| 98 | # 3. You can set the path to the program through doing: | ||||||||||||||||||||||||||||
| 99 | # my @params('program'=>'/usr/local/bin/drawgram'); | ||||||||||||||||||||||||||||
| 100 | # my $neighbor_factory = Bio::Tools::Run::Phylo::Phylip::DrawGram->new(@params) | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | 1 | ▶ | BEGIN { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 103 | 1 | %DEFAULT = ('PLOTTER' => 'P', | |||||||||||||||||||||||||||
| 104 | 'SCREEN' => 'N'); | ||||||||||||||||||||||||||||
| 105 | 1 | ▶ | $DEFAULT{'FONTFILE'} = Bio::Root::IO->catfile($ENV{'PHYLIPDIR'},"font1") if $ENV{'PHYLIPDIR'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 106 | 1 | $PROGRAMNAME = 'drawgram'; | |||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | 1 | @DRAW_PARAMS = qw(PLOTTER SCREEN TREESTYLE USEBRANCHLENS | |||||||||||||||||||||||||||
| 109 | LABEL_ANGLE HORIZMARGINS VERTICALMARGINS | ||||||||||||||||||||||||||||
| 110 | SCALE TREEDEPTH STEMLEN TIPSPACE ANCESTRALNODES | ||||||||||||||||||||||||||||
| 111 | FONT); | ||||||||||||||||||||||||||||
| 112 | 1 | @OTHER_SWITCHES = qw(QUIET); | |||||||||||||||||||||||||||
| 113 | 1 | foreach my $attr(@DRAW_PARAMS,@OTHER_SWITCHES) { | |||||||||||||||||||||||||||
| 114 | 14 | $OK_FIELD{$attr}++; | |||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | =head2 program_name | ||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | Title : program_name | ||||||||||||||||||||||||||||
| 121 | Usage : >program_name() | ||||||||||||||||||||||||||||
| 122 | Function: holds the program name | ||||||||||||||||||||||||||||
| 123 | Returns: string | ||||||||||||||||||||||||||||
| 124 | Args : None | ||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | =cut | ||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | 6 | ▶ | sub program_name { | ||||||||||||||||||||||||||
|
Subroutine
program_name: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 129 | 6 | return $PROGRAMNAME; | |||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | =head2 program_dir | ||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | Title : program_dir | ||||||||||||||||||||||||||||
| 135 | Usage : ->program_dir() | ||||||||||||||||||||||||||||
| 136 | Function: returns the program directory, obtained from ENV variable. | ||||||||||||||||||||||||||||
| 137 | Returns: string | ||||||||||||||||||||||||||||
| 138 | Args : | ||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | =cut | ||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | 3 | ▶ | sub program_dir { | ||||||||||||||||||||||||||
|
Subroutine
program_dir: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||
| 143 | 3 | ▶ | return Bio::Root::IO->catfile($ENV{PHYLIPDIR}) if $ENV{PHYLIPDIR}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | =head2 new | ||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||
| 148 | Title : new | ||||||||||||||||||||||||||||
| 149 | Usage : my $obj = Bio::Tools::Run::Phylo::Phylip::DrawGram->new(); | ||||||||||||||||||||||||||||
| 150 | Function: Builds a new Bio::Tools::Run::Phylo::Phylip::DrawGram object | ||||||||||||||||||||||||||||
| 151 | Returns : an instance of Bio::Tools::Run::Phylo::Phylip::DrawGram | ||||||||||||||||||||||||||||
| 152 | Args : The available DrawGram parameters | ||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||
| 155 | =cut | ||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | 1 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=7 SCAR=20.2
Pod
documented
| |||||||||||||||||||||||||||||
| 158 | 1 | my($class,@args) = @_; | |||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||
| 160 | 1 | my $self = $class->SUPER::new(@args); | |||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | 1 | my ($attr, $value); | |||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | 1 | ▶ | while (@args) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 165 | 2 | $attr = shift @args; | |||||||||||||||||||||||||||
| 166 | 2 | $value = shift @args; | |||||||||||||||||||||||||||
| 167 | 2 | ▶ | next if( $attr =~ /^-/ ); # don't want named parameters | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 168 | 1 | ▶ | if ($attr =~/PROGRAM/i) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 169 | 0 | $self->executable($value); | |||||||||||||||||||||||||||
| 170 | 0 | next; | |||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||
| 172 | 1 | $self->$attr($value); | |||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||
| 174 | 1 | ▶ | $self->plotter($DEFAULT{'PLOTTER'}) unless $self->plotter; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 175 | 1 | ▶ | $self->screen($DEFAULT{'SCREEN'}) unless $self->screen; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 176 | 1 | ▶ | $self->fontfile($DEFAULT{'FONTFILE'}) unless $self->fontfile; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 177 | 1 | return $self; | |||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||
| 181 | 4 | ▶ | sub AUTOLOAD { | ||||||||||||||||||||||||||
|
Subroutine
AUTOLOAD: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 182 | 4 | my $self = shift; | |||||||||||||||||||||||||||
| 183 | 4 | my $attr = $AUTOLOAD; | |||||||||||||||||||||||||||
| 184 | 4 | $attr =~ s/.*:://; | |||||||||||||||||||||||||||
| 185 | 4 | $attr = uc $attr; | |||||||||||||||||||||||||||
| 186 | 4 | ▶ | $self->throw("Unallowed parameter: $attr !") unless $OK_FIELD{$attr}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 187 | 4 | ▶ | $self->{$attr} = shift if @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 188 | 4 | return $self->{$attr}; | |||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||
| 191 | =head2 run | ||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||
| 193 | Title : run | ||||||||||||||||||||||||||||
| 194 | Usage : my $file = $app->run($treefile); | ||||||||||||||||||||||||||||
| 195 | Function: Draw a tree | ||||||||||||||||||||||||||||
| 196 | Returns : File containing the rendered tree | ||||||||||||||||||||||||||||
| 197 | Args : either a Bio::Tree::TreeI | ||||||||||||||||||||||||||||
| 198 | OR | ||||||||||||||||||||||||||||
| 199 | filename of a tree in newick format | ||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||
| 201 | =cut | ||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||
| 203 | 0 | ▶ | sub run{ | ||||||||||||||||||||||||||
|
Subroutine
run: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 204 | 0 | my ($self,$input) = @_; | |||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||
| 206 | # Create input file pointer | ||||||||||||||||||||||||||||
| 207 | 0 | my ($infilename) = $self->_setinput($input); | |||||||||||||||||||||||||||
| 208 | 0 | ▶ | if (!$infilename) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 209 | 0 | $self->throw("Problems setting up for drawgram. Probably bad input data in $input !"); | |||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||
| 212 | # Create parameter string to pass to neighbor program | ||||||||||||||||||||||||||||
| 213 | 0 | my $param_string = $self->_setparams(); | |||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||
| 215 | # run drawgram | ||||||||||||||||||||||||||||
| 216 | 0 | my $plotfile = $self->_run($infilename,$param_string); | |||||||||||||||||||||||||||
| 217 | 0 | return $plotfile; | |||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||
| 220 | =head2 draw_tree | ||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||
| 222 | Title : draw_tree | ||||||||||||||||||||||||||||
| 223 | Usage : my $file = $app->draw_tree($treefile); | ||||||||||||||||||||||||||||
| 224 | Function: This method is deprecated. Please use run instead. | ||||||||||||||||||||||||||||
| 225 | Returns : File containing the rendered tree | ||||||||||||||||||||||||||||
| 226 | Args : either a Bio::Tree::TreeI | ||||||||||||||||||||||||||||
| 227 | OR | ||||||||||||||||||||||||||||
| 228 | filename of a tree in newick format | ||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||
| 230 | =cut | ||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||
| 232 | 0 | ▶ | sub draw_tree{ | ||||||||||||||||||||||||||
|
Subroutine
draw_tree: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 233 | 0 | return shift->run(@_); | |||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||
| 236 | =head2 _run | ||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||
| 238 | Title : _run | ||||||||||||||||||||||||||||
| 239 | Usage : Internal function, not to be called directly | ||||||||||||||||||||||||||||
| 240 | Function: makes actual system call to drawgram program | ||||||||||||||||||||||||||||
| 241 | Example : | ||||||||||||||||||||||||||||
| 242 | Returns : Bio::Tree object | ||||||||||||||||||||||||||||
| 243 | Args : Name of a file the tree to draw in newick format | ||||||||||||||||||||||||||||
| 244 | and a parameter string to be passed to drawgram | ||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||
| 247 | =cut | ||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||
| 249 | 0 | ▶ | sub _run { | ||||||||||||||||||||||||||
|
Subroutine
_run: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||||||||
| 250 | 0 | my ($self,$infile,$param_string) = @_; | |||||||||||||||||||||||||||
| 251 | 0 | my $instring; | |||||||||||||||||||||||||||
| 252 | 0 | my $curpath = cwd; | |||||||||||||||||||||||||||
| 253 | 0 | ▶ | unless( File::Spec->file_name_is_absolute($infile) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 254 | 0 | $infile = $self->io->catfile($curpath,$infile); | |||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||
| 256 | 0 | $instring = $infile . "\n"; | |||||||||||||||||||||||||||
| 257 | 0 | ▶ | if( ! defined $self->fontfile ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 258 | 0 | $self->throw("You must have defined a fontfile"); | |||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||
| 261 | 0 | ▶ | if( -e $self->io->catfile($curpath,'fontfile') ) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 262 | 0 | $instring .= $self->io->catfile($curpath,'fontfile')."\n"; | |||||||||||||||||||||||||||
| 263 | } elsif( File::Spec->file_name_is_absolute($self->fontfile) ) { | ||||||||||||||||||||||||||||
| 264 | 0 | $instring .= $self->io->catfile($self->fontfile)."\n"; | |||||||||||||||||||||||||||
| 265 | } else { | ||||||||||||||||||||||||||||
| 266 | 0 | $instring .= $self->io->catfile($curpath,$self->fontfile)."\n"; | |||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||
| 269 | 0 | chdir($self->tempdir); | |||||||||||||||||||||||||||
| 270 | 0 | $instring .= $param_string; | |||||||||||||||||||||||||||
| 271 | 0 | $self->debug( "Program ".$self->executable." $param_string\n"); | |||||||||||||||||||||||||||
| 272 | # open a pipe to run drawgram to bypass interactive menus | ||||||||||||||||||||||||||||
| 273 | 0 | ▶ | 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
| |||||||||||||||||||||||||||||
| 274 | 0 | ▶ | my $null = ($^O =~ m/mswin/i) ? 'NUL' : '/dev/null'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 275 | 0 | open(DRAW,"|".$self->executable.">$null"); | |||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||
| 277 | else { | ||||||||||||||||||||||||||||
| 278 | 0 | open(DRAW,"|".$self->executable); | |||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||
| 280 | 0 | print DRAW $instring; | |||||||||||||||||||||||||||
| 281 | 0 | close(DRAW); | |||||||||||||||||||||||||||
| 282 | 0 | chdir($curpath); | |||||||||||||||||||||||||||
| 283 | #get the results | ||||||||||||||||||||||||||||
| 284 | 0 | my $plotfile = $self->io->catfile($self->tempdir,$self->plotfile); | |||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||
| 286 | 0 | ▶ | $self->throw("drawgram did not create plotfile correctly ($plotfile)") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 287 | unless (-e $plotfile); | ||||||||||||||||||||||||||||
| 288 | 0 | return $plotfile; | |||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||
| 291 | =head2 _setinput() | ||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||
| 293 | Title : _setinput | ||||||||||||||||||||||||||||
| 294 | Usage : Internal function, not to be called directly | ||||||||||||||||||||||||||||
| 295 | Function: Create input file for drawing program | ||||||||||||||||||||||||||||
| 296 | Example : | ||||||||||||||||||||||||||||
| 297 | Returns : filename containing tree in newick format | ||||||||||||||||||||||||||||
| 298 | Args : Bio::Tree::TreeI object | ||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||
| 301 | =cut | ||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||
| 303 | 0 | ▶ | sub _setinput { | ||||||||||||||||||||||||||
|
Subroutine
_setinput: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||
| 304 | 0 | my ($self, $input) = @_; | |||||||||||||||||||||||||||
| 305 | 0 | my $treefile; | |||||||||||||||||||||||||||
| 306 | 0 | ▶ | unless (ref $input) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 307 | # check that file exists or throw | ||||||||||||||||||||||||||||
| 308 | 0 | $treefile = $input; | |||||||||||||||||||||||||||
| 309 | 0 | ▶ | unless (-e $input) {return 0;} | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||
| 311 | 0 | } elsif ($input->isa("Bio::Tree::TreeI")) { | |||||||||||||||||||||||||||
| 312 | # Open temporary file for both reading & writing of BioSeq array | ||||||||||||||||||||||||||||
| 313 | 0 | my $tfh; | |||||||||||||||||||||||||||
| 314 | 0 | ($tfh,$treefile) = $self->io->tempfile(-dir=>$self->tempdir); | |||||||||||||||||||||||||||
| 315 | 0 | my $treeIO = Bio::TreeIO->new(-fh => $tfh, | |||||||||||||||||||||||||||
| 316 | -format=>'newick'); | ||||||||||||||||||||||||||||
| 317 | 0 | $treeIO->write_tree($input); | |||||||||||||||||||||||||||
| 318 | 0 | $treeIO->close(); | |||||||||||||||||||||||||||
| 319 | 0 | close($tfh); | |||||||||||||||||||||||||||
| 320 | 0 | $tfh = undef; | |||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||
| 322 | 0 | return $treefile; | |||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||
| 325 | =head2 _setparams() | ||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||
| 327 | Title : _setparams | ||||||||||||||||||||||||||||
| 328 | Usage : Internal function, not to be called directly | ||||||||||||||||||||||||||||
| 329 | Function: Create parameter inputs for drawgram program | ||||||||||||||||||||||||||||
| 330 | Example : | ||||||||||||||||||||||||||||
| 331 | Returns : parameter string to be passed to drawgram | ||||||||||||||||||||||||||||
| 332 | Args : name of calling object | ||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||
| 334 | =cut | ||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||
| 336 | 0 | ▶ | sub _setparams { | ||||||||||||||||||||||||||
|
Subroutine
_setparams: not called CC=10 SCAR=47.0
| |||||||||||||||||||||||||||||
| 337 | 0 | my ($attr, $value, $self); | |||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||
| 339 | #do nothing for now | ||||||||||||||||||||||||||||
| 340 | 0 | $self = shift; | |||||||||||||||||||||||||||
| 341 | 0 | my $param_string = ""; | |||||||||||||||||||||||||||
| 342 | 0 | my $cat = 0; | |||||||||||||||||||||||||||
| 343 | 0 | my ($hmargin,$vmargin); | |||||||||||||||||||||||||||
| 344 | 0 | my %menu = %{$Menu{$self->version}->{'DRAWGRAM'}}; | |||||||||||||||||||||||||||
| 345 | 0 | foreach my $attr ( @DRAW_PARAMS) { | |||||||||||||||||||||||||||
| 346 | 0 | $value = $self->$attr(); | |||||||||||||||||||||||||||
| 347 | 0 | ▶ | next unless defined $value; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 348 | 0 | my @vals; | |||||||||||||||||||||||||||
| 349 | 0 | ▶ | if( ref($value) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 350 | 0 | ($value,@vals) = @$value; | |||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||
| 352 | 0 | $attr = uc($attr); | |||||||||||||||||||||||||||
| 353 | 0 | ▶ | if( ! exists $menu{$attr} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 354 | 0 | $self->warn("unknown parameter $attr, known params are ". | |||||||||||||||||||||||||||
| 355 | join(",",keys %menu). "\n"); | ||||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||
| 357 | 0 | ▶ | if( ref ($menu{$attr}) !~ /HASH/i ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 358 | 0 | ▶ | unless( @vals ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 359 | 0 | $param_string .= $menu{$attr}; | |||||||||||||||||||||||||||
| 360 | } else { | ||||||||||||||||||||||||||||
| 361 | 0 | $param_string .= sprintf($menu{$attr},$value,@vals); | |||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||
| 363 | 0 | next; | |||||||||||||||||||||||||||
| 364 | } | ||||||||||||||||||||||||||||
| 365 | 0 | my $seen = 0; | |||||||||||||||||||||||||||
| 366 | 0 | for my $stype ( keys %{$menu{$attr}} ) { | |||||||||||||||||||||||||||
| 367 | 0 | ▶ | if( $value =~ /$stype/i ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 368 | 0 | $param_string .= sprintf($menu{$attr}->{$stype},@vals); | |||||||||||||||||||||||||||
| 369 | 0 | $seen = 1; | |||||||||||||||||||||||||||
| 370 | 0 | last; | |||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||
| 373 | 0 | ▶ | unless( $seen ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 374 | 0 | $self->warn("Unknown requested attribute $attr, $value is not known\n"); | |||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||
| 376 | } | ||||||||||||||||||||||||||||
| 377 | 0 | $param_string .="Y\n"; | |||||||||||||||||||||||||||
| 378 | 0 | return $param_string; | |||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||
| 382 | =head1 Bio::Tools::Run::Wrapper methods | ||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||
| 384 | =cut | ||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||
| 386 | =head2 no_param_checks | ||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||
| 388 | Title : no_param_checks | ||||||||||||||||||||||||||||
| 389 | Usage : $obj->no_param_checks($newval) | ||||||||||||||||||||||||||||
| 390 | Function: Boolean flag as to whether or not we should | ||||||||||||||||||||||||||||
| 391 | trust the sanity checks for parameter values | ||||||||||||||||||||||||||||
| 392 | Returns : value of no_param_checks | ||||||||||||||||||||||||||||
| 393 | Args : newvalue (optional) | ||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||
| 396 | =cut | ||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||
| 398 | =head2 save_tempfiles | ||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||
| 400 | Title : save_tempfiles | ||||||||||||||||||||||||||||
| 401 | Usage : $obj->save_tempfiles($newval) | ||||||||||||||||||||||||||||
| 402 | Function: | ||||||||||||||||||||||||||||
| 403 | Returns : value of save_tempfiles | ||||||||||||||||||||||||||||
| 404 | Args : newvalue (optional) | ||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||
| 407 | =cut | ||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||
| 409 | =head2 outfile_name | ||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||
| 411 | Title : outfile_name | ||||||||||||||||||||||||||||
| 412 | Usage : my $outfile = $dragram->outfile_name(); | ||||||||||||||||||||||||||||
| 413 | Function: Get/Set the name of the output file for this run | ||||||||||||||||||||||||||||
| 414 | (if you wanted to do something special) | ||||||||||||||||||||||||||||
| 415 | Returns : string | ||||||||||||||||||||||||||||
| 416 | Args : [optional] string to set value to | ||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||
| 419 | =cut | ||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||
| 422 | =head2 tempdir | ||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||
| 424 | Title : tempdir | ||||||||||||||||||||||||||||
| 425 | Usage : my $tmpdir = $self->tempdir(); | ||||||||||||||||||||||||||||
| 426 | Function: Retrieve a temporary directory name (which is created) | ||||||||||||||||||||||||||||
| 427 | Returns : string which is the name of the temporary directory | ||||||||||||||||||||||||||||
| 428 | Args : none | ||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||
| 431 | =cut | ||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||
| 433 | =head2 cleanup | ||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||
| 435 | Title : cleanup | ||||||||||||||||||||||||||||
| 436 | Usage : $codeml->cleanup(); | ||||||||||||||||||||||||||||
| 437 | Function: Will cleanup the tempdir directory after a DrawGram run | ||||||||||||||||||||||||||||
| 438 | Returns : none | ||||||||||||||||||||||||||||
| 439 | Args : none | ||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||
| 442 | =cut | ||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||
| 444 | =head2 io | ||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||
| 446 | Title : io | ||||||||||||||||||||||||||||
| 447 | Usage : $obj->io($newval) | ||||||||||||||||||||||||||||
| 448 | Function: Gets a L<Bio::Root::IO> object | ||||||||||||||||||||||||||||
| 449 | Returns : L<Bio::Root::IO> | ||||||||||||||||||||||||||||
| 450 | Args : none | ||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||
| 453 | =cut | ||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||
| 455 | 1 | 1; # Needed to keep compiler happy | |||||||||||||||||||||||||||