Expansionhunter (#666)

Please enter the commit message for your changes. Lines starting

* adds expansionhunter module

Co-authored-by: Maxime U. Garcia <maxime.garcia@scilifelab.se>
This commit is contained in:
Anders Jemt 2021-08-16 17:47:42 +02:00 committed by GitHub
parent 0954204f9e
commit b261c1f549
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 192 additions and 0 deletions

View file

@ -0,0 +1,68 @@
//
// 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_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) {
if (!args.filename.endsWith('.version.txt')) {
def ioptions = initOptions(args.options)
def path_list = [ ioptions.publish_dir ?: args.publish_dir ]
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,45 @@
// Import generic module functions
include { initOptions; saveFiles; getSoftwareName } from './functions'
params.options = [:]
options = initOptions(params.options)
process EXPANSIONHUNTER {
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::expansionhunter=4.0.2" : null)
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
container "https://depot.galaxyproject.org/singularity/expansionhunter:4.0.2--he785bd8_0"
} else {
container "quay.io/biocontainers/expansionhunter:4.0.2--he785bd8_0"
}
input:
tuple val(meta), path(bam), path(bai)
path fasta
path variant_catalog
output:
tuple val(meta), path("*.vcf"), emit: vcf
path "*.version.txt" , emit: version
script:
def software = getSoftwareName(task.process)
def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
def gender = (meta.gender == 'male' || meta.gender == 1 || meta.gender == 'XY') ? "male" : "female"
"""
ExpansionHunter \\
$options.args \\
--reads $bam \\
--output-prefix $prefix \\
--reference $fasta \\
--variant-catalog $variant_catalog \\
--sex $gender
echo \$(ExpansionHunter --version 2>&1) | sed 's/^.*ExpansionHunter //' > ${software}.version.txt
"""
}

View file

@ -0,0 +1,50 @@
name: expansionhunter
description: write your description here
keywords:
- STR
- repeat_expansions
tools:
- expansionhunter:
description: A tool for estimating repeat sizes
homepage: https://github.com/Illumina/ExpansionHunter
documentation: https://github.com/Illumina/ExpansionHunter/blob/master/docs/01_Introduction.md
tool_dev_url: None
doi: "10.1093/bioinformatics/btz431"
licence: ['Apache v2.0']
input:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- bam:
type: file
description: BAM/CRAM file
pattern: "*.{bam,cram}"
- fasta:
type: file
description: Reference genome
pattern: "*.{fa,fasta}"
- variant_catalog:
type: file
description: json file with repeat expansion sites to genotype
pattern: "*.{json}"
output:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', gender:'female' ]
- version:
type: file
description: File containing software version
pattern: "*.{version.txt}"
- vcf:
type: file
description: VCF with repeat expansions
pattern: "*.{vcf}"
authors:
- "@jemten"

View file

@ -270,6 +270,10 @@ ensemblvep:
- modules/ensemblvep/**
- tests/modules/ensemblvep/**
expansionhunter:
- modules/expansionhunter/**
- tests/modules/expansionhunter/**
fastp:
- modules/fastp/**
- tests/modules/fastp/**

View file

@ -107,6 +107,7 @@ params {
mills_and_1000g_indels_vcf_gz = "${test_data_dir}/genomics/homo_sapiens/genome/vcf/mills_and_1000G.indels.vcf.gz"
mills_and_1000g_indels_vcf_gz_tbi = "${test_data_dir}/genomics/homo_sapiens/genome/vcf/mills_and_1000G.indels.vcf.gz.tbi"
index_salmon = "${test_data_dir}/genomics/homo_sapiens/genome/index/salmon"
repeat_expansions = "${test_data_dir}/genomics/homo_sapiens/genome/loci/repeat_expansions.json"
}
'illumina' {
test_paired_end_sorted_bam = "${test_data_dir}/genomics/homo_sapiens/illumina/bam/test.paired_end.sorted.bam"

View file

@ -0,0 +1,17 @@
#!/usr/bin/env nextflow
nextflow.enable.dsl = 2
include { EXPANSIONHUNTER } from '../../../modules/expansionhunter/main.nf' addParams( options: [:] )
workflow test_expansionhunter {
input = [ [ id:'test', gender:'male' ], // meta map
file(params.test_data['homo_sapiens']['illumina']['test_paired_end_recalibrated_sorted_bam'], checkIfExists: true),
file(params.test_data['homo_sapiens']['illumina']['test_paired_end_recalibrated_sorted_bam_bai'], checkIfExists: true),
]
fasta = file(params.test_data['homo_sapiens']['genome']['genome_fasta'], checkIfExists: true)
variant_catalog = file(params.test_data['homo_sapiens']['genome']['repeat_expansions'], checkIfExists: true)
EXPANSIONHUNTER ( input, fasta, variant_catalog )
}

View file

@ -0,0 +1,7 @@
- name: expansionhunter test_expansionhunter
command: nextflow run tests/modules/expansionhunter -entry test_expansionhunter -c tests/config/nextflow.config
tags:
- expansionhunter
files:
- path: output/expansionhunter/test.vcf
md5sum: ef6c2101d7bd67211bb5a5a132690e02