Wednesday, October 14, 2015

Krona snippet

I couldn't find any kind of conversion Kraken and Krona recently and so I wrote up a little pipeline.  Full script is available at lskScripts: https://github.com/lskatz/lskScripts/blob/master/qsub/launch_kraken.sh

The main points of the script are shown below.
run $KRAKENDIR/kraken --fastq-input --paired --db=$KRAKEN_DEFAULT_DB --preload --gzip-compressed --quick --threads $NSLOTS --output $KRAKENOUT $READS

run kraken-translate --db $KRAKEN_DEFAULT_DB $KRAKENOUT | cut -f 2- | sort | uniq -c |\
  perl -lane '
              s/^ +//;   # remove leading spaces
              s/ +/\t/;  # change first set of spaces from uniq -c to a tab
              s/;/\t/g;  # change the semicolon-delimited taxonomy to tab-delimited
              print;
             ' |\
  sort -k1,1nr > $KRAKENTAXONOMY


run $KRONADIR/ktImportText -o $HTML $KRAKENTAXONOMY