Skip to content

Commit d064bb7

Browse files
cimendescimendes
authored andcommitted
- in the viral_assembly module, if the assembly fails in spades it now tries with megahit
- spades template now reports spades' exit code if the run fails
1 parent cd340f7 commit d064bb7

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ error when it is set to `null`.
3232
- Fixed minor issue preventing the `maxbin2` and `split_assembly` components
3333
from being used multiples times in a pipeline
3434
- Added a catch to the `filter_poly` process for cases where the input file is empty.
35+
- spades template now reports the exit code of spades' execution
3536

3637
### Bug fixes
3738

flowcraft/generator/templates/viral_assembly.nf

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ process va_spades_{{ pid }} {
4848
// Send POST request to platform
4949
{% include "post.txt" ignore missing %}
5050

51+
validExitStatus 0,1
52+
5153
tag { sample_id }
5254
publishDir 'results/assembly/spades_{{ pid }}/', pattern: '*_spades*.fasta', mode: 'copy'
5355

@@ -58,7 +60,7 @@ process va_spades_{{ pid }} {
5860
val clear from checkpointClear_{{ pid }}
5961

6062
output:
61-
set sample_id, file('*_spades*.fasta') into assembly_spades
63+
set sample_id, file({task.exitStatus == 1 ? ".exitcodeU" : '*_spades*.fasta'}) into assembly_spades
6264
{% with task_name="va_spades" %}
6365
{%- include "compiler_channels.txt" ignore missing -%}
6466
{% endwith %}
@@ -71,13 +73,10 @@ process va_spades_{{ pid }} {
7173
class VerifyCompletness {
7274

7375
public static boolean contigs(String filename, int threshold){
74-
println(filename)
7576
BufferedReader reader = new BufferedReader(new FileReader(filename));
7677
boolean result = processContigs(reader, threshold);
7778
reader.close()
7879

79-
println(result)
80-
8180
return result;
8281
}
8382

@@ -91,7 +90,6 @@ class VerifyCompletness {
9190
splittedLine = line.split('_')
9291
lineThreshold = splittedLine[3].toInteger()
9392
if(lineThreshold >= threshold) {
94-
println(lineThreshold)
9593
return true;
9694
}
9795
}
@@ -103,7 +101,7 @@ class VerifyCompletness {
103101

104102
megahit = Channel.create()
105103
good_assembly = Channel.create()
106-
assembly_spades.choice(good_assembly, megahit){a -> VerifyCompletness.contigs(a[1].toString(), params.minimumContigSize{{ param_id }}.toInteger()) == true ? 0 : 1}
104+
assembly_spades.choice(good_assembly, megahit){a -> a[1].toString() == "null" ? false : VerifyCompletness.contigs(a[1].toString(), params.minimumContigSize{{ param_id }}.toInteger()) == true ? 0 : 1}
107105

108106

109107
process va_megahit_{{ pid }} {

flowcraft/templates/spades.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
__template__ = "spades-nf"
4949

5050
import os
51+
import sys
5152
import re
5253
import subprocess
5354

@@ -239,7 +240,7 @@ def main(sample_id, fastq_pair, max_len, kmer, opts, clear):
239240
with open(".status", "w") as fh:
240241
if p.returncode != 0:
241242
fh.write("error")
242-
return
243+
sys.exit(p.returncode)
243244
else:
244245
fh.write("pass")
245246

0 commit comments

Comments
 (0)