Hello Nicpetbio23!,
The following example uses a couple CPAN modules
(Path::Tiny, and Capture::Tiny). The syntax of your
tblast command does not seem to be quite right. Detailed descriptions for
tblastn command line arguments can be obtained with
tblastn -help. I modified your tblastn command based
on my reading of the help output.
This code assumes that there are fasta query files in the current directory
with .fa file extensions. For each fasta file found, an output file will
be generated (with a .txt extension).
NOTE: I did not test this code thoroughly. I commented out the call to
system to be sure that the intended $cmd string is
generated, but I did not run the tblastn commands.
#!/usr/bin/env perl
use strict;
use warnings;
use Path::Tiny;
use Capture::Tiny ':all';
my @paths = path('./')->children( qr/\.fa$/ );
foreach my $file_path (@paths){
my $query_file = $file_path->stringify;
my $output_file = path(
$file_path->parent,
$file_path->basename( '.fa' ).'_output.txt'
)->stringify;
my $cmd = "tblastn -query $query_file -db genome.db".
" -out $output_file";
print "Query file: $file_path\n";
print "\t $cmd\n";
my ($stdout, $stderr, $exit) = capture {
system( $cmd );
};
if ($exit != 0){
die "Error: command failed";
}
}
exit;
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|