Skip to content

Instantly share code, notes, and snippets.

@telatin
Last active July 6, 2021 12:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save telatin/6594faebe6f8497f9a9365a83c9369d5 to your computer and use it in GitHub Desktop.
Save telatin/6594faebe6f8497f9a9365a83c9369d5 to your computer and use it in GitHub Desktop.
A minimal bash script to classify reads using Kraken2
#!/bin/bash
# Process a directory of paired end reads and classify
# it with kraken2
DATABASE=/data/db/kraken2/standard-16gb/
INPUTDIR=~/kraken-ws/filt/
OUTDIR=${INPUTDIR/filt/kraken2}
THREADS=8
set -euo pipefail
mkdir -p $OUTDIR
for R1 in ${INPUTDIR}/*_R1*gz;
do
R2=${R1/_R1/_R2};
BASE=$(basename $R1 | cut -f1 -d_)
if [ ! -e "$R2" ]; then
echo "R2 for sample $R1 was not found"
exit
fi
kraken2 --db $DATABASE --threads $THREADS --paired --report $OUTDIR/$BASE.report $R1 $R2 > $OUTDIR/$BASE.tsv
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment