File Coverage

blib/lib/Bio/Tools/Run/Genscan.pm
Criterion Covered Total %
statement 30 80 37.5
branch 0 14 0.0
condition n/a
subroutine 10 19 52.6
pod 5 5 100.0
total 45 118 38.1


line stmt bran cond sub pod time code
1             # BioPerl module for Bio::Tools::Run::Genscan
2             #
3             # Please direct questions and support issues to
4             #
5             # Cared for by
6             #
7             # Copyright Balamurugan Kumarasamy
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::Genscan - Object for identifying genes in a
15             given sequence given a matrix(for appropriate organisms).
16              
17             =head1 SYNOPSIS
18              
19             # Build a Genscan factory
20             my $param = ('MATRIX'=>HumanIso.smat);
21             my $factory = Bio::Tools::Run::Genscan->new($param);
22              
23             # Pass the factory a Bio::Seq object
24             #@genes is an array of Bio::Tools::Predictions::Gene objects
25             my @genes = $factory->run($seq);
26              
27             =head1 DESCRIPTION
28              
29             Genscan is a gene identifying program developed by Christopher Burge
30             http://genes.mit.edu/burgelab/
31              
32             By default it looks for an executable called I and data/parameter files
33             in the directory specified by the I environmental variable.
34              
35             =head1 FEEDBACK
36              
37             =head2 Mailing Lists
38              
39             User feedback is an integral part of the evolution of this and other
40             Bioperl modules. Send your comments and suggestions preferably to one
41             of the Bioperl mailing lists. Your participation is much appreciated.
42              
43             bioperl-l@bioperl.org - General discussion
44             http://bioperl.org/wiki/Mailing_lists - About the mailing lists
45              
46             =head2 Support
47              
48             Please direct usage questions or support issues to the mailing list:
49              
50             I
51              
52             rather than to the module maintainer directly. Many experienced and
53             reponsive experts will be able look at the problem and quickly
54             address it. Please include a thorough description of the problem
55             with code and data examples if at all possible.
56              
57             =head2 Reporting Bugs
58              
59             Report bugs to the Bioperl bug tracking system to help us keep track
60             the bugs and their resolution. Bug reports can be submitted via the
61             web:
62              
63             http://redmine.open-bio.org/projects/bioperl/
64              
65             =head1 AUTHOR - Bala
66              
67             Email savikalpa@fugu-sg.org
68              
69             =head1 APPENDIX
70              
71             The rest of the documentation details each of the object
72             methods. Internal methods are usually preceded with a _
73              
74             =cut
75              
76             package Bio::Tools::Run::Genscan;
77            
78 1         67 use vars qw($AUTOLOAD @ISA $PROGRAM $PROGRAMDIR
79 1     1   114710 $PROGRAMNAME @GENSCAN_PARAMS %OK_FIELD);
  1         2  
80 1     1   4 use strict;
  1         1  
  1         15  
81 1     1   534 use Bio::Seq;
  1         45416  
  1         24  
82 1     1   528 use Bio::SeqIO;
  1         20018  
  1         25  
83 1     1   5 use Bio::Root::Root;
  1         1  
  1         12  
84 1     1   4 use Bio::Root::IO;
  1         1  
  1         13  
85 1     1   389 use Bio::Factory::ApplicationFactoryI;
  1         99  
  1         18  
86 1     1   443 use Bio::Tools::Genscan;
  1         25946  
  1         35  
87 1     1   440 use Bio::Tools::Run::WrapperBase;
  1         2  
  1         57  
88              
89             @ISA = qw(Bio::Root::Root Bio::Tools::Run::WrapperBase);
90              
91             BEGIN {
92 1     1   3 @GENSCAN_PARAMS=qw(MATRIX VERBOSE QUIET);
93 1         3 foreach my $attr ( @GENSCAN_PARAMS)
94 3         514 { $OK_FIELD{$attr}++; }
95             }
96              
97             =head2 program_name
98              
99             Title : program_name
100             Usage : $factory>program_name()
101             Function: holds the program name
102             Returns: string
103             Args : None
104              
105             =cut
106              
107             sub program_name {
108 0     0 1   return 'genscan';
109             }
110              
111             =head2 program_dir
112              
113             Title : program_dir
114             Usage : $factory->program_dir(@params)
115             Function: returns the program directory, obtained from ENV variable.
116             Returns: string
117             Args :
118              
119             =cut
120              
121             sub program_dir {
122 0     0 1   return Bio::Root::IO->catfile($ENV{GENSCANDIR});
123             }
124              
125              
126             sub AUTOLOAD {
127 0     0     my $self = shift;
128 0           my $attr = $AUTOLOAD;
129 0           $attr =~ s/.*:://;
130 0           $attr = uc $attr;
131 0 0         $self->throw("Unallowed parameter: $attr !") unless $OK_FIELD{$attr};
132 0 0         $self->{$attr} = shift if @_;
133 0           return $self->{$attr};
134             }
135              
136             sub new {
137 0     0 1   my ($class,@args) = @_;
138 0           my $self = $class->SUPER::new(@args);
139 0           my ($attr, $value);
140 0           while (@args) {
141 0           $attr = shift @args;
142 0           $value = shift @args;
143 0 0         next if( $attr =~ /^-/ ); # don't want named parameters
144 0           $self->$attr($value);
145             }
146 0           return $self;
147             }
148              
149             =head2 predict_genes()
150              
151             Title : predict_genes()
152             Usage : DEPRECATED: use $obj->run($seq) instead
153             Function: Runs genscan and creates an array of Genes
154             Returns : An array of Bio::Tools::Prediction::Gene objects
155             Args : A Bio::PrimarySeqI
156              
157             =cut
158              
159             sub predict_genes{
160 0     0 1   return shift->run(@_);
161             }
162              
163             =head2 run
164              
165             Title : run
166             Usage : $obj->run($seq)
167             Function: Runs genscan and creates an array of Genes
168             Returns : An array of Bio::Tools::Prediction::Gene objects
169             Args : A Bio::PrimarySeqI
170              
171             =cut
172              
173             sub run {
174 0     0 1   my ($self,$seq) = @_;
175 0           my $infile1 = $self->_writeSeqFile($seq);
176 0           $self->_set_input($infile1);
177 0           my @feat = $self->_run();
178 0           return @feat;
179             }
180              
181             =head2 _run
182              
183             Title : _run
184             Usage : $obj->_run()
185             Function: Internal(not to be used directly)
186             Returns : An array of Bio::Tools::Prediction::Gene objects
187             Args :
188              
189             =cut
190              
191             sub _run {
192              
193 0     0     my ($self) = @_;
194 0           my @genes;
195             my $gene;
196              
197 0           my $str = $self->executable.' '.$self->MATRIX.' '.$self->{'input'};
198 0 0         if($self->verbose){
199 0           $str.=" -v ";
200             }
201 0 0         if($self->quiet){
202 0 0         my $null = ($^O =~ m/mswin/i) ? 'NUL' : '/dev/null';
203 0           open(STDERR,">$null");
204             }
205 0 0         unless (open(GENSCAN, "$str |")){
206 0           $self->warn("Cannot run $str");
207             }
208 0           close(STDERR);
209 0           my $genScanParser = Bio::Tools::Genscan->new(-fh=> \*GENSCAN);
210              
211            
212 0           while( $gene = $genScanParser->next_prediction()){
213 0           push(@genes, $gene);
214             }
215 0           $self->cleanup();
216 0           return @genes;
217             }
218              
219             =head2 _set_input()
220              
221             Title : _set_input
222             Usage : obj->_set_input($matrixFile,$seqFile)
223             Function: Internal(not to be used directly)
224             Returns :
225             Args :
226              
227             =cut
228              
229             sub _set_input() {
230 0     0     my ($self,$infile1) = @_;
231 0           $self->{'input'}=$infile1;
232             }
233              
234             =head2 _writeSeqFile()
235              
236             Title : _writeSeqFile
237             Usage : obj->_writeSeqFile($seq)
238             Function: Internal(not to be used directly)
239             Returns :
240             Args :
241              
242             =cut
243              
244              
245             sub _writeSeqFile(){
246 0     0     my ($self,$seq) = @_;
247 0           my ($tfh,$inputfile) = $self->io->tempfile(-dir=>$self->tempdir);
248 0           my $in = Bio::SeqIO->new(-fh => $tfh , '-format' => 'fasta');
249 0           $in->write_seq($seq);
250 0           $in->close();
251 0           close($tfh);
252 0           undef $tfh;
253 0           return $inputfile;
254             }
255              
256             1;