4 Bio::Tools::PrositeScan - Parser for ps_scan result
8 use Bio::Tools::PrositeScan;
10 my $factory = Bio::Tools::PrositeScan->new(
11 -file => 'out.PrositeScan'
14 while(my $match = $factory->next_prediction){
15 # $match is of Bio::SeqFeature::FeaturePair
16 my $q_id = $fatch->feature1->seq_id;
17 my $h_id = $fatch->feature2->seq_id;
22 This is the parser of the output of ps_scan program. It takes either a file
23 handler or a file name, and returns a Bio::SeqFeature::FeaturePair object.
27 Juguang Xiao, juguang@tll.org.sg
31 # Let the code begin...
33 package Bio
::Tools
::PrositeScan
;
34 use vars
qw(@FORMATS);
37 use Bio::SeqFeature::Generic;
38 use Bio::SeqFeature::FeaturePair;
40 use base qw(Bio::Root::Root Bio::Root::IO);
41 @FORMATS = qw(SCAN FASTA PSA MSA PFF MATCHLIST);
46 Usage : Bio::Tools::PrositeScan->new(-file => 'out.PrositeScan');
47 Bio::Tools::PrositeScan->new(-fh => \*FH);
48 Returns : L<Bio::Tools::PrositeScan>
53 my ($class, @args) = @_;
54 my $self = $class->SUPER::new
(@args);
55 $self->_initialize_io(@args);
56 my ($format) = $self->_rearrange([qw(FORMAT)], @args);
57 $format || $self->throw("format needed");
58 if(grep /^$format$/i, @FORMATS){
59 $self->format($format);
61 $self->throw("Invalid format, [$format]");
68 return $self->{_format
} = shift if(@_);
69 return $self->{_format
};
72 =head2 next_prediction
76 while($result = $factory->next_prediction){
80 Returns : a Bio::SeqFeature::FeaturePair object
86 unless($self->_parsed){
90 return shift @
{$self->{_matches
}};
94 return shift->next_prediction;
99 return $self->{_parsed
} = 1 if @_ && $_[0];
100 return $self->{_parsed
};
105 my $format = $self->format;
106 if($self->format =~ /^fasta$/){
109 $self->throw("the [$format] parser has not been written");
118 while(defined($_ = $self->_readline)){
122 if($fasta_head =~ /([^\/]+)\
/(\d+)\-(\d+)(\s+)\:(\s+)(\S+)/){
128 $self->_attach_seq($seq, $fp);
131 $fp = Bio
::SeqFeature
::FeaturePair
->new(
132 -feature1
=> Bio
::SeqFeature
::Generic
->new(
137 -feature2
=> Bio
::SeqFeature
::Generic
->new(
145 $self->throw("ERR:\t\[$_\]");
147 }else{ # sequence lines, ignored
152 $self->_attach_seq($seq, $fp);
155 push @
{$self->{_matches
}}, @matches;
160 my ($self, $seq, $fp) = @_;
162 my $whole_seq = 'X' x
($fp->start-1);
164 $fp->feature1->attach_seq(
165 Bio
::Seq
->new(-seq
=> $whole_seq)