| 1 | # | ||||||||||||
| 2 | # | ||||||||||||
| 3 | # Copyright Balamurugan Kumarasamy | ||||||||||||
| 4 | # | ||||||||||||
| 5 | # You may distribute this module under the same terms as perl itself | ||||||||||||
| 6 | # POD documentation - main docs before the code | ||||||||||||
| 7 | # | ||||||||||||
| 8 | |||||||||||||
| 9 | =head1 NAME | ||||||||||||
| 10 | |||||||||||||
| 11 | Bio::Tools::Run::Tmhmm - Object for identifying transmembrane helixes | ||||||||||||
| 12 | in a given protein seequence. | ||||||||||||
| 13 | |||||||||||||
| 14 | =head1 SYNOPSIS | ||||||||||||
| 15 | |||||||||||||
| 16 | # Build a Tmhmm factory | ||||||||||||
| 17 | |||||||||||||
| 18 | # $paramfile is the full path to the seg binary file | ||||||||||||
| 19 | |||||||||||||
| 20 | my @params = ('PROGRAM',$paramfile); | ||||||||||||
| 21 | my $factory = Bio::Tools::Run::Tmhmm->new($param); | ||||||||||||
| 22 | |||||||||||||
| 23 | # Pass the factory a Bio::Seq object | ||||||||||||
| 24 | # @feats is an array of Bio::SeqFeature::Generic objects | ||||||||||||
| 25 | |||||||||||||
| 26 | my @feats = $factory->run($seq); | ||||||||||||
| 27 | |||||||||||||
| 28 | =head1 DESCRIPTION | ||||||||||||
| 29 | |||||||||||||
| 30 | Tmhmm is a program for identifying transmembrane helices in proteins. | ||||||||||||
| 31 | |||||||||||||
| 32 | You must have the environmental variable TMHMMDIR set to the base | ||||||||||||
| 33 | directory where I<tmhmm> and it's associated data/option files reside | ||||||||||||
| 34 | (NOT the bin directory where the actual executable resides) | ||||||||||||
| 35 | |||||||||||||
| 36 | =head1 FEEDBACK | ||||||||||||
| 37 | |||||||||||||
| 38 | =head2 Mailing Lists | ||||||||||||
| 39 | |||||||||||||
| 40 | User feedback is an integral part of the evolution of this and other | ||||||||||||
| 41 | Bioperl modules. Send your comments and suggestions preferably to one | ||||||||||||
| 42 | of the Bioperl mailing lists. Your participation is much appreciated. | ||||||||||||
| 43 | |||||||||||||
| 44 | bioperl-l@bioperl.org - General discussion | ||||||||||||
| 45 | http://bioperl.org/wiki/Mailing_lists - About the mailing lists | ||||||||||||
| 46 | |||||||||||||
| 47 | head2 Reporting Bugs | ||||||||||||
| 48 | |||||||||||||
| 49 | Report bugs to the Bioperl bug tracking system to help us keep track | ||||||||||||
| 50 | the bugs and their resolution. Bug reports can be submitted via the | ||||||||||||
| 51 | web: | ||||||||||||
| 52 | |||||||||||||
| 53 | http://redmine.open-bio.org/projects/bioperl/ | ||||||||||||
| 54 | |||||||||||||
| 55 | =head1 AUTHOR - Bala | ||||||||||||
| 56 | |||||||||||||
| 57 | Email savikalpa@fugu-sg.org | ||||||||||||
| 58 | |||||||||||||
| 59 | |||||||||||||
| 60 | =head1 APPENDIX | ||||||||||||
| 61 | |||||||||||||
| 62 | The rest of the documentation details each of the object | ||||||||||||
| 63 | methods. Internal methods are usually preceded with a _ | ||||||||||||
| 64 | |||||||||||||
| 65 | =cut | ||||||||||||
| 66 | |||||||||||||
| 67 | package Bio::Tools::Run::Tmhmm; | ||||||||||||
| 68 | |||||||||||||
| 69 | 1 | ▶ | use vars qw($AUTOLOAD @ISA $PROGRAMNAME @TMHMM_PARAMS %OK_FIELD); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 70 | 1 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 71 | 1 | ▶ | use Cwd; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 72 | 1 | ▶ | use Bio::SeqIO; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 73 | 1 | ▶ | use Bio::Root::Root; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 74 | 1 | ▶ | use Bio::Root::IO; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 75 | 1 | ▶ | use Bio::Tools::Tmhmm; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 76 | 1 | ▶ | use Bio::Tools::Run::WrapperBase; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 77 | |||||||||||||
| 78 | 1 | @ISA = qw(Bio::Tools::Run::WrapperBase); | |||||||||||
| 79 | |||||||||||||
| 80 | 1 | ▶ | BEGIN { | ||||||||||
|
Subroutine
BEGIN: called CC=3 SCAR=11.1
| |||||||||||||
| 81 | 1 | ▶ | $PROGRAMNAME = 'tmhmm' . ($^O =~ /mswin/i ?'.exe':''); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 82 | 1 | @TMHMM_PARAMS=qw(PROGRAM VERBOSE NOPLOT); | |||||||||||
| 83 | 1 | foreach my $attr ( @TMHMM_PARAMS) | |||||||||||
| 84 | 3 | { $OK_FIELD{$attr}++; } | |||||||||||
| 85 | } | ||||||||||||
| 86 | |||||||||||||
| 87 | =head2 program_name | ||||||||||||
| 88 | |||||||||||||
| 89 | Title : program_name | ||||||||||||
| 90 | Usage : $factory>program_name() | ||||||||||||
| 91 | Function: holds the program name | ||||||||||||
| 92 | Returns: string | ||||||||||||
| 93 | Args : None | ||||||||||||
| 94 | |||||||||||||
| 95 | =cut | ||||||||||||
| 96 | |||||||||||||
| 97 | 4 | ▶ | sub program_name { | ||||||||||
|
Subroutine
program_name: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 98 | 4 | return $PROGRAMNAME; | |||||||||||
| 99 | } | ||||||||||||
| 100 | |||||||||||||
| 101 | =head2 program_dir | ||||||||||||
| 102 | |||||||||||||
| 103 | Title : program_dir | ||||||||||||
| 104 | Usage : $factory->program_dir(@params) | ||||||||||||
| 105 | Function: returns the program directory, obtained from ENV variable, in this | ||||||||||||
| 106 | case it is the tmhmm installation directory, not the location of | ||||||||||||
| 107 | the executable. | ||||||||||||
| 108 | Returns: string | ||||||||||||
| 109 | Args : | ||||||||||||
| 110 | |||||||||||||
| 111 | =cut | ||||||||||||
| 112 | |||||||||||||
| 113 | 3 | ▶ | sub program_dir { | ||||||||||
|
Subroutine
program_dir: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||
| 114 | 3 | ▶ | return $ENV{TMHMMDIR} || ''; | ||||||||||
|
Condition50%1/2
$ENV{'TMHMMDIR'} || ''
MC/DC0%0/1
$ENV{'TMHMMDIR'} || ''
$ENV{'TMHMMDIR'}
Truth table50%1/2
A
A= $ENV{'TMHMMDIR'}
| |||||||||||||
| 115 | } | ||||||||||||
| 116 | |||||||||||||
| 117 | =head2 program_path | ||||||||||||
| 118 | |||||||||||||
| 119 | Title : program_path | ||||||||||||
| 120 | Usage : my $path = $factory->program_path(); | ||||||||||||
| 121 | Function: Builds path for executable | ||||||||||||
| 122 | Returns : string representing the full path to the exe | ||||||||||||
| 123 | Args : none | ||||||||||||
| 124 | |||||||||||||
| 125 | =cut | ||||||||||||
| 126 | |||||||||||||
| 127 | 2 | ▶ | sub program_path { | ||||||||||
|
Subroutine
program_path: called CC=3 SCAR=12.6
Pod
documented
| |||||||||||||
| 128 | 2 | my ($self) = @_; | |||||||||||
| 129 | 2 | my @path; | |||||||||||
| 130 | 2 | ▶ | if ($self->program_dir) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 131 | 0 | my $program_dir = $self->program_dir; | |||||||||||
| 132 | 0 | $program_dir =~ s/\/bin//; | |||||||||||
| 133 | 0 | push @path, $program_dir; | |||||||||||
| 134 | } | ||||||||||||
| 135 | 2 | push @path, 'bin'; | |||||||||||
| 136 | 2 | ▶ | push @path, $self->program_name.($^O =~ /mswin/i ?'.exe':''); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 137 | |||||||||||||
| 138 | 2 | return File::Spec->catfile(@path); | |||||||||||
| 139 | } | ||||||||||||
| 140 | |||||||||||||
| 141 | 0 | ▶ | sub AUTOLOAD { | ||||||||||
|
Subroutine
AUTOLOAD: not called CC=3 SCAR=24.8
| |||||||||||||
| 142 | 0 | my $self = shift; | |||||||||||
| 143 | 0 | my $attr = $AUTOLOAD; | |||||||||||
| 144 | 0 | $attr =~ s/.*:://; | |||||||||||
| 145 | 0 | $attr = uc $attr; | |||||||||||
| 146 | 0 | ▶ | $self->throw("Unallowed parameter: $attr !") unless $OK_FIELD{$attr}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 147 | 0 | ▶ | $self->{$attr} = shift if @_; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 148 | 0 | return $self->{$attr}; | |||||||||||
| 149 | } | ||||||||||||
| 150 | |||||||||||||
| 151 | =head2 new | ||||||||||||
| 152 | |||||||||||||
| 153 | Title : new | ||||||||||||
| 154 | Usage : $rm->new(@params) | ||||||||||||
| 155 | Function: creates a new Tmhmm factory | ||||||||||||
| 156 | Returns: Bio::Tools::Run::Tmhmm | ||||||||||||
| 157 | Args : | ||||||||||||
| 158 | |||||||||||||
| 159 | =cut | ||||||||||||
| 160 | |||||||||||||
| 161 | 1 | ▶ | sub new { | ||||||||||
|
Subroutine
new: called CC=3 SCAR=14.8
Pod
documented
| |||||||||||||
| 162 | 1 | my ($class,@args) = @_; | |||||||||||
| 163 | 1 | my $self = $class->SUPER::new(@args); | |||||||||||
| 164 | |||||||||||||
| 165 | 1 | my ($attr, $value); | |||||||||||
| 166 | 1 | ▶ | while (@args) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 167 | 0 | $attr = shift @args; | |||||||||||
| 168 | 0 | $value = shift @args; | |||||||||||
| 169 | 0 | ▶ | next if( $attr =~ /^-/ ); # don't want named parameters | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 170 | 0 | $self->$attr($value); | |||||||||||
| 171 | } | ||||||||||||
| 172 | 1 | return $self; | |||||||||||
| 173 | } | ||||||||||||
| 174 | |||||||||||||
| 175 | =head2 predict_protein_features | ||||||||||||
| 176 | |||||||||||||
| 177 | Title : predict_protein_features() | ||||||||||||
| 178 | Usage : DEPRECATED Use $obj->run($seq) instead | ||||||||||||
| 179 | Function: Runs Tmhmm and creates an array of featrues | ||||||||||||
| 180 | Returns : An array of Bio::SeqFeature::Generic objects | ||||||||||||
| 181 | Args : A Bio::PrimarySeqI | ||||||||||||
| 182 | |||||||||||||
| 183 | =cut | ||||||||||||
| 184 | |||||||||||||
| 185 | 0 | ▶ | sub predict_protein_features{ | ||||||||||
|
Subroutine
predict_protein_features: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 186 | 0 | return shift->run(@_); | |||||||||||
| 187 | } | ||||||||||||
| 188 | |||||||||||||
| 189 | =head2 executable | ||||||||||||
| 190 | |||||||||||||
| 191 | Title : executable | ||||||||||||
| 192 | Usage : my $exe = $tmhmm->executable('tmhmm'); | ||||||||||||
| 193 | Function: Finds the full path to the 'tmhmm' executable | ||||||||||||
| 194 | Returns : string representing the full path to the exe | ||||||||||||
| 195 | Args : [optional] name of executable to set path to | ||||||||||||
| 196 | [optional] boolean flag whether or not warn when exe is not found | ||||||||||||
| 197 | |||||||||||||
| 198 | =cut | ||||||||||||
| 199 | |||||||||||||
| 200 | 1 | ▶ | sub executable { | ||||||||||
|
Subroutine
executable: called CC=3 SCAR=20.3
Pod
documented
| |||||||||||||
| 201 | 1 | my $self = shift; | |||||||||||
| 202 | 1 | ▶ | my $exe = $self->SUPER::executable(@_) || return; | ||||||||||
|
Condition0%0/2
$self->SUPER::executable(@_) || (return)
MC/DC0%0/1
$self->SUPER::executable(@_) || (return)
$self->SUPER::executable(@_)
Truth table0%0/2
A
A= $self->SUPER::executable(@_)
| |||||||||||||
| 203 | |||||||||||||
| 204 | # even if its executable, we still need the environment variable to have | ||||||||||||
| 205 | # been set | ||||||||||||
| 206 | 0 | ▶ | if (! $ENV{TMHMMDIR}) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 207 | 0 | $self->warn("Environment variable TMHMMDIR must be set, even if the tmhmm executable is in your path"); | |||||||||||
| 208 | 0 | return undef; | |||||||||||
| 209 | } | ||||||||||||
| 210 | |||||||||||||
| 211 | 0 | return $exe; | |||||||||||
| 212 | } | ||||||||||||
| 213 | |||||||||||||
| 214 | =head2 run | ||||||||||||
| 215 | |||||||||||||
| 216 | Title : run() | ||||||||||||
| 217 | Usage : $obj->run($seq) | ||||||||||||
| 218 | Function: Runs Tmhmm and creates an array of featrues | ||||||||||||
| 219 | Returns : An array of Bio::SeqFeature::Generic objects | ||||||||||||
| 220 | Args : A Bio::PrimarySeqI | ||||||||||||
| 221 | |||||||||||||
| 222 | =cut | ||||||||||||
| 223 | |||||||||||||
| 224 | 0 | ▶ | sub run { | ||||||||||
|
Subroutine
run: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||
| 225 | 0 | my ($self,$seq) = @_; | |||||||||||
| 226 | 0 | my @feats; | |||||||||||
| 227 | |||||||||||||
| 228 | 0 | ▶ | if (ref($seq) ) { # it is an object | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 229 | 0 | ▶ | if (ref($seq) =~ /GLOB/) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 230 | 0 | $self->throw("cannot use filehandle"); | |||||||||||
| 231 | } | ||||||||||||
| 232 | |||||||||||||
| 233 | 0 | my $infile1 = $self->_writeSeqFile($seq); | |||||||||||
| 234 | |||||||||||||
| 235 | 0 | $self->_input($infile1); | |||||||||||
| 236 | |||||||||||||
| 237 | 0 | @feats = $self->_run(); | |||||||||||
| 238 | 0 | unlink $infile1; | |||||||||||
| 239 | |||||||||||||
| 240 | } | ||||||||||||
| 241 | else { | ||||||||||||
| 242 | # The clone object is not a seq object but a file. Perhaps | ||||||||||||
| 243 | # should check here or before if this file is fasta format...if | ||||||||||||
| 244 | # not die Here the file does not need to be created or | ||||||||||||
| 245 | # deleted. Its already written and may be used by other | ||||||||||||
| 246 | # runnables. | ||||||||||||
| 247 | |||||||||||||
| 248 | 0 | $self->_input($seq); | |||||||||||
| 249 | 0 | @feats = $self->_run(); | |||||||||||
| 250 | } | ||||||||||||
| 251 | 0 | return @feats; | |||||||||||
| 252 | } | ||||||||||||
| 253 | |||||||||||||
| 254 | |||||||||||||
| 255 | =head2 _input | ||||||||||||
| 256 | |||||||||||||
| 257 | Title : _input | ||||||||||||
| 258 | Usage : obj->_input($seqFile) | ||||||||||||
| 259 | Function: Internal(not to be used directly) | ||||||||||||
| 260 | Returns : | ||||||||||||
| 261 | Args : | ||||||||||||
| 262 | |||||||||||||
| 263 | =cut | ||||||||||||
| 264 | |||||||||||||
| 265 | 0 | ▶ | sub _input() { | ||||||||||
|
Subroutine
_input: not called CC=2 SCAR=17.9
| |||||||||||||
| 266 | 0 | my ($self,$infile1) = @_; | |||||||||||
| 267 | 0 | ▶ | if (defined $infile1){ | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 268 | |||||||||||||
| 269 | 0 | $self->{'input'}=$infile1; | |||||||||||
| 270 | } | ||||||||||||
| 271 | 0 | return $self->{'input'}; | |||||||||||
| 272 | } | ||||||||||||
| 273 | |||||||||||||
| 274 | =head2 _run | ||||||||||||
| 275 | |||||||||||||
| 276 | Title : _run | ||||||||||||
| 277 | Usage : $obj->_run() | ||||||||||||
| 278 | Function: Internal(not to be used directly) | ||||||||||||
| 279 | Returns : An array of Bio::SeqFeature::Generic objects | ||||||||||||
| 280 | Args : | ||||||||||||
| 281 | |||||||||||||
| 282 | =cut | ||||||||||||
| 283 | |||||||||||||
| 284 | 0 | ▶ | sub _run { | ||||||||||
|
Subroutine
_run: not called CC=7 SCAR=40.3
| |||||||||||||
| 285 | 0 | my ($self)= @_; | |||||||||||
| 286 | |||||||||||||
| 287 | 0 | my ($tfh1,$outfile) = $self->io->tempfile(-dir=>$self->tempdir()); | |||||||||||
| 288 | 0 | ▶ | my $str = $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
| |||||||||||||
| 289 | |||||||||||||
| 290 | 0 | ▶ | if( $self->NOPLOT ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 291 | 0 | $str .= " --noplot"; | |||||||||||
| 292 | } | ||||||||||||
| 293 | 0 | $str .= " -basedir=".$self->program_dir." -workdir=".$self->tempdir()." ".$self->_input." > ".$outfile; | |||||||||||
| 294 | |||||||||||||
| 295 | 0 | my $status = system($str); | |||||||||||
| 296 | 0 | ▶ | $self->throw( "Tmhmm call ($str) crashed: $? \n") unless $status==0; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 297 | |||||||||||||
| 298 | 0 | my $filehandle; | |||||||||||
| 299 | 0 | ▶ | if (ref ($outfile) !~ /GLOB/) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 300 | 0 | ▶ | open (TMHMM, "<".$outfile) or $self->throw ("Couldn't open file ".$outfile.": $!\n"); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 301 | 0 | $filehandle = \*TMHMM; | |||||||||||
| 302 | } | ||||||||||||
| 303 | else { | ||||||||||||
| 304 | 0 | $filehandle = $outfile; | |||||||||||
| 305 | } | ||||||||||||
| 306 | |||||||||||||
| 307 | 0 | my $tmhmm_parser = Bio::Tools::Tmhmm->new(-fh=>$filehandle); | |||||||||||
| 308 | |||||||||||||
| 309 | 0 | my @tmhmm_feat; | |||||||||||
| 310 | |||||||||||||
| 311 | 0 | ▶ | while(my $tmhmm_feat = $tmhmm_parser->next_result){ | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 312 | |||||||||||||
| 313 | 0 | push @tmhmm_feat, $tmhmm_feat; | |||||||||||
| 314 | } | ||||||||||||
| 315 | # free resources | ||||||||||||
| 316 | 0 | $self->cleanup(); | |||||||||||
| 317 | 0 | unlink $outfile; | |||||||||||
| 318 | 0 | close($tfh1); | |||||||||||
| 319 | 0 | undef $tfh1; | |||||||||||
| 320 | |||||||||||||
| 321 | 0 | return @tmhmm_feat; | |||||||||||
| 322 | } | ||||||||||||
| 323 | |||||||||||||
| 324 | =head2 _writeSeqFile | ||||||||||||
| 325 | |||||||||||||
| 326 | Title : _writeSeqFile | ||||||||||||
| 327 | Usage : obj->_writeSeqFile($seq) | ||||||||||||
| 328 | Function: Internal(not to be used directly) | ||||||||||||
| 329 | Returns : | ||||||||||||
| 330 | Args : | ||||||||||||
| 331 | |||||||||||||
| 332 | =cut | ||||||||||||
| 333 | |||||||||||||
| 334 | 0 | ▶ | sub _writeSeqFile{ | ||||||||||
|
Subroutine
_writeSeqFile: not called CC=1 SCAR=6.9
| |||||||||||||
| 335 | 0 | my ($self,$seq) = @_; | |||||||||||
| 336 | 0 | my ($tfh,$inputfile) = $self->io->tempfile(-dir=>$self->tempdir()); | |||||||||||
| 337 | 0 | my $in = Bio::SeqIO->new(-fh => $tfh , '-format' => 'Fasta'); | |||||||||||
| 338 | 0 | $in->write_seq($seq); | |||||||||||
| 339 | 0 | close($tfh); | |||||||||||
| 340 | 0 | undef $tfh; | |||||||||||
| 341 | 0 | return $inputfile; | |||||||||||
| 342 | |||||||||||||
| 343 | } | ||||||||||||
| 344 | 1 | 1; | |||||||||||