mirror of
https://github.com/MillironX/nf-core_modules.git
synced 2024-12-22 02:58:17 +00:00
gatk4 markduplicates (#356)
* new module gatk4/markduplicates * add tests * add gatk4_markduplicates entry in pytest_software.yml * Update software/gatk4/markduplicates/main.nf Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com> * Update software/gatk4/markduplicates/main.nf Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com> * Update software/gatk4/markduplicates/main.nf Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com> * Update software/gatk4/markduplicates/main.nf Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com> * Update tests/software/gatk4/markduplicates/main.nf Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com> * Update tests/software/gatk4/markduplicates/main.nf Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com> * Apply suggestions from code review * Fix EC lint * Update md5sum Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com>
This commit is contained in:
parent
989fb7d5b7
commit
e50a525715
6 changed files with 178 additions and 1 deletions
60
software/gatk4/markduplicates/functions.nf
Normal file
60
software/gatk4/markduplicates/functions.nf
Normal file
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* -----------------------------------------------------
|
||||
* 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_id = args.publish_by_id ?: false
|
||||
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_id) {
|
||||
path_list.add(args.publish_id)
|
||||
}
|
||||
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"
|
||||
}
|
||||
}
|
||||
}
|
44
software/gatk4/markduplicates/main.nf
Normal file
44
software/gatk4/markduplicates/main.nf
Normal file
|
@ -0,0 +1,44 @@
|
|||
// Import generic module functions
|
||||
include { initOptions; saveFiles; getSoftwareName } from './functions'
|
||||
|
||||
params.options = [:]
|
||||
options = initOptions(params.options)
|
||||
|
||||
process GATK4_MARKDUPLICATES {
|
||||
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), publish_id: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)
|
||||
|
||||
output:
|
||||
tuple val(meta), path("*.bam") , emit: bam
|
||||
tuple val(meta), path("*.metrics"), emit: metrics
|
||||
path "*.version.txt" , emit: version
|
||||
|
||||
script:
|
||||
def software = getSoftwareName(task.process)
|
||||
def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
|
||||
"""
|
||||
gatk MarkDuplicates \\
|
||||
--INPUT $bam \\
|
||||
--METRICS_FILE ${prefix}.metrics \\
|
||||
--TMP_DIR . \\
|
||||
--ASSUME_SORT_ORDER coordinate \\
|
||||
--CREATE_INDEX true \\
|
||||
--OUTPUT ${prefix}.bam \\
|
||||
$options.args
|
||||
|
||||
gatk --version | grep Picard | sed "s/Picard Version: //g" > ${software}.version.txt
|
||||
"""
|
||||
}
|
49
software/gatk4/markduplicates/meta.yml
Normal file
49
software/gatk4/markduplicates/meta.yml
Normal file
|
@ -0,0 +1,49 @@
|
|||
name: gatk4_markduplicates
|
||||
description: This tool locates and tags duplicate reads in a BAM or SAM file, where duplicate reads are defined as originating from a single fragment of DNA.
|
||||
keywords:
|
||||
- markduplicates
|
||||
- bam
|
||||
- sort
|
||||
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/articles/360037052812-MarkDuplicates-Picard-
|
||||
tool_dev_url: https://github.com/broadinstitute/gatk
|
||||
doi: 10.1158/1538-7445.AM2017-3590
|
||||
licence: ['BSD-3-clause']
|
||||
|
||||
input:
|
||||
- meta:
|
||||
type: map
|
||||
description: |
|
||||
Groovy Map containing sample information
|
||||
e.g. [ id:'test', single_end:false ]
|
||||
- bam:
|
||||
type: file
|
||||
description: Sorted BAM file
|
||||
pattern: "*.{bam}"
|
||||
|
||||
output:
|
||||
- meta:
|
||||
type: map
|
||||
description: |
|
||||
Groovy Map containing sample information
|
||||
e.g. [ id:'test', single_end:false ]
|
||||
- version:
|
||||
type: file
|
||||
description: File containing software version
|
||||
pattern: "*.{version.txt}"
|
||||
- bam:
|
||||
type: file
|
||||
description: Marked duplicates BAM file
|
||||
pattern: "*.{bam}"
|
||||
- metrics:
|
||||
type: file
|
||||
description: Duplicate metrics file generated by GATK
|
||||
pattern: "*.{metrics.txt}"
|
||||
|
||||
authors:
|
||||
- "@ajodeh-juma"
|
5
tests/config/pytest_software.yml
Executable file → Normal file
5
tests/config/pytest_software.yml
Executable file → Normal file
|
@ -198,6 +198,9 @@ gatk4_createsequencedictionary:
|
|||
- software/gatk4/createsequencedictionary/**
|
||||
- tests/software/gatk4/createsequencedictionary/**
|
||||
|
||||
gatk4_markduplicates:
|
||||
- software/gatk4/markduplicates/**
|
||||
- tests/software/gatk4/markduplicates/**
|
||||
gatk4_fastqtosam:
|
||||
- software/gatk4/fastqtosam/**
|
||||
- tests/software/gatk4/fastqtosam/**
|
||||
|
@ -252,7 +255,7 @@ hisat2_build:
|
|||
hisat2_extractsplicesites:
|
||||
- software/hisat2/extractsplicesites/**
|
||||
- tests/software/hisat2/extractsplicesites/**
|
||||
|
||||
|
||||
homer_annotatepeaks:
|
||||
- software/homer/annotatepeaks/**
|
||||
- tests/software/homer/annotatepeaks/**
|
||||
|
|
13
tests/software/gatk4/markduplicates/main.nf
Normal file
13
tests/software/gatk4/markduplicates/main.nf
Normal file
|
@ -0,0 +1,13 @@
|
|||
#!/usr/bin/env nextflow
|
||||
|
||||
nextflow.enable.dsl = 2
|
||||
|
||||
include { GATK4_MARKDUPLICATES } from '../../../../software/gatk4/markduplicates/main.nf' addParams( options: [:] )
|
||||
|
||||
workflow test_gatk4_markduplicates {
|
||||
input = [ [ id:'test', single_end:false ], // meta map
|
||||
file(params.test_data['sarscov2']['illumina']['test_paired_end_sorted_bam'], checkIfExists: true)
|
||||
]
|
||||
|
||||
GATK4_MARKDUPLICATES ( input )
|
||||
}
|
8
tests/software/gatk4/markduplicates/test.yml
Normal file
8
tests/software/gatk4/markduplicates/test.yml
Normal file
|
@ -0,0 +1,8 @@
|
|||
- name: gatk4 markduplicates test_gatk4_markduplicates
|
||||
command: nextflow run tests/software/gatk4/markduplicates -entry test_gatk4_markduplicates -c tests/config/nextflow.config
|
||||
tags:
|
||||
- gatk4
|
||||
- gatk4_markduplicates
|
||||
files:
|
||||
- path: output/gatk4/test.bam
|
||||
md5sum: b58d47345e3ce5825c0641c9d6e6cb7a
|
Loading…
Reference in a new issue