2021-06-25 06:15:15 +00:00
|
|
|
// Import generic module functions
|
2021-09-27 08:41:24 +00:00
|
|
|
include { initOptions; saveFiles; getSoftwareName; getProcessName } from './functions'
|
2021-06-25 06:15:15 +00:00
|
|
|
|
|
|
|
params.options = [:]
|
|
|
|
options = initOptions(params.options)
|
|
|
|
|
|
|
|
process METAPHLAN3 {
|
|
|
|
tag "$meta.id"
|
|
|
|
label 'process_high'
|
|
|
|
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']) }
|
|
|
|
|
2021-07-28 08:10:44 +00:00
|
|
|
conda (params.enable_conda ? 'bioconda::metaphlan=3.0.12' : null)
|
2021-06-25 06:15:15 +00:00
|
|
|
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
|
2021-07-28 08:10:44 +00:00
|
|
|
container "https://depot.galaxyproject.org/singularity/metaphlan:3.0.12--pyhb7b1952_0"
|
2021-06-25 06:15:15 +00:00
|
|
|
} else {
|
2021-07-28 08:10:44 +00:00
|
|
|
container "quay.io/biocontainers/metaphlan:3.0.12--pyhb7b1952_0"
|
2021-06-25 06:15:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
input:
|
|
|
|
tuple val(meta), path(input)
|
|
|
|
path metaphlan_db
|
|
|
|
|
|
|
|
output:
|
|
|
|
tuple val(meta), path("*_profile.txt") , emit: profile
|
|
|
|
tuple val(meta), path("*.biom") , emit: biom
|
|
|
|
tuple val(meta), path('*.bowtie2out.txt'), optional:true, emit: bt2out
|
2021-10-01 13:04:56 +00:00
|
|
|
path "versions.yml" , emit: versions
|
2021-06-25 06:15:15 +00:00
|
|
|
|
|
|
|
script:
|
|
|
|
def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
|
|
|
|
def input_type = ("$input".endsWith(".fastq.gz")) ? "--input_type fastq" : ("$input".contains(".fasta")) ? "--input_type fasta" : ("$input".endsWith(".bowtie2out.txt")) ? "--input_type bowtie2out" : "--input_type sam"
|
|
|
|
def input_data = ("$input_type".contains("fastq")) && !meta.single_end ? "${input[0]},${input[1]}" : "$input"
|
|
|
|
def bowtie2_out = "$input_type" == "--input_type bowtie2out" || "$input_type" == "--input_type sam" ? '' : "--bowtie2out ${prefix}.bowtie2out.txt"
|
|
|
|
|
|
|
|
"""
|
|
|
|
metaphlan \\
|
|
|
|
--nproc $task.cpus \\
|
|
|
|
$input_type \\
|
|
|
|
$input_data \\
|
|
|
|
$options.args \\
|
|
|
|
$bowtie2_out \\
|
|
|
|
--bowtie2db ${metaphlan_db} \\
|
|
|
|
--biom ${prefix}.biom \\
|
|
|
|
--output_file ${prefix}_profile.txt
|
2021-09-27 08:41:24 +00:00
|
|
|
cat <<-END_VERSIONS > versions.yml
|
|
|
|
${getProcessName(task.process)}:
|
|
|
|
${getSoftwareName(task.process)}: \$(metaphlan --version 2>&1 | awk '{print \$3}')
|
|
|
|
END_VERSIONS
|
2021-06-25 06:15:15 +00:00
|
|
|
"""
|
|
|
|
}
|