line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Bio::Roary::External::CheckTools; |
2
|
|
|
|
|
|
|
$Bio::Roary::External::CheckTools::VERSION = '3.11.0'; |
3
|
|
|
|
|
|
|
# ABSTRACT: Check external executables are available and are the correct version |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
99714
|
use Moose; |
|
2
|
|
|
|
|
382007
|
|
|
2
|
|
|
|
|
11
|
|
7
|
2
|
|
|
2
|
|
12144
|
use File::Spec; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
52
|
|
8
|
2
|
|
|
2
|
|
739
|
use Log::Log4perl qw(:easy); |
|
2
|
|
|
|
|
33500
|
|
|
2
|
|
|
|
|
12
|
|
9
|
|
|
|
|
|
|
has 'logger' => ( is => 'ro', lazy => 1, builder => '_build_logger' ); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub _build_logger { |
12
|
1
|
|
|
1
|
|
3
|
my ($self) = @_; |
13
|
1
|
|
|
|
|
10
|
Log::Log4perl->easy_init($DEBUG); |
14
|
1
|
|
|
|
|
2908
|
my $logger = get_logger(); |
15
|
1
|
|
|
|
|
82
|
return $logger; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my $BIDEC = '(\d+\.\d+)'; # pattern of NN.NN for versions that can be compared |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my %tools = ( |
21
|
|
|
|
|
|
|
'parallel' => { |
22
|
|
|
|
|
|
|
GETVER => "parallel --version | grep '^GNU parallel 2'", |
23
|
|
|
|
|
|
|
REGEXP => qr/GNU parallel (\d+)/, |
24
|
|
|
|
|
|
|
MINVER => "20130422", |
25
|
|
|
|
|
|
|
NEEDED => 1, |
26
|
|
|
|
|
|
|
}, |
27
|
|
|
|
|
|
|
'blastp' => { |
28
|
|
|
|
|
|
|
GETVER => "blastp -version", |
29
|
|
|
|
|
|
|
REGEXP => qr/blastp:\s+(\d+\.\d+\.\d+)/, |
30
|
|
|
|
|
|
|
NEEDED => 1, |
31
|
|
|
|
|
|
|
}, |
32
|
|
|
|
|
|
|
'makeblastdb' => { |
33
|
|
|
|
|
|
|
GETVER => "makeblastdb -version", |
34
|
|
|
|
|
|
|
REGEXP => qr/makeblastdb:\s+(\d+\.\d+\.\d+)/, |
35
|
|
|
|
|
|
|
NEEDED => 1, |
36
|
|
|
|
|
|
|
}, |
37
|
|
|
|
|
|
|
'mcl' => { |
38
|
|
|
|
|
|
|
GETVER => "mcl --version | head -n 1", |
39
|
|
|
|
|
|
|
REGEXP => qr/(\d+\-\d+)/, |
40
|
|
|
|
|
|
|
NEEDED => 1, |
41
|
|
|
|
|
|
|
}, |
42
|
|
|
|
|
|
|
'bedtools' => { |
43
|
|
|
|
|
|
|
GETVER => "bedtools --version", |
44
|
|
|
|
|
|
|
REGEXP => qr/bedtools v($BIDEC)/, |
45
|
|
|
|
|
|
|
MINVER => "2.1", |
46
|
|
|
|
|
|
|
NEEDED => 1, |
47
|
|
|
|
|
|
|
}, |
48
|
|
|
|
|
|
|
'mafft' => { |
49
|
|
|
|
|
|
|
GETVER => "mafft --version < /dev/null 2>&1", |
50
|
|
|
|
|
|
|
REGEXP => qr/(\d+\.\d+) /, |
51
|
|
|
|
|
|
|
NEEDED => 1, |
52
|
|
|
|
|
|
|
}, |
53
|
|
|
|
|
|
|
'kraken' => { |
54
|
|
|
|
|
|
|
GETVER => "kraken --version | head -n 1", |
55
|
|
|
|
|
|
|
REGEXP => qr/(\d+\.\d+\.\d+.*)/, |
56
|
|
|
|
|
|
|
NEEDED => 0, |
57
|
|
|
|
|
|
|
}, |
58
|
|
|
|
|
|
|
'kraken-report' => { |
59
|
|
|
|
|
|
|
GETVER => "kraken-report --version | head -n 1", |
60
|
|
|
|
|
|
|
REGEXP => qr/(\d+\.\d+\.\d+.*)/, |
61
|
|
|
|
|
|
|
NEEDED => 0, |
62
|
|
|
|
|
|
|
}, |
63
|
|
|
|
|
|
|
'Rscript' => { |
64
|
|
|
|
|
|
|
GETVER => "Rscript --version 2>&1 | head -n 1", |
65
|
|
|
|
|
|
|
REGEXP => qr/R scripting front-end version ($BIDEC)/, |
66
|
|
|
|
|
|
|
MINVER => "3", |
67
|
|
|
|
|
|
|
NEEDED => 0, |
68
|
|
|
|
|
|
|
}, |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# prank version also performs an update check so cant use it |
71
|
|
|
|
|
|
|
'prank' => { NEEDED => 0 }, |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
# now just the standard unix tools we need |
74
|
|
|
|
|
|
|
'grep' => { NEEDED => 1 }, |
75
|
|
|
|
|
|
|
'sed' => { NEEDED => 1 }, |
76
|
|
|
|
|
|
|
'awk' => { NEEDED => 1 }, |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
); |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
my %cdhit_tools = ( |
81
|
|
|
|
|
|
|
'cdhit' => { |
82
|
|
|
|
|
|
|
GETVER => "cdhit -h | grep 'CD-HIT version'", |
83
|
|
|
|
|
|
|
REGEXP => qr/version ($BIDEC) /, |
84
|
|
|
|
|
|
|
MINVER => "4.6", |
85
|
|
|
|
|
|
|
}, |
86
|
|
|
|
|
|
|
'cd-hit' => { |
87
|
|
|
|
|
|
|
GETVER => "cd-hit -h | grep 'CD-HIT version'", |
88
|
|
|
|
|
|
|
REGEXP => qr/version ($BIDEC) /, |
89
|
|
|
|
|
|
|
MINVER => "4.6", |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
); |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
my %fasttree_tools = ( |
94
|
|
|
|
|
|
|
'fasttree' => { |
95
|
|
|
|
|
|
|
GETVER => "fasttree 2>&1 | head -n 1", |
96
|
|
|
|
|
|
|
REGEXP => qr/Usage for FastTree version ($BIDEC)/, |
97
|
|
|
|
|
|
|
}, |
98
|
|
|
|
|
|
|
'FastTree' => { |
99
|
|
|
|
|
|
|
GETVER => "FastTree 2>&1 | head -n 1", |
100
|
|
|
|
|
|
|
REGEXP => qr/Usage for FastTree version ($BIDEC)/, |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
); |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub which_tool_exec { |
105
|
2
|
|
|
2
|
0
|
4
|
my ( $self, $alt_tools ) = @_; |
106
|
2
|
|
|
|
|
3
|
for my $toolname ( sort keys %{$alt_tools} ) { |
|
2
|
|
|
|
|
9
|
|
107
|
4
|
|
|
|
|
7
|
my $fp = $self->find_exe($toolname); |
108
|
4
|
50
|
|
|
|
11
|
return $toolname if $fp; |
109
|
|
|
|
|
|
|
} |
110
|
2
|
|
|
|
|
50
|
$self->logger->error( "Required tool missing. Can't find one of " . join( '/', keys %{$alt_tools} ) . " in your \$PATH." ); |
|
2
|
|
|
|
|
12
|
|
111
|
2
|
|
|
|
|
457
|
return undef; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub check_tool { |
115
|
23
|
|
|
23
|
0
|
19162
|
my ( $self, $toolname ) = @_; |
116
|
23
|
|
|
|
|
48
|
my $t = $tools{$toolname}; |
117
|
23
|
|
|
|
|
42
|
my $fp = $self->find_exe($toolname); |
118
|
23
|
100
|
100
|
|
|
413
|
$self->logger->error("ERROR: Can't find required '$toolname' in your \$PATH") if !$fp and $t->{NEEDED}; |
119
|
23
|
100
|
100
|
|
|
3717
|
$self->logger->error("Optional tool '$toolname' not found in your \$PATH") if !$fp and !$t->{NEEDED}; |
120
|
|
|
|
|
|
|
|
121
|
23
|
100
|
|
|
|
1403
|
if ($fp) { |
122
|
6
|
|
|
|
|
12
|
$t->{HAVE} = $fp; |
123
|
6
|
|
|
|
|
154
|
$self->logger->warn("Looking for '$toolname' - found $fp"); |
124
|
6
|
50
|
|
|
|
1578
|
if ( $t->{GETVER} ) { |
125
|
0
|
|
|
|
|
0
|
my ($s) = qx($t->{GETVER}); |
126
|
0
|
0
|
|
|
|
0
|
if ( defined $s ) { |
127
|
0
|
|
|
|
|
0
|
$s =~ $t->{REGEXP}; |
128
|
0
|
0
|
|
|
|
0
|
$t->{VERSION} = $1 if defined $1; |
129
|
0
|
|
|
|
|
0
|
$self->logger->warn("Determined $toolname version is $t->{VERSION}"); |
130
|
0
|
0
|
0
|
|
|
0
|
if ( defined $t->{MINVER} and $t->{VERSION} < $t->{MINVER} ) { |
131
|
0
|
|
|
|
|
0
|
$self->logger->error("Roary needs $toolname $t->{MINVER} or higher. Please upgrade and try again."); |
132
|
|
|
|
|
|
|
} |
133
|
0
|
0
|
0
|
|
|
0
|
if ( defined $t->{MAXVER} and $t->{VERSION} > $t->{MAXVER} ) { |
134
|
0
|
|
|
|
|
0
|
$self->logger->error( |
135
|
|
|
|
|
|
|
"Roary needs a version of $toolname between $t->{MINVER} and $t->{MAXVER}. Please downgrade and try again."); |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
else { |
139
|
0
|
|
|
|
|
0
|
$self->logger->error( "Could not determine version of $toolname - please install version ", $t->{MINVER}, " or higher" ) |
140
|
|
|
|
|
|
|
; # FIXME: or less <= MAXVER if given |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
sub check_all_tools { |
147
|
1
|
|
|
1
|
0
|
1030
|
my ($self) = @_; |
148
|
1
|
|
|
|
|
7
|
$ENV{"GREP_OPTIONS"} = ''; # --colour => version grep fails (Issue #117) |
149
|
1
|
|
|
|
|
12
|
for my $toolname ( sort keys %tools ) { |
150
|
13
|
|
|
|
|
24
|
$self->check_tool($toolname); |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
|
153
|
1
|
|
|
|
|
5
|
my $cdhit = $self->which_tool_exec( \%cdhit_tools ); |
154
|
1
|
50
|
|
|
|
4
|
if ($cdhit) { |
155
|
0
|
|
|
|
|
0
|
$tools{$cdhit} = $cdhit_tools{$cdhit}; |
156
|
0
|
|
|
|
|
0
|
$self->check_tool($cdhit); |
157
|
|
|
|
|
|
|
} |
158
|
|
|
|
|
|
|
|
159
|
1
|
|
|
|
|
3
|
my $fasttree = $self->which_tool_exec( \%fasttree_tools ); |
160
|
1
|
50
|
|
|
|
4
|
if ($fasttree) { |
161
|
0
|
|
|
|
|
0
|
$tools{$fasttree} = $fasttree_tools{$fasttree}; |
162
|
0
|
|
|
|
|
0
|
$self->check_tool($fasttree); |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
|
165
|
1
|
|
|
|
|
5
|
return $self; |
166
|
|
|
|
|
|
|
} |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
sub find_exe { |
169
|
27
|
|
|
27
|
0
|
39
|
my ( $self, $bin ) = @_; |
170
|
27
|
|
|
|
|
233
|
for my $dir ( File::Spec->path ) { |
171
|
233
|
|
|
|
|
962
|
my $exe = File::Spec->catfile( $dir, $bin ); |
172
|
233
|
100
|
|
|
|
1373
|
return $exe if -x $exe; |
173
|
|
|
|
|
|
|
} |
174
|
21
|
|
|
|
|
48
|
return; |
175
|
|
|
|
|
|
|
} |
176
|
|
|
|
|
|
|
|
177
|
2
|
|
|
2
|
|
2958
|
no Moose; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
13
|
|
178
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
1; |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
__END__ |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=pod |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=encoding UTF-8 |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=head1 NAME |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
Bio::Roary::External::CheckTools - Check external executables are available and are the correct version |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=head1 VERSION |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
version 3.11.0 |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=head1 SYNOPSIS |
197
|
|
|
|
|
|
|
Functionality borrowed from PROKKA by Torsten Seemann. |
198
|
|
|
|
|
|
|
Check external executables are available and are the correct version |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
use Bio::Roary::External::CheckTools; |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
my $obj = Bio::Roary::External::CheckTools->new(); |
203
|
|
|
|
|
|
|
$obj->check_all_tools; |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=head1 AUTHOR |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
Andrew J. Page <ap13@sanger.ac.uk> |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
This software is Copyright (c) 2013 by Wellcome Trust Sanger Institute. |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
This is free software, licensed under: |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
The GNU General Public License, Version 3, June 2007 |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
=cut |