blib/lib/Bio/Tools/Run/Pseudowise.pm

filter: Statementstmt 30.6% 42 / 137 Branchbran 18.1% 8 / 44 Conditioncond 0.0% 0 / 17 MC/DCmcdc 0.0% 0 / 9 Subroutinesub 50.0% 10 / 20 Podpod 100% 6 / 6 totaltotal 28.3% 66 / 233 CC 32 SCAR 29.0
CC
32
Cov
25%
_run
56.0
_parse_results
30.0
_setparams
30.0
CRAP 18.1
« blib/lib/Bio/Tools/Run/Phylo/QuickTree.pm ↑ Summary blib/lib/Bio/DB/SoapEUtilities/FetchAdaptor.pm »
1 # BioPerl module for Bio::Tools::Run::Pseudowise
2 #
3 # Please direct questions and support issues to <bioperl-l@bioperl.org>
4 #
5 # Cared for by
6 #
7 # Copyright Kiran
8 #
9 # You may distribute this module under the same terms as perl itself
10 # POD documentation - main docs before the code
11  
12 =head1 NAME
13  
14 Bio::Tools::Run::Pseudowise - Object for prediting pseudogenes in a
15 given sequence given a protein and a cdna sequence
16  
17 =head1 SYNOPSIS
18  
19 # Build a pseudowise alignment factory
20 my $factory = Bio::Tools::Run::Pseudowise->new();
21  
22 # Pass the factory 3 Bio:SeqI objects (in the order of query
23 # peptide and cdna and target_genomic)
24 # @genes is an array of GenericSeqFeature objects
25 my @genes = $factory->run($seq1, $seq2, $seq3);
26  
27 =head1 DESCRIPTION
28  
29 Pseudowise is a pseudogene predition program developed by Ewan Birney
30 http://www.sanger.ac.uk/software/wise2.
31  
32 =head1 FEEDBACK
33  
34 =head2 Mailing Lists
35  
36 User feedback is an integral part of the evolution of this and other
37 Bioperl modules. Send your comments and suggestions preferably to one
38 of the Bioperl mailing lists. Your participation is much appreciated.
39  
40 bioperl-l@bioperl.org - General discussion
41 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
42  
43 =head2 Support
44  
45 Please direct usage questions or support issues to the mailing list:
46  
47 I<bioperl-l@bioperl.org>
48  
49 rather than to the module maintainer directly. Many experienced and
50 reponsive experts will be able look at the problem and quickly
51 address it. Please include a thorough description of the problem
52 with code and data examples if at all possible.
53  
54 =head2 Reporting Bugs
55  
56 Report bugs to the Bioperl bug tracking system to help us keep track
57 the bugs and their resolution. Bug reports can be submitted via the
58 web:
59  
60 http://redmine.open-bio.org/projects/bioperl/
61  
62 =head1 AUTHOR - Kiran
63  
64 Email kiran@fugu-sg.org
65  
66 =head1 APPENDIX
67  
68 The rest of the documentation details each of the object
69 methods. Internal methods are usually preceded with a _
70  
71 =cut
72  
73  
74 package Bio::Tools::Run::Pseudowise;
75 1 use vars qw($AUTOLOAD @ISA $PROGRAM_NAME $PROGRAM_DIR
76 @PSEUDOWISE_SWITCHES @PSEUDOWISE_PARAMS
77 1 ▶ @OTHER_SWITCHES %OK_FIELD);
Subroutine BEGIN: called CC=1 SCAR=0.0
78 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
79 1 ▶use Bio::SeqIO;
Subroutine BEGIN: called CC=1 SCAR=0.0
80 1 ▶use Bio::Tools::Run::WrapperBase;
Subroutine BEGIN: called CC=1 SCAR=0.0
81 1 ▶use Bio::Tools::Pseudowise;
Subroutine BEGIN: called CC=1 SCAR=0.0
82  
83 1 @ISA = qw(Bio::Root::Root Bio::Tools::Run::WrapperBase);
84  
85 # You will need to enable pseudowise to find the pseudowise program. This
86 # can be done in (at least) two ways:
87 #
88 # 1. define an environmental variable WISEDIR
89 # export WISEDIR =/usr/local/share/wise2.2.0
90 # where the wise2.2.20 package is installed
91 #
92 # 2. include a definition of an environmental variable WISEDIR in
93 # every script that will use DBA.pm
94 # $ENV{WISEDIR} = '/usr/local/share/wise2.2.20';
95  
96 BEGIN {
97 1 ▶ $PROGRAM_NAME = 'pseudowise';
Subroutine BEGIN: called CC=3 SCAR=11.0
98 1 ▶ $PROGRAM_DIR = Bio::Root::IO->catfile($ENV{WISEDIR},"src","bin") if $ENV{WISEDIR};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"WISEDIR"} 0 1 1
99 1 @PSEUDOWISE_PARAMS = qw(SPLICE_MAX_COLLAR SPLICE_MIN_COLLAR
100 SPLICE_SCORE_OFFSET
101 GENESTATS NOMATCHN PARAMS KBYTE
102 DYMEM DYDEBUG PALDEBUG
103 ERRORLOG);
104  
105 1 @PSEUDOWISE_SWITCHES = qw(HELP SILENT QUIET ERROROFFSTD);
106
107 # Authorize attribute fields
108 1 foreach my $attr ( @PSEUDOWISE_PARAMS, @PSEUDOWISE_SWITCHES,
109 15 @OTHER_SWITCHES) { $OK_FIELD{$attr}++; }
110  
111 }
112  
113 =head2 program_name
114  
115 Title : program_name
116 Usage : $factory>program_name()
117 Function: holds the program name
118 Returns: string
119 Args : None
120  
121 =cut
122  
123 sub program_name {
124 6 ▶ return $PROGRAM_NAME;
Subroutine program_name: called CC=1 SCAR=0.0
Pod documented
125 }
126  
127 =head2 program_dir
128  
129 Title : program_dir
130 Usage : $factory->program_dir(@params)
131 Function: returns the program directory, obtained from ENV variable.
132 Returns: string
133 Args :
134  
135 =cut
136  
137 sub program_dir {
138 3 ▶ return $PROGRAM_DIR;
Subroutine program_dir: called CC=1 SCAR=0.0
Pod documented
139 }
140  
141 sub new {
142 1 ▶ my ($class, @args) = @_;
Subroutine new: called CC=4 SCAR=14.0
Pod documented
143 1 my $self = $class->SUPER::new(@args);
144
145 1 my ($attr, $value);
146 1 ▶ while (@args) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args) 3 1 4
147 3 $attr = shift @args;
148 3 $value = shift @args;
149 3 ▶ next if( $attr =~ /^-/ ); # don't want named parameters
Branch: 1 branch
BranchTrueFalseTotal
if $attr =~ /^-/ 1 2 3
150 2 ▶ if ($attr =~/'PROGRAM'/i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($attr =~ /'PROGRAM'/i) 0 2 2
151 0 $self->executable($value);
152 0 next;
153 }
154 2 $self->$attr($value);
155 }
156 1 return $self;
157 }
158  
159  
160 sub AUTOLOAD {
161 1 ▶ my $self = shift;
Subroutine AUTOLOAD: called CC=3 SCAR=11.2
162 1 my $attr = $AUTOLOAD;
163 1 $attr =~ s/.*:://;
164 1 $attr = uc $attr;
165 1 ▶ $self->throw("Unallowed parameter: $attr !") unless $OK_FIELD{$attr};
Branch: 1 branch
BranchTrueFalseTotal
unless $Bio::Tools::Run::Pseudowise::OK_FIELD{$attr} 0 1 1
166 1 ▶ $self->{$attr} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 1 0 1
167 1 return $self->{$attr};
168 }
169  
170 =head2 version
171  
172 Title : version
173 Usage : exit if $prog->version() < 1.8
174 Function: Determine the version number of the program
175 Example :
176 Returns : float or undef
177 Args : none
178  
179 =cut
180  
181 sub version {
182 0 ▶ my ($self) = @_;
Subroutine version: not called CC=3 SCAR=24.8
Pod documented
183  
184 0 ▶ return undef unless $self->executable;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->executable 0 0 0
185 0 my $string = `pseudowise -- ` ;
186 0 $string =~ /\(([\d.]+)\)/;
187 0 ▶ return $1 || undef;
Condition0%0/2
$1 || undef
l!l
00
MC/DC0%0/1
$1 || undef
$1
Truth table0%0/2
A
A= $1
Aresult
11
00
188  
189 }
190  
191 =head2 predict_genes
192  
193 Title : predict_genes
194 Usage : DEPRECATED. Use $factory->run instead
195 Function: Predict pseudogenes
196 Returns : An array of Bio::Seqfeature::Generic objects
197 Args : Name of a file containing a set of 3 fasta sequences in the order of
198 peptide, cdna and genomic sequences
199 or else 3 Bio::Seq objects.
200  
201 Throws an exception if argument is not either a string (eg a filename)
202 or 3 Bio::Seq objects. If arguments are strings, throws exception if
203 file corresponding to string name can not be found.
204  
205 =cut
206  
207 sub predict_genes {
208 0 ▶ return shift->run(@_);
Subroutine predict_genes: not called CC=1 SCAR=6.9
Pod documented
209 }
210  
211 =head2 run
212  
213 Title : run
214 Usage : my @feats = $factory->run($seq1, $seq2, $seq3);
215 Function: Executes pseudogene binary
216 Returns : An array of Bio::Seqfeature::Generic objects
217 Args : Name of a file containing a set of 3 fasta sequences in the order of
218 peptide, cdna and genomic sequences
219 or else 3 Bio::Seq objects.
220  
221 Throws an exception if argument is not either a string (eg a filename)
222 or 3 Bio::Seq objects. If arguments are strings, throws exception if
223 file corresponding to string name can not be found.
224  
225 =cut
226  
227 sub run {
228 0 ▶ my ($self,@args)=@_;
Subroutine run: not called CC=3 SCAR=24.8
Pod documented
229 0 my ($attr, $value, $switch);
230
231 # Create input file pointer
232 0 my @files = $self->_setinput(@args);
233 0 ▶ if( @files !=3 || grep { !defined } @files ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@files != 3 or grep {not defined $_;} @files) 0 0 0
Condition0%0/3
@files != 3 or grep {not defined $_;} @files
l!l&&r!l&&!r
000
MC/DC0%0/2
@files != 3 or grep {not defined $_;} @files
@files != 3 grep {not defined $_;} @files
Truth table0%0/3
A or B
A= @files != 3B= grep {not defined $_;} @files
ABresult
1X1
011
000
234 0 $self->throw("Bad input data (sequences need an id ) ");
235 }
236
237 0 my $prot_name = $args[0]->display_id;
238 0 return $self->_run($prot_name, @files);
239 }
240  
241  
242 =head2 _run
243  
244 Title : _run
245 Usage : Internal function, not to be called directly
246 Function: makes actual system call to a pseudowise program
247 Example :
248 Returns : nothing; pseudowise output is written to a
249 temporary file $TMPOUTFILE
250 Args : Name of a files containing 3 sequences in the order of peptide, cdna and genomic
251  
252 =cut
253  
254 sub _run {
255 0 ▶ my ($self,$prot_name, @files) = @_;
Subroutine _run: not called CC=7 SCAR=40.3
256 0 my $instring;
257 0 $self->debug( "Program ".$self->executable."\n");
258 0 my ($tfh1,$outfile) = $self->io->tempfile(-dir=>$self->tempdir);
259 0 my $paramstring = $self->_setparams;
260 0 my $commandstring = sprintf("%s %s %s > %s",
261 $self->executable,
262 $paramstring,
263 join(" ", @files),
264 $outfile);
265
266 0 ▶ if($self->silent || $self->quiet || ($self->verbose < 1)){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->silent or $self->quiet or $self->verbose < 1) 0 0 0
Condition0%0/6
$self->silent or $self->quiet or $self->verbose < 1
l!l&&r!l&&!r
000
$self->silent or $self->quiet
l!l&&r!l&&!r
000
MC/DC0%0/3
$self->silent or $self->quiet or $self->verbose < 1
$self->silent $self->quiet $self->verbose < 1
Truth table0%0/4
A or B or C
A= $self->silentB= $self->quietC= $self->verbose < 1
ABCresult
1XX1
01X1
0011
0000
267 0 $commandstring .= ' 2> /dev/null';
268 }
269 0 $self->debug( "pseudowise command = $commandstring\n");
270 # my $status = system($commandstring);
271 0 `$commandstring`;
272 # $self->throw( "Pseudowise call ($commandstring) crashed: $? \n")
273 # unless $status == 0;
274 #parse the outpur and return a Bio::Seqfeature array
275 0 my $genes = $self->_parse_results($prot_name,$outfile);
276 0 close($tfh1);
277 0 undef $tfh1;
278 0 ▶ if( $self->verbose > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->verbose > 0) 0 0 0
279 0 ▶ open($tfh1,$outfile) || die $!;
Branch: 1 branch
BranchTrueFalseTotal
open $tfh1, $outfile or die $! 0 0 0
280 0 ▶ while(<$tfh1>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $tfh1)) 0 0 0
281 0 $self->debug ($_);
282 }
283 }
284 0 return @{$genes};
285 }
286  
287 =head2 _parse_results
288  
289 Title : __parse_results
290 Usage : Internal function, not to be called directly
291 Function: Parses pseudowise output
292 Example :
293 Returns : an reference to an array of Seqfeatures
294 Args : the name of the output file
295  
296 =cut
297  
298 sub _parse_results {
299 0 ▶ my ($self,$prot_name,$outfile) = @_;
Subroutine _parse_results: not called CC=5 SCAR=34.0
300 0 ▶ $outfile||$self->throw("No outfile specified");
Branch: 1 branch
BranchTrueFalseTotal
$outfile or $self->throw("No outfile specified") 0 0 0
301 0 my $filehandle;
302 0 ▶ if (ref ($outfile) !~ /GLOB/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not ref($outfile) =~ /GLOB/i) { } 0 0 0
303 0 ▶ open ($filehandle, "<".$outfile)
Branch: 1 branch
BranchTrueFalseTotal
open $filehandle, '<' . $outfile or $self->throw(q[Couldn't open file ] . $outfile . ": $!\n") 0 0 0
304 or $self->throw ("Couldn't open file ".$outfile.": $!\n");
305 } else {
306 0 $filehandle = $outfile;
307 }
308
309 0 my @genes;
310 #The big parsing loop - parses exons and predicted peptides
311 0 my $parser = Bio::Tools::Pseudowise->new(-verbose => $self->verbose,
312 -fh => $filehandle);
313 0 ▶ while( my $f = $parser->next_feature ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $f = $parser->next_feature) 0 0 0
314 0 push @genes, $f;
315 }
316 0 return \@genes;
317 }
318  
319 =head2 _setinput()
320  
321 Title : _setinput
322 Usage : Internal function, not to be called directly
323 Function: Create input files for pseudowise program
324 Example :
325 Returns : name of file containing dba data input
326 Args : Seq objects in the order of query protein and cdna and target genomic sequence
327  
328 =cut
329  
330 sub _setinput {
331 0 ▶ my ($self, $seq1, $seq2, $seq3) = @_;
Subroutine _setinput: not called CC=4 SCAR=30.0
332 0 my ($tfh1,$tfh2,$tfh3,$outfile1,$outfile2,$outfile3);
333  
334 0 ▶ if(!($seq1->isa("Bio::PrimarySeqI") && $seq2->isa("Bio::PrimarySeqI") &&
Branch: 1 branch
BranchTrueFalseTotal
unless ($seq1->isa("Bio::PrimarySeqI") and $seq2->isa("Bio::PrimarySeqI") and $seq2->isa("Bio::PrimarySeqI")) 0 0 0
Condition0%0/6
$seq1->isa("Bio::PrimarySeqI") and $seq2->isa("Bio::PrimarySeqI") and $seq2->isa("Bio::PrimarySeqI")
!ll&&!rl&&r
000
$seq1->isa("Bio::PrimarySeqI") and $seq2->isa("Bio::PrimarySeqI")
!ll&&!rl&&r
000
MC/DC0%0/3
$seq1->isa("Bio::PrimarySeqI") and $seq2->isa("Bio::PrimarySeqI") and $seq2->isa("Bio::PrimarySeqI")
$seq1->isa("Bio::PrimarySeqI") $seq2->isa("Bio::PrimarySeqI") $seq2->isa("Bio::PrimarySeqI")
Truth table0%0/4
A and B and C
A= $seq1->isa("Bio::PrimarySeqI")B= $seq2->isa("Bio::PrimarySeqI")C= $seq2->isa("Bio::PrimarySeqI")
ABCresult
0XX0
10X0
1100
1111
335 $seq2->isa("Bio::PrimarySeqI")))
336 0 { $self->throw("One or more of the sequences are nor Bio::PrimarySeqI objects\n"); }
337 0 my $tempdir = $self->tempdir();
338 0 ($tfh1,$outfile1) = $self->io->tempfile(-dir=>$tempdir);
339 0 ($tfh2,$outfile2) = $self->io->tempfile(-dir=>$tempdir);
340 0 ($tfh3,$outfile3) = $self->io->tempfile(-dir=>$tempdir);
341  
342 0 my $out1 = Bio::SeqIO->new(-fh => $tfh1 ,'-format' => 'Fasta');
343 0 my $out2 = Bio::SeqIO->new(-fh => $tfh2, '-format' => 'Fasta');
344 0 my $out3 = Bio::SeqIO->new(-fh => $tfh3, '-format' => 'Fasta');
345
346 0 $out1->write_seq($seq1);
347 0 $out2->write_seq($seq2);
348 0 $out3->write_seq($seq3);
349 0 $self->_query_pep_seq($seq1);
350 0 $self->_query_cdna_seq($seq2);
351 0 $self->_subject_dna_seq($seq3);
352  
353 0 close($tfh1);
354 0 close($tfh2);
355 0 close($tfh3);
356 0 undef ($tfh1);
357 0 undef ($tfh2);
358 0 undef ($tfh3);
359 0 return ($outfile1,$outfile2,$outfile3);
360 }
361  
362 sub _setparams {
363 0 ▶ my ($self) = @_;
Subroutine _setparams: not called CC=5 SCAR=34.0
364 0 my $param_string;
365 0 foreach my $attr(@PSEUDOWISE_PARAMS){
366 0 my $value = $self->$attr();
367 0 ▶ next unless (defined $value);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 0 0 0
368 0 my $attr_key = ' -'.(lc $attr);
369 0 $param_string .=$attr_key.' '.$value;
370 }
371  
372 0 foreach my $attr(@PSEUDOWISE_SWITCHES){
373 0 my $value = $self->$attr();
374 0 ▶ next unless (defined $value);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 0 0 0
375 0 my $attr_key = ' -'.(lc $attr);
376 0 $param_string .=$attr_key;
377 }
378  
379 0 return $param_string;
380 }
381
382  
383  
384 =head2 _query_pep_seq()
385  
386 Title : _query_pep_seq
387 Usage : Internal function, not to be called directly
388 Function: get/set for the query sequence
389 Example :
390 Returns :
391 Args :
392  
393 =cut
394  
395 sub _query_pep_seq {
396 0 ▶ my ($self,$seq) = @_;
Subroutine _query_pep_seq: not called CC=2 SCAR=17.9
397 0 ▶ if(defined $seq){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $seq) 0 0 0
398 0 $self->{'_query_pep_seq'} = $seq;
399 }
400 0 return $self->{'_query_pep_seq'};
401 }
402  
403 =head2 _query_cdna_seq()
404  
405 Title : _query_cdna_seq
406 Usage : Internal function, not to be called directly
407 Function: get/set for the query sequence
408 Example :
409 Returns :
410 Args :
411  
412 =cut
413  
414 sub _query_cdna_seq {
415 0 ▶ my ($self,$seq) = @_;
Subroutine _query_cdna_seq: not called CC=2 SCAR=17.9
416 0 ▶ if(defined $seq){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $seq) 0 0 0
417 0 $self->{'_query_cdna_seq'} = $seq;
418 }
419 0 return $self->{'_query_cdna_seq'};
420 }
421  
422 =head2 _subject_dna_seq()
423  
424 Title : _subject_dna_seq
425 Usage : Internal function, not to be called directly
426 Function: get/set for the subject sequence
427 Example :
428 Returns :
429  
430 Args :
431  
432 =cut
433  
434 sub _subject_dna_seq {
435 0 ▶ my ($self,$seq) = @_;
Subroutine _subject_dna_seq: not called CC=2 SCAR=17.9
436 0 ▶ if(defined $seq){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $seq) 0 0 0
437 0 $self->{'_subject_dna_seq'} = $seq;
438 }
439 0 return $self->{'_subject_dna_seq'};
440 }
441  
442 1 1; # Needed to keep compiler happy
« blib/lib/Bio/Tools/Run/Phylo/QuickTree.pm ↑ Summary blib/lib/Bio/DB/SoapEUtilities/FetchAdaptor.pm »