nf-core_modules/modules/sratools/fasterqdump/main.nf
Moritz E. Beber de997825de
Add a new module for fasterq-dump (#807)
* chore: use template to create fasterq module

* feat: add fasterq-dump process module

* docs: provide input and output descriptions

* docs: add comment on `--temp`

* fix: use correct variable

* tests: define test output

* refactor: address review comments

* refactor: remove vdb-config input

* chore: add new test data to config

* tests: define single-end and paired-end cases

* refactor: choose specific output

* tests: do not expect single FASTQ for paired-end

* feat: add compression

* Apply suggestions from code review

Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com>

* tests: revert the test data name

* Apply suggestions from code review

Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com>
2021-10-12 14:20:58 +01:00

58 lines
2.2 KiB
Text

// Import generic module functions
include { initOptions; saveFiles; getSoftwareName; getProcessName } from './functions'
params.options = [:]
options = initOptions(params.options)
process SRATOOLS_FASTERQDUMP {
tag "$meta.id"
label 'process_medium'
publishDir "${params.outdir}",
mode: params.publish_dir_mode,
saveAs: { filename -> saveFiles(filename:filename, options:params.options, publish_dir:getSoftwareName(task.process), meta:meta, publish_by_meta:['id']) }
conda (params.enable_conda ? 'bioconda::sra-tools=2.11.0 conda-forge::pigz=2.6' : null)
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
container 'https://depot.galaxyproject.org/singularity/mulled-v2-5f89fe0cd045cb1d615630b9261a1d17943a9b6a:6a9ff0e76ec016c3d0d27e0c0d362339f2d787e6-0'
} else {
container 'quay.io/biocontainers/mulled-v2-5f89fe0cd045cb1d615630b9261a1d17943a9b6a:6a9ff0e76ec016c3d0d27e0c0d362339f2d787e6-0'
}
input:
tuple val(meta), path(sra)
output:
tuple val(meta), path(output), emit: reads
path "versions.yml" , emit: versions
script:
def config = "/LIBS/GUID = \"${UUID.randomUUID().toString()}\"\\n/libs/cloud/report_instance_identity = \"true\"\\n"
// Paired-end data extracted by fasterq-dump (--split-3 the default) always creates
// *_1.fastq *_2.fastq files but sometimes also an additional *.fastq file
// for unpaired reads which we ignore here.
output = meta.single_end ? '*.fastq.gz' : '*_{1,2}.fastq.gz'
"""
eval "\$(vdb-config -o n NCBI_SETTINGS | sed 's/[" ]//g')"
if [[ ! -f "\${NCBI_SETTINGS}" ]]; then
mkdir -p "\$(dirname "\${NCBI_SETTINGS}")"
printf '${config}' > "\${NCBI_SETTINGS}"
fi
fasterq-dump \\
${options.args} \\
--threads $task.cpus \\
${sra.name}
pigz \\
${options.args2} \\
--no-name \\
--processes $task.cpus \\
*.fastq
cat <<-END_VERSIONS > versions.yml
${getProcessName(task.process)}:
${getSoftwareName(task.process)}: \$(fasterq-dump --version 2>&1 | grep -Eo '[0-9.]+')
pigz: \$( pigz --version 2>&1 | sed 's/pigz //g' )
END_VERSIONS
"""
}