2021-05-09 22:55:35 +00:00
|
|
|
// Import generic module functions
|
2021-09-27 08:41:24 +00:00
|
|
|
include { initOptions; saveFiles; getSoftwareName; getProcessName } from './functions'
|
2021-05-09 22:55:35 +00:00
|
|
|
|
|
|
|
params.options = [:]
|
|
|
|
options = initOptions(params.options)
|
|
|
|
|
|
|
|
process SEQTK_SAMPLE {
|
|
|
|
tag "$meta.id"
|
|
|
|
label 'process_low'
|
|
|
|
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::seqtk=1.3" : null)
|
|
|
|
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
|
|
|
|
container "https://depot.galaxyproject.org/singularity/seqtk:1.3--h5bf99c6_3"
|
|
|
|
} else {
|
|
|
|
container "quay.io/biocontainers/seqtk:1.3--h5bf99c6_3"
|
|
|
|
}
|
|
|
|
|
|
|
|
input:
|
|
|
|
tuple val(meta), path(reads)
|
|
|
|
val sample_size
|
|
|
|
|
|
|
|
output:
|
|
|
|
tuple val(meta), path("*.fastq.gz"), emit: reads
|
2021-10-01 13:04:56 +00:00
|
|
|
path "versions.yml" , emit: versions
|
2021-05-09 22:55:35 +00:00
|
|
|
|
|
|
|
script:
|
|
|
|
def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
|
|
|
|
if (meta.single_end) {
|
|
|
|
"""
|
|
|
|
seqtk \\
|
|
|
|
sample \\
|
|
|
|
$options.args \\
|
|
|
|
$reads \\
|
|
|
|
$sample_size \\
|
2021-06-14 11:23:15 +00:00
|
|
|
| gzip --no-name > ${prefix}.fastq.gz \\
|
2021-05-09 22:55:35 +00:00
|
|
|
|
2021-09-27 08:41:24 +00:00
|
|
|
cat <<-END_VERSIONS > versions.yml
|
|
|
|
${getProcessName(task.process)}:
|
2021-09-28 13:37:47 +00:00
|
|
|
${getSoftwareName(task.process)}: \$(echo \$(seqtk 2>&1) | sed 's/^.*Version: //; s/ .*\$//')
|
2021-09-27 08:41:24 +00:00
|
|
|
END_VERSIONS
|
2021-05-09 22:55:35 +00:00
|
|
|
"""
|
|
|
|
} else {
|
2021-06-14 11:23:15 +00:00
|
|
|
if (!(options.args ==~ /.*-s[0-9]+.*/)) {
|
|
|
|
options.args = options.args + " -s100"
|
|
|
|
}
|
2021-05-09 22:55:35 +00:00
|
|
|
"""
|
|
|
|
seqtk \\
|
|
|
|
sample \\
|
|
|
|
$options.args \\
|
2021-06-14 11:23:15 +00:00
|
|
|
${reads[0]} \\
|
2021-05-09 22:55:35 +00:00
|
|
|
$sample_size \\
|
2021-06-14 11:23:15 +00:00
|
|
|
| gzip --no-name > ${prefix}_1.fastq.gz \\
|
2021-05-09 22:55:35 +00:00
|
|
|
|
|
|
|
seqtk \\
|
|
|
|
sample \\
|
|
|
|
$options.args \\
|
2021-06-14 11:23:15 +00:00
|
|
|
${reads[1]} \\
|
2021-05-09 22:55:35 +00:00
|
|
|
$sample_size \\
|
2021-06-14 11:23:15 +00:00
|
|
|
| gzip --no-name > ${prefix}_2.fastq.gz \\
|
2021-05-09 22:55:35 +00:00
|
|
|
|
2021-09-27 08:41:24 +00:00
|
|
|
cat <<-END_VERSIONS > versions.yml
|
|
|
|
${getProcessName(task.process)}:
|
2021-09-28 13:37:47 +00:00
|
|
|
${getSoftwareName(task.process)}: \$(echo \$(seqtk 2>&1) | sed 's/^.*Version: //; s/ .*\$//')
|
2021-09-27 08:41:24 +00:00
|
|
|
END_VERSIONS
|
2021-05-09 22:55:35 +00:00
|
|
|
"""
|
|
|
|
}
|
|
|
|
}
|