diff --git a/ReadbasedAnalysisTasks.wdl b/ReadbasedAnalysisTasks.wdl index 851bb19..10996dd 100644 --- a/ReadbasedAnalysisTasks.wdl +++ b/ReadbasedAnalysisTasks.wdl @@ -10,6 +10,7 @@ task profilerGottcha2 { command <<< set -euo pipefail mkdir -p ${OUTPATH} + touch ${OUTPATH}/${PREFIX}.full.tsv gottcha2.py -r ${RELABD_COL} \ -i ${sep=' ' READS} \ @@ -18,7 +19,7 @@ task profilerGottcha2 { -p ${PREFIX} \ --database ${DB} - grep "^species" ${OUTPATH}/${PREFIX}.tsv | ktImportTaxonomy -t 3 -m 9 -o ${OUTPATH}/${PREFIX}.krona.html - + grep "^species" ${OUTPATH}/${PREFIX}.tsv | ktImportTaxonomy -t 3 -m 9 -o ${OUTPATH}/${PREFIX}.krona.html - || true >>> output { Map[String, String] results = { diff --git a/outputTsv2json.py b/outputTsv2json.py index 0726813..3c2e55c 100755 --- a/outputTsv2json.py +++ b/outputTsv2json.py @@ -59,7 +59,11 @@ def reduceDf(df, cols, ranks=['species','genus','family'], top=10): # parsing results if tool == "gottcha2": - df = pd.read_csv(infile, sep='\t') + try: + df = pd.read_csv(infile, sep='\t') + except: + pass + if len(df)>0: result['rawResults'] = df.set_index('TAXID').to_dict('split') result['classifiedReadCount'] = df[df['LEVEL']=='superkingdom'].READ_COUNT.sum() @@ -67,7 +71,11 @@ def reduceDf(df, cols, ranks=['species','genus','family'], top=10): result['speciesCount'] = len(df[df['LEVEL']=='species'].index) result['taxonomyTop10'] = reduceDf(df, ['LEVEL', 'NAME', 'READ_COUNT', 'REL_ABUNDANCE', 'TAXID']) elif tool == "centrifuge": - df = pd.read_csv(infile, sep='\t') + try: + df = pd.read_csv(infile, sep='\t') + except: + pass + if len(df)>0: df['abundance'] = df['abundance'].astype(float) df['abundance'] = df['abundance']/100 @@ -77,9 +85,13 @@ def reduceDf(df, cols, ranks=['species','genus','family'], top=10): result['speciesCount'] = len(df[df['taxRank']=='species'].index) result['taxonomyTop10'] = reduceDf(df, ['taxRank', 'name', 'numReads', 'abundance', 'taxID']) elif tool == "kraken2": - df = pd.read_csv(infile, + try: + df = pd.read_csv(infile, sep='\t', names=['abundance','numReads','numUniqueReads','taxRank','taxID','name']) + except: + pass + if len(df)>0: df['abundance'] = df['abundance'].astype(float) df['abundance'] = df['abundance']/100