From 7d0ddbc8abf45760e92276e6bb377c7b535baa95 Mon Sep 17 00:00:00 2001 From: "James A. Fellows Yates" Date: Fri, 1 Jul 2022 15:06:07 +0200 Subject: [PATCH] Add atlas/call (#1809) * Add atlas/call * Apply suggestions from code review * Update modules/atlas/call/main.nf Co-authored-by: Thiseas C. Lamnidis * Apply suggestions from code review Co-authored-by: Thiseas C. Lamnidis --- modules/atlas/call/main.nf | 52 +++++++++++++++++ modules/atlas/call/meta.yml | 72 ++++++++++++++++++++++++ tests/config/pytest_modules.yml | 4 ++ tests/modules/atlas/call/main.nf | 22 ++++++++ tests/modules/atlas/call/nextflow.config | 5 ++ tests/modules/atlas/call/test.yml | 9 +++ 6 files changed, 164 insertions(+) create mode 100644 modules/atlas/call/main.nf create mode 100644 modules/atlas/call/meta.yml create mode 100644 tests/modules/atlas/call/main.nf create mode 100644 tests/modules/atlas/call/nextflow.config create mode 100644 tests/modules/atlas/call/test.yml diff --git a/modules/atlas/call/main.nf b/modules/atlas/call/main.nf new file mode 100644 index 00000000..b1354505 --- /dev/null +++ b/modules/atlas/call/main.nf @@ -0,0 +1,52 @@ +process ATLAS_CALL { + tag "$meta.id" + label 'process_low' + + conda (params.enable_conda ? "bioconda::atlas=0.9.9" : null) + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/atlas:0.9.9--h082e891_0': + 'quay.io/biocontainers/atlas:0.9.9--h082e891_0' }" + + input: + tuple val(meta), path(bam), path(bai) + path fasta + path fai + path recal + path pmd + path known_alleles + val method + + output: + tuple val(meta), path("*.vcf.gz"), emit: vcf + 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 recal_file = recal ? "recal=${recal}" : "" + def pmd_file = pmd ? "pmdFile=${pmd}" : "" + def known_alleles_file = known_alleles ? "pmdFile=${known_alleles}" : "" + + def valid_method = ['MLE', 'Bayesian', 'allelePresence', 'randomBase', 'majorityBase'] + if ( !valid_method.contains(method) ) { error "Unrecognised calling method for ATLAS_CALL. Options: MLE, Bayesian, allelePresence, randomBase, majorityBase" } + + """ + atlas \\ + task=call \\ + bam=${bam} \\ + fasta=${fasta} \\ + $recal_file \\ + $pmd_file \\ + method=${method} \\ + $args + + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + atlas: \$((atlas 2>&1) | grep Atlas | head -n 1 | sed -e 's/^[ \t]*Atlas //') + END_VERSIONS + """ +} diff --git a/modules/atlas/call/meta.yml b/modules/atlas/call/meta.yml new file mode 100644 index 00000000..fd6e7436 --- /dev/null +++ b/modules/atlas/call/meta.yml @@ -0,0 +1,72 @@ +name: "atlas_call" +description: generate VCF file from a BAM file using various calling methods +keywords: + - atlas + - variant calling + - vcf + - population genetics +tools: + - "atlas": + description: "ATLAS, a suite of methods to accurately genotype and estimate genetic diversity" + homepage: "https://bitbucket.org/wegmannlab/atlas/wiki/Home" + documentation: "https://bitbucket.org/wegmannlab/atlas/wiki/Home" + tool_dev_url: "https://bitbucket.org/wegmannlab/atlas" + doi: "10.1101/105346" + licence: "['GPL v3']" + +input: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + - bam: + type: file + description: A BAM/ file + pattern: "*.bam" + - bai: + type: file + description: The BAI file for the input BAM file + pattern: "*.bai" + - fasta: + type: file + description: The reference FASTA file used to generate the BAM file + pattern: "*.{fasta,fna,fa}" + - fai: + type: file + description: The index of the FASTA file used for to generate the BAM file + pattern: "*.fai" + - recal: + type: file + description: Optional recalibration file from atlas recal function in text format + pattern: "*.txt" + - pmd: + type: file + description: Optional PMD file from atlas pmd function in text format + pattern: "*.txt" + - known_alleles: + type: file + description: Optional tab separated text file containing 1-based list of known alleles. See atlas call documentation. + pattern: "*.{txt.tsv}" + - method: + type: character + description: Which variant calling algorithm to use. Some may require additional parameters supplied via ext.args. Check atlas documentation. + pattern: "MLE|Bayesian|allelePresence|randomBase|majorityBase" + +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" + - bam: + type: file + description: VCF file with variant calls + pattern: "*.vcf.gz" + +authors: + - "@jfy133" diff --git a/tests/config/pytest_modules.yml b/tests/config/pytest_modules.yml index f7e49c83..c4d71736 100644 --- a/tests/config/pytest_modules.yml +++ b/tests/config/pytest_modules.yml @@ -86,6 +86,10 @@ ataqv/ataqv: - modules/ataqv/ataqv/** - tests/modules/ataqv/ataqv/** +atlas/call: + - modules/atlas/call/** + - tests/modules/atlas/call/** + atlas/pmd: - modules/atlas/pmd/** - tests/modules/atlas/pmd/** diff --git a/tests/modules/atlas/call/main.nf b/tests/modules/atlas/call/main.nf new file mode 100644 index 00000000..945812ef --- /dev/null +++ b/tests/modules/atlas/call/main.nf @@ -0,0 +1,22 @@ +#!/usr/bin/env nextflow + +nextflow.enable.dsl = 2 + +include { ATLAS_CALL } from '../../../../modules/atlas/call/main.nf' + +workflow test_atlas_call { + + input = [ + [ id:'test', single_end:false ], // meta map + file(params.test_data['sarscov2']['illumina']['test_paired_end_sorted_bam'], checkIfExists: true), + file(params.test_data['sarscov2']['illumina']['test_paired_end_sorted_bam_bai'], checkIfExists: true) + ] + fasta = file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true) + fai = file(params.test_data['sarscov2']['genome']['genome_fasta_fai'], checkIfExists: true) + recal = [] + pmd = [] + known_alleles = [] + method = 'randomBase' + + ATLAS_CALL ( input, fasta, fai, recal, pmd, known_alleles, method ) +} diff --git a/tests/modules/atlas/call/nextflow.config b/tests/modules/atlas/call/nextflow.config new file mode 100644 index 00000000..50f50a7a --- /dev/null +++ b/tests/modules/atlas/call/nextflow.config @@ -0,0 +1,5 @@ +process { + + publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } + +} \ No newline at end of file diff --git a/tests/modules/atlas/call/test.yml b/tests/modules/atlas/call/test.yml new file mode 100644 index 00000000..b3e13951 --- /dev/null +++ b/tests/modules/atlas/call/test.yml @@ -0,0 +1,9 @@ +- name: atlas call test_atlas_call + command: nextflow run ./tests/modules/atlas/call -entry test_atlas_call -c ./tests/config/nextflow.config -c ./tests/modules/atlas/call/nextflow.config + tags: + - atlas + - atlas/call + files: + - path: output/atlas/test.paired_end.sorted_randomBase.vcf.gz + contains: + - "##source=atlas"