diff --git a/modules/bcftools/roh/main.nf b/modules/bcftools/roh/main.nf new file mode 100644 index 00000000..890b6fad --- /dev/null +++ b/modules/bcftools/roh/main.nf @@ -0,0 +1,61 @@ +process BCFTOOLS_ROH { + tag "$meta.id" + label 'process_medium' + + conda (params.enable_conda ? "bioconda::bcftools=1.15.1" : null) + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/bcftools:1.15.1--h0ea216a_0': + 'quay.io/biocontainers/bcftools:1.15.1--h0ea216a_0' }" + + input: + tuple val(meta), path(vcf), path(tbi) + path af_file + path genetic_map + path regions_file + path samples_file + path targets_file + + output: + tuple val(meta), path("*.roh"), emit: roh + path "versions.yml" , emit: versions + + when: + task.ext.when == null || task.ext.when + + script: + def args = task.ext.args ?: '' + def prefix = task.ext.prefix ?: "${meta.id}" + def af_read = af_file ? "--AF-file ${af_file}" : '' + def gen_map = genetic_map ? "--genetic-map ${genetic_map}" : '' + def reg_file = regions_file ? "--regions-file ${regions_file}" : '' + def samp_file = samples_file ? "--samples-file ${samples_file}" : '' + def targ_file = targets_file ? "--targets-file ${targets_file}" : '' + """ + bcftools \\ + roh \\ + $args \\ + $af_read \\ + $gen_map \\ + $reg_file \\ + $samp_file \\ + $targ_file \\ + -o ${prefix}.roh \\ + $vcf + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + bcftools: \$(bcftools --version 2>&1 | head -n1 | sed 's/^.*bcftools //; s/ .*\$//') + END_VERSIONS + """ + + stub: + def prefix = task.ext.prefix ?: "${meta.id}" + """ + touch ${prefix}.roh + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + bcftools: \$(bcftools --version 2>&1 | head -n1 | sed 's/^.*bcftools //; s/ .*\$//') + END_VERSIONS + """ +} diff --git a/modules/bcftools/roh/meta.yml b/modules/bcftools/roh/meta.yml new file mode 100644 index 00000000..fd03d4ce --- /dev/null +++ b/modules/bcftools/roh/meta.yml @@ -0,0 +1,55 @@ +name: "bcftools_roh" +description: A program for detecting runs of homo/autozygosity. Only bi-allelic sites are considered. +keywords: + - roh +tools: + - "roh": + description: "A program for detecting runs of homo/autozygosity. Only bi-allelic sites are considered." + homepage: https://www.htslib.org/ + documentation: http://www.htslib.org/doc/bcftools.html + doi: 10.1093/bioinformatics/btp352 + licence: ["MIT"] + +input: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + - vcf: + type: file + description: VCF file + pattern: "*.{vcf,.vcf.gz}" + - af_file: + type: file + description: "Read allele frequencies from a tab-delimited file containing the columns: CHROM\tPOS\tREF,ALT\tAF." + - genetic_map: + type: file + description: "Genetic map in the format required also by IMPUTE2." + - regions_file: + type: file + description: "Regions can be specified either on command line or in a VCF, BED, or tab-delimited file (the default)." + - samples_file: + type: file + description: "File of sample names to include or exclude if prefixed with '^'." + - targets_file: + type: file + description: "Targets can be specified either on command line or in a VCF, BED, or tab-delimited file (the default)." + +output: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + - versions: + type: file + description: File containing software versions + pattern: "versions.yml" + - roh: + type: file + description: Contains site-specific and/or per-region runs of homo/autozygosity calls. + pattern: "*.{roh}" + +authors: + - "@ramprasadn" diff --git a/tests/config/pytest_modules.yml b/tests/config/pytest_modules.yml index 2063d691..d8227203 100644 --- a/tests/config/pytest_modules.yml +++ b/tests/config/pytest_modules.yml @@ -166,6 +166,10 @@ bcftools/reheader: - modules/bcftools/reheader/** - tests/modules/bcftools/reheader/** +bcftools/roh: + - modules/bcftools/roh/** + - tests/modules/bcftools/roh/** + bcftools/sort: - modules/bcftools/sort/** - tests/modules/bcftools/sort/** diff --git a/tests/modules/bcftools/roh/main.nf b/tests/modules/bcftools/roh/main.nf new file mode 100644 index 00000000..3eb534b6 --- /dev/null +++ b/tests/modules/bcftools/roh/main.nf @@ -0,0 +1,35 @@ +#!/usr/bin/env nextflow + +nextflow.enable.dsl = 2 + +include { BCFTOOLS_ROH } from '../../../../modules/bcftools/roh/main.nf' + +workflow test_bcftools_roh { + + input = [ [ id:'test' ], // meta map + file(params.test_data['sarscov2']['illumina']['test_vcf_gz'], checkIfExists: true), + file(params.test_data['sarscov2']['illumina']['test_vcf_gz_tbi'], checkIfExists: true)] + + af_file = [] + gen_map = [] + regions = [] + targets = [] + samples = [] + + BCFTOOLS_ROH ( input, af_file, gen_map, regions, samples, targets ) +} + +workflow test_bcftools_roh_stub { + + input = [ [ id:'test' ], // meta map + file(params.test_data['sarscov2']['illumina']['test_vcf_gz'], checkIfExists: true), + file(params.test_data['sarscov2']['illumina']['test_vcf_gz_tbi'], checkIfExists: true)] + + af_file = [] + gen_map = [] + regions = [] + targets = [] + samples = [] + + BCFTOOLS_ROH ( input, af_file, gen_map, regions, samples, targets ) +} diff --git a/tests/modules/bcftools/roh/nextflow.config b/tests/modules/bcftools/roh/nextflow.config new file mode 100644 index 00000000..8730f1c4 --- /dev/null +++ b/tests/modules/bcftools/roh/nextflow.config @@ -0,0 +1,5 @@ +process { + + publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } + +} diff --git a/tests/modules/bcftools/roh/test.yml b/tests/modules/bcftools/roh/test.yml new file mode 100644 index 00000000..9cc50a66 --- /dev/null +++ b/tests/modules/bcftools/roh/test.yml @@ -0,0 +1,17 @@ +- name: "bcftools roh" + command: nextflow run ./tests/modules/bcftools/roh -entry test_bcftools_roh -c ./tests/config/nextflow.config -c ./tests/modules/bcftools/roh/nextflow.config + tags: + - "bcftools" + - "bcftools/roh" + files: + - path: "output/bcftools/test.roh" + - path: "output/bcftools/versions.yml" + +- name: "bcftools roh stub" + command: nextflow run ./tests/modules/bcftools/roh -entry test_bcftools_roh_stub -c ./tests/config/nextflow.config -c ./tests/modules/bcftools/roh/nextflow.config + tags: + - "bcftools" + - "bcftools/roh" + files: + - path: "output/bcftools/test.roh" + - path: "output/bcftools/versions.yml"