1 # BioPerl module for Bio::Tools::Run::tRNAscanSE
3 # Please direct questions and support issues to <bioperl-l@bioperl.org>
7 # Copyright Bioperl, Mark Johnson <mjohnson-at-watson-dot-wustl-dot-edu>
9 # Special thanks to Chris Fields, Sendu Bala
11 # You may distribute this module under the same terms as perl itself
13 # POD documentation - main docs before the code
17 Bio::Tools::Run::tRNAscanSE - Wrapper for local execution of tRNAscan-SE
21 my $factory = Bio::Tools::Run::tRNAscanSE->new('-program' => 'tRNAscan-SE');
23 # Pass the factory Bio::Seq objects
24 # returns a Bio::Tools::tRNAscanSE object
25 my $factory = $factory->run($seq);
27 my $factory = $factory->run(@seq);
31 Wrapper module for tRNAscan-SE.
33 tRNAscan-SE is open source and available at
34 L<http://selab.wustl.edu/cgi-bin/selab.pl?mode=software#trnascan/>.
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.
44 bioperl-l@bioperl.org - General discussion
45 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
49 Please direct usage questions or support issues to the mailing list:
51 I<bioperl-l@bioperl.org>
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.
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
64 http://redmine.open-bio.org/projects/bioperl/
66 =head1 AUTHOR - Mark Johnson
68 Email: mjohnson-at-watson-dot-wustl-dot-edu
72 The rest of the documentation details each of the object
73 methods. Internal methods are usually preceded with a _
77 package Bio
::Tools
::Run
::tRNAscanSE
;
84 use Bio
::Tools
::Run
::WrapperBase
;
85 use Bio
::Tools
::tRNAscanSE
;
87 use IPC
::Run
; # Should be okay on WIN32 (See IPC::Run Docs)
89 use base
qw(Bio::Root::Root Bio::Tools::Run::WrapperBase);
91 our @params = (qw(program));
92 our @tRNAscanSE_switches = (qw(A B C G O P));
97 Usage : $factory>program_name()
98 Function: gets/sets the program name
106 my ($self, $val) = @_;
108 $self->program($val) if $val;
110 return $self->program();
117 Usage : $factory->program_dir()
118 Function: gets/sets the program dir
126 my ($self, $val) = @_;
128 $self->{'_program_dir'} = $val if $val;
130 return $self->{'_program_dir'};
137 Usage : $tRNAscanSE->new(@params)
138 Function: creates a new tRNAscanSE factory
139 Returns: Bio::Tools::Run::tRNAscanSE
146 my ($class,@args) = @_;
147 my $self = $class->SUPER::new
(@args);
149 $self->io->_initialize_io();
151 $self->_set_from_args(
155 @tRNAscanSE_switches,
160 unless (defined($self->program())) {
161 $self->throw('Must specify program');
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
180 my ($self, @seq) = @_;
183 $self->throw("Must supply at least one Bio::PrimarySeqI");
186 foreach my $seq (@seq) {
188 unless ($seq->isa('Bio::PrimarySeqI')) {
189 $self->throw("Object does not implement Bio::PrimarySeqI");
194 my $program_name = $self->program_name();
195 my $file_name = $self->_write_seq_file(@seq);
197 return $self->_run($file_name);
205 Function: Internal(not to be used directly)
206 Returns : An instance of Bio::Tools::tRNAscanSE
213 my ($self, $seq_file_name) = @_;
217 split(/\s+/, $self->_setparams()),
221 my $cmd = join(' ', @cmd);
222 $self->debug("tRNAscan-SE Command = $cmd");
224 my $program_name = $self->program_name();
225 my ($program_stderr);
227 my ($output_fh, $output_file_name) = $self->io->tempfile(-dir
=> $self->tempdir());
230 my @ipc_args = (\
@cmd, \
undef, '>', $output_file_name, '2>', \
$program_stderr);
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.
239 IPC
::Run
::run
(@ipc_args) || die $CHILD_ERROR;;
243 $self->throw("tRNAscan-SE call crashed: $EVAL_ERROR");
246 $self->debug(join("\n", 'tRNAscanSE STDERR:', $program_stderr)) if $program_stderr;
248 return Bio
::Tools
::tRNAscanSE
->new(-file
=> $output_file_name);
256 my $param_string = $self->SUPER::_setparams
(
259 @tRNAscanSE_switches,
265 # Kill leading and trailing whitespace
266 $param_string =~ s/^\s+//g;
267 $param_string =~ s/\s+$//g;
269 return $param_string;
273 =head2 _write_seq_file
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
283 sub _write_seq_file
{
285 my ($self, @seq) = @_;
287 my ($fh, $file_name) = $self->io->tempfile(-dir
=>$self->tempdir());
288 my $out = Bio
::SeqIO
->new(-fh
=> $fh , '-format' => 'Fasta');
290 foreach my $seq (@seq){
291 $out->write_seq($seq);