Tools/Run/Alignment/Exonerate.pm

filter: Statementstmt 35.7% 35 / 98 Branchbran 21.4% 6 / 28 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 58.8% 10 / 17 Podpod 100% 5 / 5 totaltotal 37.0% 56 / 151 CC 18 SCAR 23.5
CC
18
Cov
32%
_writeInput
30.0
_setparams
20.0
AUTOLOAD
12.0
CRAP 10.5
« Tools/Run/Phylo/Hyphy/REL.pm ↑ Summary Tools/Run/StandAloneWUBlast.pm »
1 #
2 # Please direct questions and support issues to <bioperl-l@bioperl.org>
3 #
4 # Cared for by Shawn Hoon
5 #
6 # Copyright Shawn Hoon
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::Run::Alignment::Exonerate
15  
16 =head1 SYNOPSIS
17  
18 use Bio::Tools::Run::Alignment::Exonerate;
19 use Bio::SeqIO;
20  
21 my $qio = Bio::SeqIO->new(-file=>$ARGV[0],-format=>'fasta');
22 my $query = $qio->next_seq();
23 my $tio = Bio::SeqIO->new(-file=>$ARGV[1],-format=>'fasta');
24 my $target = $sio->next_seq();
25  
26 #exonerate parameters can all be passed via arguments parameter.
27 #parameters passed are not checked for validity
28  
29 my $run = Bio::Tools::Run::Alignment::Exonerate->
30 new(arguments=>'--model est2genome --bestn 10');
31 my $searchio_obj = $run->run($query,$target);
32  
33 while(my $result = $searchio->next_result){
34 while( my $hit = $result->next_hit ) {
35 while( my $hsp = $hit->next_hsp ) {
36 print $hsp->start."\t".$hsp->end."\n";
37 }
38 }
39 }
40  
41 =head1 DESCRIPTION
42  
43 Wrapper for Exonerate alignment program. You can get exonerate at
44 http://www.ebi.ac.uk/~guy/exonerate/. This wrapper is written without
45 parameter checking. All parameters are passed via the arugment
46 parameter that is passed in the constructor. See SYNOPSIS. For
47 exonerate parameters, run exonerate --help for more details.
48  
49 =head1 PROGRAM VERSIONS
50  
51 The tests have been shown to pass with exonorate versions 2.0 - 2.2.
52  
53 =head1 FEEDBACK
54  
55 =head2 Mailing Lists
56  
57 User feedback is an integral part of the evolution of this and other
58 Bioperl modules. Send your comments and suggestions preferably to one
59 of the Bioperl mailing lists. Your participation is much appreciated.
60  
61 bioperl-l@bioperl.org - General discussion
62 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
63  
64 =head2 Support
65  
66 Please direct usage questions or support issues to the mailing list:
67  
68 I<bioperl-l@bioperl.org>
69  
70 rather than to the module maintainer directly. Many experienced and
71 reponsive experts will be able look at the problem and quickly
72 address it. Please include a thorough description of the problem
73 with code and data examples if at all possible.
74  
75 =head2 Reporting Bugs
76  
77 Report bugs to the Bioperl bug tracking system to help us keep track
78 the bugs and their resolution. Bug reports can be submitted via the
79 web:
80  
81 http://redmine.open-bio.org/projects/bioperl/
82  
83 =head1 AUTHOR - Shawn Hoon
84  
85 Email shawnh-at-stanford.edu
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::Alignment::Exonerate;
95  
96 1 ▶use vars qw($AUTOLOAD @ISA $PROGRAM $PROGRAMDIR
Subroutine BEGIN: called CC=1 SCAR=0.0
97 1 $PROGRAMNAME @EXONERATE_PARAMS %OK_FIELD);
98 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
99 1 ▶use Bio::Root::Root;
Subroutine BEGIN: called CC=1 SCAR=0.0
100 1 ▶use Bio::Root::IO;
Subroutine BEGIN: called CC=1 SCAR=0.0
101 1 ▶use Bio::Factory::ApplicationFactoryI;
Subroutine BEGIN: called CC=1 SCAR=0.0
102 1 ▶use Bio::Tools::Run::WrapperBase;
Subroutine BEGIN: called CC=1 SCAR=0.0
103 1 ▶use Bio::SearchIO;
Subroutine BEGIN: called CC=1 SCAR=0.0
104  
105 1 @ISA = qw(Bio::Root::Root Bio::Tools::Run::WrapperBase
106 Bio::Factory::ApplicationFactoryI);
107  
108 =head2 program_name
109  
110 Title : program_name
111 Usage : $factory>program_name()
112 Function: holds the program name
113 Returns: string
114 Args : None
115  
116 =cut
117  
118 6 ▶sub program_name {
Subroutine program_name: called CC=1 SCAR=0.0
Pod documented
119 6 return 'exonerate';
120 }
121  
122 =head2 program_dir
123  
124 Title : program_dir
125 Usage : $factory->program_dir(@params)
126 Function: returns the program directory, obtained from ENV variable.
127 Returns: string
128 Args :
129  
130 =cut
131  
132 3 ▶sub program_dir {
Subroutine program_dir: called CC=2 SCAR=7.6
Pod documented
133 3 ▶ return Bio::Root::IO->catfile($ENV{EXONERATEDIR}) if $ENV{EXONERATEDIR};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"EXONERATEDIR"} 0 3 3
134 }
135 0 ▶sub AUTOLOAD {
Subroutine AUTOLOAD: not called CC=3 SCAR=24.8
136 0 my $self = shift;
137 0 my $attr = $AUTOLOAD;
138 0 $attr =~ s/.*:://;
139 0 $attr = uc $attr;
140 0 ▶ $self->throw("Unallowed parameter: $attr !") unless $OK_FIELD{$attr};
Branch: 1 branch
BranchTrueFalseTotal
unless $Bio::Tools::Run::Alignment::Exonerate::OK_FIELD{$attr} 0 0 0
141 0 ▶ $self->{$attr} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
142 0 return $self->{$attr};
143 }
144  
145 =head2 new
146  
147 Title : new
148 Usage : my $factory= Bio::Tools::Run::Phrap->new();
149 Function: creates a new Phrap factory
150 Returns: Bio::Tools::Run::Phrap
151 Args :
152  
153 =cut
154  
155 1 ▶sub new {
Subroutine new: called CC=4 SCAR=14.0
Pod documented
156 1 my ($class,@args) = @_;
157 1 my $self = $class->SUPER::new(@args);
158
159 1 my ($attr, $value);
160 1 ▶ while (@args) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args) 2 1 3
161 2 $attr = shift @args;
162 2 $value = shift @args;
163 2 ▶ next if( $attr =~ /^-/ ); # don't want named parameters
Branch: 1 branch
BranchTrueFalseTotal
if $attr =~ /^-/ 1 1 2
164 1 ▶ if ($attr =~/PROGRAM/i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($attr =~ /PROGRAM/i) 0 1 1
165 0 $self->executable($value);
166 0 next;
167 }
168 1 $self->$attr($value);
169 }
170 1 return $self;
171 }
172  
173 =head2 version
174  
175 Title : version
176 Usage : exit if $prog->version() < 1.8
177 Function: Determine the version number of the program
178 Example :
179 Returns : float or undef
180 Args : none
181  
182 =cut
183  
184 0 ▶sub version {
Subroutine version: not called CC=3 SCAR=24.8
Pod documented
185 0 my ($self) = @_;
186 0 my $exe;
187 0 ▶ return undef unless $exe = $self->executable;
Branch: 1 branch
BranchTrueFalseTotal
unless $exe = $self->executable 0 0 0
188 0 my $string = `$exe -v` ;
189 #exonerate from exonerate version 2.0.0\n...
190 0 my ($version) = $string =~ /exonerate version ([\d+\.]+)/m;
191 0 $version =~ s/\.(\d+)$/$1/;
192 0 ▶ return $version || undef;
Condition0%0/2
$version || undef
l!l
00
MC/DC0%0/1
$version || undef
$version
Truth table0%0/2
A
A= $version
Aresult
11
00
193 }
194  
195  
196 =head2 run
197  
198 Title : run()
199 Usage : my $feats = $factory->run($seq)
200 Function: Runs Phrap
201 Returns : An array of Bio::SeqFeature::Generic objects
202 Args : A Bio::PrimarySeqI
203  
204 =cut
205  
206 0 ▶sub run {
Subroutine run: not called CC=1 SCAR=6.9
Pod documented
207 0 my ($self,$query,$target) = @_;
208 0 my @feats;
209 0 my ($file1) = $self->_writeInput($query);
210 0 my ($file2) = $self->_writeInput($target);
211 0 my $assembly = $self->_run($file1,$file2);
212 0 return $assembly;
213 }
214  
215 =head2 _input
216  
217 Title : _input
218 Usage : $factory->_input($seqFile)
219 Function: get/set for input file
220 Returns :
221 Args :
222  
223 =cut
224  
225 0 ▶sub _input() {
Subroutine _input: not called CC=2 SCAR=17.9
226 0 my ($self,$infile1) = @_;
227 0 ▶ $self->{'input'} = $infile1 if(defined $infile1);
Branch: 1 branch
BranchTrueFalseTotal
if defined $infile1 0 0 0
228 0 return $self->{'input'};
229 }
230  
231 =head2 _run
232  
233 Title : _run
234 Usage : $factory->_run()
235 Function: Makes a system call and runs Phrap
236 Returns : An array of Bio::SeqFeature::Generic objects
237 Args :
238  
239 =cut
240  
241 0 ▶sub _run {
Subroutine _run: not called CC=2 SCAR=17.9
242 0 my ($self,$query,$target)= @_;
243  
244 0 my ($tfh,$outfile) = $self->io->tempfile(-dir=>$self->tempdir);
245 0 my $param_str = $self->_setparams." ".$self->arguments;
246 0 my $str = $self->executable." $param_str $query $target "." > $outfile";
247 0 $self->debug( "$str\n");
248 0 my $status = system($str);
249 0 ▶ $self->throw( "Exonerate call ($str) crashed: $? \n") unless $status==0;
Branch: 1 branch
BranchTrueFalseTotal
unless $status == 0 0 0 0
250 0 my $filehandle;
251 0 my $exonerate_obj = Bio::SearchIO->new(-file=>"$outfile",-format=>'exonerate');
252  
253 0 close($tfh);
254 0 undef $tfh;
255 0 unlink $outfile;
256  
257 0 return $exonerate_obj;
258 }
259  
260  
261 =head2 _writeInput
262  
263 Title : _writeInput
264 Usage : $factory->_writeInput($query,$target)
265 Function: Creates a file from the given seq object
266 Returns : A string(filename)
267 Args : Bio::PrimarySeqI
268  
269 =cut
270  
271 0 ▶sub _writeInput{
Subroutine _writeInput: not called CC=5 SCAR=34.0
272 0 my ($self,$query) = @_;
273 0 my ($fh,$infile1);
274 0 ▶ if (ref($query) =~ /ARRAY/i) {
Branch: 2 branches
BranchTrueFalseTotal
if (ref($query) =~ /ARRAY/i) { } 0 0 0
elsif ($query->isa('Bio::PrimarySeqI')) { } 0 0 0
275 0 my @infilearr;
276 0 ($fh, $infile1) = $self->io->tempfile();
277 0 my $temp = Bio::SeqIO->new( -file => ">$infile1",
278 -format => 'Fasta' );
279 0 foreach my $seq1 (@$query) {
280 0 ▶ unless ($seq1->isa("Bio::PrimarySeqI")) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($seq1->isa("Bio::PrimarySeqI")) 0 0 0
281 0 return 0;
282 }
283 0 $temp->write_seq($seq1);
284 0 push @infilearr, $infile1;
285 }
286 }
287 elsif($query->isa("Bio::PrimarySeqI")) {
288 0 ($fh, $infile1) = $self->io->tempfile();
289 0 my $temp = Bio::SeqIO->new( -file => ">$infile1",
290 -format => 'Fasta' );
291 0 $temp->write_seq($query);
292 }
293 else {
294 0 $infile1 = $query;
295 }
296 0 return $infile1;
297 }
298  
299 =head2 _setparams
300  
301 Title : _setparams
302 Usage : Internal function, not to be called directly
303 Function: creates a string of params to be used in the command string
304 Example :
305 Returns : string of params
306 Args :
307  
308 =cut
309  
310 0 ▶sub _setparams {
Subroutine _setparams: not called CC=4 SCAR=30.0
311 0 my ($self) = @_;
312 0 my $param_string = '';
313 0 foreach my $attr(@EXONERATE_PARAMS){
314 0 ▶ next if($attr=~/PROGRAM/);
Branch: 1 branch
BranchTrueFalseTotal
if $attr =~ /PROGRAM/ 0 0 0
315 0 my $value = $self->$attr();
316 0 ▶ next unless (defined $value);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 0 0 0
317 0 my $attr_key = ' -'.(lc $attr);
318 0 $param_string .= $attr_key.' '.$value;
319 }
320 0 return $param_string;
321 }
322  
323 1 1;
« Tools/Run/Phylo/Hyphy/REL.pm ↑ Summary Tools/Run/StandAloneWUBlast.pm »