Tools/Run/Coil.pm

filter: Statementstmt 36.2% 33 / 91 Branchbran 6.6% 2 / 30 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 64.7% 11 / 17 Podpod 100% 5 / 5 totaltotal 33.5% 51 / 152 CC 19 SCAR 33.0
CC
19
Cov
28%
_run
90.0
AUTOLOAD
12.0
run
12.0
CRAP 27.1
« Tools/Run/Genemark.pm ↑ Summary Tools/Run/Promoterwise.pm »
1 # Wrapper module for Coil Bio::Tools::Run::Coil
2 #
3 # Based on the EnsEMBL module Bio::EnsEMBL::Pipeline::Runnable::Protein::Coil
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 # You may distribute this module under the same terms as perl itself
11 #
12 # POD documentation - main docs before the code
13  
14 =head1 NAME
15  
16 Bio::Tools::Run::Coil - wrapper for ncoils program
17  
18 =head1 SYNOPSIS
19  
20 # Build a Coil factory
21 my $factory = Bio::Tools::Run::Coil->new($params);
22  
23 # Pass the factory a Bio::Seq object
24 # @feats is an array of Bio::SeqFeature::Generic objects
25 my @feats = $factory->run($seq);
26  
27 =head1 DESCRIPTION
28  
29 This module is a wrapper for the B<ncoils> program available via
30 L<http://www.russell.embl-heidelberg.de/coils/coils.tar.gz> for predicting
31 coiled coils in protein sequences.
32  
33 By default it looks for an executable called I<ncoils> and data/parameter files
34 in the directory specified by the I<COILSDIR> environmental variable.
35  
36 =head1 REFERENCES
37  
38 Lupas, van Dyke & Stock,
39 I<Predicting coiled coils from protein sequences>,
40 Science B<252>:1162-1164, 1991.
41  
42 Lupas, A.,
43 I<Prediction and Analysis of Coiled-Coil Structures>,
44 Meth. Enzymology B<266>:513-525, 1996.
45  
46 =head1 FEEDBACK
47  
48 =head2 Mailing Lists
49  
50 User feedback is an integral part of the evolution of this and other
51 Bioperl modules. Send your comments and suggestions preferably to one
52 of the Bioperl mailing lists. Your participation is much appreciated.
53  
54 bioperl-l@bioperl.org - General discussion
55 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
56  
57 =head2 Support
58  
59 Please direct usage questions or support issues to the mailing list:
60  
61 I<bioperl-l@bioperl.org>
62  
63 rather than to the module maintainer directly. Many experienced and
64 reponsive experts will be able look at the problem and quickly
65 address it. Please include a thorough description of the problem
66 with code and data examples if at all possible.
67  
68 =head2 Reporting Bugs
69  
70 Report bugs to the Bioperl bug tracking system to help us keep track
71 the bugs and their resolution. Bug reports can be submitted via the
72 web:
73  
74 http://redmine.open-bio.org/projects/bioperl/
75  
76 =head1 AUTHORS
77  
78 Based on the EnsEMBL module Bio::EnsEMBL::Pipeline::Runnable::Protein::Coil
79 originally written by Marc Sohrmann (ms2@sanger.ac.uk)
80  
81 Written in BioPipe by Balamurugan Kumarasamy <savikalpa@fugu-sg.org>
82  
83 # Please direct questions and support issues to <bioperl-l@bioperl.org>
84 #
85 Cared for by the Fugu Informatics team (fuguteam@fugu-sg.org)
86  
87 =head1 APPENDIX
88  
89 The rest of the documentation details each of the object
90 methods. Internal methods are usually preceded with a _
91  
92 =cut
93  
94 package Bio::Tools::Run::Coil;
95  
96 1 ▶use vars qw($AUTOLOAD @ISA $PROGRAM $PROGRAMDIR
Subroutine BEGIN: called CC=1 SCAR=0.0
97 1 $PROGRAMNAME @COIL_PARAMS %OK_FIELD);
98 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
99 1 ▶use Bio::SeqIO;
Subroutine BEGIN: called CC=1 SCAR=0.0
100 1 ▶use Bio::Root::Root;
Subroutine BEGIN: called CC=1 SCAR=0.0
101 1 ▶use Bio::Root::IO;
Subroutine BEGIN: called CC=1 SCAR=0.0
102 1 ▶use Bio::Tools::Coil;
Subroutine BEGIN: called CC=1 SCAR=0.0
103 1 ▶use Bio::Tools::Run::WrapperBase;
Subroutine BEGIN: called CC=1 SCAR=0.0
104  
105 1 @ISA = qw(Bio::Root::Root Bio::Tools::Run::WrapperBase);
106  
107 1 ▶BEGIN {
Subroutine BEGIN: called CC=2 SCAR=6.9
108 1 @COIL_PARAMS=qw(PROGRAM VERBOSE QUIET SILENT);
109 1 foreach my $attr ( @COIL_PARAMS)
110 4 { $OK_FIELD{$attr}++; }
111 }
112  
113 0 ▶sub AUTOLOAD {
Subroutine AUTOLOAD: not called CC=3 SCAR=24.8
114 0 my $self = shift;
115 0 my $attr = $AUTOLOAD;
116 0 $attr =~ s/.*:://;
117 0 $attr = uc $attr;
118 0 ▶ $self->throw("Unallowed parameter: $attr !") unless $OK_FIELD{$attr};
Branch: 1 branch
BranchTrueFalseTotal
unless $Bio::Tools::Run::Coil::OK_FIELD{$attr} 0 0 0
119 0 ▶ $self->{$attr} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
120 0 return $self->{$attr};
121 }
122  
123 =head2 program_name
124  
125 Title : program_name
126 Usage : $factory>program_name()
127 Function: holds the program name
128 Returns: string
129 Args : None
130  
131 =cut
132  
133 6 ▶sub program_name {
Subroutine program_name: called CC=1 SCAR=0.0
Pod documented
134 6 return 'ncoils';
135 }
136  
137 =head2 program_dir
138  
139 Title : program_dir
140 Usage : $factory->program_dir(@params)
141 Function: returns the program directory, obtained from ENV variable.
142 Returns: string
143 Args :
144  
145 =cut
146  
147 3 ▶sub program_dir {
Subroutine program_dir: called CC=2 SCAR=7.6
Pod documented
148 3 ▶ return Bio::Root::IO->catfile($ENV{COILSDIR}) if $ENV{COILSDIR};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"COILSDIR"} 0 3 3
149 }
150  
151 =head2 new
152  
153 Title : new
154 Usage : $coil->new(@params)
155 Function: creates a new Coil factory
156 Returns: Bio::Tools::Run::Coil
157 Args :
158  
159 =cut
160  
161 1 ▶sub new {
Subroutine new: called CC=4 SCAR=21.7
Pod documented
162 1 my ($class,@args) = @_;
163 1 my $self = $class->SUPER::new(@args);
164 1 my ($attr, $value);
165 1 ▶ while (@args) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args) 0 1 1
166 0 $attr = shift @args;
167 0 $value = shift @args;
168 0 ▶ next if( $attr =~ /^-/ ); # don't want named parameters
Branch: 1 branch
BranchTrueFalseTotal
if $attr =~ /^-/ 0 0 0
169 0 ▶ if ($attr =~/PROGRAM/i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($attr =~ /PROGRAM/i) 0 0 0
170 0 $self->executable($value);
171 0 next;
172 }
173 0 $self->$attr($value);
174 }
175 1 return $self;
176 }
177  
178 =head2 predict_protein_features
179  
180 Title : predict_protein_features()
181 Usage : DEPRECATED. Use $obj->run instead.
182 Function: Runs Coil and creates an array of featrues
183 Returns : An array of Bio::SeqFeature::Generic objects
184 Args : A Bio::PrimarySeqI
185  
186 =cut
187  
188 0 ▶sub predict_protein_features{
Subroutine predict_protein_features: not called CC=1 SCAR=6.9
Pod documented
189 0 return shift->run(@_);
190 }
191  
192 =head2 run
193  
194 Title : run
195 Usage : $obj->run($seq)
196 Function: Runs Coil and creates an array of featrues
197 Returns : An array of Bio::SeqFeature::Generic objects
198 Args : A Bio::PrimarySeqI, or a Fasta filename.
199  
200 =cut
201  
202 0 ▶sub run{
Subroutine run: not called CC=3 SCAR=24.8
Pod documented
203 0 my ($self,$seq) = @_;
204 0 my @feats;
205
206 0 ▶ if (ref($seq) ) { # it is an object
Branch: 1 branch
BranchTrueFalseTotal
if (ref $seq) { } 0 0 0
207 0 ▶ if (ref($seq) =~ /GLOB/) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref($seq) =~ /GLOB/) 0 0 0
208 0 $self->throw("cannot use filehandle");
209 }
210
211 0 my $infile1 = $self->_writeSeqFile($seq);
212
213 0 $self->_input($infile1);
214
215 0 @feats = $self->_run();
216 0 unlink $infile1;
217 }
218 else {
219 #The argument is not a seq object but a sequence in a fasta file.
220 #Perhaps should check here or before if this file is fasta format...if not die
221 #Here the file does not need to be created or deleted. Its already written and may be used by other runnables.
222  
223 0 $self->_input($seq);
224  
225 0 @feats = $self->_run();
226
227 }
228
229 0 return @feats;
230  
231 }
232  
233 =head2 _input
234  
235 Title : _input
236 Usage : obj->_input($seqFile)
237 Function: Internal(not to be used directly)
238 Returns :
239 Args :
240  
241 =cut
242  
243 0 ▶sub _input() {
Subroutine _input: not called CC=2 SCAR=17.9
244 0 my ($self,$infile1) = @_;
245 0 ▶ if(defined $infile1){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $infile1) 0 0 0
246
247 0 $self->{'input'}=$infile1;
248 }
249 0 return $self->{'input'};
250  
251 }
252  
253 =head2 _run
254  
255 Title : _run
256 Usage : $obj->_run()
257 Function: Internal(not to be used directly)
258 Returns : An array of Bio::SeqFeature::Generic objects
259 Args :
260  
261 =cut
262  
263 0 ▶sub _run {
Subroutine _run: not called CC=9 SCAR=45.0
264 0 my ($self)= @_;
265
266 0 my ($tfh1,$outfile) = $self->io->tempfile(-dir=>$self->tempdir());
267 0 my $str =$self->executable." -f < ".$self->{'input'}." > ".$outfile;
268 0 ▶ if($self->quiet || $self->verbose <=0 || $self->silent){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->quiet or $self->verbose <= 0 or $self->silent) 0 0 0
Condition0%0/6
$self->quiet or $self->verbose <= 0 or $self->silent
l!l&&r!l&&!r
000
$self->quiet or $self->verbose <= 0
l!l&&r!l&&!r
000
MC/DC0%0/3
$self->quiet or $self->verbose <= 0 or $self->silent
$self->quiet $self->verbose <= 0 $self->silent
Truth table0%0/4
A or B or C
A= $self->quietB= $self->verbose <= 0C= $self->silent
ABCresult
1XX1
01X1
0011
0000
269 0 ▶ my $null = ($^O =~ m/mswin/i) ? 'NUL' : '/dev/null';
Branch: 1 branch
BranchTrueFalseTotal
$^O =~ /mswin/i ? : 0 0 0
270 0 $str.=" 2>$null";
271 }
272 0 my $status = system($str);
273 0 ▶ $self->throw( "Coil call ($str) crashed: $? \n") unless $status==0;
Branch: 1 branch
BranchTrueFalseTotal
unless $status == 0 0 0 0
274
275 0 my $coil_parser = Bio::Tools::Coil->new();
276 0 my $filehandle;
277 0 ▶ if (ref ($outfile) !~ /GLOB/) {
Branch: 1 branch
BranchTrueFalseTotal
if (not ref($outfile) =~ /GLOB/) { } 0 0 0
278 0 ▶ open (COIL, "<".$outfile) or $self->throw ("Couldn't open file ".$outfile.": $!\n");
Branch: 1 branch
BranchTrueFalseTotal
open COIL, '<' . $outfile or $self->throw(q[Couldn't open file ] . $outfile . ": $!\n") 0 0 0
279 0 $filehandle = \*COIL;
280 }
281 else {
282 0 $filehandle = $outfile;
283 }
284  
285 0 my @coil_feat;
286
287 0 ▶ while(my $coil_feat = $coil_parser->next_result($filehandle)){
Branch: 1 branch
BranchTrueFalseTotal
if (my $coil_feat = $coil_parser->next_result($filehandle)) 0 0 0
288  
289 0 push @coil_feat, $coil_feat;
290 }
291
292 0 $self->cleanup();
293 0 close($tfh1);
294 0 undef $tfh1;
295  
296 0 unlink $outfile;
297 0 return @coil_feat;
298  
299 }
300  
301 =head2 _writeSeqFile
302  
303 Title : _writeSeqFile
304 Usage : obj->_writeSeqFile($seq)
305 Function: Internal(not to be used directly)
306 Returns :
307 Args :
308  
309 =cut
310  
311 0 ▶sub _writeSeqFile{
Subroutine _writeSeqFile: not called CC=1 SCAR=6.9
312 0 my ($self,$seq) = @_;
313 0 my ($tfh,$inputfile) = $self->io->tempfile(-dir=>$self->tempdir());
314 0 my $in = Bio::SeqIO->new(-fh => $tfh , '-format' => 'Fasta');
315 0 $in->write_seq($seq);
316  
317 0 return $inputfile;
318  
319 }
320 1 1;
« Tools/Run/Genemark.pm ↑ Summary Tools/Run/Promoterwise.pm »