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
;
89 # Object preamble - inherits from Bio::Root::Root
92 use Bio
::SeqFeature
::Gene
::Exon
;
93 use Bio
::SeqFeature
::Gene
::Transcript
;
94 use Bio
::SeqFeature
::Gene
::Intron
;
95 use Bio
::SeqFeature
::Gene
::GeneStructure
;
96 use Bio
::SeqFeature
::SimilarityPair
;
98 use base
qw(Bio::Tools::AnalysisResult);
103 Usage : my $obj = Bio::Tools::Est2Genome->new();
104 Function: Builds a new Bio::Tools::Est2Genome object
105 Returns : an instance of Bio::Tools::Est2Genome
106 Args : -file => 'output.est2genome' or
107 -fh => \*EST2GENOMEOUTPUT
108 -genomefirst => 1 # genome was the first input (not standard)
112 sub _initialize_state
{
113 my($self,@args) = @_;
115 # call the inherited method first
116 my $make = $self->SUPER::_initialize_state
(@args);
118 my ($genome_is_first) = $self->_rearrange([qw(GENOMEFIRST)], @args);
120 delete($self->{'_genome_is_first'});
121 $self->{'_genome_is_first'} = $genome_is_first if(defined($genome_is_first));
122 $self->analysis_method("est2genome");
125 =head2 analysis_method
127 Usage : $sim4->analysis_method();
128 Purpose : Inherited method. Overridden to ensure that the name matches
136 sub analysis_method
{
138 my ($self, $method) = @_;
139 if($method && ($method !~ /est2genome/i)) {
140 $self->throw("method $method not supported in " . ref($self));
142 return $self->SUPER::analysis_method
($method);
145 =head2 parse_next_gene
147 Title : parse_next_gene
148 Usage : @gene = $est2genome_result->parse_next_gene;
149 foreach $exon (@exons) {
153 Function: Parses the next alignments of the est2genome result file and
154 returns the found exons as an array of
155 Bio::SeqFeature::SimilarityPair objects. Call
156 this method repeatedly until an empty array is returned to get the
157 results for all alignments.
159 The $exon->seq_id() attribute will be set to the identifier of the
160 respective sequence for both sequences.
161 The length is accessible via the seqlength()
162 attribute of $exon->query() and
164 Returns : An array (or array reference) of Bio::SeqFeature::SimilarityPair and Bio::SeqFeature::Generic objects
165 or Bio::SeqFeature::Gene::GeneStructure
166 Args : flag(1/0) indicating to return Bio::SeqFeature::Gene::GeneStructure or Bio::SeqFeature::SimilarityPair
171 sub parse_next_gene
{
172 my ($self,$return_gene) = @_;
173 return $self->_parse_gene_struct if $return_gene;
176 my ($qstrand,$hstrand) = (1,1);
178 while( defined($_ = $self->_readline) ) {
179 if( /Note Best alignment is between (reversed|forward) est and (reversed|forward) genome, (but|and) splice\s+sites imply\s+(forward gene|REVERSED GENE)/) {
181 $self->_pushback($_);
182 return wantarray ?
@features : \
@features;
184 $hstrand = -1 if $1 eq 'reversed';
185 $qstrand = -1 if $4 eq 'REVERSED GENE';
186 #$self->debug( "1=$1, 2=$2, 4=$4\n");
189 my ($name,$score,$perc_ident,$qstart,$qend,$qseqname,
190 $hstart,$hend, $hseqname) = split;
191 $lasthseqname = $hseqname;
192 my $query = Bio
::SeqFeature
::Similarity
->new(-primary
=> $name,
193 -source
=> $self->analysis_method,
194 -seq_id
=> $qseqname, # FIXME WHEN WE REDO THE GENERIC NAME CHANGE
200 # 'Location' => "$hstart..$hend",
201 'Sequence' => "$hseqname",
202 'identity' => $perc_ident,
205 my $hit = Bio
::SeqFeature
::Similarity
->new(-primary
=> 'exon_hit',
206 -source
=> $self->analysis_method,
207 -seq_id
=> $hseqname,
213 # 'Location' => "$qstart..$qend",
214 'Sequence' => "$qseqname",
215 'identity' => $perc_ident,
218 push @features, Bio
::SeqFeature
::SimilarityPair
->new
221 -source
=> $self->analysis_method);
222 } elsif( /^([\-\+\?])(Intron)/) {
223 my ($name,$score,$perc_ident,$qstart,$qend,$qseqname) = split;
224 push @features, Bio
::SeqFeature
::Generic
->new(-primary
=> $2,
225 -source
=> $self->analysis_method,
230 -seq_id
=> $qseqname,
232 'identity' => $perc_ident,
233 'Sequence' => $lasthseqname});
235 } elsif( /^Segment/ ) {
237 } elsif( /^\s+$/ ) { # do nothing
239 $self->warn( "unknown line $_\n");
242 return unless( @features );
243 return wantarray ?
@features : \
@features;
246 sub _parse_gene_struct
{
250 my ($qstrand,$hstrand) = (1,1);
252 my $gene = Bio
::SeqFeature
::Gene
::GeneStructure
->new(-source
=> $self->analysis_method);
253 my $transcript = Bio
::SeqFeature
::Gene
::Transcript
->new(-source
=> $self->analysis_method);
256 while( defined($_ = $self->_readline) ) {
257 if( /Note Best alignment is between (reversed|forward) est and (reversed|forward) genome, (but|and) splice\s+sites imply\s+(forward gene|REVERSED GENE)/) {
259 $self->_pushback($_);
262 $hstrand = -1 if $1 eq 'reversed';
263 $qstrand = -1 if $4 eq 'REVERSED GENE';
266 my ($name,$score,$perc_ident,$qstart,$qend,$qseqname,$hstart,$hend, $hseqname) = split;
267 $lasthseqname = $hseqname;
268 my $exon = Bio
::SeqFeature
::Gene
::Exon
->new(-primary
=> $name,
269 -source
=> $self->analysis_method,
270 -seq_id
=> $qseqname, # FIXME WHEN WE REDO THE GENERIC NAME CHANGE
276 #'Location' => "$hstart..$hend",
277 'identity' => $perc_ident,
278 'Sequence' => "$hseqname",
281 $transcript->seq_id($qseqname) unless $transcript->seq_id;
282 $exon->add_tag_value('phase',0);
285 } elsif( /^([\-\+\?])(Intron)/) {
286 next; #intron auto matically built from exons..hope thats ok..
288 } elsif( /^Segment/ ) {
289 my ($name,$score,$perc_ident,$qstart,$qend,$qseqname,$hstart,$hend, $hseqname) = split;
290 my $query = Bio
::SeqFeature
::Similarity
->new(-primary
=> $name,
291 -source
=> $self->analysis_method,
292 -seq_id
=> $qseqname, # FIXME WHEN WE REDO THE GENERIC NAME CHANGE
298 # 'Location' => "$hstart..$hend",
299 'Sequence' => "$hseqname",
300 'identity' => $perc_ident,
303 my $hit = Bio
::SeqFeature
::Similarity
->new(-primary
=> 'exon_hit',
304 -source
=> $self->analysis_method,
305 -seq_id
=> $hseqname,
311 # 'Location' => "$qstart..$qend",
312 'Sequence' => "$qseqname",
313 'identity' => $perc_ident,
316 my $support = Bio
::SeqFeature
::SimilarityPair
->new(-query
=> $query,
318 -source
=> $self->analysis_method);
319 push @suppf, $support;
320 } elsif( /^\s+$/ ) { # do nothing
322 $self->warn( "unknown line $_\n");
325 return unless $#exon >=0;
326 foreach my $e(@exon){
328 foreach my $sf(@suppf){
329 if($sf->overlaps($e)){
333 $e->add_tag_value('supporting_feature',@add);
334 $transcript->add_exon($e);
337 $gene->add_transcript($transcript);
338 $gene->seq_id($transcript->seq_id);
345 Usage : $seqfeature = $obj->next_feature();
346 Function: Returns the next feature available in the analysis result, or
347 undef if there are no more features.
349 Returns : A Bio::SeqFeatureI implementing object, or undef if there are no
357 $self->throw("We haven't really done this right, yet, use parse_next_gene");