Bio/Tools/TargetP.pm

filter: Statementstmt 94.4% 102 / 108 Branchbran 70.3% 38 / 54 Conditioncond 50.0% 9 / 18 MC/DCmcdc 18.1% 2 / 11 Subroutinesub 94.1% 16 / 17 Podpod 20.0% 1 / 5 totaltotal 78.8% 168 / 213 CC 35 SCAR 18.4
CC
35
Cov
83%
create_feature
13.6
_parse_results
8.0
_parse_line
6.2
CRAP 6.3
« Bio/Annotation/TagTree.pm ↑ Summary Bio/AlignIO/bl2seq.pm »
1 #
2 # Bioperl module for TargetP
3 #
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
5 #
6 # Cared for by Emmanuel Quevillon <emmanuel.quevillon@versailles.inra.fr>
7 #
8 # You may distribute this module under the same terms as perl itself
9 #
10 # POD documentation - main docs before the code
11  
12 =head1 NAME
13  
14 Bio::Tools::TargetP - Results of one TargetP run
15  
16 =head1 SYNOPSIS
17  
18 use Bio::Tools::TargetP;
19  
20 #filename for TargetP result :
21 $targetp = Bio::Tools::TargetP->new(-file => 'targetp.out');
22  
23 # filehandle for TargetP :
24 $targetp = Bio::Tools::TargetP->new( -fh => \*INPUT );
25  
26 ### targetp v1.1 prediction results ##################################
27 #Number of query sequences: 11
28 #Cleavage site predictions included.
29 #Using NON-PLANT networks.
30 #
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 -
36  
37  
38  
39 # parse the results
40 while($feature = $targetp->next_prediction()) {
41  
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();
46 # ...
47 }
48  
49 # essential if you gave a filename at initialization (otherwise the file
50 # will stay open)
51 $targetp->close();
52  
53 =head1 DESCRIPTION
54  
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
59  
60 =head1 FEEDBACK
61  
62 =head2 Mailing Lists
63  
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.
67  
68 bioperl-l@bioperl.org - General discussion
69 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
70  
71 =head2 Support
72  
73 Please direct usage questions or support issues to the mailing list:
74  
75 I<bioperl-l@bioperl.org>
76  
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.
81  
82 =head2 Reporting Bugs
83  
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
86 the web:
87  
88 https://github.com/bioperl/bioperl-live/issues
89  
90 =head1 AUTHORS - Emmanuel Quevillon
91  
92 Email emmanuel.quevillon@versailles.inra.fr
93  
94 Describe contact details here
95  
96 =head1 APPENDIX
97  
98 The rest of the documentation details each of the object methods.
99 Internal methods are usually preceded with a _
100  
101 =cut
102  
103  
104 # Let the code begin...
105  
106  
107 package Bio::Tools::TargetP;
108 2 $Bio::Tools::TargetP::VERSION = '1.7.8';
109 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
110 2 ▶use Bio::Tools::AnalysisResult;
Subroutine BEGIN: called CC=1 SCAR=0.0
111 2 ▶use Bio::SeqFeature::Generic;
Subroutine BEGIN: called CC=1 SCAR=0.0
112 2 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
113  
114 2 ▶use base qw(Bio::Tools::AnalysisResult);
Subroutine BEGIN: called CC=1 SCAR=0.0
115  
116  
117 #Definition of 'Loc' field according to http://www.cbs.dtu.dk/services/TargetP/output.php
118 2 my $MAPLOC = {
119 'S' => 'Secretory pathway',
120 'M' => 'Mitochondrion',
121 'C' => 'Chloroplast',
122 '_' => 'Any other',
123 '*' => 'Unknown',
124 '?' => 'Unknown',
125 };
126  
127  
128 =head1 analysis_method
129  
130 Usage : $self->analysis_method();
131 Purpose : Inherited method. Overridden to ensure that the name matches
132 Returns : String
133 Argument : n/a
134  
135 =cut
136  
137 16 ▶sub analysis_method {
Subroutine analysis_method: called CC=3 SCAR=12.0
Pod documented
138  
139 16 my ($self, $method) = @_;
140  
141 16 ▶ if($method && ($method !~ /TargetP/i)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($method and not $method =~ /TargetP/i) 0 16 16
Condition66%2/3
$method and not $method =~ /TargetP/i
!ll&&!rl&&r
1510
MC/DC0%0/2
$method and not $method =~ /TargetP/i
$method not $method =~ /TargetP/i
Truth table66%2/3
A and not(B)
A= $methodB= not $method =~ /TargetP/i
ABresult
0X0
100
111
142 0 $self->throw("method $method not supported in " . ref($self));
143 }
144  
145 16 return $self->SUPER::analysis_method($method);
146 }
147  
148 =head1 network
149  
150 Title : network
151 Usage : $self->network($network)
152 Function: This method Get/Set the network used for the analysis (PLANT or NON-PLANT)
153 Example :
154 Returns : string
155 Arguments: On set, the network used
156  
157 =cut
158  
159 33 ▶sub network {
Subroutine network: called CC=2 SCAR=6.9
Pod undocumented
160  
161 33 my($self, $net) = @_;
162  
163 33 ▶ if(defined($net)){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $net) 2 31 33
164 2 $self->{'_network'} = $net;
165 }
166  
167 33 return $self->{'_network'};
168  
169 }
170  
171  
172 =head1 cleavage
173  
174 Title : cleavage
175 Usage : $self->cleavage($cleavage)
176 Function : This method Get/Set if SignalP program was used to run TargetP
177 Example :
178 Returns : 1 or 0
179 Arguments: On set, the cleavage used or not
180  
181 =cut
182  
183 2 ▶sub cleavage {
Subroutine cleavage: called CC=3 SCAR=11.4
Pod undocumented
184  
185 2 my($self, $cleavage) = @_;
186  
187 2 ▶ if(defined($cleavage)){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $cleavage) 2 0 2
188 2 ▶ $self->{'_cleavage'} = $cleavage =~ /not included/ ? '0' : '1';
Branch: 1 branch
BranchTrueFalseTotal
$cleavage =~ /not included/ ? : 0 2 2
189 }
190  
191 2 return $self->{'_cleavage'};
192  
193 }
194  
195  
196 =head1 next_prediction
197  
198 Usage : $targetp->next_prediction()
199 Purpose : Returns the next TargetP prediction
200 Returns : A Bio::SeqFeature::Generic object
201 Arguments: n/a
202  
203 =cut
204  
205 16 ▶sub next_prediction {
Subroutine next_prediction: called CC=3 SCAR=11.0
Pod undocumented
206  
207 16 my($self) = @_;
208  
209 16 ▶ unless($self->_parsed()){
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->_parsed) 1 15 16
210 1 $self->_parse_results();
211 1 $self->_parsed(1);
212 }
213  
214 16 ▶ return shift @{$self->{'_features'}} || undef;
Condition100%2/2
shift @{$$self{'_features'};} || undef
l!l
151
MC/DC100%1/1
shift @{$$self{'_features'};} || undef
shift @{$$self{'_features'};}
Truth table100%2/2
A
A= shift @{$$self{'_features'};}
Aresult
11
00
215 }
216  
217 =head1 create_feature
218  
219 Title : create_feature
220 Usage : $self->create_feature(\%hash);
221 Function : This method creates a new Bio::SeqFeature::Generic object
222 Example :
223 Returns : Bio::SeqFeature::Generic
224 Arguments : hash reference
225  
226 =cut
227  
228 15 ▶sub create_feature {
Subroutine create_feature: called CC=11 SCAR=26.1
Pod undocumented
229  
230 15 my($self, $feat) = @_;
231  
232 15 ▶ $self->throw("Need a reference to hash table") unless($feat && ref($feat) eq 'HASH');
Branch: 1 branch
BranchTrueFalseTotal
unless $feat and ref $feat eq "HASH" 0 15 15
Condition33%1/3
$feat and ref $feat eq "HASH"
!ll&&!rl&&r
0015
MC/DC0%0/2
$feat and ref $feat eq "HASH"
$feat ref $feat eq "HASH"
Truth table33%1/3
A and B
A= $featB= ref $feat eq "HASH"
ABresult
0X0
100
111
233  
234 my $feature = Bio::SeqFeature::Generic->new(
235 -seq_id => $feat->{seqid},
236 15 -source_tag => $self->analysis_method(),
237 -primary_tag => 'signal_peptide', #Sequence Ontology compliant
238 -strand => '+',
239 );
240  
241 15 ▶ if(defined($feat->{seqlen})){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $feat->{"seqlen"}) 15 0 15
242 15 $feature->start(1);
243 15 $feature->end($feat->{seqlen});
244 }
245 15 ▶ $feature->add_tag_value('location', $MAPLOC->{$feat->{loc}}) if(exists($MAPLOC->{$feat->{loc}}));
Branch: 1 branch
BranchTrueFalseTotal
if exists $$MAPLOC{$feat->{"loc"}} 15 0 15
246 15 ▶ $feature->add_tag_value('chloroplastCutOff', $feat->{cTP}) if(defined($feat->{cTP}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $feat->{"cTP"} 0 15 15
247 15 ▶ $feature->add_tag_value('mitochondrionCutOff', $feat->{mTP}) if(defined($feat->{mTP}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $feat->{"mTP"} 15 0 15
248 15 ▶ $feature->add_tag_value('signalPeptideCutOff', $feat->{SP}) if(defined($feat->{SP}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $feat->{"SP"} 15 0 15
249 15 ▶ $feature->add_tag_value('otherCutOff', $feat->{other}) if(defined($feat->{other}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $feat->{"other"} 15 0 15
250 15 ▶ $feature->add_tag_value('reliabilityClass', $feat->{RC}) if(defined($feat->{RC}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $feat->{"RC"} 15 0 15
251 15 ▶ $feature->add_tag_value('signalPeptideLength', $feat->{TPLen}) if(defined($feat->{TPLen}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $feat->{"TPLen"} 4 11 15
252  
253 15 $feature->add_tag_value('network', $self->network());
254  
255 15 return $feature;
256  
257 }
258  
259  
260 =head2 PRIVATE METHODS
261  
262 =cut
263  
264 =head2 _initialize_state
265  
266 Title : _initialize_state
267 Usage : n/a; usually called by _initialize() itself called by new()
268 Function: This method is supposed to reset the state such that any 'history'
269 is lost. State information that does not change during object
270 lifetime is not considered as history, e.g. parent, name, etc shall
271 not be reset. An inheriting object should only be concerned with
272 state information it introduces itself, and for everything else
273 call SUPER::_initialize_state(@args).
274  
275 The argument syntax is the same as for new() and _initialize(),
276 i.e., named parameters following the -name=>$value convention.
277 The following parameters are dealt with by the implementation
278 provided here:
279 -INPUT, -FH, -FILE
280 (tags are case-insensitive).
281 Example :
282 Returns :
283 Args :
284  
285 =cut
286  
287 1 ▶sub _initialize_state {
Subroutine _initialize_state: called CC=1 SCAR=0.0
288  
289 1 my ($self,@args,) = @_;
290 # first call the inherited method!
291 1 $self->SUPER::_initialize_state(@args);
292  
293 # our private state variables
294 1 $self->{'_features'} = [ ];
295 1 $self->{'_parameters'} = undef;
296 1 $self->{'_format'} = undef;
297 1 $self->{'_network'} = undef;
298 1 $self->{'_cleavage'} = undef;
299 1 $self->{'_parsed'} = 0;
300  
301 1 $self->analysis_method('TargetP');
302  
303 1 return 1;
304 }
305  
306 =head2 _predictions
307  
308 Usage : $targetp->_prediction()
309 Purpose : Returns the number of TargetP predictions
310 Returns : A scalar (number)
311 Arguments: n/a
312  
313 =cut
314  
315 0 ▶sub _predictions {
Subroutine _predictions: not called CC=2 SCAR=17.9
316  
317 0 my($self) = @_;
318  
319 0 ▶ return scalar(@{$self->{'_features'}}) || 0;
Condition0%0/2
scalar @{$self->{'_features'};} || 0
l!l
00
MC/DC0%0/1
scalar @{$self->{'_features'};} || 0
scalar @{$self->{'_features'};}
Truth table0%0/2
A
A= scalar @{$self->{'_features'};}
Aresult
11
00
320 }
321  
322  
323 =head2 _parsed
324  
325 Title : _parsed
326 Usage : $targetp->_parsed(1)
327 Function : This method is used to know if the output result is parsed or not
328 For internal use only
329 Example :
330 Returns : 1/0
331 Arguments : 1/0 for setting
332  
333 =cut
334  
335 17 ▶sub _parsed {
Subroutine _parsed: called CC=2 SCAR=6.9
336  
337 17 my($self, $value) = @_;
338  
339 17 ▶ if(defined($value)){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 1 16 17
340 1 $self->{'_parsed'} = $value;
341 }
342  
343 17 return $self->{'_parsed'};
344 }
345  
346  
347  
348 =head2 _parse_results
349  
350 Title : _parse_results
351 Usage : $self->_parse_results()
352 Function : This method parses a TargetP output
353 For internal use only
354 Example :
355 Returns : n/a
356 Arguments: none
357  
358 =cut
359  
360 2 ▶sub _parse_results {
Subroutine _parse_results: called CC=8 SCAR=20.8
361  
362 2 my($self) = @_;
363  
364  
365 ### targetp v1.1 prediction results ##################################
366 #Number of query sequences: 11
367 #Cleavage site predictions included.
368 #Using NON-PLANT networks.
369 #
370 #Name Len mTP SP other Loc RC TPlen
371 #----------------------------------------------------------------------
372 #swall|Q9LIP3|C72Y_AR 500 0.245 0.935 0.009 S 2 22
373 #swall|Q52813|AAPQ_RH 400 0.170 0.462 0.577 _ 5 -
374 #swall|O86459|AAT_RHI 400 0.346 0.046 0.660 _ 4 -
375  
376  
377 2 ▶ while(defined(my $line = $self->_readline())){
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $line = $self->_readline)) 15 2 17
378  
379 15 ▶ if($line =~ /targetp (v[\d\.]+)/){
Branch: 4 branches
BranchTrueFalseTotal
if ($line =~ /targetp (v[\d\.]+)/) { } 2 13 15
elsif ($line =~ /Cleavage site predictions (.*)/) { } 2 11 13
elsif ($line =~ /Using (\S+) networks/) { } 2 9 11
elsif ($line =~ /^Name/) { } 2 7 9
380  
381 2 $self->analysis_method_version($1);
382  
383 }elsif($line =~ /Cleavage site predictions (.*)/){
384  
385 2 $self->cleavage($1);
386  
387 }elsif($line =~ /Using (\S+) networks/){
388  
389 2 $self->network($1);
390  
391 }elsif($line =~ /^Name/){
392  
393 #We skip the next line which is '------------------'
394 2 $self->_readline();
395  
396 2 my $hash = { };
397  
398 2 ▶ while(defined(my $line = $self->_readline())){
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $line = $self->_readline)) 17 0 17
399  
400 17 ▶ last if($line =~ /^----/);
Branch: 1 branch
BranchTrueFalseTotal
if $line =~ /^----/ 2 15 17
401  
402 15 my $hash = $self->_parse_line($line);
403  
404 15 my $new_feature = $self->create_feature($hash);
405
406 15 $self->_add_feature($new_feature);
407 }
408 }
409 }
410  
411 2 return;
412 }
413  
414 =head2 _parse_line
415  
416 Title : _parse_line
417 Usage : $self->_parse_line($line)
418 Function : This method parses the line result
419 For internal use only
420 Example :
421 Returns : Hash reference
422 Arguemnts: line to parse
423  
424 =cut
425  
426 15 ▶sub _parse_line {
Subroutine _parse_line: called CC=6 SCAR=18.3
427  
428 15 my($self, $line) = @_;
429  
430 15 ▶ $self->throw("No line to parse given") unless($line);
Branch: 1 branch
BranchTrueFalseTotal
unless $line 0 15 15
431  
432 15 my $hash = { };
433 15 my ($seqid, $seqlen, $cTP, $mTP, $SP, $other, $loc, $RC, $TPlen);
434  
435 15 ▶ if($self->network() eq 'NON-PLANT'){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->network eq 'NON-PLANT') { } 15 0 15
436  
437 15 ($seqid, $seqlen, $mTP, $SP, $other, $loc, $RC, $TPlen) = split(/\s+/, $line);
438  
439 }else{
440  
441 0 ($seqid, $seqlen, $cTP, $mTP, $SP, $other, $loc, $RC, $TPlen) = split(/\s+/, $line);
442  
443 }
444  
445 15 $hash->{seqid} = $seqid;
446 15 $hash->{seqlen} = $seqlen;
447 15 ▶ $hash->{cTP} = $cTP || undef;
Condition50%1/2
$cTP || undef
l!l
015
MC/DC0%0/1
$cTP || undef
$cTP
Truth table50%1/2
A
A= $cTP
Aresult
11
00
448 15 $hash->{mTP} = $mTP;
449 15 $hash->{SP} = $SP;
450 15 $hash->{other} = $other;
451 15 $hash->{loc} = $loc;
452 15 $hash->{RC} = $RC;
453 15 ▶ $hash->{TPLen} = ($TPlen && $TPlen =~ /\d+/) ? $TPlen : undef;
Branch: 1 branch
BranchTrueFalseTotal
$TPlen && $TPlen =~ /\d+/ ? : 4 11 15
Condition66%2/3
$TPlen and $TPlen =~ /\d+/
!ll&&!rl&&r
0114
MC/DC50%1/2
$TPlen and $TPlen =~ /\d+/
$TPlen $TPlen =~ /\d+/
Truth table66%2/3
A and B
A= $TPlenB= $TPlen =~ /\d+/
ABresult
0X0
100
111
454  
455 15 return $hash;
456  
457 }
458  
459 =head2 _add_feature
460  
461 Title : _add_feature
462 Usage : $self->_add_feature($feature)
463 Function : This method stores a feature object
464 For internal use only
465 Example :
466 Returns : n/a
467 Arguments: Bio::SeqFeature::Generic
468  
469 =cut
470  
471 15 ▶sub _add_feature {
Subroutine _add_feature: called CC=2 SCAR=7.0
472  
473 15 my($self, $feature) = @_;
474  
475 15 ▶ $self->throw("Need a Bio::SeqFeature::Generic object") unless $feature->isa("Bio::SeqFeature::Generic");
Branch: 1 branch
BranchTrueFalseTotal
unless $feature->isa("Bio::SeqFeature::Generic") 0 15 15
476  
477 15 push(@{$self->{'_features'}}, $feature);
478  
479 15 return;
480  
481 }
482  
483 =head2 _toString_location
484  
485 Title : _toString_location
486 Usage : $self->_toString_location($key)
487 Function : This method convert the 'one letter code' location to
488 the corresponding definition
489 For internal use only
490 Example :
491 Returns : Location or undef
492 Arguments: String
493  
494 =cut
495  
496 15 ▶sub _toString_location {
Subroutine _toString_location: called CC=3 SCAR=13.3
497  
498 15 my($self, $key) = @_;
499  
500 15 ▶ if($key && exists($MAPLOC->{$key})){
Branch: 1 branch
BranchTrueFalseTotal
if ($key and exists $MAPLOC->{$key}) 15 0 15
Condition33%1/3
$key and exists $MAPLOC->{$key}
!ll&&!rl&&r
0015
MC/DC0%0/2
$key and exists $MAPLOC->{$key}
$key exists $MAPLOC->{$key}
Truth table33%1/3
A and B
A= $keyB= exists $MAPLOC->{$key}
ABresult
0X0
100
111
501 15 return $MAPLOC->{$key};
502 }
503  
504 0 return;
505 }
506  
507  
508  
509 2 1;
« Bio/Annotation/TagTree.pm ↑ Summary Bio/AlignIO/bl2seq.pm »