line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# BioPerl module for Bio::Tools::Run::tRNAscanSE |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# Please direct questions and support issues to |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# Cared for by Bioperl |
6
|
|
|
|
|
|
|
# |
7
|
|
|
|
|
|
|
# Copyright Bioperl, Mark Johnson |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
# Special thanks to Chris Fields, Sendu Bala |
10
|
|
|
|
|
|
|
# |
11
|
|
|
|
|
|
|
# You may distribute this module under the same terms as perl itself |
12
|
|
|
|
|
|
|
# |
13
|
|
|
|
|
|
|
# POD documentation - main docs before the code |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 NAME |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Bio::Tools::Run::tRNAscanSE - Wrapper for local execution of tRNAscan-SE |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 SYNOPSIS |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my $factory = Bio::Tools::Run::tRNAscanSE->new('-program' => 'tRNAscan-SE'); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# Pass the factory Bio::Seq objects |
24
|
|
|
|
|
|
|
# returns a Bio::Tools::tRNAscanSE object |
25
|
|
|
|
|
|
|
my $factory = $factory->run($seq); |
26
|
|
|
|
|
|
|
or |
27
|
|
|
|
|
|
|
my $factory = $factory->run(@seq); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 DESCRIPTION |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
Wrapper module for tRNAscan-SE. |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
tRNAscan-SE is open source and available at |
34
|
|
|
|
|
|
|
L. |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 FEEDBACK |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head2 Mailing Lists |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
User feedback is an integral part of the evolution of this and other |
41
|
|
|
|
|
|
|
Bioperl modules. Send your comments and suggestions preferably to one |
42
|
|
|
|
|
|
|
of the Bioperl mailing lists. Your participation is much appreciated. |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
bioperl-l@bioperl.org - General discussion |
45
|
|
|
|
|
|
|
http://bioperl.org/wiki/Mailing_lists - About the mailing lists |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head2 Support |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
Please direct usage questions or support issues to the mailing list: |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
I |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
rather than to the module maintainer directly. Many experienced and |
54
|
|
|
|
|
|
|
reponsive experts will be able look at the problem and quickly |
55
|
|
|
|
|
|
|
address it. Please include a thorough description of the problem |
56
|
|
|
|
|
|
|
with code and data examples if at all possible. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head2 Reporting Bugs |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Report bugs to the Bioperl bug tracking system to help us keep track |
61
|
|
|
|
|
|
|
the bugs and their resolution. Bug reports can be submitted via the |
62
|
|
|
|
|
|
|
web: |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
http://redmine.open-bio.org/projects/bioperl/ |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 AUTHOR - Mark Johnson |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Email: johnsonm-at-gmail-dot-com |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 APPENDIX |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
The rest of the documentation details each of the object |
73
|
|
|
|
|
|
|
methods. Internal methods are usually preceded with a _ |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=cut |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
package Bio::Tools::Run::tRNAscanSE; |
78
|
|
|
|
|
|
|
|
79
|
1
|
|
|
1
|
|
137318
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
40
|
|
80
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
32
|
|
81
|
|
|
|
|
|
|
|
82
|
1
|
|
|
1
|
|
512
|
use Bio::SeqIO; |
|
1
|
|
|
|
|
40880
|
|
|
1
|
|
|
|
|
11
|
|
83
|
1
|
|
|
1
|
|
28
|
use Bio::Root::Root; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
3
|
|
84
|
1
|
|
|
1
|
|
417
|
use Bio::Tools::Run::WrapperBase; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
16
|
|
85
|
1
|
|
|
1
|
|
480
|
use Bio::Tools::tRNAscanSE; |
|
1
|
|
|
|
|
49562
|
|
|
1
|
|
|
|
|
17
|
|
86
|
1
|
|
|
1
|
|
567
|
use English; |
|
1
|
|
|
|
|
1559
|
|
|
1
|
|
|
|
|
5
|
|
87
|
1
|
|
|
1
|
|
505
|
use IPC::Run; # Should be okay on WIN32 (See IPC::Run Docs) |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
39
|
|
88
|
|
|
|
|
|
|
|
89
|
1
|
|
|
1
|
|
4
|
use base qw(Bio::Root::Root Bio::Tools::Run::WrapperBase); |
|
1
|
|
|
|
|
0
|
|
|
1
|
|
|
|
|
765
|
|
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
our @params = (qw(program)); |
92
|
|
|
|
|
|
|
our @tRNAscanSE_switches = (qw(A B C G O P)); |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head2 program_name |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Title : program_name |
97
|
|
|
|
|
|
|
Usage : $factory>program_name() |
98
|
|
|
|
|
|
|
Function: gets/sets the program name |
99
|
|
|
|
|
|
|
Returns: string |
100
|
|
|
|
|
|
|
Args : string |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=cut |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub program_name { |
105
|
|
|
|
|
|
|
|
106
|
6
|
|
|
6
|
1
|
19
|
my ($self, $val) = @_; |
107
|
|
|
|
|
|
|
|
108
|
6
|
50
|
|
|
|
7
|
$self->program($val) if $val; |
109
|
|
|
|
|
|
|
|
110
|
6
|
|
|
|
|
93
|
return $self->program(); |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head2 program_dir |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Title : program_dir |
117
|
|
|
|
|
|
|
Usage : $factory->program_dir() |
118
|
|
|
|
|
|
|
Function: gets/sets the program dir |
119
|
|
|
|
|
|
|
Returns: string |
120
|
|
|
|
|
|
|
Args : string |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=cut |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
sub program_dir { |
125
|
|
|
|
|
|
|
|
126
|
3
|
|
|
3
|
1
|
3
|
my ($self, $val) = @_; |
127
|
|
|
|
|
|
|
|
128
|
3
|
50
|
|
|
|
6
|
$self->{'_program_dir'} = $val if $val; |
129
|
|
|
|
|
|
|
|
130
|
3
|
|
|
|
|
9
|
return $self->{'_program_dir'}; |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head2 new |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
Title : new |
137
|
|
|
|
|
|
|
Usage : $tRNAscanSE->new(@params) |
138
|
|
|
|
|
|
|
Function: creates a new tRNAscanSE factory |
139
|
|
|
|
|
|
|
Returns: Bio::Tools::Run::tRNAscanSE |
140
|
|
|
|
|
|
|
Args : |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=cut |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
sub new { |
145
|
|
|
|
|
|
|
|
146
|
1
|
|
|
1
|
1
|
106
|
my ($class,@args) = @_; |
147
|
1
|
|
|
|
|
11
|
my $self = $class->SUPER::new(@args); |
148
|
|
|
|
|
|
|
|
149
|
1
|
|
|
|
|
40
|
$self->io->_initialize_io(); |
150
|
|
|
|
|
|
|
|
151
|
1
|
|
|
|
|
28
|
$self->_set_from_args( |
152
|
|
|
|
|
|
|
\@args, |
153
|
|
|
|
|
|
|
-methods => [ |
154
|
|
|
|
|
|
|
@params, |
155
|
|
|
|
|
|
|
@tRNAscanSE_switches, |
156
|
|
|
|
|
|
|
], |
157
|
|
|
|
|
|
|
-create => 1, |
158
|
|
|
|
|
|
|
); |
159
|
|
|
|
|
|
|
|
160
|
1
|
50
|
|
|
|
722
|
unless (defined($self->program())) { |
161
|
0
|
|
|
|
|
0
|
$self->throw('Must specify program'); |
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
|
164
|
1
|
|
|
|
|
8
|
return $self; |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
} |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head2 run |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
Title : run |
171
|
|
|
|
|
|
|
Usage : $obj->run($seq_file) |
172
|
|
|
|
|
|
|
Function: Runs tRNAscan-SE |
173
|
|
|
|
|
|
|
Returns : A Bio::Tools::tRNAscanSE object |
174
|
|
|
|
|
|
|
Args : An array of Bio::PrimarySeqI objects |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=cut |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
sub run{ |
179
|
|
|
|
|
|
|
|
180
|
0
|
|
|
0
|
1
|
|
my ($self, @seq) = @_; |
181
|
|
|
|
|
|
|
|
182
|
0
|
0
|
|
|
|
|
unless (@seq) { |
183
|
0
|
|
|
|
|
|
$self->throw("Must supply at least one Bio::PrimarySeqI"); |
184
|
|
|
|
|
|
|
} |
185
|
|
|
|
|
|
|
|
186
|
0
|
|
|
|
|
|
foreach my $seq (@seq) { |
187
|
|
|
|
|
|
|
|
188
|
0
|
0
|
|
|
|
|
unless ($seq->isa('Bio::PrimarySeqI')) { |
189
|
0
|
|
|
|
|
|
$self->throw("Object does not implement Bio::PrimarySeqI"); |
190
|
|
|
|
|
|
|
} |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
} |
193
|
|
|
|
|
|
|
|
194
|
0
|
|
|
|
|
|
my $program_name = $self->program_name(); |
195
|
0
|
|
|
|
|
|
my $file_name = $self->_write_seq_file(@seq); |
196
|
|
|
|
|
|
|
|
197
|
0
|
|
|
|
|
|
return $self->_run($file_name); |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
} |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=head2 _run |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
Title : _run |
204
|
|
|
|
|
|
|
Usage : $obj->_run() |
205
|
|
|
|
|
|
|
Function: Internal(not to be used directly) |
206
|
|
|
|
|
|
|
Returns : An instance of Bio::Tools::tRNAscanSE |
207
|
|
|
|
|
|
|
Args : file name |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
=cut |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
sub _run { |
212
|
|
|
|
|
|
|
|
213
|
0
|
|
|
0
|
|
|
my ($self, $seq_file_name) = @_; |
214
|
|
|
|
|
|
|
|
215
|
0
|
|
|
|
|
|
my @cmd = ( |
216
|
|
|
|
|
|
|
$self->executable(), |
217
|
|
|
|
|
|
|
split(/\s+/, $self->_setparams()), |
218
|
|
|
|
|
|
|
$seq_file_name, |
219
|
|
|
|
|
|
|
); |
220
|
|
|
|
|
|
|
|
221
|
0
|
|
|
|
|
|
my $cmd = join(' ', @cmd); |
222
|
0
|
|
|
|
|
|
$self->debug("tRNAscan-SE Command = $cmd"); |
223
|
|
|
|
|
|
|
|
224
|
0
|
|
|
|
|
|
my $program_name = $self->program_name(); |
225
|
0
|
|
|
|
|
|
my ($program_stderr); |
226
|
|
|
|
|
|
|
|
227
|
0
|
|
|
|
|
|
my ($output_fh, $output_file_name) = $self->io->tempfile(-dir=> $self->tempdir()); |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
|
230
|
0
|
|
|
|
|
|
my @ipc_args = (\@cmd, \undef, '>', $output_file_name, '2>', \$program_stderr); |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
# Run the program via IPC::Run so: |
233
|
|
|
|
|
|
|
# 1) The console doesn't get cluttered up with the program's STDERR/STDOUT |
234
|
|
|
|
|
|
|
# 2) We don't have to embed STDERR/STDOUT redirection in $cmd |
235
|
|
|
|
|
|
|
# 3) We don't have to deal with signal handling (IPC::Run should take care |
236
|
|
|
|
|
|
|
# of everything automagically. |
237
|
|
|
|
|
|
|
|
238
|
0
|
|
|
|
|
|
eval { |
239
|
0
|
0
|
|
|
|
|
IPC::Run::run(@ipc_args) || die $CHILD_ERROR;; |
240
|
|
|
|
|
|
|
}; |
241
|
|
|
|
|
|
|
|
242
|
0
|
0
|
|
|
|
|
if ($EVAL_ERROR) { |
243
|
0
|
|
|
|
|
|
$self->throw("tRNAscan-SE call crashed: $EVAL_ERROR"); |
244
|
|
|
|
|
|
|
} |
245
|
|
|
|
|
|
|
|
246
|
0
|
0
|
|
|
|
|
$self->debug(join("\n", 'tRNAscanSE STDERR:', $program_stderr)) if $program_stderr; |
247
|
|
|
|
|
|
|
|
248
|
0
|
|
|
|
|
|
return Bio::Tools::tRNAscanSE->new(-file => $output_file_name); |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
} |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
sub _setparams { |
253
|
|
|
|
|
|
|
|
254
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
255
|
|
|
|
|
|
|
|
256
|
0
|
|
|
|
|
|
my $param_string = $self->SUPER::_setparams( |
257
|
|
|
|
|
|
|
-params => [ ], |
258
|
|
|
|
|
|
|
-switches => [ |
259
|
|
|
|
|
|
|
@tRNAscanSE_switches, |
260
|
|
|
|
|
|
|
], |
261
|
|
|
|
|
|
|
-dash => 1 |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
); |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
# Kill leading and trailing whitespace |
266
|
0
|
|
|
|
|
|
$param_string =~ s/^\s+//g; |
267
|
0
|
|
|
|
|
|
$param_string =~ s/\s+$//g; |
268
|
|
|
|
|
|
|
|
269
|
0
|
|
|
|
|
|
return $param_string; |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
} |
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
=head2 _write_seq_file |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
Title : _write_seq_file |
276
|
|
|
|
|
|
|
Usage : obj->_write_seq_file($seq) or obj->_write_seq_file(@seq) |
277
|
|
|
|
|
|
|
Function: Internal(not to be used directly) |
278
|
|
|
|
|
|
|
Returns : Name of a temp file containing program output |
279
|
|
|
|
|
|
|
Args : One or more Bio::PrimarySeqI objects |
280
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
=cut |
282
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
sub _write_seq_file { |
284
|
|
|
|
|
|
|
|
285
|
0
|
|
|
0
|
|
|
my ($self, @seq) = @_; |
286
|
|
|
|
|
|
|
|
287
|
0
|
|
|
|
|
|
my ($fh, $file_name) = $self->io->tempfile(-dir=>$self->tempdir()); |
288
|
0
|
|
|
|
|
|
my $out = Bio::SeqIO->new(-fh => $fh , '-format' => 'Fasta'); |
289
|
|
|
|
|
|
|
|
290
|
0
|
|
|
|
|
|
foreach my $seq (@seq){ |
291
|
0
|
|
|
|
|
|
$out->write_seq($seq); |
292
|
|
|
|
|
|
|
} |
293
|
|
|
|
|
|
|
|
294
|
0
|
|
|
|
|
|
close($fh); |
295
|
0
|
|
|
|
|
|
$out->close(); |
296
|
|
|
|
|
|
|
|
297
|
0
|
|
|
|
|
|
return $file_name; |
298
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
} |
300
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
1; |