Skip to content

Commit

Permalink
Merge pull request #6 from microbiomedata/develop
Browse files Browse the repository at this point in the history
fixed the WorkflowFailedState caused by set-pipefail and empty results
  • Loading branch information
poeli authored Feb 11, 2021
2 parents 8da038b + fb161fc commit f11373e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
3 changes: 2 additions & 1 deletion ReadbasedAnalysisTasks.wdl
Original file line number Diff line number Diff line change
Expand Up @@ -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} \
Expand All @@ -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 = {
Expand Down
18 changes: 15 additions & 3 deletions outputTsv2json.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,23 @@ 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()
result['speciesReadCount'] = df[df['LEVEL']=='species'].READ_COUNT.sum()
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
Expand All @@ -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
Expand Down

0 comments on commit f11373e

Please sign in to comment.