diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f426074..bad7da5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -12,9 +12,6 @@ variables: docker-run: - # Remove this directive in downstream templates - tags: [large_ram] # no need for big ram - # Define a 1D job matrix to inject a variable named MATRIX_NAME into # the CI environment, we can use the value of MATRIX_NAME to determine # which options to apply as part of the rules block below diff --git a/CHANGELOG.md b/CHANGELOG.md index c5c9773..d831a5d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Demo differential expression data in repository. - Improved DE explanation in docs ### Fixed +- Fix JAFFAL terminating workflow when no fusions found. - Error if condition sheet and sample sheet don't match. ## [v0.1.5] diff --git a/bin/report.py b/bin/report.py index 206bd1a..faa59f5 100755 --- a/bin/report.py +++ b/bin/report.py @@ -791,31 +791,43 @@ def jaffal_table(report, result_csv): 'sample_id', 'fusion genes', 'chrom1', 'chrom2', 'spanning reads', 'classification', 'known'] - df = pd.read_csv(result_csv) - sid_col = df.pop('sample_id') - df.insert(0, 'sample_id', sid_col) - - df = df[cols] - df['chroms'] = df.chrom1.astype(str) + ':' + df.chrom2.astype(str) - df.rename(columns={ - 'spanning reads': 'nreads', - 'fusion genes': 'genes'}, inplace=True) - df.drop(columns=['chrom1', 'chrom2'], inplace=True) section = report.add_section() - section.markdown(""" - ### JAFFAL fusion transcript summary + try: + df = pd.read_csv(result_csv) + except pd.errors.EmptyDataError: + section.markdown(""" + ### JAFFAL fusion transcript summary - This table summarizes putative fusion transcripts identified - by [JAFFAL](https://github.com/Oshlack/JAFFA/). + This section summarizes putative fusion transcripts identified + by [JAFFAL](https://github.com/Oshlack/JAFFA/). - * genes: the gene symbols of the fusion partners - * nreads: The number of reads supporting the fusion - * classification: JAFFAL's classification - * known: whether this fusion is in the given set of known gene fusions - * chroms: the respective, original chromosome location of the two partner - genes - """) - section.table(df) + No fusion transcripts detected for current sample. + """) + else: + sid_col = df.pop('sample_id') + df.insert(0, 'sample_id', sid_col) + + df = df[cols] + df['chroms'] = df.chrom1.astype(str) + ':' + df.chrom2.astype(str) + df.rename(columns={ + 'spanning reads': 'nreads', + 'fusion genes': 'genes'}, inplace=True) + df.drop(columns=['chrom1', 'chrom2'], inplace=True) + + section.markdown(""" + ### JAFFAL fusion transcript summary + + This table summarizes putative fusion transcripts identified + by [JAFFAL](https://github.com/Oshlack/JAFFA/). + + * genes: the gene symbols of the fusion partners + * nreads: The number of reads supporting the fusion + * classification: JAFFAL's classification + * known: whether this fusion is in the given set of known gene fusions + * chroms: the respective, original chromosome location of the + two partner genes + """) + section.table(df) def de_section(report): diff --git a/main.nf b/main.nf index a3f07c9..da88457 100644 --- a/main.nf +++ b/main.nf @@ -454,7 +454,6 @@ workflow pipeline { jaffal_out = file("$projectDir/data/OPTIONAL_FILE_1") } - get_transcriptome( merge_gff_bundles.out.gff .join(run_gffcompare.out.gffcmp_dir) diff --git a/subworkflows/JAFFAL/gene_fusions.nf b/subworkflows/JAFFAL/gene_fusions.nf index 0456da1..e50f87d 100644 --- a/subworkflows/JAFFAL/gene_fusions.nf +++ b/subworkflows/JAFFAL/gene_fusions.nf @@ -12,6 +12,8 @@ process jaffal{ script: """ JAFFAOUT=jaffal_output_$sample_id + + # JAFFAL exists with status code 1 when there's 0 fusion hits. Prevent this with '||:' $params.jaffal_dir/tools/bin/bpipe run \ -n $params.threads \ -p jaffa_output="\$JAFFAOUT/" \ @@ -20,14 +22,26 @@ process jaffal{ -p annotation=$annotation \ -p fastqInputFormat="*.fastq" \ $params.jaffal_dir/JAFFAL.groovy \ - $fastq - mv "\$JAFFAOUT/jaffa_results.csv" "\$JAFFAOUT/${sample_id}_jaffa_results.csv" + $fastq || : - # Add sample id column - sed "s/\$/,${sample_id}/" \$JAFFAOUT/${sample_id}_jaffa_results.csv > tmp1 - # Add header - sed "1 s/${sample_id}/sample_id/" tmp1 > tmp2 - mv tmp2 \$JAFFAOUT/${sample_id}_jaffa_results.csv + summary="\$JAFFAOUT/all/all.summary" + + if [ -f \$summary ]; then + # The summary is writtten so assume JAFFAL completed. + if [ ! -s \$summary ]; then + echo "JAFFAL failed to find any fusion transcripts for ${sample_id}" + touch "\$JAFFAOUT/${sample_id}_jaffa_results.csv" + else + echo JAFFAL found fusion transcripts for ${sample_id} + mv "\$JAFFAOUT/jaffa_results.csv" "\$JAFFAOUT/${sample_id}_jaffa_results.csv" + # Add sample id column and header + sed "s/\$/,${sample_id}/" \$JAFFAOUT/${sample_id}_jaffa_results.csv \ + | sed "1 s/${sample_id}/sample_id/" > tmp + mv tmp \$JAFFAOUT/${sample_id}_jaffa_results.csv + fi + else + echo JAFFAL encountered an error while prosessing ${sample_id} + fi """ }