2 # BioPerl module for Bio::Tools::tRNAscanSE
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::tRNAscanSE - A parser for tRNAscan-SE output
20 use Bio::Tools::tRNAscanSE;
22 my $parser = Bio::Tools::tRNAscanSE->new(-file => 'result.tRNAscanSE');
25 while( my $gene = $parser->next_prediction ) {
27 @exon_arr = $gene->get_SeqFeatures();
33 This script will parse tRNAscan-SE output. Just the tabular output of
34 the tRNA locations in the genome for now.
40 User feedback is an integral part of the evolution of this and other
41 Bioperl modules. Send your comments and suggestions preferably to
42 the Bioperl mailing list. Your participation is much appreciated.
44 bioperl-l@bioperl.org - General discussion
45 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
49 Please direct usage questions or support issues to the mailing list:
51 I<bioperl-l@bioperl.org>
53 rather than to the module maintainer directly. Many experienced and
54 reponsive experts will be able look at the problem and quickly
55 address it. Please include a thorough description of the problem
56 with code and data examples if at all possible.
60 Report bugs to the Bioperl bug tracking system to help us keep track
61 of the bugs and their resolution. Bug reports can be submitted via the
64 https://github.com/bioperl/bioperl-live/issues
66 =head1 AUTHOR - Jason Stajich
68 Email jason-at-bioperl.org
72 The rest of the documentation details each of the object methods.
73 Internal methods are usually preceded with a _
78 # Let the code begin...
81 package Bio
::Tools
::tRNAscanSE
;
84 use Bio
::SeqFeature
::Generic
;
86 use base
qw(Bio::Tools::AnalysisResult);
88 use vars
qw($GeneTag $SrcTag $ExonTag);
89 ($GeneTag,$SrcTag,$ExonTag) = qw(gene tRNAscan-SE exon);
94 Usage : my $obj = Bio::Tools::tRNAscanSE->new();
95 Function: Builds a new Bio::Tools::tRNAscanSE object
96 Returns : an instance of Bio::Tools::tRNAscanSE
97 Args : -fh/-file for input filename
98 -genetag => primary tag used in gene features (default 'tRNA_gene')
99 -exontag => primary tag used in exon features (default 'tRNA_exon')
100 -srctag => source tag used in all features (default 'tRNAscan-SE')
106 my($self,@args) = @_;
107 $self->SUPER::_initialize
(@args);
108 my ($genetag,$exontag,$srctag) = $self->SUPER::_rearrange
([qw(GENETAG
112 $self->gene_tag(defined $genetag ?
$genetag : $GeneTag);
113 $self->source_tag(defined $srctag ?
$srctag : $SrcTag);
114 $self->exon_tag(defined $exontag ?
$exontag : $ExonTag);
115 $self->{'_seen'} = {};
121 Usage : $obj->gene_tag($newval)
122 Function: Get/Set the value used for the 'gene_tag' of genes
123 Default is 'tRNA_gene' as set by the global $GeneTag
124 Returns : value of gene_tag (a scalar)
125 Args : on set, new value (a scalar or undef, optional)
133 return $self->{'gene_tag'} = shift if @_;
134 return $self->{'gene_tag'};
140 Usage : $obj->source_tag($newval)
141 Function: Get/Set the value used for the 'source_tag' of exons and genes
142 Default is 'tRNAscan-SE' as set by the global $SrcTag
143 Returns : value of source_tag (a scalar)
144 Args : on set, new value (a scalar or undef, optional)
152 return $self->{'_source_tag'} = shift if @_;
153 return $self->{'_source_tag'};
159 Usage : $obj->exon_tag($newval)
160 Function: Get/Set the value used for the 'primary_tag' of exons
161 Default is 'tRNA_exon' as set by the global $ExonTag
162 Returns : value of exon_tag (a scalar)
163 Args : on set, new value (a scalar or undef, optional)
171 return $self->{'_exon_tag'} = shift if @_;
172 return $self->{'_exon_tag'};
176 =head2 analysis_method
178 Usage : $genscan->analysis_method();
179 Purpose : Inherited method. Overridden to ensure that the name matches
187 sub analysis_method
{
189 my ($self, $method) = @_;
190 if($method && ($method !~ /tRNAscan-SE/i)) {
191 $self->throw("method $method not supported in " . ref($self));
193 return $self->SUPER::analysis_method
($method);
199 Usage : while($gene = $genscan->next_feature()) {
202 Function: Returns the next gene structure prediction of the Genscan result
203 file. Call this method repeatedly until FALSE is returned.
205 The returned object is actually a SeqFeatureI implementing object.
206 This method is required for classes implementing the
207 SeqAnalysisParserI interface, and is merely an alias for
208 next_prediction() at present.
211 Returns : A Bio::SeqFeature::Generic object.
213 See also : L<Bio::SeqFeature::Generic>
218 my ($self,@args) = @_;
219 # even though next_prediction doesn't expect any args (and this method
220 # does neither), we pass on args in order to be prepared if this changes
222 return $self->next_prediction(@args);
225 =head2 next_prediction
227 Title : next_prediction
228 Usage : while($gene = $genscan->next_prediction()) {
231 Function: Returns the next gene structure prediction of the Genscan result
232 file. Call this method repeatedly until FALSE is returned.
235 Returns : A Bio::SeqFeature::Generic object.
237 See also : L<Bio::SeqFeature::Generic>
241 sub next_prediction
{
243 my ($genetag,$srctag,$exontag) = ( $self->gene_tag,
247 while( defined($_ = $self->_readline) ) {
248 if( m
/^(\S
+)\s
+ # sequence name
250 (\d
+)\s
+(\d
+)\s
+ # tRNA start,end
251 (\w
{3})\s
+ # tRNA type
252 ([CAGT
]{3})\s
+ # Codon
253 (\d
+)\s
+(\d
+)\s
+ # Intron Begin End
254 (\d
+\
.\d
+)/ox
# Cove Score
257 my ($seqid,$tRNAnum,$start,$end,$type,
258 $codon,$intron_start,$intron_end,
259 $score) = ($1,$2,$3,$4,$5,$6,$7,$8,$9);
262 if( $start > $end ) {
263 ($start,$end,$strand) = ($end,$start,-1);
265 if( $self->{'_seen'}->{$type}++ ) {
266 $type .= "-".$self->{'_seen'}->{$type};
268 my $gene = Bio
::SeqFeature
::Generic
->new
274 -primary_tag
=> $genetag,
275 -source_tag
=> $srctag,
277 'ID' => "tRNA:$type",
278 'Name' => "tRNA:$type",
279 'AminoAcid' => $type,
282 if( $intron_start ) {
283 if( $intron_start > $intron_end ) {
284 ($intron_start,$intron_end) = ($intron_end,$intron_start);
286 $gene->add_SeqFeature(Bio
::SeqFeature
::Generic
->new
289 -end
=> $intron_start-1,
291 -primary_tag
=> $exontag,
292 -source_tag
=> $srctag,
294 'Parent' => "tRNA:$type",
296 $gene->add_SeqFeature(Bio
::SeqFeature
::Generic
->new
298 -start
=> $intron_end+1,
301 -primary_tag
=> $exontag,
302 -source_tag
=> $srctag,
304 'Parent' => "tRNA:$type"
307 $gene->add_SeqFeature(Bio
::SeqFeature
::Generic
->new
312 -primary_tag
=> $exontag,
313 -source_tag
=> $srctag,
315 'Parent' => "tRNA:$type"