Add strelka/somatic module (#866)

* Add strelka/somatic module

* Fill out meta.yml properly
This commit is contained in:
Harshil Patel 2021-10-18 22:34:23 +01:00 committed by GitHub
parent cbfc8eb46c
commit 4e9e732b76
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 265 additions and 4 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,59 @@
// Import generic module functions
include { initOptions; saveFiles; getSoftwareName; getProcessName } from './functions'
params.options = [:]
options = initOptions(params.options)
process STRELKA_SOMATIC {
tag "$meta.id"
label 'process_high'
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::strelka=2.9.10" : null)
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
container "https://depot.galaxyproject.org/singularity/strelka:2.9.10--h9ee0642_1"
} else {
container "quay.io/biocontainers/strelka:2.9.10--h9ee0642_1"
}
input:
tuple val(meta), path(cram_normal), path(crai_normal), path(cram_tumor), path(crai_tumor)
path fasta
path fai
path target_bed
path target_bed_tbi
output:
tuple val(meta), path("*.somatic_indels.vcf.gz") , emit: vcf_indels
tuple val(meta), path("*.somatic_indels.vcf.gz.tbi"), emit: vcf_indels_tbi
tuple val(meta), path("*.somatic_snvs.vcf.gz") , emit: vcf_snvs
tuple val(meta), path("*.somatic_snvs.vcf.gz.tbi") , emit: vcf_snvs_tbi
path "versions.yml" , emit: versions
script:
def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
def options_strelka = params.target_bed ? "--exome --callRegions ${target_bed}" : ""
"""
configureStrelkaSomaticWorkflow.py \\
--tumor $cram_tumor \\
--normal $cram_normal \\
--referenceFasta $fasta \\
$options_strelka \\
$options.args \\
--runDir strelka
python strelka/runWorkflow.py -m local -j $task.cpus
mv strelka/results/variants/somatic.indels.vcf.gz ${prefix}.somatic_indels.vcf.gz
mv strelka/results/variants/somatic.indels.vcf.gz.tbi ${prefix}.somatic_indels.vcf.gz.tbi
mv strelka/results/variants/somatic.snvs.vcf.gz ${prefix}.somatic_snvs.vcf.gz
mv strelka/results/variants/somatic.snvs.vcf.gz.tbi ${prefix}.somatic_snvs.vcf.gz.tbi
cat <<-END_VERSIONS > versions.yml
${getProcessName(task.process)}:
${getSoftwareName(task.process)}: \$( configureStrelkaSomaticWorkflow.py --version )
END_VERSIONS
"""
}

View file

@ -0,0 +1,85 @@
name: strelka_somatic
description: Strelka2 is a fast and accurate small variant caller optimized for analysis of germline variation in small cohorts and somatic variation in tumor/normal sample pairs
keywords:
- variant calling
- germline
- wgs
- vcf
- variants
tools:
- strelka:
description: Strelka calls somatic and germline small variants from mapped sequencing reads
homepage: https://github.com/Illumina/strelka
documentation: https://github.com/Illumina/strelka/blob/v2.9.x/docs/userGuide/README.md
tool_dev_url: https://github.com/Illumina/strelka
doi: 10.1038/s41592-018-0051-x
licence: ['GPL v3']
input:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- cram_normal:
type: file
description: BAM/CRAM/SAM file
pattern: "*.{bam,cram,sam}"
- crai_normal:
type: file
description: BAM/CRAM/SAM index file
pattern: "*.{bai,crai,sai}"
- cram_tumor:
type: file
description: BAM/CRAM/SAM file
pattern: "*.{bam,cram,sam}"
- crai_tumor:
type: file
description: BAM/CRAM/SAM index file
pattern: "*.{bai,crai,sai}"
- fasta:
type: file
description: Genome reference FASTA file
pattern: "*.{fa,fasta}"
- fai:
type: file
description: Genome reference FASTA index file
pattern: "*.{fa.fai,fasta.fai}"
- target_bed:
type: file
description: BED file containing target regions for variant calling
pattern: "*.{bed}"
- target_bed_tbi:
type: file
description: Index for BED file containing target regions for variant calling
pattern: "*.{bed.tbi}"
output:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- vcf_indels:
type: file
description: Gzipped VCF file containing variants
pattern: "*.{vcf.gz}"
- vcf_indels_tbi:
type: file
description: Index for gzipped VCF file containing variants
pattern: "*.{vcf.gz.tbi}"
- vcf_snvs:
type: file
description: Gzipped VCF file containing variants
pattern: "*.{vcf.gz}"
- vcf_snvs_tbi:
type: file
description: Index for gzipped VCF file containing variants
pattern: "*.{vcf.gz.tbi}"
- versions:
type: file
description: File containing software versions
pattern: "versions.yml"
authors:
- "@drpatelh"

View file

@ -991,14 +991,14 @@ spatyper:
- modules/spatyper/**
- tests/modules/spatyper/**
sratools/prefetch:
- modules/sratools/prefetch/**
- tests/modules/sratools/prefetch/**
sratools/fasterqdump:
- modules/sratools/fasterqdump/**
- tests/modules/sratools/fasterqdump/**
sratools/prefetch:
- modules/sratools/prefetch/**
- tests/modules/sratools/prefetch/**
staphopiasccmec:
- modules/staphopiasccmec/**
- tests/modules/staphopiasccmec/**
@ -1015,6 +1015,10 @@ strelka/germline:
- modules/strelka/germline/**
- tests/modules/strelka/germline/**
strelka/somatic:
- modules/strelka/somatic/**
- tests/modules/strelka/somatic/**
stringtie/merge:
- modules/stringtie/merge/**
- tests/modules/stringtie/merge/**

View file

@ -0,0 +1,23 @@
#!/usr/bin/env nextflow
nextflow.enable.dsl = 2
include { STRELKA_SOMATIC } from '../../../../modules/strelka/somatic/main.nf' addParams( options: [:] )
workflow test_strelka_somatic {
input = [
[ id:'test', single_end:false ], // meta map
file(params.test_data['homo_sapiens']['illumina']['test_paired_end_recalibrated_sorted_cram'], checkIfExists: true),
file(params.test_data['homo_sapiens']['illumina']['test_paired_end_recalibrated_sorted_cram_crai'], checkIfExists: true),
file(params.test_data['homo_sapiens']['illumina']['test2_paired_end_recalibrated_sorted_cram'], checkIfExists: true),
file(params.test_data['homo_sapiens']['illumina']['test2_paired_end_recalibrated_sorted_cram_crai'], checkIfExists: true)
]
fasta = file(params.test_data['homo_sapiens']['genome']['genome_fasta'], checkIfExists: true)
fai = file(params.test_data['homo_sapiens']['genome']['genome_fasta_fai'], checkIfExists: true)
bed = file(params.test_data['homo_sapiens']['genome']['genome_bed_gz'], checkIfExists: true)
bed_tbi = file(params.test_data['homo_sapiens']['genome']['genome_bed_gz_tbi'], checkIfExists: true)
STRELKA_SOMATIC ( input, fasta, fai, bed, bed_tbi )
}

View file

@ -0,0 +1,12 @@
- name: strelka somatic test_strelka_somatic
command: nextflow run tests/modules/strelka/somatic -entry test_strelka_somatic -c tests/config/nextflow.config
tags:
- strelka
- strelka/somatic
files:
- path: output/strelka/test.somatic_indels.vcf.gz
- path: output/strelka/test.somatic_indels.vcf.gz.tbi
md5sum: 4cb176febbc8c26d717a6c6e67b9c905
- path: output/strelka/test.somatic_snvs.vcf.gz
- path: output/strelka/test.somatic_snvs.vcf.gz.tbi
md5sum: 4cb176febbc8c26d717a6c6e67b9c905