/usr/share/perl5/Bio/Tools/QRNA.pm is in libbio-perl-perl 1.6.924-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 | #
# BioPerl module for Bio::Tools::QRNA
#
# Please direct questions and support issues to <bioperl-l@bioperl.org>
#
# Cared for by Jason Stajich <jason-at-bioperl-dot-org>
#
# Copyright Jason Stajich
#
# You may distribute this module under the same terms as perl itself
# POD documentation - main docs before the code
=head1 NAME
Bio::Tools::QRNA - A Parser for qrna output
=head1 SYNOPSIS
use Bio::Tools::QRNA;
my $parser = Bio::Tools::QRNA->new(-file => $qrnaoutput);
while( my $feature = $parser->next_feature ) {
# do something here
}
=head1 DESCRIPTION
Parses QRNA output (E.Rivas:
http://selab.janelia.org/software.html
ftp://selab.janelia.org/pub/software/qrna/).
This module is not complete, but currently it packs information from
each QRNA alignment into a single Bio::SeqFeature::Generic object.
Not all options for QRNA output have been tested or tried. It has
been tested on sliding window output (-w -x) and shuffled output (-b
or -B).
See t/QRNA.t for example usage.
At some point we may have more complicated feature object which will
support this data rather than forcing most of the information into
tag/value pairs in a SeqFeature::Generic.
Running with -verbose =E<gt> 1 will store extra data in the feature. The
entire unparsed entry for a particular feature will be stored as a
string in the tag 'entry' it is accessible via:
my ($entry) = $f->each_tag_value('entry');
The winning model for any given alignment test will be the name stored
in the primary_tag field of feature. The bit score will stored in the
score field. The logoddpost is available via the a tag/value pair.
This example code will show how to print out the score and log odds
post for each model.
# assuming you got a feature already
print "model score logoddspost\n";
foreach my $model ( qw(OTH COD RNA) ) {
my ($score) = $f->get_tag_values("$model\_score");
my ($logoddspost) = $f->get_tag_values("$model\_logoddspost");
print "$model $score $logoddspost\n";
}
The start and end of the alignment for both the query and hit sequence
are available through the L<Bio::SeqFeature::FeaturePair> interface,
specifically L<Bio::SeqFeature::FeaturePair::feature1> and
L<Bio::SeqFeature::FeaturePair::feature2>. Additionally if you have
run QRNA with an input file which has the location of the alignment
stored in the FASTA filename as in (ID/START-END) which is the default
output format from L<Bio::AlignIO::fasta> produced alignment output,
this module will re-number start/end for the two sequences so they are
in the actual coordinates of the sequence rather than the relative
coordinates of the alignment. You may find the bioperl utillity
script search2alnblocks useful in creating your input files for QRNA.
Some other words of warning, QRNA uses a 0 based numbering system for
sequence locations, Bioperl uses a 1 based system. You'll notice that
locations will be +1 they are reported in the raw QRNA output.
=head1 FEEDBACK
=head2 Mailing Lists
User feedback is an integral part of the evolution of this and other
Bioperl modules. Send your comments and suggestions preferably to
the Bioperl mailing list. Your participation is much appreciated.
bioperl-l@bioperl.org - General discussion
http://bioperl.org/wiki/Mailing_lists - About the mailing lists
=head2 Support
Please direct usage questions or support issues to the mailing list:
I<bioperl-l@bioperl.org>
rather than to the module maintainer directly. Many experienced and
reponsive experts will be able look at the problem and quickly
address it. Please include a thorough description of the problem
with code and data examples if at all possible.
=head2 Reporting Bugs
Report bugs to the Bioperl bug tracking system to help us keep track
of the bugs and their resolution. Bug reports can be submitted via
the web:
https://github.com/bioperl/bioperl-live/issues
=head1 AUTHOR - Jason Stajich
Email jason-at-bioperl-dot-org
=head1 APPENDIX
The rest of the documentation details each of the object methods.
Internal methods are usually preceded with a _
=cut
# Let the code begin...
package Bio::Tools::QRNA;
use vars qw(@Models);
use strict;
use Bio::SeqFeature::Generic;
use Bio::SeqFeature::FeaturePair;
use base qw(Bio::Root::IO Bio::SeqAnalysisParserI);
@Models = qw(OTH COD RNA);
=head2 new
Title : new
Usage : my $obj = Bio::Tools::QRNA->new();
Function: Builds a new Bio::Tools::QRNA object
Returns : an instance of Bio::Tools::QRNA
Args : -fh/-file filehandle/filename standard input for
Bio::Root:IO objects
=cut
=head2 next_feature
Title : next_feature
Usage : my $feature = $parser->next_feature
Function: Get the next QRNA feature
Returns :
Args :
=cut
sub next_feature {
my ($self) = @_;
my $f = shift @{$self->{'_parsed_features'} || []};
if( ! defined $f && $self->_parse_pair ) {
$f = shift @{$self->{'_parsed_features'} || []};
}
return $f;
}
sub _parse_pair {
my ($self,@args) = @_;
my (@features,%data);
my $seenstart = 0;
while( defined( $_ = $self->_readline) ) {
next if( /^\#\-\-/o );
if( /^\#\s+(qrna)\s+(\S+)\s+\(([^\)]+)\)/o ) {
$self->program_name($1);
$self->program_version($2);
$self->program_date($3);
} elsif( /^\#\s+(PAM model)\s+\=\s+(.+)\s+$/o ) {
$self->PAM_model($2);
} elsif( /^\#\s+(RNA model)\s+\=\s+(\S+)/o ) {
$self->RNA_model($2);
} elsif( /^\#\s+(seq file)\s+\=\s+(.+)\s+$/o ) {
$self->seq_file($2);
} elsif( /^\#\s+(\d+)\s+\[([\-+])\s+strand\]/o ) {
if( $seenstart ) {
if( $data{'alignment_len'} ) {
push @features, $self->_make_feature(\%data);
}
$self->_pushback($_);
last;
}
$seenstart = 1;
} elsif( /^\#/ ) {
next;
} elsif( />(\S+)\s+\((\d+)\)/ ) {
if( @{$data{'seqs'} || []} == 2 ) {
$self->warn( "already seen seqs ".join(' ', ,map { $_->[0] }
@{$data{'seqs'}}). "\n");
} else {
push @{$data{'seqs'}}, [$1,$2];
}
} elsif( /^length alignment:\s+(\d+)\s+\(id\=(\d+(\.\d+)?)\)/o ) {
if( $data{'alignment_len'} ) {
push @features, $self->_make_feature(\%data);
# reset all the data but the 'seqs' field
%data = ( 'seqs' => $data{'seqs'} );
}
if( /\(((sre_)?shuffled)\)/ ) {
$data{'shuffled'} = $1;
}
$data{'alignment_len'} = $1;
$data{'alignment_pid'} = $2;
} elsif ( /^pos([XY]):\s+(\d+)\-(\d+)\s+\[(\d+)\-(\d+)\]\((\d+)\)\s+
\-\-\s+\((\S+\s+\S+\s+\S+\s+\S+)\)/ox ) {
$data{"seq\_$1"}->{'aln'} = [ $2,$3, $4,$5, $6];
@{$data{"seq\_$1"}->{'base_comp'}} = split(/\s+/,$7);
} elsif( /^winner\s+\=\s+(\S{3})/ ) {
$data{'winning_model'} = $1;
} elsif( /^(\S{3})\s+ends\s+\=\s+(\-?\d+)\s+(\-?\d+)/ ) {
# QRNA is 0-based
# Bioperl is 1 based
$data{'model_location'}->{$1} = [ $2,$3 ];
} elsif( /^\s+(logoddspost)?OTH\s+\=\s+/ox ) {
while( /(\S+)\s+\=\s+(\-?\d+(\.\d+))/g ) {
my ($model,$score)= ($1,$2);
if( $model =~ s/^logoddspost// ) {
$data{'model_scores'}->{'logoddspost'}->{$model} = $score;
} else {
$data{'model_scores'}->{'bits'}->{$model} = $score;
}
}
}
$data{'entry'} .= $_;
}
if( @features ) {
push @{$self->{'_parsed_features'}}, @features;
return scalar @features;
}
return 0;
}
=head2 PAM_model
Title : PAM_model
Usage : $obj->PAM_model($newval)
Function:
Example :
Returns : value of PAM_model (a scalar)
Args : on set, new value (a scalar or undef, optional)
=cut
sub PAM_model{
my $self = shift;
return $self->{'PAM_model'} = shift if @_;
return $self->{'PAM_model'};
}
=head2 RNA_model
Title : RNA_model
Usage : $obj->RNA_model($newval)
Function:
Example :
Returns : value of RNA_model (a scalar)
Args : on set, new value (a scalar or undef, optional)
=cut
sub RNA_model{
my $self = shift;
return $self->{'RNA_model'} = shift if @_;
return $self->{'RNA_model'};
}
=head2 seq_file
Title : seq_file
Usage : $obj->seq_file($newval)
Function:
Example :
Returns : value of seq_file (a scalar)
Args : on set, new value (a scalar or undef, optional)
=cut
sub seq_file{
my $self = shift;
return $self->{'seq_file'} = shift if @_;
return $self->{'seq_file'};
}
=head2 program_name
Title : program_name
Usage : $obj->program_name($newval)
Function:
Example :
Returns : value of program_name (a scalar)
Args : on set, new value (a scalar or undef, optional)
=cut
sub program_name{
my $self = shift;
return $self->{'program_name'} = shift if @_;
return $self->{'program_name'} || 'qrna';
}
=head2 program_version
Title : program_version
Usage : $obj->program_version($newval)
Function:
Example :
Returns : value of program_version (a scalar)
Args : on set, new value (a scalar or undef, optional)
=cut
sub program_version{
my $self = shift;
return $self->{'program_version'} = shift if @_;
return $self->{'program_version'};
}
=head2 program_date
Title : program_date
Usage : $obj->program_date($newval)
Function:
Example :
Returns : value of program_date (a scalar)
Args : on set, new value (a scalar or undef, optional)
=cut
sub program_date{
my $self = shift;
return $self->{'program_date'} = shift if @_;
return $self->{'program_date'};
}
sub _make_feature {
my ($self,$data) = @_;
my ($qoffset,$hoffset) = (1,1);
# when you run qrna and have produced ID/START-END
# formatted input strings we can remap the location
# to the original
# name is stored as the first entry in the seq array ref
my ($qid,$hid) = ( $data->{'seqs'}->[0]->[0],
$data->{'seqs'}->[1]->[0]);
if( $qid =~ /(\S+)\/(\d+)\-(\d+)/ ) {
($qid,$qoffset) = ($1,$2);
}
if( $hid =~ /(\S+)\/(\d+)\-(\d+)/ ) {
($hid,$hoffset) = ($1,$2);
}
my $f = Bio::SeqFeature::FeaturePair->new();
my ($s,$e) = @{$data->{'model_location'}->{$data->{'winning_model'}}};
my $qf = Bio::SeqFeature::Generic->new
( -primary_tag => $data->{'winning_model'},
-source_tag => $self->program_name,
-score => $data->{'model_scores'}->{'bits'}->{$data->{'winning_model'}},
-start => $s+$qoffset,
-end => $e+$qoffset,
-seq_id => $qid,
-strand => ($s < $e ) ? 1 : -1,
);
my $hf = Bio::SeqFeature::Generic->new
( -primary_tag => $qf->primary_tag,
-source_tag => $qf->source_tag,
-score => $qf->score,
-seq_id => $hid,
-start => $s + $hoffset,
-end => $e + $hoffset,
-strand => $qf->strand,
);
$f->feature1($qf);
$f->feature2($hf);
$f->add_tag_value('alignment_len', $data->{'alignment_len'});
$f->add_tag_value('alignment_pid', $data->{'alignment_pid'});
# store the other model scores and data
foreach my $model ( @Models ) {
$f->add_tag_value("$model\_score", $data->{'model_scores'}->{'bits'}->{$model});
$f->add_tag_value("$model\_logoddspost", $data->{'model_scores'}->{'logoddspost'}->{$model});
if( ! $data->{'model_location'}->{$model} ) {
if( $self->verbose > 0 ) {
$self->debug( $data->{'entry'} );
}
$self->throw("no location parsed for $model in ",
(map { @$_ } @{$data->{'seqs'}}), " ", $f->start, " ", $f->end);
} else {
$f->add_tag_value("$model\_positions",
join("..",@{$data->{'model_location'}->{$model} }));
}
}
# probably a better way to store this - as
# a seq object perhaps
$f->add_tag_value('seq1', @{$data->{'seqs'}->[0]});
$f->add_tag_value('seq2', @{$data->{'seqs'}->[1]});
$f->add_tag_value('entry', $data->{'entry'}) if $self->verbose > 0;
if( $data->{'shuffled'} ) {
$f->add_tag_value('shuffled', $data->{'shuffled'});
}
return $f;
}
1;
|