2 # BioPerl module for Bio::Tools::Est2Genome
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
6 # Cared for by Jason Stajich <jason-at-bioperl.org>
8 # Copyright Jason Stajich
10 # You may distribute this module under the same terms as perl itself
12 # POD documentation - main docs before the code
16 Bio::Tools::Est2Genome - Parse est2genome output, makes simple Bio::SeqFeature::Generic objects
20 use Bio::Tools::Est2Genome;
22 my $featureiter = Bio::Tools::Est2Genome->new(-file => 'output.est2genome');
24 # This is going to be fixed to use the SeqAnalysisI next_feature
25 # Method eventually when we have the objects to put the data in
27 while( my $f = $featureiter->parse_next_gene ) {
28 # process Bio::SeqFeature::Generic objects here
33 This module is a parser for C<est2genome> [EMBOSS] alignments of est/cdna
34 sequence to genomic DNA. This is generally accepted as the best
35 program for predicting splice sites based on est/dnas (as far as I know).
37 This module currently does not try pull out the ungapped alignments
38 (Segment) but may in the future.
44 User feedback is an integral part of the evolution of this and other
45 Bioperl modules. Send your comments and suggestions preferably to
46 the Bioperl mailing list. Your participation is much appreciated.
48 bioperl-l@bioperl.org - General discussion
49 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
53 Please direct usage questions or support issues to the mailing list:
55 I<bioperl-l@bioperl.org>
57 rather than to the module maintainer directly. Many experienced and
58 reponsive experts will be able look at the problem and quickly
59 address it. Please include a thorough description of the problem
60 with code and data examples if at all possible.
64 Report bugs to the Bioperl bug tracking system to help us keep track
65 of the bugs and their resolution. Bug reports can be submitted the
68 https://github.com/bioperl/bioperl-live/issues
70 =head1 AUTHOR - Jason Stajich
72 Email jason-at-bioperl.org
76 The rest of the documentation details each of the object methods.
77 Internal methods are usually preceded with a _
82 # Let the code begin...
85 package Bio
::Tools
::Est2Genome
;
88 # Object preamble - inherits from Bio::Root::Root
91 use Bio
::SeqFeature
::Gene
::Exon
;
92 use Bio
::SeqFeature
::Gene
::Transcript
;
93 use Bio
::SeqFeature
::Gene
::Intron
;
94 use Bio
::SeqFeature
::Gene
::GeneStructure
;
95 use Bio
::SeqFeature
::SimilarityPair
;
97 use base
qw(Bio::Tools::AnalysisResult);
102 Usage : my $obj = Bio::Tools::Est2Genome->new();
103 Function: Builds a new Bio::Tools::Est2Genome object
104 Returns : an instance of Bio::Tools::Est2Genome
105 Args : -file => 'output.est2genome' or
106 -fh => \*EST2GENOMEOUTPUT
107 -genomefirst => 1 # genome was the first input (not standard)
111 sub _initialize_state
{
112 my($self,@args) = @_;
114 # call the inherited method first
115 my $make = $self->SUPER::_initialize_state
(@args);
117 my ($genome_is_first) = $self->_rearrange([qw(GENOMEFIRST)], @args);
119 delete($self->{'_genome_is_first'});
120 $self->{'_genome_is_first'} = $genome_is_first if(defined($genome_is_first));
121 $self->analysis_method("est2genome");
124 =head2 analysis_method
126 Usage : $sim4->analysis_method();
127 Purpose : Inherited method. Overridden to ensure that the name matches
135 sub analysis_method
{
137 my ($self, $method) = @_;
138 if($method && ($method !~ /est2genome/i)) {
139 $self->throw("method $method not supported in " . ref($self));
141 return $self->SUPER::analysis_method
($method);
144 =head2 parse_next_gene
146 Title : parse_next_gene
147 Usage : @gene = $est2genome_result->parse_next_gene;
148 foreach $exon (@exons) {
152 Function: Parses the next alignments of the est2genome result file and
153 returns the found exons as an array of
154 Bio::SeqFeature::SimilarityPair objects. Call
155 this method repeatedly until an empty array is returned to get the
156 results for all alignments.
158 The $exon->seq_id() attribute will be set to the identifier of the
159 respective sequence for both sequences.
160 The length is accessible via the seqlength()
161 attribute of $exon->query() and
163 Returns : An array (or array reference) of Bio::SeqFeature::SimilarityPair and Bio::SeqFeature::Generic objects
164 or Bio::SeqFeature::Gene::GeneStructure
165 Args : flag(1/0) indicating to return Bio::SeqFeature::Gene::GeneStructure or Bio::SeqFeature::SimilarityPair
170 sub parse_next_gene
{
171 my ($self,$return_gene) = @_;
172 return $self->_parse_gene_struct if $return_gene;
175 my ($qstrand,$hstrand) = (1,1);
177 while( defined($_ = $self->_readline) ) {
178 if( /Note Best alignment is between (reversed|forward) est and (reversed|forward) genome, (but|and) splice\s+sites imply\s+(forward gene|REVERSED GENE)/) {
180 $self->_pushback($_);
181 return wantarray ?
@features : \
@features;
183 $hstrand = -1 if $1 eq 'reversed';
184 $qstrand = -1 if $4 eq 'REVERSED GENE';
185 #$self->debug( "1=$1, 2=$2, 4=$4\n");
188 my ($name,$score,$perc_ident,$qstart,$qend,$qseqname,
189 $hstart,$hend, $hseqname) = split;
190 $lasthseqname = $hseqname;
191 my $query = Bio
::SeqFeature
::Similarity
->new(-primary
=> $name,
192 -source
=> $self->analysis_method,
193 -seq_id
=> $qseqname, # FIXME WHEN WE REDO THE GENERIC NAME CHANGE
199 # 'Location' => "$hstart..$hend",
200 'Sequence' => "$hseqname",
201 'identity' => $perc_ident,
204 my $hit = Bio
::SeqFeature
::Similarity
->new(-primary
=> 'exon_hit',
205 -source
=> $self->analysis_method,
206 -seq_id
=> $hseqname,
212 # 'Location' => "$qstart..$qend",
213 'Sequence' => "$qseqname",
214 'identity' => $perc_ident,
217 push @features, Bio
::SeqFeature
::SimilarityPair
->new
220 -source
=> $self->analysis_method);
221 } elsif( /^([\-\+\?])(Intron)/) {
222 my ($name,$score,$perc_ident,$qstart,$qend,$qseqname) = split;
223 push @features, Bio
::SeqFeature
::Generic
->new(-primary
=> $2,
224 -source
=> $self->analysis_method,
229 -seq_id
=> $qseqname,
231 'identity' => $perc_ident,
232 'Sequence' => $lasthseqname});
234 } elsif( /^Segment/ ) {
236 } elsif( /^\s+$/ ) { # do nothing
238 $self->warn( "unknown line $_\n");
241 return unless( @features );
242 return wantarray ?
@features : \
@features;
245 sub _parse_gene_struct
{
249 my ($qstrand,$hstrand) = (1,1);
251 my $gene = Bio
::SeqFeature
::Gene
::GeneStructure
->new(-source
=> $self->analysis_method);
252 my $transcript = Bio
::SeqFeature
::Gene
::Transcript
->new(-source
=> $self->analysis_method);
255 while( defined($_ = $self->_readline) ) {
256 if( /Note Best alignment is between (reversed|forward) est and (reversed|forward) genome, (but|and) splice\s+sites imply\s+(forward gene|REVERSED GENE)/) {
258 $self->_pushback($_);
261 $hstrand = -1 if $1 eq 'reversed';
262 $qstrand = -1 if $4 eq 'REVERSED GENE';
265 my ($name,$score,$perc_ident,$qstart,$qend,$qseqname,$hstart,$hend, $hseqname) = split;
266 $lasthseqname = $hseqname;
267 my $exon = Bio
::SeqFeature
::Gene
::Exon
->new(-primary
=> $name,
268 -source
=> $self->analysis_method,
269 -seq_id
=> $qseqname, # FIXME WHEN WE REDO THE GENERIC NAME CHANGE
275 #'Location' => "$hstart..$hend",
276 'identity' => $perc_ident,
277 'Sequence' => "$hseqname",
280 $transcript->seq_id($qseqname) unless $transcript->seq_id;
281 $exon->add_tag_value('phase',0);
284 } elsif( /^([\-\+\?])(Intron)/) {
285 next; #intron auto matically built from exons..hope thats ok..
287 } elsif( /^Segment/ ) {
288 my ($name,$score,$perc_ident,$qstart,$qend,$qseqname,$hstart,$hend, $hseqname) = split;
289 my $query = Bio
::SeqFeature
::Similarity
->new(-primary
=> $name,
290 -source
=> $self->analysis_method,
291 -seq_id
=> $qseqname, # FIXME WHEN WE REDO THE GENERIC NAME CHANGE
297 # 'Location' => "$hstart..$hend",
298 'Sequence' => "$hseqname",
299 'identity' => $perc_ident,
302 my $hit = Bio
::SeqFeature
::Similarity
->new(-primary
=> 'exon_hit',
303 -source
=> $self->analysis_method,
304 -seq_id
=> $hseqname,
310 # 'Location' => "$qstart..$qend",
311 'Sequence' => "$qseqname",
312 'identity' => $perc_ident,
315 my $support = Bio
::SeqFeature
::SimilarityPair
->new(-query
=> $query,
317 -source
=> $self->analysis_method);
318 push @suppf, $support;
319 } elsif( /^\s+$/ ) { # do nothing
321 $self->warn( "unknown line $_\n");
324 return unless $#exon >=0;
325 foreach my $e(@exon){
327 foreach my $sf(@suppf){
328 if($sf->overlaps($e)){
332 $e->add_tag_value('supporting_feature',@add);
333 $transcript->add_exon($e);
336 $gene->add_transcript($transcript);
337 $gene->seq_id($transcript->seq_id);
344 Usage : $seqfeature = $obj->next_feature();
345 Function: Returns the next feature available in the analysis result, or
346 undef if there are no more features.
348 Returns : A Bio::SeqFeatureI implementing object, or undef if there are no
356 $self->throw("We haven't really done this right, yet, use parse_next_gene");