Merge freebayes subtools (#1015)

* feat: merge freebayes subtools

* fix: typo

* assess comments from review

* fix: path to module
This commit is contained in:
Maxime U. Garcia 2021-11-03 11:22:06 +01:00 committed by GitHub
parent 4619d012e5
commit 9767b081b9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 148 additions and 361 deletions

View file

@ -4,7 +4,7 @@ include { initOptions; saveFiles; getProcessName; getSoftwareName } from './func
params.options = [:] params.options = [:]
options = initOptions(params.options) options = initOptions(params.options)
process FREEBAYES_GERMLINE { process FREEBAYES {
tag "$meta.id" tag "$meta.id"
label 'process_low' label 'process_low'
publishDir "${params.outdir}", publishDir "${params.outdir}",
@ -19,7 +19,7 @@ process FREEBAYES_GERMLINE {
} }
input: input:
tuple val(meta), path(input), path(input_index) tuple val(meta), path(input_1), path(input_1_index), path(input_2), path(input_2_index)
path fasta path fasta
path fai path fai
path targets path targets
@ -33,6 +33,7 @@ process FREEBAYES_GERMLINE {
script: script:
def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}" def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
def input = input_2 ? "${input_1} ${input_2}" : "${input_1}"
def targets_file = targets ? "--target ${targets}" : "" def targets_file = targets ? "--target ${targets}" : ""
def samples_file = samples ? "--samples ${samples}" : "" def samples_file = samples ? "--samples ${samples}" : ""
def populations_file = populations ? "--populations ${populations}" : "" def populations_file = populations ? "--populations ${populations}" : ""
@ -48,7 +49,7 @@ process FREEBAYES_GERMLINE {
$populations_file \\ $populations_file \\
$cnv_file \\ $cnv_file \\
$options.args \\ $options.args \\
$input > ${prefix}.vcf $input > ${prefix}.vcf
gzip --no-name ${prefix}.vcf gzip --no-name ${prefix}.vcf

View file

@ -1,11 +1,14 @@
name: freebayes_germline name: freebayes
description: A haplotype-based variant detector description: A haplotype-based variant detector
keywords: keywords:
- variant caller - variant caller
- SNP - SNP
- genotyping - genotyping
- variant calling - somatic variant calling
- germline variant calling
- bacterial variant calling
- bayesian - bayesian
tools: tools:
- freebayes: - freebayes:
description: Bayesian haplotype-based polymorphism discovery and genotyping description: Bayesian haplotype-based polymorphism discovery and genotyping
@ -73,6 +76,8 @@ output:
type: file type: file
description: Compressed VCF file description: Compressed VCF file
pattern: "*.vcf.gz" pattern: "*.vcf.gz"
authors: authors:
- "@maxibor" - "@maxibor"
- "@FriederikeHanssen" - "@FriederikeHanssen"
- "@maxulysse"

View file

@ -1,78 +0,0 @@
//
// 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

@ -1,74 +0,0 @@
// Import generic module functions
include { initOptions; saveFiles; getProcessName; getSoftwareName } from './functions'
params.options = [:]
options = initOptions(params.options)
process FREEBAYES_SOMATIC {
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::freebayes=1.3.5" : null)
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
container "https://depot.galaxyproject.org/singularity/freebayes:1.3.5--py38ha193a2f_3"
} else {
container "quay.io/biocontainers/freebayes:1.3.5--py38ha193a2f_3"
}
input:
tuple val(meta), path(input_normal), path(input_index_normal), path(input_tumor), path(input_index_tumor)
path fasta
path fai
path targets
path samples
output:
tuple val(meta), path("*.vcf.gz") , emit: vcf
path "versions.yml" , emit: versions
script:
def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
def targets_file = targets ? "--target ${targets}" : ""
def samples_file = samples ? "--samples ${samples}" : ""
if (task.cpus > 1) {
"""
freebayes-parallel \\
<(fasta_generate_regions.py ${fasta}.fai 10000) ${task.cpus} \\
-f $fasta \\
$targets_file \\
$samples_file \\
$options.args \\
$input_tumor \\
$input_normal > ${prefix}.vcf
gzip --no-name ${prefix}.vcf
cat <<-END_VERSIONS > versions.yml
${getProcessName(task.process)}:
${getSoftwareName(task.process)}: \$(echo \$(freebayes --version 2>&1) | sed 's/version:\s*v//g' )
END_VERSIONS
"""
} else {
"""
freebayes \\
-f $fasta \\
$targets_file \\
$samples_file \\
$options.args \\
$input_tumor \\
$input_normal > ${prefix}.vcf
gzip --no-name ${prefix}.vcf
cat <<-END_VERSIONS > versions.yml
${getProcessName(task.process)}:
${getSoftwareName(task.process)}: \$(echo \$(freebayes --version 2>&1) | sed 's/version:\s*v//g' )
END_VERSIONS
"""
}
}

View file

@ -1,66 +0,0 @@
name: freebayes_somatic
description: A haplotype-based variant detector
keywords:
- variant caller
- SNP
- genotyping
- somatic variant calling
- bayesian
tools:
- freebayes:
description: Bayesian haplotype-based polymorphism discovery and genotyping
homepage: https://github.com/freebayes/freebayes
documentation: https://github.com/freebayes/freebayes
tool_dev_url: https://github.com/freebayes/freebayes
doi: "arXiv:1207.3907"
licence: ['MIT']
input:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- input:
type: file
description: BAM/CRAM/SAM file
pattern: "*.{bam,cram,sam}"
- input_index:
type: file
description: BAM/CRAM/SAM index file
pattern: "*.bam.bai"
- fasta:
type: file
description: reference fasta file
pattern: ".{fa,fa.gz,fasta,fasta.gz}"
- fai:
type: file
description: reference fasta file index
pattern: "*.fai"
- targets:
type: file
description: Optional - Limit analysis to targets listed in this BED-format FILE.
pattern: "*.bed"
- samples:
type: file
description: Optional - Limit analysis to samples listed (one per line) in the FILE.
pattern: "*.txt"
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}"
- vcf:
type: file
description: Compressed VCF file
pattern: "*.vcf.gz"
authors:
- "@FriederikeHanssen"

View file

@ -410,13 +410,9 @@ flash:
- modules/flash/** - modules/flash/**
- tests/modules/flash/** - tests/modules/flash/**
freebayes/germline: freebayes:
- modules/freebayes/germline/** - modules/freebayes/**
- tests/modules/freebayes/germline/** - tests/modules/freebayes/**
freebayes/somatic:
- modules/freebayes/somatic/**
- tests/modules/freebayes/somatic/**
gatk4/applybqsr: gatk4/applybqsr:
- modules/gatk4/applybqsr/** - modules/gatk4/applybqsr/**

View file

@ -1,51 +0,0 @@
#!/usr/bin/env nextflow
nextflow.enable.dsl = 2
include { FREEBAYES_GERMLINE } from '../../../../modules/freebayes/germline/main.nf' addParams( options: [:] )
workflow test_freebayes {
input = [ [ id:'test', single_end:false ], // meta map
file(params.test_data['sarscov2']['illumina']['test_paired_end_sorted_bam'], checkIfExists: true),
file(params.test_data['sarscov2']['illumina']['test_paired_end_sorted_bam_bai'], checkIfExists: true)]
fasta = file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true)
fai = file(params.test_data['sarscov2']['genome']['genome_fasta_fai'], checkIfExists: true)
targets = []
samples = []
populations = []
cnv = []
FREEBAYES_GERMLINE ( input, fasta, fai, targets, samples, populations, cnv)
}
workflow test_freebayes_bed {
input = [ [ id:'test', single_end:false ], // meta map
file(params.test_data['sarscov2']['illumina']['test_paired_end_sorted_bam'], checkIfExists: true),
file(params.test_data['sarscov2']['illumina']['test_paired_end_sorted_bam_bai'], checkIfExists: true)]
fasta = file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true)
fai = file(params.test_data['sarscov2']['genome']['genome_fasta_fai'], checkIfExists: true)
targets = file(params.test_data['sarscov2']['genome']['test_bed'], checkIfExists: true)
samples = []
populations = []
cnv = []
FREEBAYES_GERMLINE ( input, fasta, fai, targets, samples, populations, cnv)
}
workflow test_freebayes_cram {
input = [ [ id:'test', single_end:false ], // meta map
file(params.test_data['homo_sapiens']['illumina']['test_paired_end_sorted_cram'], checkIfExists: true),
file(params.test_data['homo_sapiens']['illumina']['test_paired_end_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)
targets = []
samples = []
populations = []
cnv = []
FREEBAYES_GERMLINE ( input, fasta, fai, targets, samples, populations, cnv)
}

View file

@ -1,26 +0,0 @@
- name: freebayes germline test_freebayes
command: nextflow run tests/modules/freebayes/germline -entry test_freebayes -c tests/config/nextflow.config
tags:
- freebayes
- freebayes/germline
files:
- path: output/freebayes/test.vcf.gz
md5sum: 1ec210ad27514c7a4140c924dc66d979
- name: freebayes germline test_freebayes_bed
command: nextflow run tests/modules/freebayes/germline -entry test_freebayes_bed -c tests/config/nextflow.config
tags:
- freebayes
- freebayes/germline
files:
- path: output/freebayes/test.vcf.gz
md5sum: e8923cccd5dac196f72d3d3997a60706
- name: freebayes germline test_freebayes_cram
command: nextflow run tests/modules/freebayes/germline -entry test_freebayes_cram -c tests/config/nextflow.config
tags:
- freebayes
- freebayes/germline
files:
- path: output/freebayes/test.vcf.gz
md5sum: cb57a3ed154618e3aa4a5272fcfb7521

View file

@ -0,0 +1,95 @@
#!/usr/bin/env nextflow
nextflow.enable.dsl = 2
include { FREEBAYES } from '../../../modules/freebayes/main.nf' addParams( options: [:] )
workflow test_freebayes {
input = [ [ id:'test', single_end:false ], // meta map
file(params.test_data['sarscov2']['illumina']['test_paired_end_sorted_bam'], checkIfExists: true),
file(params.test_data['sarscov2']['illumina']['test_paired_end_sorted_bam_bai'], checkIfExists: true),
[],
[]
]
fasta = file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true)
fai = file(params.test_data['sarscov2']['genome']['genome_fasta_fai'], checkIfExists: true)
targets = []
samples = []
populations = []
cnv = []
FREEBAYES (input, fasta, fai, targets, samples, populations, cnv)
}
workflow test_freebayes_bed {
input = [ [ id:'test', single_end:false ], // meta map
file(params.test_data['sarscov2']['illumina']['test_paired_end_sorted_bam'], checkIfExists: true),
file(params.test_data['sarscov2']['illumina']['test_paired_end_sorted_bam_bai'], checkIfExists: true),
[],
[]
]
fasta = file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true)
fai = file(params.test_data['sarscov2']['genome']['genome_fasta_fai'], checkIfExists: true)
targets = file(params.test_data['sarscov2']['genome']['test_bed'], checkIfExists: true)
samples = []
populations = []
cnv = []
FREEBAYES (input, fasta, fai, targets, samples, populations, cnv)
}
workflow test_freebayes_cram {
input = [ [ id:'test', single_end:false ], // meta map
file(params.test_data['homo_sapiens']['illumina']['test_paired_end_sorted_cram'], checkIfExists: true),
file(params.test_data['homo_sapiens']['illumina']['test_paired_end_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)
targets = []
samples = []
populations = []
cnv = []
FREEBAYES (input, fasta, fai, targets, samples, populations, cnv)
}
workflow test_freebayes_somatic {
input = [ [ id:'test', single_end:false ], // meta map
file(params.test_data['homo_sapiens']['illumina']['test_paired_end_sorted_bam'], checkIfExists: true),
file(params.test_data['homo_sapiens']['illumina']['test_paired_end_sorted_bam_bai'], checkIfExists: true),
file(params.test_data['homo_sapiens']['illumina']['test2_paired_end_sorted_bam'], checkIfExists: true),
file(params.test_data['homo_sapiens']['illumina']['test2_paired_end_sorted_bam_bai'], 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)
targets = []
samples = []
populations = []
cnv = []
FREEBAYES (input, fasta, fai, targets, samples, populations, cnv)
}
workflow test_freebayes_somatic_cram_intervals {
input = [ [ id:'test', single_end:false ], // meta map
file(params.test_data['homo_sapiens']['illumina']['test_paired_end_sorted_cram'], checkIfExists: true),
file(params.test_data['homo_sapiens']['illumina']['test_paired_end_sorted_cram_crai'], checkIfExists: true),
file(params.test_data['homo_sapiens']['illumina']['test2_paired_end_sorted_cram'], checkIfExists: true),
file(params.test_data['homo_sapiens']['illumina']['test2_paired_end_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)
targets = file(params.test_data['homo_sapiens']['genome']['genome_bed'], checkIfExists: true)
samples = []
populations = []
cnv = []
FREEBAYES (input, fasta, fai, targets, samples, populations, cnv)
}

View file

@ -1,37 +0,0 @@
#!/usr/bin/env nextflow
nextflow.enable.dsl = 2
include { FREEBAYES_SOMATIC } from '../../../../modules/freebayes/somatic/main.nf' addParams( options: [:] )
workflow test_freebayes {
input = [ [ id:'test', single_end:false ], // meta map
file(params.test_data['homo_sapiens']['illumina']['test_paired_end_sorted_bam'], checkIfExists: true),
file(params.test_data['homo_sapiens']['illumina']['test_paired_end_sorted_bam_bai'], checkIfExists: true),
file(params.test_data['homo_sapiens']['illumina']['test2_paired_end_sorted_bam'], checkIfExists: true),
file(params.test_data['homo_sapiens']['illumina']['test2_paired_end_sorted_bam_bai'], 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)
targets = []
samples = []
FREEBAYES_SOMATIC ( input, fasta, fai, targets, samples)
}
workflow test_freebayes_intervals {
input = [ [ id:'test', single_end:false ], // meta map
file(params.test_data['homo_sapiens']['illumina']['test_paired_end_sorted_cram'], checkIfExists: true),
file(params.test_data['homo_sapiens']['illumina']['test_paired_end_sorted_cram_crai'], checkIfExists: true),
file(params.test_data['homo_sapiens']['illumina']['test2_paired_end_sorted_cram'], checkIfExists: true),
file(params.test_data['homo_sapiens']['illumina']['test2_paired_end_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)
targets = file(params.test_data['homo_sapiens']['genome']['genome_bed'], checkIfExists: true)
samples = []
FREEBAYES_SOMATIC ( input, fasta, fai, targets, samples)
}

View file

@ -1,17 +0,0 @@
- name: freebayes somatic test_freebayes
command: nextflow run tests/modules/freebayes/somatic -entry test_freebayes -c tests/config/nextflow.config
tags:
- freebayes/somatic
- freebayes
files:
- path: output/freebayes/test.vcf.gz
md5sum: 1c47d02f27ec5918558c8688ce6e7780
- name: freebayes somatic test_freebayes_intervals
command: nextflow run tests/modules/freebayes/somatic -entry test_freebayes_intervals -c tests/config/nextflow.config
tags:
- freebayes/somatic
- freebayes
files:
- path: output/freebayes/test.vcf.gz
md5sum: 5b8a12666bde63746dcec7afcd3ef789

View file

@ -0,0 +1,39 @@
- name: freebayes test_freebayes
command: nextflow run tests/modules/freebayes -entry test_freebayes -c tests/config/nextflow.config
tags:
- freebayes
files:
- path: output/freebayes/test.vcf.gz
md5sum: 04d60a7135768777e0c764daec6519db
- name: freebayes test_freebayes_bed
command: nextflow run tests/modules/freebayes -entry test_freebayes_bed -c tests/config/nextflow.config
tags:
- freebayes
files:
- path: output/freebayes/test.vcf.gz
md5sum: fc6e228c8ac5508bd83da45eafc2e7b2
- name: freebayes test_freebayes_cram
command: nextflow run tests/modules/freebayes -entry test_freebayes_cram -c tests/config/nextflow.config
tags:
- freebayes
files:
- path: output/freebayes/test.vcf.gz
md5sum: 91b8caaa0e396e1ba4f264a83bb67254
- name: freebayes test_freebayes_somatic
command: nextflow run tests/modules/freebayes -entry test_freebayes_somatic -c tests/config/nextflow.config
tags:
- freebayes
files:
- path: output/freebayes/test.vcf.gz
md5sum: 40da977199f16d9888e0e0e07e8bebee
- name: freebayes test_freebayes_somatic_cram_intervals
command: nextflow run tests/modules/freebayes -entry test_freebayes_somatic_cram_intervals -c tests/config/nextflow.config
tags:
- freebayes
files:
- path: output/freebayes/test.vcf.gz
md5sum: dd976880365287d9ad31a606eb4d091f