Getpileupsummaries (#689)

* first commit, added template files for new module

* created getpileupsummaries script, tests and both yml files

* fixed typo in meta.yml

* Update modules/gatk4/getpileupsummaries/meta.yml

changed gz_tbi to gz.tbi as suggested

Co-authored-by: Maxime U. Garcia <maxime.garcia@scilifelab.se>

Co-authored-by: GCJMackenzie <gavin.mackenzie@nibsc.org>
Co-authored-by: Maxime U. Garcia <max.u.garcia@gmail.com>
Co-authored-by: Maxime U. Garcia <maxime.garcia@scilifelab.se>
This commit is contained in:
GCJMackenzie 2021-09-13 16:04:14 +01:00 committed by GitHub
parent c5634ba99b
commit 1023a98b51
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 225 additions and 0 deletions

View file

@ -0,0 +1,68 @@
//
// Utility functions used in nf-core DSL2 module files
//
//
// Extract name of software tool from process name using $task.process
//
def getSoftwareName(task_process) {
return task_process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()
}
//
// Function to initialise default values and to generate a Groovy Map of available options for nf-core modules
//
def initOptions(Map args) {
def Map options = [:]
options.args = args.args ?: ''
options.args2 = args.args2 ?: ''
options.args3 = args.args3 ?: ''
options.publish_by_meta = args.publish_by_meta ?: []
options.publish_dir = args.publish_dir ?: ''
options.publish_files = args.publish_files
options.suffix = args.suffix ?: ''
return options
}
//
// Tidy up and join elements of a list to return a path string
//
def getPathFromList(path_list) {
def paths = path_list.findAll { item -> !item?.trim().isEmpty() } // Remove empty entries
paths = paths.collect { it.trim().replaceAll("^[/]+|[/]+\$", "") } // Trim whitespace and trailing slashes
return paths.join('/')
}
//
// Function to save/publish module results
//
def saveFiles(Map args) {
if (!args.filename.endsWith('.version.txt')) {
def ioptions = initOptions(args.options)
def path_list = [ ioptions.publish_dir ?: args.publish_dir ]
if (ioptions.publish_by_meta) {
def key_list = ioptions.publish_by_meta instanceof List ? ioptions.publish_by_meta : args.publish_by_meta
for (key in key_list) {
if (args.meta && key instanceof String) {
def path = key
if (args.meta.containsKey(key)) {
path = args.meta[key] instanceof Boolean ? "${key}_${args.meta[key]}".toString() : args.meta[key]
}
path = path instanceof String ? path : ''
path_list.add(path)
}
}
}
if (ioptions.publish_files instanceof Map) {
for (ext in ioptions.publish_files) {
if (args.filename.endsWith(ext.key)) {
def ext_list = path_list.collect()
ext_list.add(ext.value)
return "${getPathFromList(ext_list)}/$args.filename"
}
}
} else if (ioptions.publish_files == null) {
return "${getPathFromList(path_list)}/$args.filename"
}
}
}

View file

@ -0,0 +1,48 @@
// Import generic module functions
include { initOptions; saveFiles; getSoftwareName } from './functions'
params.options = [:]
options = initOptions(params.options)
process GATK4_GETPILEUPSUMMARIES {
tag "$meta.id"
label 'process_low'
publishDir "${params.outdir}",
mode: params.publish_dir_mode,
saveAs: { filename -> saveFiles(filename:filename, options:params.options, publish_dir:getSoftwareName(task.process), meta:meta, publish_by_meta:['id']) }
conda (params.enable_conda ? "bioconda::gatk4=4.2.0.0" : null)
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
container "https://depot.galaxyproject.org/singularity/gatk4:4.2.0.0--0"
} else {
container "quay.io/biocontainers/gatk4:4.2.0.0--0"
}
input:
tuple val(meta), path(bam), path(bai)
path variants
path variants_idx
path sites
output:
tuple val(meta), path('*.pileups.table'), emit: table
path '*.version.txt' , emit: version
script:
def software = getSoftwareName(task.process)
def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
def sitesCommand = ''
sitesCommand = sites ? " -L ${sites} " : " -L ${variants} "
"""
gatk GetPileupSummaries \\
-I $bam \\
-V $variants \\
$sitesCommand \\
-O ${prefix}.pileups.table \\
$options.args
echo \$(gatk --version 2>&1) | sed 's/^.*(GATK) v//; s/ .*\$//' > ${software}.version.txt
"""
}

View file

@ -0,0 +1,57 @@
name: gatk4_getpileupsummaries
description: |
Summarizes counts of reads that support reference, alternate and other alleles for given sites. Results can be used with CalculateContamination. Requires a common germline variant sites file, such as from gnomAD.
keywords:
- gatk4
- getpileupsumaries
- readcountssummary
- germlinevariantsites
tools:
- gatk4:
description: |
Developed in the Data Sciences Platform at the Broad Institute, the toolkit offers a wide variety of tools
with a primary focus on variant discovery and genotyping. Its powerful processing engine
and high-performance computing features make it capable of taking on projects of any size.
homepage: https://gatk.broadinstitute.org/hc/en-us
documentation: https://gatk.broadinstitute.org/hc/en-us/categories/360002369672s
doi: 10.1158/1538-7445.AM2017-3590
input:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test' ]
- bam:
type: file
description: BAM file to be summarised.
pattern: "*.bam"
- bai:
type: file
description: BAM file index.
pattern: "*.bam.bai"
- variants:
type: file
description: Population vcf of germline sequencing, containing allele fractions. Is also used as sites file if no separate sites file is specified.
pattern: "*.vcf.gz"
- variants_idx:
type: file
description: Index file for the germline resource.
pattern: "*.vcf.gz.tbi"
- sites:
type: file
description: File containing specified sites to be used for the summary. If this option is not specified, variants file is used instead automatically.
pattern: "*.interval_list"
output:
- pileup:
type: file
description: File containing the pileup summary table.
pattern: "*.pileups.table"
- version:
type: file
description: File containing software version
pattern: "*.version.txt"
authors:
- "@GCJMackenzie"

View file

@ -334,6 +334,10 @@ gatk4/fastqtosam:
- modules/gatk4/fastqtosam/**
- tests/modules/gatk4/fastqtosam/**
gatk4/getpileupsummaries:
- modules/gatk4/getpileupsummaries/**
- tests/modules/gatk4/getpileupsummaries/**
gatk4/haplotypecaller:
- modules/gatk4/haplotypecaller/**
- tests/modules/gatk4/haplotypecaller/**

View file

@ -0,0 +1,31 @@
#!/usr/bin/env nextflow
nextflow.enable.dsl = 2
include { GATK4_GETPILEUPSUMMARIES } from '../../../../modules/gatk4/getpileupsummaries/main.nf' addParams( options: [:] )
workflow test_gatk4_getpileupsummaries_just_variants {
input = [ [ id:'test' ], // meta map
file(params.test_data['homo_sapiens']['illumina']['test_paired_end_recalibrated_sorted_bam'], checkIfExists: true) ,
file(params.test_data['homo_sapiens']['illumina']['test_paired_end_recalibrated_sorted_bam_bai'], checkIfExists: true) ]
variants = file(params.test_data['homo_sapiens']['genome']['gnomad_r2_1_1_vcf_gz'], checkIfExists: true)
variants_idx = file(params.test_data['homo_sapiens']['genome']['gnomad_r2_1_1_vcf_gz_tbi'], checkIfExists: true)
sites = []
GATK4_GETPILEUPSUMMARIES ( input , variants , variants_idx , sites )
}
workflow test_gatk4_getpileupsummaries_separate_sites {
input = [ [ id:'test' ], // meta map
file(params.test_data['homo_sapiens']['illumina']['test_paired_end_recalibrated_sorted_bam'], checkIfExists: true) ,
file(params.test_data['homo_sapiens']['illumina']['test_paired_end_recalibrated_sorted_bam_bai'], checkIfExists: true) ]
variants = file(params.test_data['homo_sapiens']['genome']['gnomad_r2_1_1_vcf_gz'], checkIfExists: true)
variants_idx = file(params.test_data['homo_sapiens']['genome']['gnomad_r2_1_1_vcf_gz_tbi'], checkIfExists: true)
sites = file( "https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/genomics/homo_sapiens/genome/genome.interval_list" , checkIfExists: true)
GATK4_GETPILEUPSUMMARIES ( input , variants , variants_idx , sites )
}

View file

@ -0,0 +1,17 @@
- name: gatk4 getpileupsummaries test_gatk4_getpileupsummaries_just_variants
command: nextflow run tests/modules/gatk4/getpileupsummaries -entry test_gatk4_getpileupsummaries_just_variants -c tests/config/nextflow.config
tags:
- gatk4
- gatk4/getpileupsummaries
files:
- path: output/gatk4/test.pileups.table
md5sum: 00f92a8f7282d6129f1aca04e2c7d968
- name: gatk4 getpileupsummaries test_gatk4_getpileupsummaries_separate_sites
command: nextflow run tests/modules/gatk4/getpileupsummaries -entry test_gatk4_getpileupsummaries_separate_sites -c tests/config/nextflow.config
tags:
- gatk4
- gatk4/getpileupsummaries
files:
- path: output/gatk4/test.pileups.table
md5sum: 00f92a8f7282d6129f1aca04e2c7d968