Skip to content

Commit f11373e

Browse files
authored
Merge pull request #6 from microbiomedata/develop
fixed the WorkflowFailedState caused by set-pipefail and empty results
2 parents 8da038b + fb161fc commit f11373e

2 files changed

Lines changed: 17 additions & 4 deletions

File tree

ReadbasedAnalysisTasks.wdl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ task profilerGottcha2 {
1010
command <<<
1111
set -euo pipefail
1212
mkdir -p ${OUTPATH}
13+
touch ${OUTPATH}/${PREFIX}.full.tsv
1314
1415
gottcha2.py -r ${RELABD_COL} \
1516
-i ${sep=' ' READS} \
@@ -18,7 +19,7 @@ task profilerGottcha2 {
1819
-p ${PREFIX} \
1920
--database ${DB}
2021
21-
grep "^species" ${OUTPATH}/${PREFIX}.tsv | ktImportTaxonomy -t 3 -m 9 -o ${OUTPATH}/${PREFIX}.krona.html -
22+
grep "^species" ${OUTPATH}/${PREFIX}.tsv | ktImportTaxonomy -t 3 -m 9 -o ${OUTPATH}/${PREFIX}.krona.html - || true
2223
>>>
2324
output {
2425
Map[String, String] results = {

outputTsv2json.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,23 @@ def reduceDf(df, cols, ranks=['species','genus','family'], top=10):
5959

6060
# parsing results
6161
if tool == "gottcha2":
62-
df = pd.read_csv(infile, sep='\t')
62+
try:
63+
df = pd.read_csv(infile, sep='\t')
64+
except:
65+
pass
66+
6367
if len(df)>0:
6468
result['rawResults'] = df.set_index('TAXID').to_dict('split')
6569
result['classifiedReadCount'] = df[df['LEVEL']=='superkingdom'].READ_COUNT.sum()
6670
result['speciesReadCount'] = df[df['LEVEL']=='species'].READ_COUNT.sum()
6771
result['speciesCount'] = len(df[df['LEVEL']=='species'].index)
6872
result['taxonomyTop10'] = reduceDf(df, ['LEVEL', 'NAME', 'READ_COUNT', 'REL_ABUNDANCE', 'TAXID'])
6973
elif tool == "centrifuge":
70-
df = pd.read_csv(infile, sep='\t')
74+
try:
75+
df = pd.read_csv(infile, sep='\t')
76+
except:
77+
pass
78+
7179
if len(df)>0:
7280
df['abundance'] = df['abundance'].astype(float)
7381
df['abundance'] = df['abundance']/100
@@ -77,9 +85,13 @@ def reduceDf(df, cols, ranks=['species','genus','family'], top=10):
7785
result['speciesCount'] = len(df[df['taxRank']=='species'].index)
7886
result['taxonomyTop10'] = reduceDf(df, ['taxRank', 'name', 'numReads', 'abundance', 'taxID'])
7987
elif tool == "kraken2":
80-
df = pd.read_csv(infile,
88+
try:
89+
df = pd.read_csv(infile,
8190
sep='\t',
8291
names=['abundance','numReads','numUniqueReads','taxRank','taxID','name'])
92+
except:
93+
pass
94+
8395
if len(df)>0:
8496
df['abundance'] = df['abundance'].astype(float)
8597
df['abundance'] = df['abundance']/100

0 commit comments

Comments
 (0)