mirror of
https://github.com/MillironX/nf-core_modules.git
synced 2024-12-22 11:08:17 +00:00
Mutect2 (#682)
* mutect2 files added, first draft of module code entered * removing comment from main.nf * removing comment from main.nf * test added, commit made before editing yaml * tests added, still needs final check and info/comments added * gatk4 version changed to gatk4=4.2.0.0 * multiple sample support added, information added to module yaml file * Update meta.yml fixed linting error * add keywords to meta.yml * Corrections made to meta.yml * removed whitespace from meta.yml Co-authored-by: Gavin.Mackenzie <gavin.mackenzie@nibsc.org> Co-authored-by: Maxime U. Garcia <max.u.garcia@gmail.com>
This commit is contained in:
parent
1023a98b51
commit
bd68797ffb
6 changed files with 326 additions and 0 deletions
68
modules/gatk4/mutect2/functions.nf
Normal file
68
modules/gatk4/mutect2/functions.nf
Normal 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"
|
||||
}
|
||||
}
|
||||
}
|
76
modules/gatk4/mutect2/main.nf
Normal file
76
modules/gatk4/mutect2/main.nf
Normal file
|
@ -0,0 +1,76 @@
|
|||
// Import generic module functions
|
||||
include { initOptions; saveFiles; getSoftwareName } from './functions'
|
||||
|
||||
params.options = [:]
|
||||
options = initOptions(params.options)
|
||||
|
||||
process GATK4_MUTECT2 {
|
||||
tag "$meta.id"
|
||||
label 'process_medium'
|
||||
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) , val(which_norm)
|
||||
val run_single
|
||||
val run_pon
|
||||
path fasta
|
||||
path fastaidx
|
||||
path dict
|
||||
path germline_resource
|
||||
path germline_resource_idx
|
||||
path panel_of_normals
|
||||
path panel_of_normals_idx
|
||||
|
||||
output:
|
||||
tuple val(meta), path("*.vcf.gz"), emit: vcf
|
||||
tuple val(meta), path("*.tbi") , emit: tbi
|
||||
tuple val(meta), path("*.f1r2.tar.gz"), optional:true, emit: f1r2
|
||||
path "*.version.txt" , emit: version
|
||||
|
||||
script:
|
||||
def software = getSoftwareName(task.process)
|
||||
def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
|
||||
def inputsList = []
|
||||
def normalsList = []
|
||||
def inputsCommand = ''
|
||||
def panelsCommand = ''
|
||||
def normalsCommand = ''
|
||||
|
||||
bam.each() {a -> inputsList.add(" -I " + a ) }
|
||||
inputsCommand = inputsList.join( ' ')
|
||||
|
||||
if(run_pon) {
|
||||
panelsCommand = ''
|
||||
normalsCommand = ''
|
||||
|
||||
} else if(run_single) {
|
||||
panelsCommand = " --germline-resource $germline_resource --panel-of-normals $panel_of_normals"
|
||||
normalsCommand = ''
|
||||
|
||||
} else {
|
||||
panelsCommand = " --germline-resource $germline_resource --panel-of-normals $panel_of_normals --f1r2-tar-gz ${prefix}.f1r2.tar.gz"
|
||||
which_norm.each() {a -> normalsList.add(" -normal " + a ) }
|
||||
normalsCommand = normalsList.join( ' ')
|
||||
}
|
||||
|
||||
"""
|
||||
gatk Mutect2 \\
|
||||
-R ${fasta} \\
|
||||
${inputsCommand} \\
|
||||
${normalsCommand} \\
|
||||
${panelsCommand} \\
|
||||
-O ${prefix}.vcf.gz \\
|
||||
$options.args
|
||||
|
||||
echo \$(gatk --version 2>&1) | sed 's/^.*(GATK) v//; s/ .*\$//' > ${software}.version.txt
|
||||
"""
|
||||
}
|
89
modules/gatk4/mutect2/meta.yml
Normal file
89
modules/gatk4/mutect2/meta.yml
Normal file
|
@ -0,0 +1,89 @@
|
|||
name: gatk4_mutect2
|
||||
description: Call somatic SNVs and indels via local assembly of haplotypes.
|
||||
keywords:
|
||||
- gatk4
|
||||
- mutect2
|
||||
- haplotype
|
||||
- somatic
|
||||
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: list
|
||||
description: list of BAM files
|
||||
pattern: "*.bam"
|
||||
- bai:
|
||||
type: list
|
||||
description: list of BAM file indexes
|
||||
pattern: "*.bam.bai"
|
||||
- which_norm:
|
||||
type: list
|
||||
description: optional list of sample headers contained in the normal sample bam files (these are required for tumor_normal_pair mode)
|
||||
- run_single:
|
||||
type: boolean
|
||||
description: Specify whether or not to run in tumor_single mode instead of tumor_normal_pair mode (will be ignored if run_pon is also true)
|
||||
- run_pon:
|
||||
type: boolean
|
||||
description: Specify whether or not to run in panel_of_normal mode instead of tumor_normal_pair mode
|
||||
- fasta:
|
||||
type: file
|
||||
description: The reference fasta file
|
||||
pattern: "*.fasta"
|
||||
- fastaidx:
|
||||
type: file
|
||||
description: Index of reference fasta file
|
||||
pattern: "fasta.fai"
|
||||
- dict:
|
||||
type: file
|
||||
description: GATK sequence dictionary
|
||||
pattern: "*.dict"
|
||||
- germline_resource:
|
||||
type: file
|
||||
description: Population vcf of germline sequencing, containing allele fractions.
|
||||
pattern: "*.vcf.gz"
|
||||
- germline_resource_idx:
|
||||
type: file
|
||||
description: Index file for the germline resource.
|
||||
pattern: "*.vcf.gz_tbi"
|
||||
- panel_of_normals:
|
||||
type: file
|
||||
description: vcf file to be used as a panel of normals.
|
||||
pattern: "*.vcf.gz"
|
||||
- panel_of_normals_idx:
|
||||
type: file
|
||||
description: Index for the panel of normals.
|
||||
pattern: "*.vcf.gz_tbi"
|
||||
|
||||
output:
|
||||
- vcf:
|
||||
type: file
|
||||
description: compressed vcf file
|
||||
pattern: "*.vcf.gz"
|
||||
- tbi:
|
||||
type: file
|
||||
description: Index of vcf file
|
||||
pattern: "*vcf.gz.tbi"
|
||||
- f1r2:
|
||||
type: file
|
||||
description: file containing information to be passed to LearnReadOrientationModel (only outputted when tumor_normal_pair mode is run)
|
||||
pattern: "*.f1r2.tar.gz"
|
||||
- version:
|
||||
type: file
|
||||
description: File containing software version
|
||||
pattern: "*.version.txt"
|
||||
|
||||
authors:
|
||||
- "@GCJMackenzie"
|
|
@ -358,6 +358,10 @@ gatk4/mergevcfs:
|
|||
- modules/gatk4/mergevcfs/**
|
||||
- tests/modules/gatk4/mergevcfs/**
|
||||
|
||||
gatk4/mutect2:
|
||||
- modules/gatk4/mutect2/**
|
||||
- tests/modules/gatk4/mutect2/**
|
||||
|
||||
gatk4/revertsam:
|
||||
- modules/gatk4/revertsam/**
|
||||
- tests/modules/gatk4/revertsam/**
|
||||
|
|
62
tests/modules/gatk4/mutect2/main.nf
Normal file
62
tests/modules/gatk4/mutect2/main.nf
Normal file
|
@ -0,0 +1,62 @@
|
|||
#!/usr/bin/env nextflow
|
||||
|
||||
nextflow.enable.dsl = 2
|
||||
|
||||
include { GATK4_MUTECT2 } from '../../../../modules/gatk4/mutect2/main.nf' addParams( options: [:] )
|
||||
|
||||
workflow test_gatk4_mutect2_tumor_normal_pair {
|
||||
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']['test2_paired_end_recalibrated_sorted_bam'], checkIfExists: true)],
|
||||
[ file(params.test_data['homo_sapiens']['illumina']['test_paired_end_recalibrated_sorted_bam_bai'], checkIfExists: true) , file(params.test_data['homo_sapiens']['illumina']['test2_paired_end_recalibrated_sorted_bam_bai'], checkIfExists: true)],
|
||||
["testN"]
|
||||
]
|
||||
run_single = false
|
||||
run_pon = false
|
||||
fasta = file(params.test_data['homo_sapiens']['genome']['genome_fasta'], checkIfExists: true)
|
||||
fastaidx = file(params.test_data['homo_sapiens']['genome']['genome_fasta_fai'], checkIfExists: true)
|
||||
dict = file(params.test_data['homo_sapiens']['genome']['genome_dict'], checkIfExists: true)
|
||||
germline_resource = file(params.test_data['homo_sapiens']['genome']['gnomad_r2_1_1_vcf_gz'], checkIfExists: true)
|
||||
germline_resource_idx = file(params.test_data['homo_sapiens']['genome']['gnomad_r2_1_1_vcf_gz_tbi'], checkIfExists: true)
|
||||
panel_of_normals = file(params.test_data['homo_sapiens']['genome']['mills_and_1000g_indels_vcf_gz'], checkIfExists: true)
|
||||
panel_of_normals_idx = file(params.test_data['homo_sapiens']['genome']['mills_and_1000g_indels_vcf_gz_tbi'], checkIfExists: true)
|
||||
|
||||
GATK4_MUTECT2 ( input , run_single , run_pon , fasta , fastaidx , dict , germline_resource, germline_resource_idx , panel_of_normals , panel_of_normals_idx )
|
||||
}
|
||||
|
||||
workflow test_gatk4_mutect2_tumor_single {
|
||||
input = [ [ id:'test'], // meta map
|
||||
[ file(params.test_data['homo_sapiens']['illumina']['test2_paired_end_recalibrated_sorted_bam'], checkIfExists: true)],
|
||||
[ file(params.test_data['homo_sapiens']['illumina']['test2_paired_end_recalibrated_sorted_bam_bai'], checkIfExists: true)],
|
||||
[]
|
||||
]
|
||||
run_single = true
|
||||
run_pon = false
|
||||
fasta = file(params.test_data['homo_sapiens']['genome']['genome_fasta'], checkIfExists: true)
|
||||
fastaidx = file(params.test_data['homo_sapiens']['genome']['genome_fasta_fai'], checkIfExists: true)
|
||||
dict = file(params.test_data['homo_sapiens']['genome']['genome_dict'], checkIfExists: true)
|
||||
germline_resource = file(params.test_data['homo_sapiens']['genome']['gnomad_r2_1_1_vcf_gz'], checkIfExists: true)
|
||||
germline_resource_idx = file(params.test_data['homo_sapiens']['genome']['gnomad_r2_1_1_vcf_gz_tbi'], checkIfExists: true)
|
||||
panel_of_normals = file(params.test_data['homo_sapiens']['genome']['mills_and_1000g_indels_vcf_gz'], checkIfExists: true)
|
||||
panel_of_normals_idx = file(params.test_data['homo_sapiens']['genome']['mills_and_1000g_indels_vcf_gz_tbi'], checkIfExists: true)
|
||||
|
||||
GATK4_MUTECT2 ( input , run_single , run_pon , fasta , fastaidx , dict , germline_resource, germline_resource_idx , panel_of_normals , panel_of_normals_idx )
|
||||
}
|
||||
|
||||
workflow test_gatk4_mutect2_generate_pon {
|
||||
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)],
|
||||
[]
|
||||
]
|
||||
run_single = false
|
||||
run_pon = true
|
||||
fasta = file(params.test_data['homo_sapiens']['genome']['genome_fasta'], checkIfExists: true)
|
||||
fastaidx = file(params.test_data['homo_sapiens']['genome']['genome_fasta_fai'], checkIfExists: true)
|
||||
dict = file(params.test_data['homo_sapiens']['genome']['genome_dict'], checkIfExists: true)
|
||||
germline_resource = []
|
||||
germline_resource_idx = []
|
||||
panel_of_normals = []
|
||||
panel_of_normals_idx = []
|
||||
|
||||
GATK4_MUTECT2 ( input , run_single , run_pon , fasta , fastaidx , dict , germline_resource, germline_resource_idx , panel_of_normals , panel_of_normals_idx )
|
||||
}
|
27
tests/modules/gatk4/mutect2/test.yml
Normal file
27
tests/modules/gatk4/mutect2/test.yml
Normal file
|
@ -0,0 +1,27 @@
|
|||
- name: gatk4 mutect2 test_gatk4_mutect2_tumor_normal_pair
|
||||
command: nextflow run tests/modules/gatk4/mutect2 -entry test_gatk4_mutect2_tumor_normal_pair -c tests/config/nextflow.config
|
||||
tags:
|
||||
- gatk4
|
||||
- gatk4/mutect2
|
||||
files:
|
||||
- path: output/gatk4/test.f1r2.tar.gz
|
||||
- path: output/gatk4/test.vcf.gz
|
||||
- path: output/gatk4/test.vcf.gz.tbi
|
||||
|
||||
- name: gatk4 mutect2 test_gatk4_mutect2_tumor_single
|
||||
command: nextflow run tests/modules/gatk4/mutect2 -entry test_gatk4_mutect2_tumor_single -c tests/config/nextflow.config
|
||||
tags:
|
||||
- gatk4
|
||||
- gatk4/mutect2
|
||||
files:
|
||||
- path: output/gatk4/test.vcf.gz
|
||||
- path: output/gatk4/test.vcf.gz.tbi
|
||||
|
||||
- name: gatk4 mutect2 test_gatk4_mutect2_generate_pon
|
||||
command: nextflow run tests/modules/gatk4/mutect2 -entry test_gatk4_mutect2_generate_pon -c tests/config/nextflow.config
|
||||
tags:
|
||||
- gatk4
|
||||
- gatk4/mutect2
|
||||
files:
|
||||
- path: output/gatk4/test.vcf.gz
|
||||
- path: output/gatk4/test.vcf.gz.tbi
|
Loading…
Reference in a new issue