Tools/Run/Signalp.pm

filter: Statementstmt 36.7% 36 / 98 Branchbran 6.6% 2 / 30 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 66.6% 12 / 18 Podpod 100% 5 / 5 totaltotal 36.4% 55 / 151 CC 17 SCAR 24.1
CC
17
Cov
30%
_run
30.0
AUTOLOAD
20.0
run
20.0
CRAP 11.1
« Tools/Run/EMBOSSacd.pm ↑ Summary Tools/Run/Phylo/Hyphy/REL.pm »
1 # Wrapper module for SignalP Bio::Tools::Run::Signalp
2 #
3 # Based on the EnsEMBL module Bio::EnsEMBL::Pipeline::Runnable::Protein::Signalp
4 # originally written by Marc Sohrmann (ms2@sanger.ac.uk)
5 # Written in BioPipe by Balamurugan Kumarasamy <savikalpa@fugu-sg.org>
6 # Please direct questions and support issues to <bioperl-l@bioperl.org>
7 #
8 # Cared for by the Fugu Informatics team (fuguteam@fugu-sg.org)
9  
10 =head1 NAME
11  
12 Bio::Tools::Run::Signalp
13  
14 =head1 SYNOPSIS
15  
16 Build a Signalp factory
17  
18 my $factory = Bio::Tools::Run::Signalp->new();
19 # Pass the factory a Bio::Seq object
20 # @feats is an array of Bio::SeqFeature::Generic objects
21 my @feats = $factory->run($seq);
22  
23 =head1 DESCRIPTION
24  
25 wrapper module for Signalp program
26  
27 =head1 FEEDBACK
28  
29 =head2 Mailing Lists
30  
31 User feedback is an integral part of the evolution of this and other
32 Bioperl modules. Send your comments and suggestions preferably to one
33 of the Bioperl mailing lists. Your participation is much appreciated.
34  
35 bioperl-l@bioperl.org - General discussion
36 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
37  
38 =head2 Support
39  
40 Please direct usage questions or support issues to the mailing list:
41  
42 I<bioperl-l@bioperl.org>
43  
44 rather than to the module maintainer directly. Many experienced and
45 reponsive experts will be able look at the problem and quickly
46 address it. Please include a thorough description of the problem
47 with code and data examples if at all possible.
48  
49 =head2 Reporting Bugs
50  
51 Report bugs to the Bioperl bug tracking system to help us keep track
52 the bugs and their resolution. Bug reports can be submitted via the
53 web:
54  
55 http://redmine.open-bio.org/projects/bioperl/
56  
57 =head1 AUTHOR
58  
59 Based on the EnsEMBL module Bio::EnsEMBL::Pipeline::Runnable::Protein::Signalp
60 originally written by Marc Sohrmann (ms2@sanger.ac.uk)
61 Written in BioPipe by Balamurugan Kumarasamy <savikalpa@fugu-sg.org>
62 Contributions by David Vilanova (david.vilanova@urbanet.ch)
63 Shawn Hoon (shawnh@fugu-sg.org)
64 # Please direct questions and support issues to <bioperl-l@bioperl.org>
65 #
66 Cared for by the Fugu Informatics team (fuguteam@fugu-sg.org)
67  
68 =head1 APPENDIX
69  
70 The rest of the documentation details each of the object
71 methods. Internal methods are usually preceded with a _
72  
73 =cut
74  
75 package Bio::Tools::Run::Signalp;
76  
77 1 ▶use vars qw($AUTOLOAD @ISA $PROGRAM $PROGRAMDIR
Subroutine BEGIN: called CC=1 SCAR=0.0
78 1 $PROGRAMNAME @SIGNALP_PARAMS %OK_FIELD);
79 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
80 1 ▶use Bio::SeqIO;
Subroutine BEGIN: called CC=1 SCAR=0.0
81 1 ▶use Bio::Root::Root;
Subroutine BEGIN: called CC=1 SCAR=0.0
82 1 ▶use Bio::Root::IO;
Subroutine BEGIN: called CC=1 SCAR=0.0
83 1 ▶use Bio::Factory::ApplicationFactoryI;
Subroutine BEGIN: called CC=1 SCAR=0.0
84 1 ▶use Bio::Tools::Signalp;
Subroutine BEGIN: called CC=1 SCAR=0.0
85 1 ▶use Bio::Tools::Run::WrapperBase;
Subroutine BEGIN: called CC=1 SCAR=0.0
86  
87 1 @ISA = qw(Bio::Root::Root Bio::Tools::Run::WrapperBase);
88  
89 1 ▶BEGIN {
Subroutine BEGIN: called CC=2 SCAR=6.9
90 1 @SIGNALP_PARAMS=qw(PROGRAM VERBOSE);
91 1 foreach my $attr ( @SIGNALP_PARAMS)
92 2 { $OK_FIELD{$attr}++; }
93 }
94  
95 =head2 program_name
96  
97 Title : program_name
98 Usage : $factory>program_name()
99 Function: holds the program name
100 Returns: string
101 Args : None
102  
103 =cut
104  
105 6 ▶sub program_name {
Subroutine program_name: called CC=1 SCAR=0.0
Pod documented
106 6 return 'signalp';
107 }
108  
109 =head2 program_dir
110  
111 Title : program_dir
112 Usage : $factory->program_dir(@params)
113 Function: returns the program directory, obtained from ENV variable.
114 Returns: string
115 Args :
116  
117 =cut
118  
119 3 ▶sub program_dir {
Subroutine program_dir: called CC=2 SCAR=7.6
Pod documented
120 3 ▶ return Bio::Root::IO->catfile($ENV{SIGNALPDIR}) if $ENV{SIGNALPDIR};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"SIGNALPDIR"} 0 3 3
121 }
122  
123 0 ▶sub AUTOLOAD {
Subroutine AUTOLOAD: not called CC=4 SCAR=30.0
124 0 my $self = shift;
125 0 my $attr = $AUTOLOAD;
126 0 ▶ return $self->$attr if $self->$attr;
Branch: 1 branch
BranchTrueFalseTotal
if $self->$attr 0 0 0
127 0 $attr =~ s/.*:://;
128 0 $attr = uc $attr;
129 0 ▶ $self->throw("Unallowed parameter: $attr !") unless $OK_FIELD{$attr};
Branch: 1 branch
BranchTrueFalseTotal
unless $Bio::Tools::Run::Signalp::OK_FIELD{$attr} 0 0 0
130 0 ▶ $self->{$attr} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
131 0 return $self->{$attr};
132 }
133  
134 =head2 new
135  
136 Title : new
137 Usage : my $factory= Bio::Tools::Run::Signalp->new();
138 Function: creates a new Signalp factory
139 Returns: Bio::Tools::Run::Signalp
140 Args :
141  
142 =cut
143  
144 1 ▶sub new {
Subroutine new: called CC=4 SCAR=21.7
Pod documented
145 1 my ($class,@args) = @_;
146 1 my $self = $class->SUPER::new(@args);
147
148 1 my ($attr, $value);
149 1 ▶ while (@args) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args) 0 1 1
150 0 $attr = shift @args;
151 0 $value = shift @args;
152 0 ▶ next if( $attr =~ /^-/ ); # don't want named parameters
Branch: 1 branch
BranchTrueFalseTotal
if $attr =~ /^-/ 0 0 0
153 0 ▶ if ($attr =~/PROGRAM/i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($attr =~ /PROGRAM/i) 0 0 0
154 0 $self->executable($value);
155 0 next;
156 }
157 0 $self->$attr($value);
158 }
159 1 return $self;
160 }
161  
162 =head2 predict_protein_features
163  
164 Title : predict_protein_features()
165 Usage : DEPRECATED. Use $factory->run($seq) instead
166 Function: Runs Signalp and creates an array of featrues
167 Returns : An array of Bio::SeqFeature::Generic objects
168 Args : A Bio::PrimarySeqI
169  
170 =cut
171  
172 0 ▶sub predict_protein_features{
Subroutine predict_protein_features: not called CC=1 SCAR=6.9
Pod documented
173 0 return shift->run(@_);
174 }
175  
176 =head2 run
177  
178 Title : run()
179 Usage : my $feats = $factory->run($seq)
180 Function: Runs Signalp
181 Returns : An array of Bio::SeqFeature::Generic objects
182 Args : A Bio::PrimarySeqI
183  
184 =cut
185  
186 0 ▶sub run {
Subroutine run: not called CC=4 SCAR=30.0
Pod documented
187 0 my ($self,$seq) = @_;
188 0 my @feats;
189  
190 0 ▶ if (ref($seq) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $seq) { } 0 0 0
191  
192 0 ▶ if (ref($seq) =~ /GLOB/) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref($seq) =~ /GLOB/) 0 0 0
193 0 $self->throw("cannot use filehandle");
194 }
195  
196 0 my $infile1 = $self->_writeSeqFile($seq);
197  
198 0 $self->_input($infile1);
199  
200 0 @feats = $self->_run();
201 0 unlink $infile1;
202  
203 }
204 else {
205 0 my $in = Bio::SeqIO->new(-file => $seq, '-format' =>'fasta');
206 0 my $infile1;
207  
208 0 ▶ while ( my $tmpseq = $in->next_seq() ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $tmpseq = $in->next_seq) 0 0 0
209 0 $infile1 = $self->_writeSeqFile($tmpseq);
210 }
211  
212 0 $self->_input($infile1);
213  
214 0 @feats = $self->_run();
215 }
216  
217 0 return @feats;
218 }
219  
220 =head2 _input
221  
222 Title : _input
223 Usage : $factory->_input($seqFile)
224 Function: get/set for input file
225 Returns :
226 Args :
227  
228 =cut
229  
230 0 ▶sub _input() {
Subroutine _input: not called CC=2 SCAR=17.9
231 0 my ($self,$infile1) = @_;
232 0 ▶ $self->{'input'} = $infile1 if(defined $infile1);
Branch: 1 branch
BranchTrueFalseTotal
if defined $infile1 0 0 0
233 0 return $self->{'input'};
234 }
235  
236 =head2 _run
237  
238 Title : _run
239 Usage : $factory->_run()
240 Function: Makes a system call and runs signalp
241 Returns : An array of Bio::SeqFeature::Generic objects
242 Args :
243  
244 =cut
245  
246 0 ▶sub _run {
Subroutine _run: not called CC=5 SCAR=34.0
247 0 my ($self)= @_;
248  
249 0 my ($tfh1,$outfile) = $self->io->tempfile(-dir=>$self->tempdir());
250 0 my $str =$self->executable." -t euk -trunc 50 ".$self->{'input'}." > ".$outfile;
251 0 my $status = system($str);
252 0 ▶ $self->throw( "Signalp call ($str) crashed: $? \n") unless $status==0;
Branch: 1 branch
BranchTrueFalseTotal
unless $status == 0 0 0 0
253
254 0 my $filehandle;
255 0 ▶ if (ref ($outfile) !~ /GLOB/) {
Branch: 1 branch
BranchTrueFalseTotal
if (not ref($outfile) =~ /GLOB/) { } 0 0 0
256 0 ▶ open (SIGNALP, "<".$outfile) or $self->throw ("Couldn't open file ".$outfile.": $!\n");
Branch: 1 branch
BranchTrueFalseTotal
open SIGNALP, '<' . $outfile or $self->throw(q[Couldn't open file ] . $outfile . ": $!\n") 0 0 0
257 0 $filehandle = \*SIGNALP;
258 }
259 else {
260 0 $filehandle = $outfile;
261 }
262  
263 0 my $signalp_parser = Bio::Tools::Signalp->new(-fh=>$filehandle);
264  
265 0 my @signalp_feat;
266  
267 0 ▶ while(my $signalp_feat = $signalp_parser->next_result){
Branch: 1 branch
BranchTrueFalseTotal
if (my $signalp_feat = $signalp_parser->next_result) 0 0 0
268  
269 0 push @signalp_feat, $signalp_feat;
270 }
271
272 0 $self->cleanup();
273 0 close($tfh1);
274 0 undef $tfh1;
275 0 unlink $outfile;
276
277 0 return @signalp_feat;
278 }
279  
280  
281 =head2 _writeSeqFile
282  
283 Title : _writeSeqFile
284 Usage : $factory->_writeSeqFile($seq)
285 Function: Creates a file from the given seq object
286 Returns : A string(filename)
287 Args : Bio::PrimarySeqI
288  
289 =cut
290  
291 0 ▶sub _writeSeqFile{
Subroutine _writeSeqFile: not called CC=1 SCAR=6.9
292 0 my ($self,$seq) = @_;
293 0 my ($tfh,$inputfile) = $self->io->tempfile(-dir=>$self->tempdir());
294 0 my $in = Bio::SeqIO->new(-fh => $tfh , '-format' => 'fasta');
295 0 $in->write_seq($seq);
296 0 $in->close();
297 0 close($tfh);
298 0 undef $tfh;
299 0 return $inputfile;
300  
301 }
302 1 1;
« Tools/Run/EMBOSSacd.pm ↑ Summary Tools/Run/Phylo/Hyphy/REL.pm »