2 | 2 |
use warnings;
|
3 | 3 |
use List::Util qw(max);
|
4 | 4 |
use FindBin;
|
|
5 |
use File::Temp;
|
5 | 6 |
|
6 | 7 |
# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
7 | 8 |
# global variables
|
|
9 | 10 |
my $EXE = $FindBin::RealScript;
|
10 | 11 |
my $VERSION = "0.9-dev";
|
11 | 12 |
my $DESC = "rapid ribosomal RNA prediction";
|
12 | |
my $AUTHOR = 'Torsten Seemann <torsten.seemann@gmail.com>';
|
|
13 |
my $AUTHOR = 'Torsten Seemann';
|
13 | 14 |
my $URL = 'https://github.com/tseemann/barrnap';
|
14 | 15 |
my $DBDIR = "$FindBin::RealBin/../db";
|
15 | 16 |
my $OPSYS = $^O;
|
|
63 | 64 |
msg("Using database: $hmmdb");
|
64 | 65 |
|
65 | 66 |
# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
|
67 |
# check if user is piping to STDIN
|
|
68 |
# nhmmer needs to fseek() so we make a temp fasta file
|
|
69 |
|
|
70 |
my $fasta = shift @ARGV;
|
|
71 |
my $tmpfh;
|
|
72 |
if (defined($fasta) && $fasta eq '-' or !defined($fasta) && !-t \*STDIN) {
|
|
73 |
$tmpfh = File::Temp->new(UNLINK=>1);
|
|
74 |
msg("Copying STDIN to a temporary file:", $tmpfh->filename);
|
|
75 |
while (<STDIN>) {
|
|
76 |
print $tmpfh $_;
|
|
77 |
}
|
|
78 |
$fasta = $tmpfh->filename;
|
|
79 |
}
|
|
80 |
$fasta && -r $fasta or err("No input file on command line or stdin");
|
|
81 |
|
|
82 |
# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
66 | 83 |
# run the external command
|
67 | |
|
68 | |
my $fasta = shift @ARGV;
|
69 | |
$fasta && -r $fasta or err("Usage: $EXE <file.fasta>");
|
70 | 84 |
|
71 | 85 |
msg("Scanning $fasta for $kdom rRNA genes... please wait");
|
72 | 86 |
my $cmd = "$NHMMER --cpu $threads -E $evalue --w_length $MAXLEN -o /dev/null --tblout /dev/stdout \Q$hmmdb\E \Q$fasta\E";
|
|
160 | 174 |
|
161 | 175 |
sub err {
|
162 | 176 |
$quiet=0;
|
163 | |
msg(@_);
|
|
177 |
msg("ERROR:", @_);
|
164 | 178 |
exit(2);
|
165 | 179 |
}
|
166 | 180 |
|
|
178 | 192 |
|
179 | 193 |
If you use Barrnap in your work, please cite:
|
180 | 194 |
|
181 | |
Seemann T (2017)
|
|
195 |
Seemann T
|
182 | 196 |
$EXE $VERSION : $DESC
|
183 | 197 |
$URL
|
184 | 198 |
|
|
204 | 218 |
{OPT=>"quiet!", VAR=>\$quiet, DEFAULT=>0, DESC=>"No screen output"},
|
205 | 219 |
{OPT=>"threads=i", VAR=>\$threads, DEFAULT=>1, DESC=>"Number of threads/cores/CPUs to use"},
|
206 | 220 |
{OPT=>"lencutoff=f",VAR=>\$lencutoff, DEFAULT=>0.8, DESC=>"Proportional length threshold to label as partial"},
|
207 | |
{OPT=>"reject=f",VAR=>\$reject, DEFAULT=>0.5, DESC=>"Proportional length threshold to reject prediction"},
|
|
221 |
{OPT=>"reject=f",VAR=>\$reject, DEFAULT=>0.25, DESC=>"Proportional length threshold to reject prediction"},
|
208 | 222 |
{OPT=>"evalue=f",VAR=>\$evalue, DEFAULT=>1E-6, DESC=>"Similarity e-value cut-off"},
|
209 | 223 |
{OPT=>"incseq!", VAR=>\$incseq, DEFAULT=>0, DESC=>"Include FASTA input sequences in GFF3 output"},
|
210 | 224 |
# {OPT=>"outseq!", VAR=>\$outseq, DEFAULT=>'', DESC=>"Save hits to this FASTA file"},
|
211 | 225 |
);
|
212 | 226 |
|
213 | |
(!@ARGV) && (usage(1));
|
|
227 |
# (!@ARGV) && (usage(1));
|
214 | 228 |
|
215 | 229 |
&GetOptions(map {$_->{OPT}, $_->{VAR}} grep { ref } @Options) || usage(1);
|
216 | 230 |
|
|
232 | 246 |
|
233 | 247 |
print "Synopsis:\n $EXE $VERSION - $DESC\n";
|
234 | 248 |
print "Author:\n $AUTHOR\n";
|
235 | |
print "Usage:\n $EXE [options] <chromosomes.fasta>\n";
|
|
249 |
print "Usage:\n";
|
|
250 |
print " $EXE [options] chr.fa\n";
|
|
251 |
print " $EXE [options] < chr.fa\n";
|
|
252 |
print " $EXE [options] - < chr.fa\n";
|
236 | 253 |
foreach (@Options) {
|
237 | 254 |
if (ref) {
|
238 | 255 |
my $def = defined($_->{DEFAULT}) ? " (default '$_->{DEFAULT}')" : "";
|