From 589ce2d73a0b9a3109f5291587eff425ca7fbfa5 Mon Sep 17 00:00:00 2001 From: jtangrot Date: Mon, 23 May 2022 14:02:10 +0200 Subject: [PATCH] Add options for output file type --- modules/vsearch/usearchglobal/main.nf | 38 +++++++++++++++---- tests/modules/vsearch/usearchglobal/main.nf | 14 ++++++- .../vsearch/usearchglobal/nextflow.config | 4 +- tests/modules/vsearch/usearchglobal/test.yml | 14 ++++++- 4 files changed, 58 insertions(+), 12 deletions(-) diff --git a/modules/vsearch/usearchglobal/main.nf b/modules/vsearch/usearchglobal/main.nf index 65ee62cc..0b31842f 100644 --- a/modules/vsearch/usearchglobal/main.nf +++ b/modules/vsearch/usearchglobal/main.nf @@ -10,7 +10,7 @@ // bwa mem | samtools view -B -T ref.fasta process VSEARCH_USEARCHGLOBAL { - tag '$queryfasta' + tag "$meta.id" label 'process_low' conda (params.enable_conda ? "bioconda::vsearch=2.21.1" : null) @@ -19,29 +19,53 @@ process VSEARCH_USEARCHGLOBAL { 'quay.io/biocontainers/vsearch:2.21.1--h95f258a_0' }" input: - path queryfasta + tuple val(meta), path(queryfasta) path db - val outprefix + val outoption + val user_columns // TODO nf-core: Where applicable please provide/convert compressed files as input/output // e.g. "*.fastq.gz" and NOT "*.fastq", "*.bam" and NOT "*.sam" etc. output: - path ("*.tsv") , emit: tsv - path "versions.yml" , emit: versions - + tuple val(meta), path('*.aln') , optional: true, emit: aln + tuple val(meta), path('*.biom') , optional: true, emit: biom + tuple val(meta), path('*.sam') , optional: true, emit: sam + tuple val(meta), path('*.tsv') , optional: true, emit: tsv + tuple val(meta), path('*.uc') , optional: true, emit: uc + path "versions.yml" , emit: versions + when: task.ext.when == null || task.ext.when script: def args = task.ext.args ?: '' + def prefix = task.ext.prefix ?: "${meta.id}" + def columns = user_columns ? "--userfields ${user_columns}" : '' + switch ( outoption ) { + case "alnout": outfmt = "--alnout"; out_ext = 'aln'; break + case "biomout": outfmt = "--biomout"; out_ext = 'biom'; break + case "blast6out": outfmt = "--blast6out"; out_ext = 'blast6out.tsv'; break + case "mothur_shared_out": outfmt = "--mothur_shared_out"; out_ext = 'mothur.tsv'; break + case "otutabout": outfmt = "--otutabout"; out_ext = 'otu.tsv'; break + case "samout": outfmt = "--samout"; out_ext = 'sam'; break + case "uc": outfmt = "--uc"; out_ext = 'uc'; break + case "userout": outfmt = "--userout"; out_ext = 'user.tsv'; break + case "lcaout": outfmt = "--lcaout"; out_ext = 'lca.tsv'; break + default: + outfmt = "--alnout"; + out_ext = 'aln'; + log.warn("Unknown output file format provided (${outoption}): selectingpairwise alignments (alnout)"); + break + } """ vsearch \\ --usearch_global $queryfasta \\ --db $db \\ --threads $task.cpus \\ $args \\ - --blast6out ${outprefix}.tsv + ${columns} \\ + ${outfmt} ${prefix}.${out_ext} cat <<-END_VERSIONS > versions.yml "${task.process}": diff --git a/tests/modules/vsearch/usearchglobal/main.nf b/tests/modules/vsearch/usearchglobal/main.nf index 02becd21..cdf0fb2f 100644 --- a/tests/modules/vsearch/usearchglobal/main.nf +++ b/tests/modules/vsearch/usearchglobal/main.nf @@ -8,5 +8,17 @@ workflow test_vsearch_usearchglobal { query = file(params.test_data['sarscov2']['genome']['transcriptome_fasta'], checkIfExists: true) db = file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true) - VSEARCH_USEARCHGLOBAL ( query, db, "blast6out_results" ) + + outoption = "xcfert" // Nonsense text to check default case. + columns = "" + VSEARCH_USEARCHGLOBAL ( [ [id:'test'], query ], db, outoption, columns ) +} + +workflow test_vsearch_usearchglobal_userout { + + query = file(params.test_data['sarscov2']['genome']['transcriptome_fasta'], checkIfExists: true) + db = file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true) + outoption = "userout" + columns = "query+target+id" + VSEARCH_USEARCHGLOBAL ( [ [id:'test'], query ], db, outoption, columns ) } diff --git a/tests/modules/vsearch/usearchglobal/nextflow.config b/tests/modules/vsearch/usearchglobal/nextflow.config index aab29979..3148a59e 100644 --- a/tests/modules/vsearch/usearchglobal/nextflow.config +++ b/tests/modules/vsearch/usearchglobal/nextflow.config @@ -1,5 +1,5 @@ process { ext.args = '--id 0.985' publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } - -} \ No newline at end of file +} + diff --git a/tests/modules/vsearch/usearchglobal/test.yml b/tests/modules/vsearch/usearchglobal/test.yml index b013519d..b7ebec4a 100644 --- a/tests/modules/vsearch/usearchglobal/test.yml +++ b/tests/modules/vsearch/usearchglobal/test.yml @@ -1,7 +1,17 @@ - name: vsearch usearchglobal test_vsearch_usearchglobal command: nextflow run ./tests/modules/vsearch/usearchglobal -entry test_vsearch_usearchglobal -c ./tests/config/nextflow.config -c ./tests/modules/vsearch/usearchglobal/nextflow.config tags: + - vsearch - vsearch/usearchglobal files: - - path: output/vsearch/blast6out_results.tsv - md5sum: 09733131643f1d951321a6e17a35eb8c + - path: output/vsearch/test.aln + md5sum: 7b7479c16e0ecb503913da8bde48d6c5 + +- name: vsearch usearchglobal test_vsearch_usearchglobal_userout + command: nextflow run ./tests/modules/vsearch/usearchglobal -entry test_vsearch_usearchglobal_userout -c ./tests/config/nextflow.config -c ./tests/modules/vsearch/usearchglobal/nextflow.config + tags: + - vsearch + - vsearch/usearchglobal + files: + - path: output/vsearch/test.user.tsv + md5sum: b6cc50f7c8d18cb82e74dab70ed4baab