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
;
85 use Bio
::SeqFeature
::Generic
;
87 use base
qw(Bio::Tools::AnalysisResult);
89 use vars
qw($GeneTag $SrcTag $ExonTag);
90 ($GeneTag,$SrcTag,$ExonTag) = qw(gene tRNAscan-SE exon);
95 Usage : my $obj = Bio::Tools::tRNAscanSE->new();
96 Function: Builds a new Bio::Tools::tRNAscanSE object
97 Returns : an instance of Bio::Tools::tRNAscanSE
98 Args : -fh/-file for input filename
99 -genetag => primary tag used in gene features (default 'tRNA_gene')
100 -exontag => primary tag used in exon features (default 'tRNA_exon')
101 -srctag => source tag used in all features (default 'tRNAscan-SE')
107 my($self,@args) = @_;
108 $self->SUPER::_initialize
(@args);
109 my ($genetag,$exontag,$srctag) = $self->SUPER::_rearrange
([qw(GENETAG
113 $self->gene_tag(defined $genetag ?
$genetag : $GeneTag);
114 $self->source_tag(defined $srctag ?
$srctag : $SrcTag);
115 $self->exon_tag(defined $exontag ?
$exontag : $ExonTag);
116 $self->{'_seen'} = {};
122 Usage : $obj->gene_tag($newval)
123 Function: Get/Set the value used for the 'gene_tag' of genes
124 Default is 'tRNA_gene' as set by the global $GeneTag
125 Returns : value of gene_tag (a scalar)
126 Args : on set, new value (a scalar or undef, optional)
134 return $self->{'gene_tag'} = shift if @_;
135 return $self->{'gene_tag'};
141 Usage : $obj->source_tag($newval)
142 Function: Get/Set the value used for the 'source_tag' of exons and genes
143 Default is 'tRNAscan-SE' as set by the global $SrcTag
144 Returns : value of source_tag (a scalar)
145 Args : on set, new value (a scalar or undef, optional)
153 return $self->{'_source_tag'} = shift if @_;
154 return $self->{'_source_tag'};
160 Usage : $obj->exon_tag($newval)
161 Function: Get/Set the value used for the 'primary_tag' of exons
162 Default is 'tRNA_exon' as set by the global $ExonTag
163 Returns : value of exon_tag (a scalar)
164 Args : on set, new value (a scalar or undef, optional)
172 return $self->{'_exon_tag'} = shift if @_;
173 return $self->{'_exon_tag'};
177 =head2 analysis_method
179 Usage : $genscan->analysis_method();
180 Purpose : Inherited method. Overridden to ensure that the name matches
188 sub analysis_method
{
190 my ($self, $method) = @_;
191 if($method && ($method !~ /tRNAscan-SE/i)) {
192 $self->throw("method $method not supported in " . ref($self));
194 return $self->SUPER::analysis_method
($method);
200 Usage : while($gene = $genscan->next_feature()) {
203 Function: Returns the next gene structure prediction of the Genscan result
204 file. Call this method repeatedly until FALSE is returned.
206 The returned object is actually a SeqFeatureI implementing object.
207 This method is required for classes implementing the
208 SeqAnalysisParserI interface, and is merely an alias for
209 next_prediction() at present.
212 Returns : A Bio::SeqFeature::Generic object.
214 See also : L<Bio::SeqFeature::Generic>
219 my ($self,@args) = @_;
220 # even though next_prediction doesn't expect any args (and this method
221 # does neither), we pass on args in order to be prepared if this changes
223 return $self->next_prediction(@args);
226 =head2 next_prediction
228 Title : next_prediction
229 Usage : while($gene = $genscan->next_prediction()) {
232 Function: Returns the next gene structure prediction of the Genscan result
233 file. Call this method repeatedly until FALSE is returned.
236 Returns : A Bio::SeqFeature::Generic object.
238 See also : L<Bio::SeqFeature::Generic>
242 sub next_prediction
{
244 my ($genetag,$srctag,$exontag) = ( $self->gene_tag,
248 while( defined($_ = $self->_readline) ) {
249 if( m
/^(\S
+)\s
+ # sequence name
251 (\d
+)\s
+(\d
+)\s
+ # tRNA start,end
252 (\w
{3})\s
+ # tRNA type
253 ([CAGT
]{3})\s
+ # Codon
254 (\d
+)\s
+(\d
+)\s
+ # Intron Begin End
255 (\d
+\
.\d
+)/ox
# Cove Score
258 my ($seqid,$tRNAnum,$start,$end,$type,
259 $codon,$intron_start,$intron_end,
260 $score) = ($1,$2,$3,$4,$5,$6,$7,$8,$9);
263 if( $start > $end ) {
264 ($start,$end,$strand) = ($end,$start,-1);
266 if( $self->{'_seen'}->{$type}++ ) {
267 $type .= "-".$self->{'_seen'}->{$type};
269 my $gene = Bio
::SeqFeature
::Generic
->new
275 -primary_tag
=> $genetag,
276 -source_tag
=> $srctag,
278 'ID' => "tRNA:$type",
279 'Name' => "tRNA:$type",
280 'AminoAcid' => $type,
283 if( $intron_start ) {
284 if( $intron_start > $intron_end ) {
285 ($intron_start,$intron_end) = ($intron_end,$intron_start);
287 $gene->add_SeqFeature(Bio
::SeqFeature
::Generic
->new
290 -end
=> $intron_start-1,
292 -primary_tag
=> $exontag,
293 -source_tag
=> $srctag,
295 'Parent' => "tRNA:$type",
297 $gene->add_SeqFeature(Bio
::SeqFeature
::Generic
->new
299 -start
=> $intron_end+1,
302 -primary_tag
=> $exontag,
303 -source_tag
=> $srctag,
305 'Parent' => "tRNA:$type"
308 $gene->add_SeqFeature(Bio
::SeqFeature
::Generic
->new
313 -primary_tag
=> $exontag,
314 -source_tag
=> $srctag,
316 'Parent' => "tRNA:$type"