Add options for output file type

This commit is contained in:
jtangrot 2022-05-23 14:02:10 +02:00
parent 8d5680a6b7
commit 853b76d16a
4 changed files with 58 additions and 12 deletions

View file

@ -10,7 +10,7 @@
// bwa mem | samtools view -B -T ref.fasta // bwa mem | samtools view -B -T ref.fasta
process VSEARCH_USEARCHGLOBAL { process VSEARCH_USEARCHGLOBAL {
tag '$queryfasta' tag "$meta.id"
label 'process_low' label 'process_low'
conda (params.enable_conda ? "bioconda::vsearch=2.21.1" : null) conda (params.enable_conda ? "bioconda::vsearch=2.21.1" : null)
@ -19,15 +19,20 @@ process VSEARCH_USEARCHGLOBAL {
'quay.io/biocontainers/vsearch:2.21.1--h95f258a_0' }" 'quay.io/biocontainers/vsearch:2.21.1--h95f258a_0' }"
input: input:
path queryfasta tuple val(meta), path(queryfasta)
path db path db
val outprefix val outoption
val user_columns
// TODO nf-core: Where applicable please provide/convert compressed files as input/output // 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. // e.g. "*.fastq.gz" and NOT "*.fastq", "*.bam" and NOT "*.sam" etc.
output: output:
path ("*.tsv") , emit: tsv 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 path "versions.yml" , emit: versions
when: when:
@ -35,13 +40,32 @@ process VSEARCH_USEARCHGLOBAL {
script: script:
def args = task.ext.args ?: '' 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 \\ vsearch \\
--usearch_global $queryfasta \\ --usearch_global $queryfasta \\
--db $db \\ --db $db \\
--threads $task.cpus \\ --threads $task.cpus \\
$args \\ $args \\
--blast6out ${outprefix}.tsv ${columns} \\
${outfmt} ${prefix}.${out_ext}
cat <<-END_VERSIONS > versions.yml cat <<-END_VERSIONS > versions.yml
"${task.process}": "${task.process}":

View file

@ -8,5 +8,17 @@ workflow test_vsearch_usearchglobal {
query = file(params.test_data['sarscov2']['genome']['transcriptome_fasta'], checkIfExists: true) query = file(params.test_data['sarscov2']['genome']['transcriptome_fasta'], checkIfExists: true)
db = file(params.test_data['sarscov2']['genome']['genome_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 )
} }

View file

@ -1,5 +1,5 @@
process { process {
ext.args = '--id 0.985' ext.args = '--id 0.985'
publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" }
} }

View file

@ -1,7 +1,17 @@
- name: vsearch usearchglobal test_vsearch_usearchglobal - 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 command: nextflow run ./tests/modules/vsearch/usearchglobal -entry test_vsearch_usearchglobal -c ./tests/config/nextflow.config -c ./tests/modules/vsearch/usearchglobal/nextflow.config
tags: tags:
- vsearch
- vsearch/usearchglobal - vsearch/usearchglobal
files: files:
- path: output/vsearch/blast6out_results.tsv - path: output/vsearch/test.aln
md5sum: 09733131643f1d951321a6e17a35eb8c 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