mirror of
https://github.com/MillironX/nf-core_modules.git
synced 2024-11-13 05:13:09 +00:00
Strelka germline (#340)
* nf-core template created * boilerplate and sarek_dsl2 code merged * adding an option to give it args * bai got away * seperating vcf files and vcf index files into seperate streams * some minor spacefixes * adding standard information about the module * removing typos * some basic tests based on tiddit tests * removed the bed parameter, should be provided via options.args instead * removing typos * adding indexed bam file instead * Adding changing out fasta with reference to deal with empty fasta input * adding the correct fasta * removing the empty test * adding the correct data to the testoutput and removing the md5sum since it constantly changes * adding target_bed to input * adding info on target bed * adding target bed to test * adding more files to the test * adding meta for target bed test * adding a test for target_bed * typo * fixing pytest with master
This commit is contained in:
parent
67b3e00f58
commit
86bb832fae
6 changed files with 236 additions and 0 deletions
60
software/strelka/germline/functions.nf
Normal file
60
software/strelka/germline/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"
|
||||
}
|
||||
}
|
||||
}
|
54
software/strelka/germline/main.nf
Normal file
54
software/strelka/germline/main.nf
Normal file
|
@ -0,0 +1,54 @@
|
|||
// Import generic module functions
|
||||
include { initOptions; saveFiles; getSoftwareName } from './functions'
|
||||
|
||||
params.options = [:]
|
||||
options = initOptions(params.options)
|
||||
|
||||
process STRELKA_GERMLINE {
|
||||
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), publish_id: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--0"
|
||||
} else {
|
||||
container "quay.io/biocontainers/strelka:2.9.10--0"
|
||||
}
|
||||
|
||||
input:
|
||||
tuple val(meta), path(bam), path(bai)
|
||||
path fasta
|
||||
path fai
|
||||
path target_bed
|
||||
|
||||
output:
|
||||
tuple val(meta), path("*_variants.vcf.gz"), emit: vcf
|
||||
tuple val(meta), path("*_variants.vcf.gz.tbi"), emit: vcf_tbi
|
||||
tuple val(meta), path("*_genome.vcf.gz"), emit: genome_vcf
|
||||
tuple val(meta), path("*_genome.vcf.gz.tbi"), emit: genome_vcf_tbi
|
||||
path "*.version.txt", emit: version
|
||||
|
||||
script:
|
||||
def software = getSoftwareName(task.process)
|
||||
def ioptions = initOptions(options)
|
||||
def prefix = ioptions.suffix ? "strelka_${meta.id}${ioptions.suffix}" : "strelka_${meta.id}"
|
||||
|
||||
options_strelka = params.target_bed ? "--exome --callRegions ${target_bed}" : ""
|
||||
"""
|
||||
configureStrelkaGermlineWorkflow.py \
|
||||
--bam ${bam} \
|
||||
--referenceFasta ${fasta} \
|
||||
${options_strelka} \
|
||||
${options.args} \
|
||||
--runDir strelka
|
||||
python strelka/runWorkflow.py -m local -j ${task.cpus}
|
||||
mv strelka/results/variants/genome.*.vcf.gz ${prefix}_genome.vcf.gz
|
||||
mv strelka/results/variants/genome.*.vcf.gz.tbi ${prefix}_genome.vcf.gz.tbi
|
||||
mv strelka/results/variants/variants.vcf.gz ${prefix}_variants.vcf.gz
|
||||
mv strelka/results/variants/variants.vcf.gz.tbi ${prefix}_variants.vcf.gz.tbi
|
||||
echo configureStrelkaGermlineWorkflow.py --version &> ${software}.version.txt #2>&1
|
||||
"""
|
||||
}
|
63
software/strelka/germline/meta.yml
Normal file
63
software/strelka/germline/meta.yml
Normal file
|
@ -0,0 +1,63 @@
|
|||
name: strelka_germline
|
||||
description: Strelka2 is a fast and accurate small variant caller optimized for analysis of germline variation
|
||||
keywords:
|
||||
- variantcalling
|
||||
- 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']
|
||||
- bam:
|
||||
type: file
|
||||
description: BAM file
|
||||
pattern: "*.{bam}"
|
||||
- bai:
|
||||
type: file
|
||||
description: BAM index file
|
||||
pattern: "*.{bai}"
|
||||
- target_bed:
|
||||
type: file
|
||||
description: An optional bed file
|
||||
pattern: "*.{bed}"
|
||||
output:
|
||||
- meta:
|
||||
type: map
|
||||
description: |
|
||||
Groovy Map containing sample information
|
||||
e.g. [ id:'test']
|
||||
- vcf:
|
||||
type: file
|
||||
description: gzipped germline variant file
|
||||
pattern: "*.{vcf.gz}"
|
||||
- vcf_tbi:
|
||||
type: file
|
||||
description: index file for the vcf file
|
||||
pattern: "*.vcf.gz.tbi"
|
||||
- genome_vcf:
|
||||
type: file
|
||||
description: variant records and compressed non-variant blocks
|
||||
pattern: "*_genome.vcf.gz"
|
||||
- genome_vcf_tbi:
|
||||
type: file
|
||||
description: index file for the genome_vcf file
|
||||
pattern: "*_genome.vcf.gz.tbi"
|
||||
- version:
|
||||
type: file
|
||||
description: File containing software version
|
||||
pattern: "*.{version.txt}"
|
||||
authors:
|
||||
- "@arontommi"
|
|
@ -411,6 +411,10 @@ star_genomegenerate:
|
|||
- software/star/genomegenerate/**
|
||||
- tests/software/star/genomegenerate/**
|
||||
|
||||
strelka_germline:
|
||||
- software/strelka/germline/**
|
||||
- tests/software/strelka/germline/**
|
||||
|
||||
stringtie:
|
||||
- software/stringtie/**
|
||||
- tests/software/stringtie/**
|
||||
|
|
33
tests/software/strelka/germline/main.nf
Normal file
33
tests/software/strelka/germline/main.nf
Normal file
|
@ -0,0 +1,33 @@
|
|||
#!/usr/bin/env nextflow
|
||||
|
||||
nextflow.enable.dsl = 2
|
||||
|
||||
include { STRELKA_GERMLINE } from '../../../../software/strelka/germline/main.nf' addParams( options: [:] )
|
||||
|
||||
workflow test_strelka_germline {
|
||||
|
||||
def input = []
|
||||
|
||||
def fasta = file("${launchDir}/tests/data/genomics/sarscov2/fasta/test_genome.fasta", checkIfExists: true)
|
||||
def fai = file("${launchDir}/tests/data/genomics/sarscov2/fasta/test_genome.fasta.fai", checkIfExists: true)
|
||||
def target_bed = []
|
||||
input = [ [ id:'test'], // meta map
|
||||
file("${launchDir}/tests/data/genomics/sarscov2/bam/test_paired_end.sorted.bam", checkIfExists: true),
|
||||
file("${launchDir}/tests/data/genomics/sarscov2/bam/test_paired_end.sorted.bam.bai", checkIfExists: true) ]
|
||||
|
||||
STRELKA_GERMLINE ( input, fasta, fai, target_bed )
|
||||
}
|
||||
workflow test_strelka_germline_target_bed {
|
||||
|
||||
def input = []
|
||||
|
||||
def fasta = file("${launchDir}/tests/data/genomics/sarscov2/fasta/test_genome.fasta", checkIfExists: true)
|
||||
def fai = file("${launchDir}/tests/data/genomics/sarscov2/fasta/test_genome.fasta.fai", checkIfExists: true)
|
||||
def target_bed = file("${launchDir}/tests/data/genomics/sarscov2/bed/test.bed", checkIfExists: true)
|
||||
input = [ [ id:'test'], // meta map
|
||||
file("${launchDir}/tests/data/genomics/sarscov2/bam/test_paired_end.sorted.bam", checkIfExists: true),
|
||||
file("${launchDir}/tests/data/genomics/sarscov2/bam/test_paired_end.sorted.bam.bai", checkIfExists: true) ]
|
||||
|
||||
STRELKA_GERMLINE ( input, fasta, fai, target_bed )
|
||||
}
|
||||
|
22
tests/software/strelka/germline/test.yml
Normal file
22
tests/software/strelka/germline/test.yml
Normal file
|
@ -0,0 +1,22 @@
|
|||
## TODO nf-core: Please run the following command to build this file:
|
||||
# nf-core modules create-test-yml strelka/germline
|
||||
- name: strelka germline
|
||||
command: nextflow run ./tests/software/strelka/germline -entry test_strelka_germline -c tests/config/nextflow.config
|
||||
tags:
|
||||
- strelka
|
||||
- strelka_germline
|
||||
files:
|
||||
- path: output/strelka/strelka_test_variants.vcf.gz
|
||||
- path: output/strelka/strelka_test_variants.vcf.gz.tbi
|
||||
- path: output/strelka/strelka_test_genome.vcf.gz
|
||||
- path: output/strelka/strelka_test_genome.vcf.gz.tbi
|
||||
- name: strelka germline target bed
|
||||
command: nextflow run ./tests/software/strelka/germline -entry test_strelka_germline_target_bed -c tests/config/nextflow.config
|
||||
tags:
|
||||
- strelka
|
||||
- strelka_germline
|
||||
files:
|
||||
- path: output/strelka/strelka_test_variants.vcf.gz
|
||||
- path: output/strelka/strelka_test_variants.vcf.gz.tbi
|
||||
- path: output/strelka/strelka_test_genome.vcf.gz
|
||||
- path: output/strelka/strelka_test_genome.vcf.gz.tbi
|
Loading…
Reference in a new issue