Skip to content

Commit

Permalink
Issue #27 resolved - ensure Kraken stuff is set up
Browse files Browse the repository at this point in the history
  • Loading branch information
tseemann committed Oct 2, 2015
1 parent 5b55d11 commit 224f62a
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
7 changes: 6 additions & 1 deletion bin/nullarbor.pl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
use Nullarbor::IsolateSet;
use Nullarbor::Logger qw(msg err);
use Nullarbor::Report;
use Nullarbor::Requirements qw(require_exe require_perlmod require_version);
use Nullarbor::Requirements qw(require_exe require_perlmod require_version require_var require_file);

#-------------------------------------------------------------------
# constants
Expand Down Expand Up @@ -75,13 +75,18 @@
require_exe( qw'prokka roary kraken snippy mlst abricate megahit nw_order nw_display trimal FastTree' );
require_exe( qw'fq fa afa-pairwise.pl' );
require_exe( qw'convert pandoc head cat install env' );

require_perlmod( qw'Data::Dumper Moo SVG::Graph Bio::SeqIO File::Copy Time::Piece YAML::Tiny' );

require_version('megahit', 1.0);
require_version('snippy', 2.5);
require_version('prokka', 1.10);
require_version('roary', 3.0);

my $value = require_var('KRAKEN_DEFAULT_DB', 'kraken');
require_file("$value/database.idx", 'kraken');
require_file("$value/database.kdb", 'kraken');

my $cfg;
if (-r $conf_file) {
my $yaml = YAML::Tiny->read( $conf_file );
Expand Down
30 changes: 29 additions & 1 deletion perl5/Nullarbor/Requirements.pm
Original file line number Diff line number Diff line change
@@ -1,10 +1,38 @@
package Nullarbor::Requirements;

use base Exporter;
@EXPORT_OK = qw(require_exe require_perlmod require_version);
@EXPORT_OK = qw(require_exe require_perlmod require_version require_var require_file);

use File::Spec;
use Nullarbor::Logger qw(err msg);
use strict;

#----------------------------------------------------------------------
sub require_var {
my($var, $reason) = @_;
$reason ||= 'nullarbor';
my $value = $ENV{$var};
if ($value) {
msg("Found $reason environmental variable $var=$value");
}
else {
err("Please set $var appropriately.");
}
return $value;
}

#----------------------------------------------------------------------
sub require_file {
my($fname, $reason) = @_;
$reason || 'nullarbor';
if (-r $fname) {
msg("Found file required by $reason: $fname");
}
else {
err("Can not find file $fname required by $reason.");
}
return;
}

#----------------------------------------------------------------------
sub require_version {
Expand Down

0 comments on commit 224f62a

Please sign in to comment.