2021-02-23 18:05:26 +00:00
|
|
|
process BCFTOOLS_MPILEUP {
|
|
|
|
tag "$meta.id"
|
2021-02-23 20:52:15 +00:00
|
|
|
label 'process_medium'
|
2021-02-23 18:05:26 +00:00
|
|
|
|
2022-01-07 17:52:39 +00:00
|
|
|
conda (params.enable_conda ? 'bioconda::bcftools=1.14' : null)
|
2021-11-26 07:58:40 +00:00
|
|
|
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
|
2022-01-07 17:52:39 +00:00
|
|
|
'https://depot.galaxyproject.org/singularity/bcftools:1.14--h88f3f91_0' :
|
|
|
|
'quay.io/biocontainers/bcftools:1.14--h88f3f91_0' }"
|
2021-02-23 18:05:26 +00:00
|
|
|
|
|
|
|
input:
|
|
|
|
tuple val(meta), path(bam)
|
2022-01-18 16:04:56 +00:00
|
|
|
path fasta
|
|
|
|
val save_mpileup
|
2021-02-23 18:05:26 +00:00
|
|
|
|
|
|
|
output:
|
|
|
|
tuple val(meta), path("*.gz") , emit: vcf
|
|
|
|
tuple val(meta), path("*.tbi") , emit: tbi
|
|
|
|
tuple val(meta), path("*stats.txt"), emit: stats
|
2022-01-18 16:04:56 +00:00
|
|
|
tuple val(meta), path("*.mpileup") , emit: mpileup, optional: true
|
2021-10-01 13:04:56 +00:00
|
|
|
path "versions.yml" , emit: versions
|
2021-02-23 18:05:26 +00:00
|
|
|
|
2022-02-04 08:53:32 +00:00
|
|
|
when:
|
|
|
|
task.ext.when == null || task.ext.when
|
|
|
|
|
2021-02-23 18:05:26 +00:00
|
|
|
script:
|
2021-11-26 07:58:40 +00:00
|
|
|
def args = task.ext.args ?: ''
|
|
|
|
def args2 = task.ext.args2 ?: ''
|
|
|
|
def args3 = task.ext.args3 ?: ''
|
2021-12-02 12:39:55 +00:00
|
|
|
def prefix = task.ext.prefix ?: "${meta.id}"
|
2022-01-18 16:04:56 +00:00
|
|
|
def mpileup = save_mpileup ? "| tee ${prefix}.mpileup" : ""
|
2021-02-23 18:05:26 +00:00
|
|
|
"""
|
|
|
|
echo "${meta.id}" > sample_name.list
|
2021-11-26 07:58:40 +00:00
|
|
|
|
2022-01-18 16:04:56 +00:00
|
|
|
bcftools \\
|
|
|
|
mpileup \\
|
2021-02-23 18:05:26 +00:00
|
|
|
--fasta-ref $fasta \\
|
2021-11-26 07:58:40 +00:00
|
|
|
$args \\
|
2021-02-23 18:05:26 +00:00
|
|
|
$bam \\
|
2022-01-18 16:04:56 +00:00
|
|
|
$mpileup \\
|
2021-11-26 07:58:40 +00:00
|
|
|
| bcftools call --output-type v $args2 \\
|
2021-02-23 18:05:26 +00:00
|
|
|
| bcftools reheader --samples sample_name.list \\
|
2021-11-26 07:58:40 +00:00
|
|
|
| bcftools view --output-file ${prefix}.vcf.gz --output-type z $args3
|
|
|
|
|
2021-02-23 18:05:26 +00:00
|
|
|
tabix -p vcf -f ${prefix}.vcf.gz
|
2021-11-26 07:58:40 +00:00
|
|
|
|
2021-02-23 18:05:26 +00:00
|
|
|
bcftools stats ${prefix}.vcf.gz > ${prefix}.bcftools_stats.txt
|
2021-11-26 07:58:40 +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}":
|
|
|
|
bcftools: \$(bcftools --version 2>&1 | head -n1 | sed 's/^.*bcftools //; s/ .*\$//')
|
2021-09-27 08:41:24 +00:00
|
|
|
END_VERSIONS
|
2021-02-23 18:05:26 +00:00
|
|
|
"""
|
|
|
|
}
|