A test to ensure Bio::PrimarySeqI->trunc() doesn't use clone() for a Bio::Seq::RichSe...
[bioperl-live.git] / Bio / Tools / Signalp.pm
blobc80f4cd135c855a132cf33b763397cf49173f7f0
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;
95 use strict;
97 use Bio::SeqFeature::Generic;
98 use base qw(Bio::Root::Root Bio::Root::IO);
102 =head2 new
104 Title : new
105 Usage : my $obj = Bio::Tools::Signalp->new();
106 Function: Builds a new Bio::Tools::Signalp object
107 Returns : Bio::Tools::Signalp
108 Args : -fh/-file => $val, # for initing input, see Bio::Root::IO
110 =cut
112 sub new {
113 my($class,@args) = @_;
115 my $self = $class->SUPER::new(@args);
116 $self->_initialize_io(@args);
118 return $self;
121 =head2 next_result
123 Title : next_result
124 Usage : my $feat = $signalp->next_result
125 Function: Get the next result set from parser data
126 Returns : Bio::SeqFeature::Generic
127 Args : none
129 =cut
131 sub next_result {
132 my ($self) = @_;
134 while (my $line=$self->_readline()) {
135 chomp $line;
137 if ($line=~/^\>(\S+)/) {
138 $self->_seqname($1);
140 elsif ($line=~/max\.\s+Y\s+(\S+)\s+\S+\s+\S+\s+(\S+)/) {
141 $self->_fact1($2);
143 elsif ($line=~/mean\s+S\s+(\S+)\s+\S+\s+\S+\s+(\S+)/) {
144 my $fact2 = $2;
146 if ($fact2 eq 'YES' and $self->_fact1 eq 'YES') {
148 my $line = $self->_readline();
150 ###########################################
151 # modification to suit new SignalP output
152 ###########################################
153 chomp $line;
154 #print STDERR "********** <$line>\n";
155 if ($line =~ /\s+D\s+.*/) {
156 $line = $self->_readline();
158 #print STDERR "********** <$line>\n";
159 my $end;
160 ###########################################
163 if ($line =~ /Most likely cleavage site between pos\.\s+(\d+)/) {
164 my $end = $1;
165 my (%feature);
166 $feature{seq_id} = $self->_seqname;
167 $feature{start} = 1;
168 $feature{end} = $end;
169 $feature{source_tag} = 'Signalp';
170 $feature{primary}= 'signal_peptide';
171 $self->_parse_hmm_result(\%feature);
172 my $new_feat = $self->_create_feature (\%feature);
173 return $new_feat;
175 else {
176 $self->throw ("parsing problem in signalp");
185 =head2 _parse_hmm_result
187 Title : _parse_hmm_result
188 Usage : $self->_parse_hmm_result(\%feature)
189 Function: Internal (not to be used directly)
190 Returns : hash of feature values
191 Args : hash of more feature values
193 =cut
195 sub _parse_hmm_result {
196 my ($self, $feature_hash) = @_;
197 while(my $line = $self->_readline){
198 chomp $line;
199 if($line =~ /Prediction: (.+)$/){
200 $feature_hash->{hmmProdiction} = $1;
201 }elsif($line =~ /Signal peptide probability: ([0-9\.]+)/){
202 $feature_hash->{peptideProb} = $1;
203 }elsif($line =~ /Signal anchor probability: ([0-9\.]+)/){
204 $feature_hash->{anchorProb} = $1;
205 last;
210 =head2 _create_feature
212 Title : _create_feature
213 Usage : $self->create_feature(\%feature)
214 Function: Internal (not to be used directly)
215 Returns : hash of feature values
216 Args : hash of more feature values
218 =cut
220 sub _create_feature {
221 my ($self, $feat) = @_;
223 # create feature object
224 my $feature = Bio::SeqFeature::Generic->new(
225 -seq_id => $feat->{name},
226 -start => $feat->{start},
227 -end => $feat->{end},
228 -score => $feat->{score},
229 -source => $feat->{source},
230 -primary => $feat->{primary},
231 -logic_name => $feat->{logic_name},
234 $feature->score($feat->{peptideProb});
235 $feature->add_tag_value('peptideProb', $feat->{peptideProb});
236 $feature->add_tag_value('anchorProb', $feat->{anchorProb});
237 $feature->add_tag_value('evalue',$feat->{anchorProb});
238 $feature->add_tag_value('percent_id','NULL');
239 $feature->add_tag_value("hid",$feat->{primary});
240 $feature->add_tag_value('SignalpPrediction', $feat->{hmmProdiction});
241 return $feature;
245 =head2 _seqname
247 Title : _seqname
248 Usage : $self->_seqname($name)
249 Function: Internal (not to be used directly)
250 Returns :
251 Args :
253 =cut
255 sub _seqname{
256 my ($self,$seqname)=@_;
258 if (defined$seqname){
259 $self->{'seqname'}=$seqname;
261 return $self->{'seqname'};
264 =head2 _fact1
266 Title : _fact1
267 Usage : $self->fact1($fact1)
268 Function: Internal (not to be used directly)
269 Returns :
270 Args :
272 =cut
274 sub _fact1{
275 my ($self, $fact1)=@_;
277 if (defined $fact1){
278 $self->{'fact1'}=$fact1;
280 return $self->{'fact1'};