Learnreadorientationmodel (#794)

* files for learnreadorientationmodel initialised for first commit

* finished scripts and yml files. test working locally but needs an f1r2 test data on nf-core before it can be submitted

* updated test data location

* versions file updated, test data added

* updated versions file, edited test file

* small formatting update to main.nf

* Update main.nf

* Update test_data.config

* updated tests main.nf

* Update test_data.config

* Apply suggestions from code review

* Update modules/gatk4/learnreadorientationmodel/main.nf

* Update modules/gatk4/learnreadorientationmodel/meta.yml

* fixed tests failing

Co-authored-by: GCJMackenzie <gavin.mackenzie@nibsc.org>
Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com>
This commit is contained in:
GCJMackenzie 2021-10-07 13:55:06 +01:00 committed by GitHub
parent 5a49d2c1bf
commit f479d4fb8d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 195 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,44 @@
// Import generic module functions
include { initOptions; saveFiles; getSoftwareName; getProcessName } from './functions'
params.options = [:]
options = initOptions(params.options)
process GATK4_LEARNREADORIENTATIONMODEL {
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(f1r2)
output:
tuple val(meta), path("*.tar.gz"), emit: artifactprior
path "versions.yml" , emit: versions
script:
def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
def inputs_list = []
f1r2.each() { a -> inputs_list.add(" -I " + a) }
"""
gatk \\
LearnReadOrientationModel \\
${inputs_list.join(' ')} \\
-O ${prefix}.tar.gz \\
$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,41 @@
name: gatk4_learnreadorientationmodel
description: |
Uses f1r2 counts collected during mutect2 to Learn the prior probability of read orientation artifacts
keywords:
- gatk4
- learnreadorientationmodel
- readorientationartifacts
- mutect2
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' ]
- f1r2:
type: list
description: list of f1r2 files to be used as input.
pattern: "*.f1r2.tar.gz"
output:
- artifactprior:
type: file
description: file containing artifact-priors to be used by filtermutectcalls
pattern: "*.tar.gz"
- versions:
type: file
description: File containing software versions
pattern: "versions.yml"
authors:
- "@GCJMackenzie"

View file

@ -410,6 +410,10 @@ gatk4/intervallisttools:
- modules/gatk4/intervallisttools/**
- tests/modules/gatk4/intervallisttools/**
gatk4/learnreadorientationmodel:
- modules/gatk4/learnreadorientationmodel/**
- tests/modules/gatk4/learnreadorientationmodel/**
gatk4/markduplicates:
- modules/gatk4/markduplicates/**
- tests/modules/gatk4/markduplicates/**

View file

@ -155,6 +155,14 @@ 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_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"
test_test2_paired_mutect2_calls_vcf_gz_stats = "${test_data_dir}/genomics/homo_sapiens/illumina/gatk/paired_mutect2_calls/test_test2_paired_mutect2_calls.vcf.gz.stats"
test_test2_paired_mutect2_calls_f1r2_tar_gz = "${test_data_dir}/genomics/homo_sapiens/illumina/gatk/paired_mutect2_calls/test_test2_paired_mutect2_calls.f1r2.tar.gz"
test_test2_paired_mutect2_calls_artifact_prior_tar_gz = "${test_data_dir}/genomics/homo_sapiens/illumina/gatk/test_test2_paired_mutect2_calls.artifact-prior.tar.gz"
test_test2_paired_segmentation_table = "${test_data_dir}/genomics/homo_sapiens/illumina/gatk/test_test2_paired.segmentation.table"
test_test2_paired_contamination_table = "${test_data_dir}/genomics/homo_sapiens/illumina/gatk/test_test2_paired.contamination.table"
test_genome_vcf = "${test_data_dir}/genomics/homo_sapiens/illumina/gvcf/test.genome.vcf"
test_genome_vcf_gz = "${test_data_dir}/genomics/homo_sapiens/illumina/gvcf/test.genome.vcf.gz"

View file

@ -0,0 +1,13 @@
#!/usr/bin/env nextflow
nextflow.enable.dsl = 2
include { GATK4_LEARNREADORIENTATIONMODEL } from '../../../../modules/gatk4/learnreadorientationmodel/main.nf' addParams( options: [suffix:'.artifact-prior'] )
workflow test_gatk4_learnreadorientationmodel {
input = [ [ id:'test' ], // meta map
[file(params.test_data['homo_sapiens']['illumina']['test_test2_paired_mutect2_calls_f1r2_tar_gz'], checkIfExists: true)] ]
GATK4_LEARNREADORIENTATIONMODEL ( input )
}

View file

@ -0,0 +1,7 @@
- name: gatk4 learnreadorientationmodel test_gatk4_learnreadorientationmodel
command: nextflow run tests/modules/gatk4/learnreadorientationmodel -entry test_gatk4_learnreadorientationmodel -c tests/config/nextflow.config
tags:
- gatk4
- gatk4/learnreadorientationmodel
files:
- path: output/gatk4/test.artifact-prior.tar.gz