Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print header with kraken version and database #22

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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