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

Make build db compatible for OS X #58

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
13 changes: 11 additions & 2 deletions scripts/build_kraken_db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@ else
# Estimate hash size as 1.15 * chars in library FASTA files
if [ -z "$KRAKEN_HASH_SIZE" ]
then
KRAKEN_HASH_SIZE=$(find library/ '(' -name '*.fna' -o -name '*.fa' -o -name '*.ffn' ')' -printf '%s\n' | perl -nle '$sum += $_; END {print int(1.15 * $sum)}')
if [[ $(uname) == "Darwin" ]]; then
KRAKEN_HASH_SIZE=$(find library/ -name '*.ffn' -ls | awk '{print $7}' | perl -nle '$sum += $_; END {print int(1.15 * $sum)}')
else
KRAKEN_HASH_SIZE=$(find library/ '(' -name '*.fna' -o -name '*.fa' -o -name '*.ffn' ')' -printf '%s\n' | perl -nle '$sum += $_; END {print int(1.15 * $sum)}')
fi
echo "Hash size not specified, using '$KRAKEN_HASH_SIZE'"
fi

Expand Down Expand Up @@ -104,7 +108,12 @@ else
echo "Skipping step 2, database reduction already done."
else
start_time1=$(date "+%s.%N")
kdb_size=$(stat -c '%s' database.jdb)
if [[ $(uname) == "Darwin" ]]; then
kdb_size=$(stat -f '%z' database.jdb)
else
kdb_size=$(stat -c '%s' database.jdb)
fi

idx_size=$(echo "8 * (4 ^ $KRAKEN_MINIMIZER_LEN + 2)" | bc)
resize_needed=$(echo "scale = 10; ($kdb_size+$idx_size)/(2^30) > $KRAKEN_MAX_DB_SIZE" | bc)
if (( resize_needed == 0 ))
Expand Down
6 changes: 5 additions & 1 deletion scripts/upgrade_db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ then
exit 1
fi

idx_size=$(stat -c '%s' database.idx)
if [[ $(uname) == "Darwin" ]]; then
idx_size=$(stat -f '%z' database.idx)
else
idx_size=$(stat -c '%s' database.idx)
fi
# Calculate minimizer length based on existing index size
minimizer_len=$(perl -le 'print int(log(shift() / 8 - 2) / log(4))' $idx_size)

Expand Down