2 # Bioperl module for TargetP
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
6 # Cared for by Emmanuel Quevillon <emmanuel.quevillon@versailles.inra.fr>
8 # You may distribute this module under the same terms as perl itself
10 # POD documentation - main docs before the code
14 Bio::Tools::TargetP - Results of one TargetP run
18 use Bio::Tools::TargetP;
20 #filename for TargetP result :
21 $targetp = Bio::Tools::TargetP->new(-file => 'targetp.out');
23 # filehandle for TargetP :
24 $targetp = Bio::Tools::TargetP->new( -fh => \*INPUT );
26 ### targetp v1.1 prediction results ##################################
27 #Number of query sequences: 11
28 #Cleavage site predictions included.
29 #Using NON-PLANT networks.
31 #Name Len mTP SP other Loc RC TPlen
32 #----------------------------------------------------------------------
33 #swall|Q9LIP3|C72Y_AR 500 0.245 0.935 0.009 S 2 22
34 #swall|Q52813|AAPQ_RH 400 0.170 0.462 0.577 _ 5 -
35 #swall|O86459|AAT_RHI 400 0.346 0.046 0.660 _ 4 -
40 while($feature = $targetp->next_prediction()) {
42 #$feature is a Bio::SeqFeature::Generic object
43 my $method = $targetp->analysis_method();
44 my $vesion = $targetp->analysis_method_version() || $feature->source();
45 my $seqid = $feature->seq_id();
49 # essential if you gave a filename at initialization (otherwise the file
55 TargetP modules will provides parsed information about protein
56 localization. It reads in a targetp output file. It parses the
57 results, and returns a Bio::SeqFeature::Generic object for each
58 seqeunces found to have a subcellular localization
64 User feedback is an integral part of the evolution of this and other
65 Bioperl modules. Send your comments and suggestions preferably to
66 the Bioperl mailing list. Your participation is much appreciated.
68 bioperl-l@bioperl.org - General discussion
69 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
73 Please direct usage questions or support issues to the mailing list:
75 I<bioperl-l@bioperl.org>
77 rather than to the module maintainer directly. Many experienced and
78 reponsive experts will be able look at the problem and quickly
79 address it. Please include a thorough description of the problem
80 with code and data examples if at all possible.
84 Report bugs to the Bioperl bug tracking system to help us keep track
85 of the bugs and their resolution. Bug reports can be submitted via
88 https://github.com/bioperl/bioperl-live/issues
90 =head1 AUTHORS - Emmanuel Quevillon
92 Email emmanuel.quevillon@versailles.inra.fr
94 Describe contact details here
98 The rest of the documentation details each of the object methods.
99 Internal methods are usually preceded with a _
104 # Let the code begin...
107 package Bio
::Tools
::TargetP
;
109 use Bio
::Tools
::AnalysisResult
;
110 use Bio
::SeqFeature
::Generic
;
113 use base
qw(Bio::Tools::AnalysisResult);
116 #Definition of 'Loc' field according to http://www.cbs.dtu.dk/services/TargetP/output.php
118 'S' => 'Secretory pathway',
119 'M' => 'Mitochondrion',
120 'C' => 'Chloroplast',
127 =head1 analysis_method
129 Usage : $self->analysis_method();
130 Purpose : Inherited method. Overridden to ensure that the name matches
136 sub analysis_method
{
138 my ($self, $method) = @_;
140 if($method && ($method !~ /TargetP/i)) {
141 $self->throw("method $method not supported in " . ref($self));
144 return $self->SUPER::analysis_method
($method);
150 Usage : $self->network($network)
151 Function: This method Get/Set the network used for the analysis (PLANT or NON-PLANT)
154 Arguments: On set, the network used
160 my($self, $net) = @_;
163 $self->{'_network'} = $net;
166 return $self->{'_network'};
174 Usage : $self->cleavage($cleavage)
175 Function : This method Get/Set if SignalP program was used to run TargetP
178 Arguments: On set, the cleavage used or not
184 my($self, $cleavage) = @_;
186 if(defined($cleavage)){
187 $self->{'_cleavage'} = $cleavage =~ /not included/ ?
'0' : '1';
190 return $self->{'_cleavage'};
195 =head1 next_prediction
197 Usage : $targetp->next_prediction()
198 Purpose : Returns the next TargetP prediction
199 Returns : A Bio::SeqFeature::Generic object
204 sub next_prediction
{
208 unless($self->_parsed()){
209 $self->_parse_results();
213 return shift @
{$self->{'_features'}} || undef;
216 =head1 create_feature
218 Title : create_feature
219 Usage : $self->create_feature(\%hash);
220 Function : This method creates a new Bio::SeqFeature::Generic object
222 Returns : Bio::SeqFeature::Generic
223 Arguments : hash reference
229 my($self, $feat) = @_;
231 $self->throw("Need a reference to hash table") unless($feat && ref($feat) eq 'HASH');
233 my $feature = Bio
::SeqFeature
::Generic
->new(
234 -seq_id
=> $feat->{seqid
},
235 -source_tag
=> $self->analysis_method(),
236 -primary_tag
=> 'signal_peptide', #Sequence Ontology compliant
240 if(defined($feat->{seqlen
})){
242 $feature->end($feat->{seqlen
});
244 $feature->add_tag_value('location', $MAPLOC->{$feat->{loc
}}) if(exists($MAPLOC->{$feat->{loc
}}));
245 $feature->add_tag_value('chloroplastCutOff', $feat->{cTP
}) if(defined($feat->{cTP
}));
246 $feature->add_tag_value('mitochondrionCutOff', $feat->{mTP
}) if(defined($feat->{mTP
}));
247 $feature->add_tag_value('signalPeptideCutOff', $feat->{SP
}) if(defined($feat->{SP
}));
248 $feature->add_tag_value('otherCutOff', $feat->{other
}) if(defined($feat->{other
}));
249 $feature->add_tag_value('reliabilityClass', $feat->{RC
}) if(defined($feat->{RC
}));
250 $feature->add_tag_value('signalPeptideLength', $feat->{TPLen
}) if(defined($feat->{TPLen
}));
252 $feature->add_tag_value('network', $self->network());
259 =head2 PRIVATE METHODS
263 =head2 _initialize_state
265 Title : _initialize_state
266 Usage : n/a; usually called by _initialize() itself called by new()
267 Function: This method is supposed to reset the state such that any 'history'
268 is lost. State information that does not change during object
269 lifetime is not considered as history, e.g. parent, name, etc shall
270 not be reset. An inheriting object should only be concerned with
271 state information it introduces itself, and for everything else
272 call SUPER::_initialize_state(@args).
274 The argument syntax is the same as for new() and _initialize(),
275 i.e., named parameters following the -name=>$value convention.
276 The following parameters are dealt with by the implementation
279 (tags are case-insensitive).
286 sub _initialize_state
{
288 my ($self,@args,) = @_;
289 # first call the inherited method!
290 $self->SUPER::_initialize_state
(@args);
292 # our private state variables
293 $self->{'_features'} = [ ];
294 $self->{'_parameters'} = undef;
295 $self->{'_format'} = undef;
296 $self->{'_network'} = undef;
297 $self->{'_cleavage'} = undef;
298 $self->{'_parsed'} = 0;
300 $self->analysis_method('TargetP');
307 Usage : $targetp->_prediction()
308 Purpose : Returns the number of TargetP predictions
309 Returns : A scalar (number)
318 return scalar(@
{$self->{'_features'}}) || 0;
325 Usage : $targetp->_parsed(1)
326 Function : This method is used to know if the output result is parsed or not
327 For internal use only
330 Arguments : 1/0 for setting
336 my($self, $value) = @_;
339 $self->{'_parsed'} = $value;
342 return $self->{'_parsed'};
347 =head2 _parse_results
349 Title : _parse_results
350 Usage : $self->_parse_results()
351 Function : This method parses a TargetP output
352 For internal use only
364 ### targetp v1.1 prediction results ##################################
365 #Number of query sequences: 11
366 #Cleavage site predictions included.
367 #Using NON-PLANT networks.
369 #Name Len mTP SP other Loc RC TPlen
370 #----------------------------------------------------------------------
371 #swall|Q9LIP3|C72Y_AR 500 0.245 0.935 0.009 S 2 22
372 #swall|Q52813|AAPQ_RH 400 0.170 0.462 0.577 _ 5 -
373 #swall|O86459|AAT_RHI 400 0.346 0.046 0.660 _ 4 -
376 while(defined(my $line = $self->_readline())){
378 if($line =~ /targetp (v[\d\.]+)/){
380 $self->analysis_method_version($1);
382 }elsif($line =~ /Cleavage site predictions (.*)/){
386 }elsif($line =~ /Using (\S+) networks/){
390 }elsif($line =~ /^Name/){
392 #We skip the next line which is '------------------'
397 while(defined(my $line = $self->_readline())){
399 last if($line =~ /^----/);
401 my $hash = $self->_parse_line($line);
403 my $new_feature = $self->create_feature($hash);
405 $self->_add_feature($new_feature);
416 Usage : $self->_parse_line($line)
417 Function : This method parses the line result
418 For internal use only
420 Returns : Hash reference
421 Arguemnts: line to parse
427 my($self, $line) = @_;
429 $self->throw("No line to parse given") unless($line);
432 my ($seqid, $seqlen, $cTP, $mTP, $SP, $other, $loc, $RC, $TPlen);
434 if($self->network() eq 'NON-PLANT'){
436 ($seqid, $seqlen, $mTP, $SP, $other, $loc, $RC, $TPlen) = split(/\s+/, $line);
440 ($seqid, $seqlen, $cTP, $mTP, $SP, $other, $loc, $RC, $TPlen) = split(/\s+/, $line);
444 $hash->{seqid
} = $seqid;
445 $hash->{seqlen
} = $seqlen;
446 $hash->{cTP
} = $cTP || undef;
449 $hash->{other
} = $other;
452 $hash->{TPLen
} = ($TPlen && $TPlen =~ /\d+/) ?
$TPlen : undef;
461 Usage : $self->_add_feature($feature)
462 Function : This method stores a feature object
463 For internal use only
466 Arguments: Bio::SeqFeature::Generic
472 my($self, $feature) = @_;
474 $self->throw("Need a Bio::SeqFeature::Generic object") unless $feature->isa("Bio::SeqFeature::Generic");
476 push(@
{$self->{'_features'}}, $feature);
482 =head2 _toString_location
484 Title : _toString_location
485 Usage : $self->_toString_location($key)
486 Function : This method convert the 'one letter code' location to
487 the corresponding definition
488 For internal use only
490 Returns : Location or undef
495 sub _toString_location
{
497 my($self, $key) = @_;
499 if($key && exists($MAPLOC->{$key})){
500 return $MAPLOC->{$key};