On 2019-10-09 7:21 p.m., 刘东 wrote:
hellow:
I have written a script, but it does not work, can you tell me what wrong with
me?
#! /usr/bin/perl
use strict;
use warnings;
use Getopt::Long;
my ($dir, $files, $file_name, $file_format, $file_dir, $file_main);
GetOptions ('dr=s' =>\$dir);
open INF,"<",'sine.fa' or die "can't read open sine";
foreach $files (glob("$dir/*.fa")) {
open FASEQ, "<", $files or die "can not read open $!";
($file_dir, $file_main) = split (/\/\//,$files);
($file_name,$file_format) =split(/\./,$file_main);
open OUTFILE, '>', $file_name.".txt";
`./usearch -ublast FASEQ -db INF -evalue 1e-5 -userout OUTFILE -strand both
-userfields query+qlo+qhi+ql+qs+qstrand+target+tlo+thi+tl`;
}
close FASEQ;
close OUTFILE;
close INF;
Perhaps it may work better like this:
#!/usr/bin/perl
use strict;
use warnings;
use Getopt::Long;
GetOptions( 'dr=s' => \my $dir );
opendir my $DH, $dir or "Cannot open '$dir' because: $!";
while ( my $file = readdir $DH ) {
my $file_name = $file =~ s/\.fa\z/.txt/r or next;
0 == system './usearch',
'-ublast', "$dir/$file",
'-db', 'sine.fa',
'-evalue', '1e-5',
'-userout', $file_name,
'-strand', 'both',
'-userfields', 'query+qlo+qhi+ql+qs+qstrand+target+tlo+thi+tl'
or die "system ./usearch failed: $?";
}
John
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/