Tools/Run/Genewise.pm

filter: Statementstmt 37.7% 60 / 159 Branchbran 12.5% 7 / 56 Conditioncond 0.0% 0 / 12 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 65.3% 17 / 26 Podpod 85.7% 6 / 7 totaltotal 33.7% 90 / 267 CC 36 SCAR 33.8
CC
36
Cov
30%
_setinput
90.0
_run
72.0
_setparams
30.0
CRAP 29.5
« DB/SoapEUtilities/Result.pm ↑ Summary Tools/Run/AnalysisFactory/soap.pm »
1 #
2 # Please direct questions and support issues to <bioperl-l@bioperl.org>
3 #
4 # Cared for by
5 #
6 # Copyright to a FUGU Student Intern
7 #
8 # You may distribute this module under the same terms as perl itself
9 # POD documentation - main docs before the code
10  
11 =head1 NAME
12  
13 Bio::Tools::Run::Genewise - Object for predicting genes in a
14 given sequence given a protein
15  
16 =head1 SYNOPSIS
17  
18 # Build a Genewise alignment factory
19 my $factory = Bio::Tools::Run::Genewise->new();
20  
21 # Pass the factory 2 Bio:SeqI objects (in the order of query peptide
22 # and target_genomic).
23  
24 # @genes is an array of Bio::SeqFeature::Gene::GeneStructure objects
25 my @genes = $factory->run($protein_seq, $genomic_seq);
26  
27 # Alternatively pass the factory a profile HMM filename and a
28 # Bio:SeqI object (in the order of query HMM and target_genomic).
29  
30 # Set hmmer switch first to tell genewise to expect an HMM
31 $factory->hmmer(1);
32 my @genes = $factory->run($hmmfile, $genomic_seq);
33  
34  
35 =head1 DESCRIPTION
36  
37 Genewise is a gene prediction program developed by Ewan Birney
38 http://www.sanger.ac.uk/software/wise2.
39  
40 =head2 Available Params:
41  
42 NB: These should be passed without the '-' or they will be ignored,
43 except switches such as 'hmmer' (which have no corresponding value)
44 which should be set on the factory object using the AUTOLOADed methods
45 of the same name.
46  
47 Model [-codon,-gene,-cfreq,-splice,-subs,-indel,-intron,-null]
48 Alg [-kbyte,-alg]
49 HMM [-hmmer]
50 Output [-gff,-gener,-alb,-pal,-block,-divide]
51 Standard [-help,-version,-silent,-quiet,-errorlog]
52  
53  
54 =head1 FEEDBACK
55  
56 =head2 Mailing Lists
57  
58 User feedback is an integral part of the evolution of this and other
59 Bioperl modules. Send your comments and suggestions preferably to one
60 of the Bioperl mailing lists. Your participation is much appreciated.
61  
62 bioperl-l@bioperl.org - General discussion
63 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
64  
65 =head2 Support
66  
67 Please direct usage questions or support issues to the mailing list:
68  
69 I<bioperl-l@bioperl.org>
70  
71 rather than to the module maintainer directly. Many experienced and
72 reponsive experts will be able look at the problem and quickly
73 address it. Please include a thorough description of the problem
74 with code and data examples if at all possible.
75  
76 =head2 Reporting Bugs
77  
78 Report bugs to the Bioperl bug tracking system to help us keep track
79 the bugs and their resolution. Bug reports can be submitted via
80 the web:
81  
82 http://redmine.open-bio.org/projects/bioperl/
83  
84 =head1 AUTHOR - FUGU Student Intern
85  
86 Email: fugui@worf.fugu-sg.org
87  
88 =head1 CONTRIBUTORS
89  
90 Jason Stajich jason-AT-bioperl_DOT_org
91 Keith James kdj@sanger.ac.uk
92  
93 =head1 APPENDIX
94  
95 The rest of the documentation details each of the object
96 methods. Internal methods are usually preceded with a _
97  
98 =cut
99  
100 package Bio::Tools::Run::Genewise;
101 1 ▶use vars qw($AUTOLOAD @ISA $PROGRAM $PROGRAMDIR $PROGRAMNAME
Subroutine BEGIN: called CC=1 SCAR=0.0
102 @GENEWISE_SWITCHES @GENEWISE_PARAMS
103 1 @OTHER_SWITCHES %OK_FIELD);
104 1 ▶use Bio::SeqIO;
Subroutine BEGIN: called CC=1 SCAR=0.0
105 1 ▶use Bio::SeqFeature::Generic;
Subroutine BEGIN: called CC=1 SCAR=0.0
106 1 ▶use Bio::SeqFeature::Gene::Exon;
Subroutine BEGIN: called CC=1 SCAR=0.0
107 1 ▶use Bio::Root::Root;
Subroutine BEGIN: called CC=1 SCAR=0.0
108 1 ▶use Bio::Tools::Run::WrapperBase;
Subroutine BEGIN: called CC=1 SCAR=0.0
109 1 ▶use Bio::SeqFeature::FeaturePair;
Subroutine BEGIN: called CC=1 SCAR=0.0
110 1 ▶use Bio::SeqFeature::Gene::Transcript;
Subroutine BEGIN: called CC=1 SCAR=0.0
111 1 ▶use Bio::SeqFeature::Gene::GeneStructure;
Subroutine BEGIN: called CC=1 SCAR=0.0
112 1 ▶use Bio::Tools::Genewise;
Subroutine BEGIN: called CC=1 SCAR=0.0
113 1 ▶use Bio::Tools::AnalysisResult;
Subroutine BEGIN: called CC=1 SCAR=0.0
114 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
115  
116 1 @ISA = qw(Bio::Root::Root Bio::Tools::Run::WrapperBase );
117  
118 # Two ways to run the program .....
119 # 1. define an environmental variable WISEDIR
120 # export WISEDIR =/usr/local/share/wise2.2.0
121 # where the wise2.2.20 package is installed
122 #
123 # 2. include a definition of an environmental variable WISEDIR in
124 # every script that will use DBA.pm
125 # $ENV{WISEDIR} = '/usr/local/share/wise2.2.20';
126  
127 1 ▶BEGIN {
Subroutine BEGIN: called CC=2 SCAR=6.9
128 1 @GENEWISE_PARAMS = qw( DYMEM CODON GENE CFREQ SPLICE GENESTATS INIT
129 SUBS INDEL INTRON NULL INSERT SPLICE_MAX_COLLAR SPLICE_MIN_COLLAR
130 GW_EDGEQUERY GW_EDGETARGET GW_SPLICESPREAD
131 KBYTE HNAME ALG BLOCK DIVIDE GENER U V S T G E M);
132  
133 1 @GENEWISE_SWITCHES = qw(HELP SILENT QUIET ERROROFFSTD TREV PSEUDO NOSPLICE_GTAG
134 SPLICE_GTAG NOGWHSP GWHSP
135 TFOR TABS BOTH HMMER );
136  
137 # Authorize attribute fields
138 1 foreach my $attr ( @GENEWISE_PARAMS, @GENEWISE_SWITCHES,
139 44 @OTHER_SWITCHES) { $OK_FIELD{$attr}++; }
140 }
141  
142 =head2 program_name
143  
144 Title : program_name
145 Usage : $factory>program_name()
146 Function: holds the program name
147 Returns: string
148 Args : None
149  
150 =cut
151  
152 6 ▶sub program_name {
Subroutine program_name: called CC=1 SCAR=0.0
Pod documented
153 6 return 'genewise';
154 }
155  
156 =head2 program_dir
157  
158 Title : program_dir
159 Usage : $factory->program_dir(@params)
160 Function: returns the program directory, obtained from ENV variable.
161 Returns: string
162 Args :
163  
164 =cut
165  
166 3 ▶sub program_dir {
Subroutine program_dir: called CC=2 SCAR=7.6
Pod documented
167 3 ▶ return Bio::Root::IO->catfile($ENV{WISEDIR},"/src/bin/") if $ENV{WISEDIR};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"WISEDIR"} 0 3 3
168 }
169  
170 1 ▶sub new {
Subroutine new: called CC=3 SCAR=11.0
Pod documented
171 1 my ($class, @args) = @_;
172 1 my $self = $class->SUPER::new(@args);
173  
174 1 my ($attr, $value);
175 1 ▶ while (@args) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args) 3 1 4
176 3 $attr = shift @args;
177 3 $value = shift @args;
178 3 ▶ next if( $attr =~ /^-/ ); # don't want named parameters
Branch: 1 branch
BranchTrueFalseTotal
if $attr =~ /^-/ 1 2 3
179 2 $self->$attr($value);
180 }
181  
182 1 return $self;
183 }
184  
185 1 ▶sub AUTOLOAD {
Subroutine AUTOLOAD: called CC=3 SCAR=11.2
186 1 my $self = shift;
187 1 my $attr = $AUTOLOAD;
188 1 $attr =~ s/.*:://;
189 1 $attr = uc $attr;
190 1 ▶ $self->throw("Unallowed parameter: $attr !") unless $OK_FIELD{$attr};
Branch: 1 branch
BranchTrueFalseTotal
unless $Bio::Tools::Run::Genewise::OK_FIELD{$attr} 0 1 1
191 1 ▶ $self->{$attr} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 1 0 1
192 1 return $self->{$attr};
193 }
194  
195 =head2 version
196  
197 Title : version
198 Usage : exit if $prog->version() < 1.8
199 Function: Determine the version number of the program
200 Example :
201 Returns : float or undef
202 Args : none
203  
204 =cut
205  
206 0 ▶sub version {
Subroutine version: not called CC=4 SCAR=30.0
Pod documented
207 0 my ($self) = @_;
208  
209 0 ▶ return undef unless $self->executable;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->executable 0 0 0
210 0 my $prog = $self->executable;
211 0 my $string = `$prog -version`;
212 0 ▶ if( $string =~ /Version:\s+\$\s*Name:\s+(\S+)\s+\$/ ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($string =~ /Version:\s+\$\s*Name:\s+(\S+)\s+\$/) { } 0 0 0
elsif ($string =~ /(Version *)/i) { } 0 0 0
213 0 return $1;
214 } elsif( $string =~ /(Version *)/i ) {
215 0 return $1;
216 } else {
217 0 return undef;
218 }
219 }
220  
221 =head2 predict_genes
222  
223 Title : predict_genes
224 Usage : DEPRECATED. Use $factory->run($seq1,$seq2)
225 Function: Predict genes
226 Returns : A Bio::Seqfeature::Gene:GeneStructure object
227 Args : Name of a file containing a set of 2 fasta sequences in the order of
228 peptide and genomic sequences
229 or else 2 Bio::Seq objects.
230  
231 Throws an exception if argument is not either a string (eg a filename)
232 or 2 Bio::Seq objects. If arguments are strings, throws exception if
233 file corresponding to string name can not be found.
234  
235 =cut
236  
237 0 ▶sub predict_genes {
Subroutine predict_genes: not called CC=1 SCAR=6.9
Pod documented
238 0 return shift->run(@_);
239 }
240  
241 =head2 run
242  
243 Title : run
244 Usage : 2 sequence objects
245 $genes = $factory->run($seq1, $seq2);
246 Function: run
247 Returns : A Bio::Seqfeature::Gene:GeneStructure object
248 Args : Names of a files each containing a fasta sequence in the order
249 of either (peptide sequence, genomic sequence) or (profile HMM,
250 genomic sequence). Alternatively any of the fasta sequence
251 filenames may be substituted with a Bio::Seq object.
252  
253 Throws an exception if argument is not either a string (eg a filename)
254 or Bio::Seq objects. If arguments are strings, throws exception if
255 file corresponding to string name can not be found. Also throws an
256 exception if a profile HMM is expected (the -hmmer genewise switch has
257 been set).
258  
259 =cut
260  
261 0 ▶sub run{
Subroutine run: not called CC=3 SCAR=24.8
Pod documented
262 0 my ($self, $seq1, $seq2) = @_;
263 0 my ($attr, $value, $switch);
264 0 $self->io->_io_cleanup();
265 # Create input file pointer
266 0 my ($infile1,$infile2)= $self->_setinput($seq1, $seq2);
267 0 ▶ if (!($infile1 && $infile2)) {$self->throw("Bad input data (sequences need an id ) ");}
Branch: 1 branch
BranchTrueFalseTotal
unless ($infile1 and $infile2) 0 0 0
Condition0%0/3
$infile1 and $infile2
!ll&&!rl&&r
000
MC/DC0%0/2
$infile1 and $infile2
$infile1 $infile2
Truth table0%0/3
A and B
A= $infile1B= $infile2
ABresult
0X0
100
111
268  
269 # run genewise
270 0 my @genes = $self->_run($infile1,$infile2);
271 0 return @genes;
272 }
273  
274 =head2 _run
275  
276 Title : _run
277 Usage : Internal function, not to be called directly
278 Function: Makes actual system call to a genewise program
279 Example :
280 Returns : L<Bio::SeqFeature::Gene::GeneStructure>
281 Args : Name of a files containing 2 sequences in the order of peptide and genomic
282  
283 =cut
284  
285 0 ▶sub _run {
Subroutine _run: not called CC=8 SCAR=42.8
286 0 my ($self,$infile1,$infile2) = @_;
287 0 my $instring;
288 0 $self->debug("Program ".$self->executable."\n");
289 0 ▶ unless ( $self->executable ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->executable) 0 0 0
290 0 $self->throw("Cannot run Genewise unless the executable is found. Check your environment variables or make sure genewise is in your path.");
291 }
292 0 my $paramstring = $self->_setparams;
293  
294 0 my $commandstring = $self->executable." $paramstring $infile1 $infile2";
295 # this is to capture STDERR messages which leak out when you run programs
296 # with open(FH, "... |");
297 0 ▶ if (($self->silent && $self->quiet) &&
Branch: 1 branch
BranchTrueFalseTotal
if ($self->silent and $self->quiet and not $^O =~ /os2|dos|amigaos/) 0 0 0
Condition0%0/6
$self->silent and $self->quiet and not $^O =~ /os2|dos|amigaos/
!ll&&!rl&&r
000
$self->silent and $self->quiet
!ll&&!rl&&r
000
MC/DC0%0/3
$self->silent and $self->quiet and not $^O =~ /os2|dos|amigaos/
$self->silent $self->quiet not $^O =~ /os2|dos|amigaos/
Truth table0%0/4
A and B and not(C)
A= $self->silentB= $self->quietC= not $^O =~ /os2|dos|amigaos/
ABCresult
0XX0
10X0
1100
1111
298 ($^O !~ /os2|dos|amigaos/)) {
299 0 ▶ my $null = ($^O =~ m/mswin/i) ? 'NUL' : '/dev/null';
Branch: 1 branch
BranchTrueFalseTotal
$^O =~ /mswin/i ? : 0 0 0
300 0 $commandstring .= " 2> $null";
301 }
302 0 my ($tfh1,$outfile1) = $self->io->tempfile(-dir=>$self->tempdir);
303 0 $self->debug("genewise command = $commandstring");
304 0 my $status = system("$commandstring > $outfile1");
305 0 ▶ $self->throw("Genewise call $commandstring crashed: $? \n") unless $status == 0;
Branch: 1 branch
BranchTrueFalseTotal
unless $status == 0 0 0 0
306
307 0 my $genewiseParser = Bio::Tools::Genewise->new(-file=> $outfile1);
308 0 my @genes;
309 0 ▶ while (my $gene = $genewiseParser->next_prediction()) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $gene = $genewiseParser->next_prediction) 0 0 0
310 0 push @genes, $gene;
311 }
312 0 close ($tfh1);
313 0 undef ($tfh1);
314 0 return @genes;
315 }
316  
317 0 ▶sub get_strand {
Subroutine get_strand: not called CC=4 SCAR=30.0
Pod undocumented
318 0 my ($self,$start,$end) = @_;
319 0 ▶ $start || $self->throw("Need a start");
Branch: 1 branch
BranchTrueFalseTotal
$start or $self->throw("Need a start") 0 0 0
320 0 ▶ $end || $self->throw("Need an end");
Branch: 1 branch
BranchTrueFalseTotal
$end or $self->throw("Need an end") 0 0 0
321 0 my $strand;
322 0 ▶ if ($start > $end) {
Branch: 1 branch
BranchTrueFalseTotal
if ($start > $end) { } 0 0 0
323 0 my $tmp = $start;
324 0 $start = $end;
325 0 $end = $tmp;
326 0 $strand = -1;
327 }
328 else {
329 0 $strand = 1;
330 }
331 0 return ($start,$end,$strand);
332 }
333  
334 0 ▶sub _setinput {
Subroutine _setinput: not called CC=9 SCAR=45.0
335 0 my ($self, $arg1, $seq2) = @_;
336 0 my ($tfh1,$tfh2,$outfile1,$outfile2);
337  
338 0 ▶ $self->throw("calling with not enough arguments") unless $arg1 && $seq2;
Branch: 1 branch
BranchTrueFalseTotal
unless $arg1 and $seq2 0 0 0
Condition0%0/3
$arg1 and $seq2
!ll&&!rl&&r
000
MC/DC0%0/2
$arg1 and $seq2
$arg1 $seq2
Truth table0%0/3
A and B
A= $arg1B= $seq2
ABresult
0X0
100
111
339  
340 # Not going to set _query_pep/_subject_dna_seq if you pass in a
341 # filename
342  
343 0 ▶ unless( ref($arg1) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $arg1) { } 0 0 0
344 0 ▶ unless( -e $arg1 ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-e $arg1) 0 0 0
345 0 ▶ if ($self->hmmer) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->hmmer) { } 0 0 0
346 0 $self->throw("Argument1 was not a HMMER profile HMM file\n")
347 }
348 else {
349 0 $self->throw("Argument1 is not a Bio::PrimarySeqI object nor file\n");
350 }
351 }
352 0 $outfile1 = $arg1;
353 }
354 else {
355 0 ▶ if ($self->hmmer) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->hmmer) { } 0 0 0
356 0 $self->throw("Argument1 was not a HMMER profile HMM file\n")
357 }
358 else {
359 0 ($tfh1,$outfile1) = $self->io->tempfile(-dir=>$self->tempdir);
360 0 my $out1 = Bio::SeqIO->new('-fh' => $tfh1,
361 '-format' => 'fasta');
362 0 $out1->write_seq($arg1);
363 0 $self->_query_pep_seq($arg1);
364 # Make sure you close things - this is what creates
365 # Out of filehandle errors
366 0 close($tfh1);
367 0 undef $tfh1;
368 }
369 }
370  
371 0 ▶ unless( ref($seq2) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $seq2) { } 0 0 0
372 0 ▶ unless( -e $seq2 ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-e $seq2) 0 0 0
373 0 $self->throw("Sequence2 is not a Bio::PrimarySeqI object nor file\n");
374 }
375 0 $outfile2 = $seq2;
376 }
377 else {
378 0 ($tfh2,$outfile2) = $self->io->tempfile(-dir=>$self->tempdir);
379 0 my $out2 = Bio::SeqIO->new('-fh' => $tfh2,
380 '-format' => 'fasta');
381 0 $out2->write_seq($seq2);
382  
383 0 $self->_subject_dna_seq($seq2);
384 # Make sure you close things - this is what creates
385 # Out of filehandle errors
386 0 close($tfh2);
387 0 undef $tfh2;
388 }
389 0 return ($outfile1,$outfile2);
390 }
391  
392 =head2 _setparams
393  
394 Title : _setparams
395 Usage : Internal function, not to be called directly
396 Function: creates a string of params to be used in the command string
397 Example :
398 Returns : string of params
399 Args :
400  
401 =cut
402  
403 0 ▶sub _setparams {
Subroutine _setparams: not called CC=5 SCAR=34.0
404 0 my ($self) = @_;
405 0 my $param_string;
406 0 foreach my $attr(@GENEWISE_PARAMS){
407 0 my $value = $self->$attr();
408 0 ▶ next unless (defined $value);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 0 0 0
409 0 my $attr_key = ' -'.(lc $attr);
410 0 $param_string .= $attr_key.' '.$value;
411 }
412 0 foreach my $attr(@GENEWISE_SWITCHES){
413 0 my $value = $self->$attr();
414 0 ▶ next unless (defined $value);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 0 0 0
415 0 my $attr_key = ' -'.(lc $attr);
416 0 $param_string .=$attr_key;
417 }
418  
419 0 $param_string = $param_string." -genesf"; #specify the output option
420 0 return $param_string;
421 }
422  
423 =head2 _query_pep_seq
424  
425 Title : _query_pep_seq
426 Usage : Internal function, not to be called directly
427 Function: get/set for the query sequence
428 Example :
429 Returns :
430 Args :
431  
432 =cut
433  
434 0 ▶sub _query_pep_seq {
Subroutine _query_pep_seq: not called CC=2 SCAR=17.9
435 0 my ($self,$seq) = @_;
436 0 ▶ if(defined $seq){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $seq) 0 0 0
437 0 $self->{'_query_pep_seq'} = $seq;
438 }
439 0 return $self->{'_query_pep_seq'};
440 }
441  
442 =head2 _subject_dna_seq
443  
444 Title : _subject_dna_seq
445 Usage : Internal function, not to be called directly
446 Function: get/set for the subject sequence
447 Example :
448 Returns :
449  
450 Args :
451  
452 =cut
453  
454 0 ▶sub _subject_dna_seq {
Subroutine _subject_dna_seq: not called CC=2 SCAR=17.9
455 0 my ($self,$seq) = @_;
456 0 ▶ if(defined $seq){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $seq) 0 0 0
457 0 $self->{'_subject_dna_seq'} = $seq;
458 }
459 0 return $self->{'_subject_dna_seq'};
460 }
461  
462 1 1;
« DB/SoapEUtilities/Result.pm ↑ Summary Tools/Run/AnalysisFactory/soap.pm »