Bio::Tools::CodonTable and Bio::Tools::IUPAC: use our and drop BEGIN blocks.
[bioperl-live.git] / lib / Bio / Tools / Signalp.pm
blob8b3505a9eb47bac69812469e09453893171d8cfa
1 # Parser module for Signalp Bio::Tools::Signalp
3 #
4 # Based on the EnsEMBL module
5 # Bio::EnsEMBL::Pipeline::Runnable::Protein::Signalp originally
6 # written by Marc Sohrmann (ms2@sanger.ac.uk) Written in BioPipe by
7 # Please direct questions and support issues to <bioperl-l@bioperl.org>
9 # Balamurugan Kumarasamy <savikalpa@fugu-sg.org> Cared for by the Fugu
10 # Informatics team (fuguteam@fugu-sg.org)
12 # You may distribute this module under the same terms as perl itself
14 # POD documentation - main docs before the code
16 =head1 NAME
18 Bio::Tools::Signalp - parser for Signalp output
20 =head1 SYNOPSIS
22 use Bio::Tools::Signalp;
24 my $parser = Bio::Tools::Signalp->new(-fh =>$filehandle );
26 while( my $sp_feat = $parser->next_result ) {
27 if ($sp_feat->score > 0.9) {
28 push @likely_sigpep, $sp_feat;
32 =head1 DESCRIPTION
34 C<SignalP> predicts the presence and location of signal peptide
35 cleavage sites in amino acid sequences.
37 L<Bio::Tools::Signalp> parses the output of C<SignalP> to provide a
38 L<Bio::SeqFeature::Generic> object describing the signal peptide
39 found, if any. It returns a variety of tags extracted from the NN and HMM
40 analysis. Most importantly, the C<score()> attribute contains the
41 NN probability of this being a true signal peptide.
44 =head1 FEEDBACK
46 =head2 Mailing Lists
48 User feedback is an integral part of the evolution of this and other
49 Bioperl modules. Send your comments and suggestions preferably to
50 the Bioperl mailing list. Your participation is much appreciated.
52 bioperl-l@bioperl.org - General discussion
53 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
55 =head2 Support
57 Please direct usage questions or support issues to the mailing list:
59 I<bioperl-l@bioperl.org>
61 rather than to the module maintainer directly. Many experienced and
62 reponsive experts will be able look at the problem and quickly
63 address it. Please include a thorough description of the problem
64 with code and data examples if at all possible.
66 =head2 Reporting Bugs
68 Report bugs to the Bioperl bug tracking system to help us keep track
69 of the bugs and their resolution. Bug reports can be submitted va the
70 web:
72 https://github.com/bioperl/bioperl-live/issues
74 =head1 AUTHOR
76 # Please direct questions and support issues to I<bioperl-l@bioperl.org>
78 Based on the EnsEMBL module Bio::EnsEMBL::Pipeline::Runnable::Protein::Signalp
79 originally written by Marc Sohrmann (ms2_AT_sanger.ac.uk). Written in BioPipe by
80 Balamurugan Kumarasamy savikalpa_AT_fugu-sg.org. Cared for by the Fugu
81 Informatics team (fuguteam_AT_fugu-sg.org)
83 =head1 CONTRIBUTORS
85 Torsten Seemann - torsten.seemann AT infotech.monash.edu.au
87 =head1 APPENDIX
89 The rest of the documentation details each of the object methods.
90 Internal methods are usually preceded with a _
92 =cut
94 package Bio::Tools::Signalp;
96 use strict;
98 use Bio::SeqFeature::Generic;
99 use base qw(Bio::Root::Root Bio::Root::IO);
103 =head2 new
105 Title : new
106 Usage : my $obj = Bio::Tools::Signalp->new();
107 Function: Builds a new Bio::Tools::Signalp object
108 Returns : Bio::Tools::Signalp
109 Args : -fh/-file => $val, # for initing input, see Bio::Root::IO
111 =cut
113 sub new {
114 my($class,@args) = @_;
116 my $self = $class->SUPER::new(@args);
117 $self->_initialize_io(@args);
119 return $self;
122 =head2 next_result
124 Title : next_result
125 Usage : my $feat = $signalp->next_result
126 Function: Get the next result set from parser data
127 Returns : Bio::SeqFeature::Generic
128 Args : none
130 =cut
132 sub next_result {
133 my ($self) = @_;
135 while (my $line=$self->_readline()) {
136 chomp $line;
138 if ($line=~/^\>(\S+)/) {
139 $self->_seqname($1);
141 elsif ($line=~/max\.\s+Y\s+(\S+)\s+\S+\s+\S+\s+(\S+)/) {
142 $self->_fact1($2);
144 elsif ($line=~/mean\s+S\s+(\S+)\s+\S+\s+\S+\s+(\S+)/) {
145 my $fact2 = $2;
147 if ($fact2 eq 'YES' and $self->_fact1 eq 'YES') {
149 my $line = $self->_readline();
151 ###########################################
152 # modification to suit new SignalP output
153 ###########################################
154 chomp $line;
155 #print STDERR "********** <$line>\n";
156 if ($line =~ /\s+D\s+.*/) {
157 $line = $self->_readline();
159 #print STDERR "********** <$line>\n";
160 my $end;
161 ###########################################
164 if ($line =~ /Most likely cleavage site between pos\.\s+(\d+)/) {
165 my $end = $1;
166 my (%feature);
167 $feature{seq_id} = $self->_seqname;
168 $feature{start} = 1;
169 $feature{end} = $end;
170 $feature{source_tag} = 'Signalp';
171 $feature{primary}= 'signal_peptide';
172 $self->_parse_hmm_result(\%feature);
173 my $new_feat = $self->_create_feature (\%feature);
174 return $new_feat;
176 else {
177 $self->throw ("parsing problem in signalp");
186 =head2 _parse_hmm_result
188 Title : _parse_hmm_result
189 Usage : $self->_parse_hmm_result(\%feature)
190 Function: Internal (not to be used directly)
191 Returns : hash of feature values
192 Args : hash of more feature values
194 =cut
196 sub _parse_hmm_result {
197 my ($self, $feature_hash) = @_;
198 while(my $line = $self->_readline){
199 chomp $line;
200 if($line =~ /Prediction: (.+)$/){
201 $feature_hash->{hmmProdiction} = $1;
202 }elsif($line =~ /Signal peptide probability: ([0-9\.]+)/){
203 $feature_hash->{peptideProb} = $1;
204 }elsif($line =~ /Signal anchor probability: ([0-9\.]+)/){
205 $feature_hash->{anchorProb} = $1;
206 last;
211 =head2 _create_feature
213 Title : _create_feature
214 Usage : $self->create_feature(\%feature)
215 Function: Internal (not to be used directly)
216 Returns : hash of feature values
217 Args : hash of more feature values
219 =cut
221 sub _create_feature {
222 my ($self, $feat) = @_;
224 # create feature object
225 my $feature = Bio::SeqFeature::Generic->new(
226 -seq_id => $feat->{name},
227 -start => $feat->{start},
228 -end => $feat->{end},
229 -score => $feat->{score},
230 -source => $feat->{source},
231 -primary => $feat->{primary},
232 -logic_name => $feat->{logic_name},
235 $feature->score($feat->{peptideProb});
236 $feature->add_tag_value('peptideProb', $feat->{peptideProb});
237 $feature->add_tag_value('anchorProb', $feat->{anchorProb});
238 $feature->add_tag_value('evalue',$feat->{anchorProb});
239 $feature->add_tag_value('percent_id','NULL');
240 $feature->add_tag_value("hid",$feat->{primary});
241 $feature->add_tag_value('SignalpPrediction', $feat->{hmmProdiction});
242 return $feature;
246 =head2 _seqname
248 Title : _seqname
249 Usage : $self->_seqname($name)
250 Function: Internal (not to be used directly)
251 Returns :
252 Args :
254 =cut
256 sub _seqname{
257 my ($self,$seqname)=@_;
259 if (defined$seqname){
260 $self->{'seqname'}=$seqname;
262 return $self->{'seqname'};
265 =head2 _fact1
267 Title : _fact1
268 Usage : $self->fact1($fact1)
269 Function: Internal (not to be used directly)
270 Returns :
271 Args :
273 =cut
275 sub _fact1{
276 my ($self, $fact1)=@_;
278 if (defined $fact1){
279 $self->{'fact1'}=$fact1;
281 return $self->{'fact1'};