refresh patches
Sascha Steinbiss
5 years ago
0 | 0 | Description: Use_both_hmmsets |
1 | 1 | --- a/bin/barrnap |
2 | 2 | +++ b/bin/barrnap |
3 | @@ -4,8 +4,9 @@ | |
4 | use Time::Piece; | |
3 | @@ -3,6 +3,7 @@ | |
4 | use warnings; | |
5 | 5 | use List::Util qw(max); |
6 | 6 | use FindBin; |
7 | 7 | +use File::Temp qw/ tempfile tempdir /; |
8 | use File::Temp; | |
8 | 9 | |
9 | -# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . | |
10 | +# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . | |
11 | # global variables | |
12 | ||
13 | my $EXE = $FindBin::RealScript; | |
14 | @@ -29,13 +30,13 @@ | |
15 | ); | |
16 | my $MAXLEN = int( 1.2 * max(values %LENG) ); | |
17 | ||
18 | -# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . | |
19 | +# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . | |
20 | # command line options | |
21 | ||
22 | my(@Options, $quiet, $kingdom, $threads, $evalue, $lencutoff, $reject, $incseq); | |
23 | setOptions(); | |
24 | ||
25 | -# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . | |
26 | +# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . | |
27 | # check all is well | |
28 | ||
29 | msg("This is $EXE $VERSION"); | |
30 | @@ -64,23 +65,38 @@ | |
10 | # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . | |
11 | @@ -64,6 +65,7 @@ | |
31 | 12 | my $hmmdb = "$DBDIR/$kdom.hmm"; |
32 | 13 | err("Can't find database: $hmmdb") unless -r $hmmdb; |
33 | 14 | msg("Using database: $hmmdb"); |
34 | 15 | +my $nonfreehmmdb = "$DBDIR/nonfree/$kdom.hmm"; |
35 | 16 | |
36 | -# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . | |
37 | +# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . | |
17 | # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . | |
18 | # check if user is piping to STDIN | |
19 | @@ -84,6 +86,20 @@ | |
20 | # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . | |
38 | 21 | # run the external command |
39 | ||
40 | my $fasta = shift @ARGV; | |
41 | $fasta && -r $fasta or err("Usage: $EXE <file.fasta>"); | |
42 | 22 | |
43 | 23 | +if (-e $nonfreehmmdb) { |
44 | 24 | + # prepare full pHMM file (with nonfree if it exists) |
55 | 35 | +} |
56 | 36 | + |
57 | 37 | msg("Scanning $fasta for $kdom rRNA genes... please wait"); |
58 | my $cmd = "$NHMMER --cpu $threads -E $evalue --w_length $MAXLEN -o /dev/null --tblout /dev/stdout \Q$hmmdb\E \Q$fasta\E"; | |
59 | msg("Command: $cmd"); | |
60 | my @hits = qx($cmd 2>&1); | |
61 | ||
62 | -# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . | |
63 | +# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . | |
64 | # process the output | |
65 | ||
66 | my @feat; | |
67 | -HIT: | |
68 | +HIT: | |
69 | foreach (@hits) { | |
70 | chomp; | |
71 | err("nhmmer failed to run - $_") if m/fail|error|core dump|bus error/i; | |
72 | @@ -103,7 +119,7 @@ | |
38 | my $opts = "--cpu $threads -E $evalue --w_length $MAXLEN -o /dev/null --tblout /dev/stdout"; | |
39 | my $cmd = "nhmmer $opts '$hmmdb' '$fasta'"; | |
40 | @@ -123,7 +139,7 @@ | |
73 | 41 | # check for incomplete alignments |
74 | 42 | my $note = ''; |
75 | 43 | my $len = $end-$begin+1; |
78 | 46 | if ( $len < int($reject * $LENG{$gene}) ) { |
79 | 47 | msg("Rejecting short $len nt predicted $gene. Adjust via --reject option."); |
80 | 48 | next HIT; |
81 | @@ -121,7 +137,7 @@ | |
49 | @@ -144,7 +160,7 @@ | |
82 | 50 | ]; |
83 | 51 | } |
84 | 52 | |
87 | 55 | # output a sorted GFF3 |
88 | 56 | |
89 | 57 | sub gff_sort { |
90 | @@ -169,13 +185,13 @@ | |
91 | ||
92 | sub show_citation { | |
93 | print STDERR << "EOCITE"; | |
94 | - | |
95 | + | |
96 | If you use Barrnap in your work, please cite: | |
97 | ||
98 | Seemann T (2013) | |
99 | $EXE $VERSION : $DESC | |
100 | $URL | |
101 | - | |
102 | + | |
103 | Thank you. | |
104 | ||
105 | EOCITE | |
106 | @@ -194,7 +210,7 @@ | |
107 | {OPT=>"help", VAR=>\&usage, DESC=>"This help"}, | |
108 | {OPT=>"version", VAR=>\&version, DESC=>"Print version and exit"}, | |
109 | {OPT=>"citation",VAR=>\&show_citation, DESC=>"Print citation for referencing $EXE"}, | |
110 | - {OPT=>"kingdom=s", VAR=>\$kingdom, DEFAULT=>'bac', | |
111 | + {OPT=>"kingdom=s", VAR=>\$kingdom, DEFAULT=>'bac', | |
112 | DESC=>"Kingdom: ".join(' ', values %KINGDOM) }, | |
113 | {OPT=>"quiet!", VAR=>\$quiet, DEFAULT=>0, DESC=>"No screen output"}, | |
114 | {OPT=>"threads=i", VAR=>\$threads, DEFAULT=>8, DESC=>"Number of threads/cores/CPUs to use"}, | |
115 | @@ -227,15 +243,15 @@ | |
116 | my $def = defined($_->{DEFAULT}) ? " (default '$_->{DEFAULT}')" : ""; | |
117 | $def = ($def ? ' (default OFF)' : '(default ON)') if $_->{OPT} =~ m/!$/; | |
118 | my $opt = $_->{OPT}; | |
119 | - $opt =~ s/!$//; | |
120 | - $opt =~ s/=s$/ [X]/; | |
121 | + $opt =~ s/!$//; | |
122 | + $opt =~ s/=s$/ [X]/; | |
123 | $opt =~ s/=i$/ [N]/; | |
124 | $opt =~ s/=f$/ [n.n]/; | |
125 | printf STDERR " --%-15s %s%s\n", $opt, $_->{DESC}, $def; | |
126 | } | |
127 | else { | |
128 | print STDERR "$_\n"; | |
129 | - } | |
130 | + } | |
131 | } | |
132 | exit(1); | |
133 | } |