blib/lib/Bio/Tools/Run/Seg.pm

filter: Statementstmt 37.5% 33 / 88 Branchbran 8.3% 2 / 24 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 64.7% 11 / 17 Podpod 100% 5 / 5 totaltotal 38.0% 51 / 134 CC 14 SCAR 21.9
CC
14
Cov
31%
_run
30.0
AUTOLOAD
12.0
run
12.0
CRAP 8.9
« blib/lib/Bio/Tools/Run/Alignment/Gmap.pm ↑ Summary blib/lib/Bio/Tools/Run/Genscan.pm »
1 # $Id$
2 # Copyright Balamurugan Kumarasamy
3 # You may distribute this module under the same terms as perl itself
4 # POD documentation - main docs before the code
5  
6 =head1 NAME
7  
8 Bio::Tools::Run::Seg - Object for identifying low complexity
9 regions in a given protein seequence.
10  
11 =head1 SYNOPSIS
12  
13 # Build a Seg factory
14 # $paramfile is the full path to the seg binary file
15 my @params = ('PROGRAM',$paramfile);
16 my $factory = Bio::Tools::Run::Seg->new($param);
17  
18 # Pass the factory a Bio::Seq object
19 # @feats is an array of Bio::SeqFeature::Generic objects
20 my @feats = $factory->run($seq);
21  
22 =head1 DESCRIPTION
23  
24 Seg is a program which identifies low complexity regions in proteins.
25 It was developed by Wootton and Federhen at NCBI.
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  
39 =head2 Support
40  
41 Please direct usage questions or support issues to the mailing list:
42  
43 I<bioperl-l@bioperl.org>
44  
45 rather than to the module maintainer directly. Many experienced and
46 reponsive experts will be able look at the problem and quickly
47 address it. Please include a thorough description of the problem
48 with code and data examples if at all possible.
49  
50 =head2 Reporting Bugs
51  
52 Report bugs to the Bioperl bug tracking system to help us keep track
53 the bugs and their resolution. Bug reports can be submitted via the
54 web:
55  
56 http://redmine.open-bio.org/projects/bioperl/
57  
58 =head1 AUTHOR - Bala
59  
60 Email savikalpa@fugu-sg.org
61  
62 =head1 APPENDIX
63  
64 The rest of the documentation details each of the object
65 methods. Internal methods are usually preceded with a _
66  
67 =cut
68  
69 package Bio::Tools::Run::Seg;
70  
71 1 use vars qw($AUTOLOAD @ISA $PROGRAM $PROGRAMDIR
72 1 ▶ $PROGRAMNAME @SEG_PARAMS %OK_FIELD);
Subroutine BEGIN: called CC=1 SCAR=0.0
73 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
74 1 ▶use Bio::SeqIO;
Subroutine BEGIN: called CC=1 SCAR=0.0
75 1 ▶use Bio::Root::Root;
Subroutine BEGIN: called CC=1 SCAR=0.0
76 1 ▶use Bio::Root::IO;
Subroutine BEGIN: called CC=1 SCAR=0.0
77 1 ▶use Bio::Tools::Seg;
Subroutine BEGIN: called CC=1 SCAR=0.0
78 1 ▶use Bio::Tools::Run::WrapperBase;
Subroutine BEGIN: called CC=1 SCAR=0.0
79  
80 1 @ISA = qw(Bio::Root::Root Bio::Tools::Run::WrapperBase);
81  
82 BEGIN {
83 1 ▶ @SEG_PARAMS=qw(PROGRAM VERBOSE);
Subroutine BEGIN: called CC=2 SCAR=6.9
84 1 foreach my $attr ( @SEG_PARAMS)
85 2 { $OK_FIELD{$attr}++; }
86 }
87  
88 =head2 program_name
89  
90 Title : program_name
91 Usage : $factory->program_name()
92 Function: holds the program name
93 Returns: string
94 Args : None
95  
96 =cut
97  
98 sub program_name {
99 6 ▶ return 'seg';
Subroutine program_name: called CC=1 SCAR=0.0
Pod documented
100 }
101  
102 =head2 program_dir
103  
104 Title : program_dir
105 Usage : $factory->program_dir(@params)
106 Function: returns the program directory, obtained from ENV variable.
107 Returns : string, or undef if $SEGDIR not in ENV
108 Args : None
109  
110 =cut
111  
112 sub program_dir {
113 3 ▶ return Bio::Root::IO->catfile($ENV{SEGDIR}) if $ENV{SEGDIR};
Subroutine program_dir: called CC=2 SCAR=7.6
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"SEGDIR"} 0 3 3
114 }
115  
116 sub AUTOLOAD {
117 0 ▶ my $self = shift;
Subroutine AUTOLOAD: not called CC=3 SCAR=24.8
118 0 my $attr = $AUTOLOAD;
119 0 $attr =~ s/.*:://;
120 0 $attr = uc $attr;
121 0 ▶ $self->throw("Unallowed parameter: $attr !") unless $OK_FIELD{$attr};
Branch: 1 branch
BranchTrueFalseTotal
unless $Bio::Tools::Run::Seg::OK_FIELD{$attr} 0 0 0
122 0 ▶ $self->{$attr} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
123 0 return $self->{$attr};
124 }
125  
126 =head2 new
127  
128 Title : new
129 Usage : $rm->new(@params)
130 Function: creates a new Seg factory
131 Returns: Bio::Tools::Run::Seg
132 Args :
133  
134 =cut
135  
136 sub new {
137 1 ▶ my ($class,@args) = @_;
Subroutine new: called CC=3 SCAR=14.8
Pod documented
138 1 my $self = $class->SUPER::new(@args);
139  
140 1 my ($attr, $value);
141 1 ▶ while (@args) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args) 0 1 1
142 0 $attr = shift @args;
143 0 $value = shift @args;
144 0 ▶ next if( $attr =~ /^-/ );
Branch: 1 branch
BranchTrueFalseTotal
if $attr =~ /^-/ 0 0 0
145 0 $self->$attr($value);
146 }
147 1 return $self;
148 }
149  
150 =head2 predict_protein_features
151  
152 Title : predict_protein_features()
153 Usage : DEPRECATED Use $obj->run($seq) instead
154 Function: Runs Seg and creates an array of featrues
155 Returns : An array of Bio::SeqFeature::Generic objects
156 Args : A Bio::PrimarySeqI
157  
158 =cut
159  
160 sub predict_protein_features{
161 0 ▶ return shift->run(@_);
Subroutine predict_protein_features: not called CC=1 SCAR=6.9
Pod documented
162 }
163  
164 =head2 run
165  
166 Title : run
167 Usage : $obj->run($seq)
168 Function: Runs Seg and creates an array of featrues
169 Returns : An array of Bio::SeqFeature::Generic objects
170 Args : A Bio::PrimarySeqI
171  
172 =cut
173  
174 sub run{
175 0 ▶ my ($self,$seq) = @_;
Subroutine run: not called CC=3 SCAR=24.8
Pod documented
176 0 my @feats;
177  
178 0 ▶ if (ref($seq) ) { # it is an object
Branch: 1 branch
BranchTrueFalseTotal
if (ref $seq) { } 0 0 0
179 0 ▶ if (ref($seq) =~ /GLOB/) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref($seq) =~ /GLOB/) 0 0 0
180 0 $self->throw("cannot use filehandle");
181 }
182  
183 0 my $infile1 = $self->_writeSeqFile($seq);
184  
185 0 $self->_input($infile1);
186  
187 0 @feats = $self->_run();
188 0 unlink $infile1;
189 }
190 else {
191 #The seq object is not a seq object but a file.
192 #Here the file does not need to be created.
193  
194 0 $self->_input($seq);
195  
196 0 @feats = $self->_run();
197  
198 }
199  
200 0 return @feats;
201  
202 }
203  
204 =head2 _input
205  
206 Title : _input
207 Usage : obj->_input($seqFile)
208 Function: Internal (not to be used directly)
209 Returns :
210 Args :
211  
212 =cut
213  
214 sub _input {
215 0 ▶ my ($self,$infile1) = @_;
Subroutine _input: not called CC=2 SCAR=17.9
216 0 ▶ if(defined $infile1){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $infile1) 0 0 0
217  
218 0 $self->{'input'}=$infile1;
219 }
220 0 return $self->{'input'};
221 }
222  
223 =head2 _run
224  
225 Title : _run
226 Usage : $obj->_run()
227 Function: Internal (not to be used directly)
228 Returns : An array of Bio::SeqFeature::Generic objects
229 Args : None
230  
231 =cut
232  
233 sub _run {
234 0 ▶ my ($self)= @_;
Subroutine _run: not called CC=5 SCAR=34.0
235  
236 0 my ($tfh1,$outfile) = $self->io->tempfile(-dir=>$self->tempdir());
237 0 my $str =$self->executable." ".$self->_input." -l > ".$outfile;
238 0 my $status = system($str);
239 0 ▶ $self->throw( "Seg call ($str) crashed: $? \n") unless $status==0;
Branch: 1 branch
BranchTrueFalseTotal
unless $status == 0 0 0 0
240
241 0 my $filehandle;
242 0 ▶ if (ref ($outfile) !~ /GLOB/) {
Branch: 1 branch
BranchTrueFalseTotal
if (not ref($outfile) =~ /GLOB/) { } 0 0 0
243 0 ▶ open (SEG, "<".$outfile) or $self->throw ("Couldn't open file ".$outfile.": $!\n");
Branch: 1 branch
BranchTrueFalseTotal
open SEG, '<' . $outfile or $self->throw(q[Couldn't open file ] . $outfile . ": $!\n") 0 0 0
244 0 $filehandle = \*SEG;
245 }
246 else {
247 0 $filehandle = $outfile;
248 }
249 0 my $seg_parser = Bio::Tools::Seg->new(-fh=>$filehandle);
250  
251 0 my @seg_feat;
252  
253 0 ▶ while(my $seg_feat = $seg_parser->next_result){
Branch: 1 branch
BranchTrueFalseTotal
if (my $seg_feat = $seg_parser->next_result) 0 0 0
254  
255 0 push @seg_feat, $seg_feat;
256 }
257 # free resources
258 0 $self->cleanup();
259 0 unlink $outfile;
260 0 close($tfh1);
261 0 undef $tfh1;
262 0 return @seg_feat;
263  
264 }
265  
266 =head2 _writeSeqFile
267  
268 Title : _writeSeqFile
269 Usage : obj->_writeSeqFile($seq)
270 Function: Internal (not to be used directly)
271 Returns : string - Fasta filename to which $seq was written
272 Args : Bio::Seq object
273  
274 =cut
275  
276 sub _writeSeqFile{
277 0 ▶ my ($self,$seq) = @_;
Subroutine _writeSeqFile: not called CC=1 SCAR=6.9
278 0 my ($tfh,$inputfile) = $self->io->tempfile(-dir=>$self->tempdir());
279 0 my $in = Bio::SeqIO->new(-fh => $tfh , '-format' => 'Fasta');
280 0 $in->write_seq($seq);
281 0 $in->close();
282 0 close($tfh);
283 0 undef $tfh;
284 0 return $inputfile;
285  
286 }
287 1 1;
« blib/lib/Bio/Tools/Run/Alignment/Gmap.pm ↑ Summary blib/lib/Bio/Tools/Run/Genscan.pm »