/usr/share/perl5/Bio/Tools/PrositeScan.pm is in libbio-perl-perl 1.7.2-2.
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 | =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',
-format => 'fasta'
);
while(my $match = $factory->next_prediction){
# $match is a Bio::SeqFeature::FeaturePair
# Sequence ID
my $seq_id = $match->seq_id;
# PROSITE accession number
my $psac = $match->hseq_id;
# Coordinates
my @coords = ( $match->start, $match->end );
# Subsequence
my $seq = $match->feature1->seq;
}
=head1 DESCRIPTION
This is a parser of the output of the ps_scan program. It takes either a file
handle or a file name, and returns a L<Bio::SeqFeature::FeaturePair> object.
Note that the current implementation parses the entire file at once.
=head1 AUTHOR
Juguang Xiao, juguang@tll.org.sg
=head1 SEE ALSO
=over
=item * L<ps_scan software|ftp://ftp.expasy.org/databases/prosite/ps_scan>
=item * L<PROSITE User Manual|http://prosite.expasy.org/prosuser.html>
=back
=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>
Args : -format => string representing the format type for the
ps_scan output, REQUIRED
The C<-format> argument must currently be set to C<fasta> since this is the
only parser implemented. This corresponds with using the ps_scan arguments
C<-o fasta>.
=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 where
feature1 is the matched subsequence and
feature2 is the PROSITE accession number.
See <http://prosite.expasy.org/prosuser.html#conv_ac>.
=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;
|