| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# |
|
2
|
|
|
|
|
|
|
# Please direct questions and support issues to |
|
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 |
|
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
|
|
|
|
|
63
|
use vars qw($AUTOLOAD @ISA $PROGRAM $PROGRAMDIR |
|
97
|
1
|
|
|
1
|
|
101504
|
$PROGRAMNAME @EXONERATE_PARAMS %OK_FIELD); |
|
|
1
|
|
|
|
|
2
|
|
|
98
|
1
|
|
|
1
|
|
4
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
14
|
|
|
99
|
1
|
|
|
1
|
|
441
|
use Bio::Root::Root; |
|
|
1
|
|
|
|
|
17071
|
|
|
|
1
|
|
|
|
|
26
|
|
|
100
|
1
|
|
|
1
|
|
5
|
use Bio::Root::IO; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
15
|
|
|
101
|
1
|
|
|
1
|
|
374
|
use Bio::Factory::ApplicationFactoryI; |
|
|
1
|
|
|
|
|
105
|
|
|
|
1
|
|
|
|
|
17
|
|
|
102
|
1
|
|
|
1
|
|
350
|
use Bio::Tools::Run::WrapperBase; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
20
|
|
|
103
|
1
|
|
|
1
|
|
407
|
use Bio::SearchIO; |
|
|
1
|
|
|
|
|
7413
|
|
|
|
1
|
|
|
|
|
702
|
|
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
@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
|
|
|
|
|
|
|
sub program_name { |
|
119
|
6
|
|
|
6
|
1
|
33
|
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
|
|
|
|
|
|
|
sub program_dir { |
|
133
|
3
|
50
|
|
3
|
1
|
12
|
return Bio::Root::IO->catfile($ENV{EXONERATEDIR}) if $ENV{EXONERATEDIR}; |
|
134
|
|
|
|
|
|
|
} |
|
135
|
|
|
|
|
|
|
sub AUTOLOAD { |
|
136
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
|
137
|
0
|
|
|
|
|
0
|
my $attr = $AUTOLOAD; |
|
138
|
0
|
|
|
|
|
0
|
$attr =~ s/.*:://; |
|
139
|
0
|
|
|
|
|
0
|
$attr = uc $attr; |
|
140
|
0
|
0
|
|
|
|
0
|
$self->throw("Unallowed parameter: $attr !") unless $OK_FIELD{$attr}; |
|
141
|
0
|
0
|
|
|
|
0
|
$self->{$attr} = shift if @_; |
|
142
|
0
|
|
|
|
|
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
|
|
|
|
|
|
|
sub new { |
|
156
|
1
|
|
|
1
|
1
|
116
|
my ($class,@args) = @_; |
|
157
|
1
|
|
|
|
|
11
|
my $self = $class->SUPER::new(@args); |
|
158
|
|
|
|
|
|
|
|
|
159
|
1
|
|
|
|
|
37
|
my ($attr, $value); |
|
160
|
1
|
|
|
|
|
3
|
while (@args) { |
|
161
|
2
|
|
|
|
|
3
|
$attr = shift @args; |
|
162
|
2
|
|
|
|
|
2
|
$value = shift @args; |
|
163
|
2
|
100
|
|
|
|
8
|
next if( $attr =~ /^-/ ); # don't want named parameters |
|
164
|
1
|
50
|
|
|
|
5
|
if ($attr =~/PROGRAM/i) { |
|
165
|
0
|
|
|
|
|
0
|
$self->executable($value); |
|
166
|
0
|
|
|
|
|
0
|
next; |
|
167
|
|
|
|
|
|
|
} |
|
168
|
1
|
|
|
|
|
7
|
$self->$attr($value); |
|
169
|
|
|
|
|
|
|
} |
|
170
|
1
|
|
|
|
|
2
|
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
|
|
|
|
|
|
|
sub version { |
|
185
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
|
186
|
0
|
|
|
|
|
|
my $exe; |
|
187
|
0
|
0
|
|
|
|
|
return undef unless $exe = $self->executable; |
|
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
|
|
0
|
|
|
|
return $version || undef; |
|
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
|
|
|
|
|
|
|
sub run { |
|
207
|
0
|
|
|
0
|
1
|
|
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
|
|
|
|
|
|
|
sub _input() { |
|
226
|
0
|
|
|
0
|
|
|
my ($self,$infile1) = @_; |
|
227
|
0
|
0
|
|
|
|
|
$self->{'input'} = $infile1 if(defined $infile1); |
|
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
|
|
|
|
|
|
|
sub _run { |
|
242
|
0
|
|
|
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
|
0
|
|
|
|
|
$self->throw( "Exonerate call ($str) crashed: $? \n") unless $status==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
|
|
|
|
|
|
|
sub _writeInput{ |
|
272
|
0
|
|
|
0
|
|
|
my ($self,$query) = @_; |
|
273
|
0
|
|
|
|
|
|
my ($fh,$infile1); |
|
274
|
0
|
0
|
|
|
|
|
if (ref($query) =~ /ARRAY/i) { |
|
|
|
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
|
0
|
|
|
|
|
unless ($seq1->isa("Bio::PrimarySeqI")) { |
|
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
|
|
|
|
|
|
|
sub _setparams { |
|
311
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
|
312
|
0
|
|
|
|
|
|
my $param_string = ''; |
|
313
|
0
|
|
|
|
|
|
foreach my $attr(@EXONERATE_PARAMS){ |
|
314
|
0
|
0
|
|
|
|
|
next if($attr=~/PROGRAM/); |
|
315
|
0
|
|
|
|
|
|
my $value = $self->$attr(); |
|
316
|
0
|
0
|
|
|
|
|
next unless (defined $value); |
|
317
|
0
|
|
|
|
|
|
my $attr_key = ' -'.(lc $attr); |
|
318
|
0
|
|
|
|
|
|
$param_string .= $attr_key.' '.$value; |
|
319
|
|
|
|
|
|
|
} |
|
320
|
0
|
|
|
|
|
|
return $param_string; |
|
321
|
|
|
|
|
|
|
} |
|
322
|
|
|
|
|
|
|
|
|
323
|
|
|
|
|
|
|
1; |