New module genomicsdbimport (#857)

* saving changes to checkout

* saving to sort out other branch

* removed yml tracking of files that cant be tracked due to directory name changing between runs

* test data added, ready for pr

* fix eol linting error

* Update modules/gatk4/genomicsdbimport/main.nf

Co-authored-by: Francesco L <53608000+lescai@users.noreply.github.com>

* merging with master

* update push to show progress

* tests now working untar able to pass data to genomicsdbimport

* commit to checkout

* tests updated, module reworked to simplify and emit updated gendb

* Apply suggestions from code review

Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com>

* update meta.yml 

Priority of input options changed, updated to reflect this

* Update test.yml

name prefix changed in main script, test.yml updated to reflect this

* fix tests due to review changes

Co-authored-by: GCJMackenzie <gavin.mackenzie@nibsc.org>
Co-authored-by: Francesco L <53608000+lescai@users.noreply.github.com>
Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com>
This commit is contained in:
GCJMackenzie 2021-10-29 17:21:34 +01:00 committed by GitHub
parent 3df4fe6085
commit 7afb962f0b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 342 additions and 0 deletions

View file

@ -0,0 +1,78 @@
//
// 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()
}
//
// Extract name of module from process name using $task.process
//
def getProcessName(task_process) {
return task_process.tokenize(':')[-1]
}
//
// 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) {
def ioptions = initOptions(args.options)
def path_list = [ ioptions.publish_dir ?: args.publish_dir ]
// Do not publish versions.yml unless running from pytest workflow
if (args.filename.equals('versions.yml') && !System.getenv("NF_CORE_MODULES_TEST")) {
return null
}
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,67 @@
// Import generic module functions
include { initOptions; saveFiles; getSoftwareName; getProcessName } from './functions'
params.options = [:]
options = initOptions(params.options)
process GATK4_GENOMICSDBIMPORT {
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(vcf), path(tbi), path(intervalfile), val(intervalval), path(wspace)
val run_intlist
val run_updatewspace
val input_map
output:
tuple val(meta), path("*_genomicsdb") , optional:true, emit: genomicsdb
tuple val(meta), path("$updated_db") , optional:true, emit: updatedb
tuple val(meta), path("*.interval_list"), optional:true, emit: intervallist
path "versions.yml" , emit: versions
script:
def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
// settings for running default create gendb mode
def inputs_command = input_map ? "--sample-name-map ${vcf[0]}" : "${'-V ' + vcf.join(' -V')}"
def dir_command = "--genomicsdb-workspace-path ${prefix}"
def intervals_command = intervalfile ? " -L ${intervalfile} " : " -L ${intervalval} "
// settings changed for running get intervals list mode if run_intlist is true
if (run_intlist) {
inputs_command = ''
dir_command = "--genomicsdb-update-workspace-path ${wspace}"
intervals_command = "--output-interval-list-to-file ${prefix}.interval_list"
}
// settings changed for running update gendb mode. inputs_command same as default, update_db forces module to emit the updated gendb
if (run_updatewspace) {
dir_command = "--genomicsdb-update-workspace-path ${wspace}"
intervals_command = ''
updated_db = wspace.toString()
}
"""
gatk GenomicsDBImport \\
$inputs_command \\
$dir_command \\
$intervals_command \\
$options.args
cat <<-END_VERSIONS > versions.yml
${getProcessName(task.process)}:
${getSoftwareName(task.process)}: \$(echo \$(gatk --version 2>&1) | sed 's/^.*(GATK) v//; s/ .*\$//')
END_VERSIONS
"""
}

View file

@ -0,0 +1,80 @@
name: gatk4_genomicsdbimport
description: merge GVCFs from multiple samples. For use in joint genotyping or somatic panel of normal creation.
keywords:
- gatk4
- genomicsdbimport
- genomicsdb
- panelofnormalscreation
- jointgenotyping
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']
- vcf:
type: list
description: either a list of vcf files to be used to create or update a genomicsdb, or a file that contains a map to vcf files to be used.
pattern: "*.vcf.gz"
- tbi:
type: list
description: list of tbi files that match with the input vcf files
pattern: "*.vcf.gz_tbi"
- wspace:
type: path
description: path to an existing genomicsdb to be used in update db mode or get intervals mode. This WILL NOT specify name of a new genomicsdb in create db mode.
pattern: "/path/to/existing/gendb"
- intervalfile:
type: file
description: file containing the intervals to be used when creating the genomicsdb
pattern: "*.interval_list"
- intervalval:
type: string
description: if an intervals file has not been spcified, the value enetered here will be used as an interval via the "-L" argument
pattern: "example: chr1:1000-10000"
- run_intlist:
type: boolean
description: Specify whether to run get interval list mode, this option cannot be specified at the same time as run_updatewspace.
pattern: "true/false"
- run_updatewspace:
type: boolean
description: Specify whether to run update genomicsdb mode, this option takes priority over run_intlist.
pattern: "true/false"
- input_map:
type: boolean
description: Specify whether the vcf input is providing a list of vcf file(s) or a single file containing a map of paths to vcf files to be used to create or update a genomicsdb.
pattern: "*.sample_map"
output:
- genomicsdb:
type: directory
description: Directory containing the files that compose the genomicsdb workspace, this is only output for create mode, as update changes an existing db
pattern: "*_genomicsdb"
- intervallist:
type: file
description: File containing the intervals used to generate the genomicsdb, only created by get intervals mode.
pattern: "*.interval_list"
- versions:
type: file
description: File containing software versions
pattern: "versions.yml"
authors:
- "@GCJMackenzie"

View file

@ -450,6 +450,10 @@ gatk4/fastqtosam:
- modules/gatk4/fastqtosam/**
- tests/modules/gatk4/fastqtosam/**
gatk4/genomicsdbimport:
- modules/gatk4/genomicsdbimport/**
- tests/modules/gatk4/genomicsdbimport/**
gatk4/filtermutectcalls:
- modules/gatk4/filtermutectcalls/**
- tests/modules/gatk4/filtermutectcalls/**

View file

@ -103,6 +103,7 @@ params {
genome_dict = "${test_data_dir}/genomics/homo_sapiens/genome/genome.dict"
genome_gff3 = "${test_data_dir}/genomics/homo_sapiens/genome/genome.gff3"
genome_gtf = "${test_data_dir}/genomics/homo_sapiens/genome/genome.gtf"
genome_interval_list = "${test_data_dir}/genomics/homo_sapiens/genome/genome.interval_list"
genome_sizes = "${test_data_dir}/genomics/homo_sapiens/genome/genome.sizes"
genome_bed = "${test_data_dir}/genomics/homo_sapiens/genome/genome.bed"
genome_header = "${test_data_dir}/genomics/homo_sapiens/genome/genome.header"
@ -181,6 +182,7 @@ params {
test2_baserecalibrator_table = "${test_data_dir}/genomics/homo_sapiens/illumina/gatk/test2.baserecalibrator.table"
test_pileups_table = "${test_data_dir}/genomics/homo_sapiens/illumina/gatk/test.pileups.table"
test2_pileups_table = "${test_data_dir}/genomics/homo_sapiens/illumina/gatk/test2.pileups.table"
test_genomicsdb_tar_gz = "${test_data_dir}/genomics/homo_sapiens/illumina/gatk/test_genomicsdb.tar.gz"
test_test2_paired_mutect2_calls_vcf_gz = "${test_data_dir}/genomics/homo_sapiens/illumina/gatk/paired_mutect2_calls/test_test2_paired_mutect2_calls.vcf.gz"
test_test2_paired_mutect2_calls_vcf_gz_tbi = "${test_data_dir}/genomics/homo_sapiens/illumina/gatk/paired_mutect2_calls/test_test2_paired_mutect2_calls.vcf.gz.tbi"

View file

@ -0,0 +1,61 @@
#!/usr/bin/env nextflow
nextflow.enable.dsl = 2
include { UNTAR } from '../../../../modules/untar/main.nf' addParams( options: [:] )
include { GATK4_GENOMICSDBIMPORT } from '../../../../modules/gatk4/genomicsdbimport/main.nf' addParams( options: [:] )
workflow test_gatk4_genomicsdbimport_create_genomicsdb {
input = [ [ id:'test_genomicsdb'], // meta map
file(params.test_data['homo_sapiens']['illumina']['test_genome_vcf_gz'], checkIfExists: true) ,
file(params.test_data['homo_sapiens']['illumina']['test_genome_vcf_gz_tbi'], checkIfExists: true) ,
file(params.test_data['homo_sapiens']['genome']['genome_interval_list'], checkIfExists: true) ,
[] ,
[] ]
run_intlist = false
run_updatewspace = false
input_map = false
GATK4_GENOMICSDBIMPORT ( input, run_intlist, run_updatewspace, input_map )
}
workflow test_gatk4_genomicsdbimport_get_intervalslist {
db = file(params.test_data['homo_sapiens']['illumina']['test_genomicsdb_tar_gz'], checkIfExists: true)
UNTAR ( db )
def input = Channel.of([ [ id:'test_genomicsdb'], // meta map
[] ,
[] ,
[] ,
[] ])
.combine(UNTAR.out.untar)
run_intlist = true
run_updatewspace = false
input_map = false
GATK4_GENOMICSDBIMPORT ( input, run_intlist, run_updatewspace, input_map )
}
workflow test_gatk4_genomicsdbimport_update_genomicsdb {
db = file(params.test_data['homo_sapiens']['illumina']['test_genomicsdb_tar_gz'], checkIfExists: true)
UNTAR ( db )
def input = Channel.of([ [ id:'test_genomicsdb'], // meta map
file( params.test_data['homo_sapiens']['illumina']['test2_genome_vcf_gz'] , checkIfExists: true) ,
file( params.test_data['homo_sapiens']['illumina']['test2_genome_vcf_gz_tbi'] , checkIfExists: true) ,
[] ,
[] ])
.combine(UNTAR.out.untar)
run_intlist = false
run_updatewspace = true
input_map = false
GATK4_GENOMICSDBIMPORT ( input, run_intlist, run_updatewspace, input_map )
}

View file

@ -0,0 +1,50 @@
- name: gatk4 genomicsdbimport test_gatk4_genomicsdbimport_create_genomicsdb
command: nextflow run tests/modules/gatk4/genomicsdbimport -entry test_gatk4_genomicsdbimport_create_genomicsdb -c tests/config/nextflow.config
tags:
- gatk4/genomicsdbimport
- gatk4
files:
- path: output/gatk4/test_genomicsdb/__tiledb_workspace.tdb
md5sum: d41d8cd98f00b204e9800998ecf8427e
- path: output/gatk4/test_genomicsdb/callset.json
md5sum: a7d07d1c86449bbb1091ff29368da07a
- path: output/gatk4/test_genomicsdb/chr22$1$40001/.__consolidation_lock
md5sum: d41d8cd98f00b204e9800998ecf8427e
- path: output/gatk4/test_genomicsdb/chr22$1$40001/__array_schema.tdb
- path: output/gatk4/test_genomicsdb/chr22$1$40001/genomicsdb_meta_dir/genomicsdb_column_bounds.json
md5sum: 2502f79658bc000578ebcfddfc1194c0
- path: output/gatk4/test_genomicsdb/vcfheader.vcf
contains:
- "FORMAT=<ID=AD,Number=R,Type=Integer,Description="
- path: output/gatk4/test_genomicsdb/vidmap.json
md5sum: 18d3f68bd2cb6f4474990507ff95017a
- name: gatk4 genomicsdbimport test_gatk4_genomicsdbimport_get_intervalslist
command: nextflow run tests/modules/gatk4/genomicsdbimport -entry test_gatk4_genomicsdbimport_get_intervalslist -c tests/config/nextflow.config
tags:
- gatk4/genomicsdbimport
- gatk4
files:
- path: output/gatk4/test_genomicsdb.interval_list
md5sum: 4c85812ac15fc1cd29711a851d23c0bf
- name: gatk4 genomicsdbimport test_gatk4_genomicsdbimport_update_genomicsdb
command: nextflow run tests/modules/gatk4/genomicsdbimport -entry test_gatk4_genomicsdbimport_update_genomicsdb -c tests/config/nextflow.config
tags:
- gatk4/genomicsdbimport
- gatk4
files:
- path: output/gatk4/test_genomicsdb/__tiledb_workspace.tdb
md5sum: d41d8cd98f00b204e9800998ecf8427e
- path: output/gatk4/test_genomicsdb/callset.json
md5sum: 1ea31b59b9a218dd5681164aff4a5e07
- path: output/gatk4/test_genomicsdb/chr22$1$40001/.__consolidation_lock
md5sum: d41d8cd98f00b204e9800998ecf8427e
- path: output/gatk4/test_genomicsdb/chr22$1$40001/__array_schema.tdb
md5sum: 35e7fdd18149be80c0c3f56fa1f23971
- path: output/gatk4/test_genomicsdb/chr22$1$40001/genomicsdb_meta_dir/genomicsdb_column_bounds.json
md5sum: 2502f79658bc000578ebcfddfc1194c0
- path: output/gatk4/test_genomicsdb/vcfheader.vcf
md5sum: 47a615385a49f9261e088104b903bb9b
- path: output/gatk4/test_genomicsdb/vidmap.json
md5sum: 18d3f68bd2cb6f4474990507ff95017a