added cram_bam conversion & tumor_only check

This commit is contained in:
SusiJo 2022-05-20 09:11:45 +02:00
parent 9f8d6cbdd5
commit 064712c4ea

View file

@ -5,7 +5,7 @@ process CNVKIT_BATCH {
conda (params.enable_conda ? 'bioconda::cnvkit=0.9.9' : null) conda (params.enable_conda ? 'bioconda::cnvkit=0.9.9' : null)
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://depot.galaxyproject.org/singularity/cnvkit:0.9.9--pyhdfd78af_0' : 'https://depot.galaxyproject.org/singularity/cnvkit:0.9.9--pyhdfd78af_0' :
'quay.io/biocontainers/cnvkit:0.9.9--pyhdfd78af_0' }" 'quay.io/biocontainers/mulled-v2-780d630a9bb6a0ff2e7b6f730906fd703e40e98f:304d1c5ab610f216e77c61420ebe85f1e7c5968a-0' }"
input: input:
tuple val(meta), path(tumor), path(normal) tuple val(meta), path(tumor), path(normal)
@ -18,6 +18,8 @@ process CNVKIT_BATCH {
tuple val(meta), path("*.cnn"), emit: cnn, optional: true tuple val(meta), path("*.cnn"), emit: cnn, optional: true
tuple val(meta), path("*.cnr"), emit: cnr, optional: true tuple val(meta), path("*.cnr"), emit: cnr, optional: true
tuple val(meta), path("*.cns"), emit: cns, optional: true tuple val(meta), path("*.cns"), emit: cns, optional: true
tuple val(meta), path("*.pdf"), emit: pdf, optional: true
tuple val(meta), path("*.png"), emit: png, optional: true
path "versions.yml" , emit: versions path "versions.yml" , emit: versions
when: when:
@ -25,21 +27,42 @@ process CNVKIT_BATCH {
script: script:
def args = task.ext.args ?: '' def args = task.ext.args ?: ''
def normal_args = normal ? "--normal $normal" : "" // execute samtools only when cram files are input
def fasta_args = fasta ? "--fasta $fasta" : "" // 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) = ["", "", "", ""]
def reference_args = reference ? "--reference $reference" : "" def reference_args = reference ? "--reference $reference" : ""
def target_args = "" 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" : ""
}
if (args.contains("--method wgs") || args.contains("-m wgs")) { if (args.contains("--method wgs") || args.contains("-m wgs")) {
target_args = targets ? "--targets $targets" : "" target_args = targets ? "--targets $targets" : ""
} }
else { else {
target_args = "--targets $targets" target_args = "--targets $targets"
} }
""" """
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
cnvkit.py \\ cnvkit.py \\
batch \\ batch \\
$tumor \\ $tumor_out \\
$normal_args \\ $normal_args \\
$fasta_args \\ $fasta_args \\
$reference_args \\ $reference_args \\