/usr/share/perl5/Bio/Tools/PrositeScan.pm is in libbio-perl-perl 1.6.924-3.
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 | =head1 NAME
Bio::Tools::PrositeScan - Parser for ps_scan result
=head1 SYNOPSIS
use Bio::Tools::PrositeScan;
my $factory = Bio::Tools::PrositeScan->new(
-file => 'out.PrositeScan'
);
while(my $match = $factory->next_prediction){
# $match is of Bio::SeqFeature::FeaturePair
my $q_id = $fatch->feature1->seq_id;
my $h_id = $fatch->feature2->seq_id;
}
=head1 DESCRIPTION
This is the parser of the output of ps_scan program. It takes either a file
handler or a file name, and returns a Bio::SeqFeature::FeaturePair object.
=head1 AUTHOR
Juguang Xiao, juguang@tll.org.sg
=cut
# Let the code begin...
package Bio::Tools::PrositeScan;
use vars qw(@FORMATS);
use strict;
use Bio::Seq;
use Bio::SeqFeature::Generic;
use Bio::SeqFeature::FeaturePair;
use base qw(Bio::Root::Root Bio::Root::IO);
@FORMATS = qw(SCAN FASTA PSA MSA PFF MATCHLIST);
=head2 new
Title : new
Usage : Bio::Tools::PrositeScan->new(-file => 'out.PrositeScan');
Bio::Tools::PrositeScan->new(-fh => \*FH);
Returns : L<Bio::Tools::PrositeScan>
=cut
sub new {
my ($class, @args) = @_;
my $self = $class->SUPER::new(@args);
$self->_initialize_io(@args);
my ($format) = $self->_rearrange([qw(FORMAT)], @args);
$format || $self->throw("format needed");
if(grep /^$format$/i, @FORMATS){
$self->format($format);
}else{
$self->throw("Invalid format, [$format]");
}
return $self;
}
sub format {
my $self = shift;
return $self->{_format} = shift if(@_);
return $self->{_format};
}
=head2 next_prediction
Title : new
Usage :
while($result = $factory->next_prediction){
;
}
Returns : a Bio::SeqFeature::FeaturePair object
=cut
sub next_prediction {
my ($self) = @_;
unless($self->_parsed){
$self->_parse;
$self->_parsed(1);
}
return shift @{$self->{_matches}};
}
sub next_result {
return shift->next_prediction;
}
sub _parsed {
my $self = shift;
return $self->{_parsed} = 1 if @_ && $_[0];
return $self->{_parsed};
}
sub _parse {
my $self = shift;
my $format = $self->format;
if($self->format =~ /^fasta$/){
$self->_parse_fasta;
}else{
$self->throw("the [$format] parser has not been written");
}
}
sub _parse_fasta {
my ($self) = @_;
my @matches;
my $fp;
my $seq;
while(defined($_ = $self->_readline)){
chop;
if(/^\>([^>]+)/){
my $fasta_head = $1;
if($fasta_head =~ /([^\/]+)\/(\d+)\-(\d+)(\s+)\:(\s+)(\S+)/){
my $q_id = $1;
my $q_start = $2;
my $q_end = $3;
my $h_id = $6;
if(defined $fp){
$self->_attach_seq($seq, $fp);
push @matches, $fp;
}
$fp = Bio::SeqFeature::FeaturePair->new(
-feature1 => Bio::SeqFeature::Generic->new(
-seq_id => $q_id,
-start => $q_start,
-end => $q_end
),
-feature2 => Bio::SeqFeature::Generic->new(
-seq_id => $h_id,
-start => 0,
-end => 0
)
);
$seq = '';
}else{
$self->throw("ERR:\t\[$_\]");
}
}else{ # sequence lines, ignored
$seq .= $_;
}
}
if(defined $fp){
$self->_attach_seq($seq, $fp);
push @matches, $fp;
}
push @{$self->{_matches}}, @matches;
}
sub _attach_seq {
my ($self, $seq, $fp) = @_;
if(defined $fp){
my $whole_seq = 'X' x ($fp->start-1);
$whole_seq .= $seq;
$fp->feature1->attach_seq(
Bio::Seq->new(-seq => $whole_seq)
);
}
}
1;
|