From 93a57467571452e7715e08f8180f5081fc0633eb Mon Sep 17 00:00:00 2001 From: Rad Suchecki Date: Tue, 10 Dec 2019 17:01:38 +1030 Subject: [PATCH] better handling of "no sequences placed scenario" --- main.nf | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/main.nf b/main.nf index 755f7fb..f53dd75 100644 --- a/main.nf +++ b/main.nf @@ -181,7 +181,7 @@ process alignToGenome { outmeta = [ref: refmeta, seqs: seqsmeta.subMap(['name', 'seqtype'])] //preset: short read OR long assembly to ref OR long, HQ spliced to ref preset = seqsmeta.seqtype == 'markers' ? 'sr' : seqsmeta.seqtype == 'genomic' ? 'asm5' : 'splice:hq' - secondary = seqsmeta.seqtype.matches('markers|transcripts') ? 'yes' : 'no' + secondary = seqsmeta.seqtype.toLowerCase().matches('markers|transcripts|cds|orf') ? 'yes' : 'no' csTag = seqsmeta.seqtype == 'markers' ? '--cs=long' : '' //save space by not printing cs in non-maraker modes alnParams = "-x ${preset} --secondary=${secondary} ${csTag} -I 30G" outmeta.align = [tool: 'minimap2', params: alnParams] @@ -232,13 +232,14 @@ process generateFeaturesFromSeqAlignmentsJSON { tag { tag } label 'groovy' label 'json' - label 'mem' + label 'mem' + validExitStatus 0,3 //expecting exit status 3 if no features placed which is valid e.g. when no good-enough alignments found input: set val(meta), file(paf) from alignedSeqsChannel output: - file "*.json.gz" into placedSeqsJSON + file "*.json.gz" optional true into placedSeqsJSON file "*.counts" into placedSeqsCounts script: @@ -305,10 +306,14 @@ process generateGenomeBlocksJSON { genome.blocks = [] idx.eachLine { line -> if(line.toLowerCase() =~ /^(chr|[0-9]{1,2}|x|y|i|v)/ ) { - toks = line.split('\t') + toks = line.split('\\t| ') genome.blocks += [ "scope": toks[0].replaceFirst("^(C|c)(H|h)(R|r)[_]?",""), "featureType": "linear", "range": [1, toks[1].toInteger()] ] } } + if(genome.blocks.isEmpty()) { + System.err.println('No blocks defined for ${tag}, this may be caused by chromosome naming, terminating') + System.exit(2) + } out.text = prettyPrint(toJson(genome)) """ }