Skip to content

Commit

Permalink
Print header with kraken version and database
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewjpage committed May 26, 2015
1 parent adfaa26 commit 7d33069
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions scripts/kraken-report
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,13 @@ require "$KRAKEN_DIR/krakenlib.pm";

my $show_zeros = 0;
my $db_prefix;
my $print_header;

GetOptions(
"help" => \&display_help,
"version" => \&display_version,
"show-zeros" => \$show_zeros,
"print_header" => \$print_header,
"db=s" => \$db_prefix,
);

Expand All @@ -52,7 +54,7 @@ if ($@) {

sub usage {
my $exit_code = @_ ? shift : 64;
print STDERR "Usage: $PROG [--db KRAKEN_DB_NAME] [--show-zeros] <kraken output file(s)>\n";
print STDERR "Usage: $PROG [--db KRAKEN_DB_NAME] [--show-zeros] [--print_header] <kraken output file(s)>\n";
my $default_db;
eval { $default_db = krakenlib::find_db(); };
if (defined $default_db) {
Expand All @@ -65,12 +67,22 @@ sub display_help {
usage(0);
}

sub version {
return "#####=VERSION=#####";
}

sub display_version {
print "Kraken version #####=VERSION=#####\n";
print "Kraken version ".version()."\n";
print "Copyright 2013-2015, Derrick Wood (dwood\@cs.jhu.edu)\n";
exit 0;
}

sub print_header {
my ($version,$db_prefix) = @_;
printf "#Kraken version: %s\n", $version;
printf "#Database: %s\n", $db_prefix;
}

my (%child_lists, %name_map, %rank_map);
load_taxonomy($db_prefix);

Expand All @@ -91,6 +103,7 @@ for (keys %name_map) {
$clade_counts{$_} ||= 0;
}

print_header(version(), $db_prefix) if($print_header);
printf "%6.2f\t%d\t%d\t%s\t%d\t%s%s\n",
$clade_counts{0} * 100 / $seq_count,
$clade_counts{0}, $taxo_counts{0}, "U",
Expand Down

0 comments on commit 7d33069

Please sign in to comment.