2021-11-21 19:56:57 +00:00
|
|
|
process CNVKIT_BATCH {
|
2021-03-22 22:27:30 +00:00
|
|
|
tag "$meta.id"
|
|
|
|
label 'process_low'
|
|
|
|
|
2022-05-20 08:37:46 +00:00
|
|
|
conda (params.enable_conda ? 'bioconda::cnvkit=0.9.9 bioconda::samtools=1.15.1' : null)
|
2021-11-26 07:58:40 +00:00
|
|
|
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
|
2022-05-20 08:37:46 +00:00
|
|
|
'https://depot.galaxyproject.org/singularity/mulled-v2-780d630a9bb6a0ff2e7b6f730906fd703e40e98f:304d1c5ab610f216e77c61420ebe85f1e7c5968a-0' :
|
2022-05-20 07:11:45 +00:00
|
|
|
'quay.io/biocontainers/mulled-v2-780d630a9bb6a0ff2e7b6f730906fd703e40e98f:304d1c5ab610f216e77c61420ebe85f1e7c5968a-0' }"
|
2021-03-22 22:27:30 +00:00
|
|
|
|
|
|
|
input:
|
2021-11-21 19:56:57 +00:00
|
|
|
tuple val(meta), path(tumor), path(normal)
|
2021-07-01 15:13:01 +00:00
|
|
|
path fasta
|
2021-11-21 19:56:57 +00:00
|
|
|
path targets
|
|
|
|
path reference
|
2021-03-22 22:27:30 +00:00
|
|
|
|
|
|
|
output:
|
|
|
|
tuple val(meta), path("*.bed"), emit: bed
|
2021-11-21 19:56:57 +00:00
|
|
|
tuple val(meta), path("*.cnn"), emit: cnn, optional: true
|
|
|
|
tuple val(meta), path("*.cnr"), emit: cnr, optional: true
|
|
|
|
tuple val(meta), path("*.cns"), emit: cns, optional: true
|
2022-05-20 07:11:45 +00:00
|
|
|
tuple val(meta), path("*.pdf"), emit: pdf, optional: true
|
|
|
|
tuple val(meta), path("*.png"), emit: png, optional: true
|
2021-10-01 13:04:56 +00:00
|
|
|
path "versions.yml" , emit: versions
|
2021-03-22 22:27:30 +00:00
|
|
|
|
2022-02-04 08:53:32 +00:00
|
|
|
when:
|
|
|
|
task.ext.when == null || task.ext.when
|
|
|
|
|
2021-03-22 22:27:30 +00:00
|
|
|
script:
|
2021-11-26 07:58:40 +00:00
|
|
|
def args = task.ext.args ?: ''
|
2022-05-20 07:11:45 +00:00
|
|
|
// execute samtools only when cram files are input
|
|
|
|
// input pair is assumed to have same extension if both exist
|
|
|
|
def is_cram = tumor.Extension == "cram" ? true : false
|
|
|
|
def tumor_out = is_cram ? tumor.BaseName + ".bam" : "${tumor}"
|
|
|
|
// do not run samtools on normal samples in tumor_only
|
|
|
|
def normal_exists = normal ? true: false
|
|
|
|
// tumor_only mode does not need fasta & target
|
|
|
|
// instead it requires a pre-computed reference which is built from fasta & target
|
|
|
|
def (normal_out, normal_args, fasta_args, target_args) = ["", "", "", ""]
|
2021-11-26 07:58:40 +00:00
|
|
|
def reference_args = reference ? "--reference $reference" : ""
|
2021-11-21 19:56:57 +00:00
|
|
|
|
2022-05-20 07:11:45 +00:00
|
|
|
if (normal_exists){
|
|
|
|
def normal_prefix = normal.BaseName
|
|
|
|
normal_out = is_cram ? "${normal_prefix}" + ".bam" : "${normal}"
|
|
|
|
normal_args = normal_prefix ? "--normal $normal_out" : ""
|
|
|
|
fasta_args = fasta ? "--fasta $fasta" : ""
|
|
|
|
}
|
|
|
|
|
2021-11-26 07:58:40 +00:00
|
|
|
if (args.contains("--method wgs") || args.contains("-m wgs")) {
|
2021-11-21 19:56:57 +00:00
|
|
|
target_args = targets ? "--targets $targets" : ""
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
target_args = "--targets $targets"
|
|
|
|
}
|
2022-05-20 07:11:45 +00:00
|
|
|
|
2021-03-22 22:27:30 +00:00
|
|
|
"""
|
2022-05-20 07:11:45 +00:00
|
|
|
if $is_cram; then
|
|
|
|
samtools view -T $fasta $tumor -@ $task.cpus -o $tumor_out
|
|
|
|
if $normal_exists; then
|
|
|
|
samtools view -T $fasta $normal -@ $task.cpus -o $normal_out
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2021-07-01 15:13:01 +00:00
|
|
|
cnvkit.py \\
|
|
|
|
batch \\
|
2022-05-20 07:11:45 +00:00
|
|
|
$tumor_out \\
|
2021-11-21 19:56:57 +00:00
|
|
|
$normal_args \\
|
|
|
|
$fasta_args \\
|
|
|
|
$reference_args \\
|
|
|
|
$target_args \\
|
2021-11-26 07:58:40 +00:00
|
|
|
--processes $task.cpus \\
|
|
|
|
$args
|
2021-03-22 22:27:30 +00:00
|
|
|
|
2021-09-27 08:41:24 +00:00
|
|
|
cat <<-END_VERSIONS > versions.yml
|
2021-11-26 07:58:40 +00:00
|
|
|
"${task.process}":
|
|
|
|
cnvkit: \$(cnvkit.py version | sed -e "s/cnvkit v//g")
|
2021-09-27 08:41:24 +00:00
|
|
|
END_VERSIONS
|
2021-03-22 22:27:30 +00:00
|
|
|
"""
|
|
|
|
}
|