add genmap/mappability (#509)

* add genmap/mappability

* Add index module.
Remove -w parameter from mappability module.

* change the output of genmap/index

* fix the lint error which can not handle stageAs.

* Apply suggestions from code review

* Update main.nf

* Update test.yml

* Update main.nf

* Update test.yml

* Update tests/software/genmap/mappability/main.nf

* Update software/genmap/mappability/main.nf

* Update software/genmap/mappability/main.nf

Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com>
This commit is contained in:
JIANHONG OU 2021-05-25 17:12:10 -04:00 committed by GitHub
parent 207930139a
commit 18440df87a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 382 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,38 @@
// Import generic module functions
include { initOptions; saveFiles; getSoftwareName } from './functions'
params.options = [:]
options = initOptions(params.options)
process GENMAP_INDEX {
tag '$fasta'
label 'process_high'
publishDir "${params.outdir}",
mode: params.publish_dir_mode,
saveAs: { filename -> saveFiles(filename:filename, options:params.options, publish_dir:'index', meta:[:], publish_by_meta:[]) }
conda (params.enable_conda ? "bioconda::genmap=1.3.0" : null)
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
container "https://depot.galaxyproject.org/singularity/genmap:1.3.0--h1b792b2_1"
} else {
container "quay.io/biocontainers/genmap:1.3.0--h1b792b2_1"
}
input:
path fasta
output:
path "genmap" , emit: index
path "*.version.txt", emit: version
script:
def software = getSoftwareName(task.process)
"""
genmap \\
index \\
-F $fasta \\
-I genmap
echo \$(genmap --version 2>&1) | sed 's/GenMap version: //; s/SeqAn.*\$//' > ${software}.version.txt
"""
}

View file

@ -0,0 +1,31 @@
name: genmap_index
description: create index file for genmap
keywords:
- index
tools:
- genmap:
description: Ultra-fast computation of genome mappability.
homepage: https://github.com/cpockrandt/genmap
documentation: https://github.com/cpockrandt/genmap
tool_dev_url: https://github.com/cpockrandt/genmap
doi: "10.1093/bioinformatics/btaa222"
licence: ['BSD']
input:
- fasta:
type: file
description: fasta file
pattern: "*.{fasta,fa}"
output:
- version:
type: file
description: File containing software version
pattern: "*.{version.txt}"
- index:
type: index
description: Genmap index file
pattern: "{index}.*"
authors:
- "@jianhong"

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,41 @@
// Import generic module functions
include { initOptions; saveFiles; getSoftwareName } from './functions'
params.options = [:]
options = initOptions(params.options)
process GENMAP_MAPPABILITY {
tag '$fasta'
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:[:], publish_by_meta:[]) }
conda (params.enable_conda ? "bioconda::genmap=1.3.0" : null)
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
container "https://depot.galaxyproject.org/singularity/genmap:1.3.0--h1b792b2_1"
} else {
container "quay.io/biocontainers/genmap:1.3.0--h1b792b2_1"
}
input:
path index
output:
path "*.wig" , optional:true, emit: wig
path "*.bedgraph" , optional:true, emit: bedgraph
path "*.txt" , optional:true, emit: txt
path "*.version.txt" , emit: version
script:
def software = getSoftwareName(task.process)
"""
genmap \\
map \\
$options.args \\
-I $index \\
-O mappability
echo \$(genmap --version 2>&1) | sed 's/GenMap version: //; s/SeqAn.*\$//' > ${software}.version.txt
"""
}

View file

@ -0,0 +1,42 @@
name: genmap_mappability
description: create mappability file for a genome
keywords:
- mappability
tools:
- genmap:
description: Ultra-fast computation of genome mappability.
homepage: https://github.com/cpockrandt/genmap
documentation: https://github.com/cpockrandt/genmap
tool_dev_url: https://github.com/cpockrandt/genmap
doi: "10.1093/bioinformatics/btaa222"
licence: ['BSD']
input:
- fasta:
type: file
description: fasta file
pattern: "*.{fasta,fa}"
- index:
type: file
description: index file
output:
- version:
type: file
description: File containing software version
pattern: "*.{version.txt}"
- wig:
type: file
description: genmap wig mappability file
pattern: "*.wig"
- bedgraph:
type: file
description: genmap bedgraph mappability file
pattern: "*.bedgraph"
- txt:
type: file
description: genmap text mappability file
pattern: "*.txt"
authors:
- "@jianhong"

View file

@ -294,6 +294,14 @@ gatk4/variantfiltration:
- software/gatk4/variantfiltration/**
- tests/software/gatk4/variantfiltration/**
genmap/index:
- software/genmap/index/**
- tests/software/genmap/index/**
genmap/mappability:
- software/genmap/mappability/**
- tests/software/genmap/mappability/**
gffread:
- software/gffread/**
- tests/software/gffread/**

View file

@ -0,0 +1,12 @@
#!/usr/bin/env nextflow
nextflow.enable.dsl = 2
include { GENMAP_INDEX } from '../../../../software/genmap/index/main.nf' addParams( options: [:] )
workflow test_genmap_index {
input = file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true)
GENMAP_INDEX ( input )
}

View file

@ -0,0 +1,48 @@
- name: genmap index test_genmap_index
command: nextflow run tests/software/genmap/index -entry test_genmap_index -c tests/config/nextflow.config
tags:
- genmap
- genmap/index
files:
- path: output/index/genmap/index.ids.concat
md5sum: da6caa25f62c5407ccdfbcce1fa92408
- path: output/index/genmap/index.ids.limits
md5sum: f82636c5da188aec131d3a809473eff1
- path: output/index/genmap/index.info.concat
md5sum: 8ba5273aa9e58722bf45b9cc39fc6bfe
- path: output/index/genmap/index.info.limits
md5sum: 3522f2811f4ddf04598809fc84a1459e
- path: output/index/genmap/index.lf.drp
md5sum: dd85d6a23af2c7adf2695658e3056c08
- path: output/index/genmap/index.lf.drp.sbl
md5sum: f1d3ff8443297732862df21dc4e57262
- path: output/index/genmap/index.lf.drs
md5sum: 93b885adfe0da089cdf634904fd59f71
- path: output/index/genmap/index.lf.drv
md5sum: e06b605496bd91b32afa3c4f56d934ac
- path: output/index/genmap/index.lf.drv.sbl
md5sum: 8dd6bb7329a71449b0a1b292b5999164
- path: output/index/genmap/index.lf.pst
md5sum: e8daba34298e99e42942435286f9b3f0
- path: output/index/genmap/index.rev.lf.drp
md5sum: 5d9107e3aeec0721553dd661d4365fef
- path: output/index/genmap/index.rev.lf.drp.sbl
md5sum: f1d3ff8443297732862df21dc4e57262
- path: output/index/genmap/index.rev.lf.drs
md5sum: 93b885adfe0da089cdf634904fd59f71
- path: output/index/genmap/index.rev.lf.drv
md5sum: df7e795edc0a034577a9d2599fe8cfeb
- path: output/index/genmap/index.rev.lf.drv.sbl
md5sum: 8dd6bb7329a71449b0a1b292b5999164
- path: output/index/genmap/index.rev.lf.pst
md5sum: e8daba34298e99e42942435286f9b3f0
- path: output/index/genmap/index.sa.ind
md5sum: e21e5c7ce887cc8e3d0fa44ab1019cab
- path: output/index/genmap/index.sa.len
md5sum: 5dfc20cfe8ed9892451461a8d402f51c
- path: output/index/genmap/index.sa.val
md5sum: 400ee7f2fe93b2000ae3a5da5e509730
- path: output/index/genmap/index.txt.concat
md5sum: b4303962e0c176107945f3405370e6ae
- path: output/index/genmap/index.txt.limits
md5sum: 4480a068db603e4c9a27bc4fa9ceaf14

View file

@ -0,0 +1,14 @@
#!/usr/bin/env nextflow
nextflow.enable.dsl = 2
include { GENMAP_INDEX } from '../../../../software/genmap/index/main.nf' addParams( options: [:] )
include { GENMAP_MAPPABILITY } from '../../../../software/genmap/mappability/main.nf' addParams( options: [args : '-K 50 -E 2 -w -t -bg'] )
workflow test_genmap_map {
input = file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true)
GENMAP_INDEX ( input )
GENMAP_MAPPABILITY ( GENMAP_INDEX.out.index )
}

View file

@ -0,0 +1,12 @@
- name: genmap mappability test_genmap_map
command: nextflow run tests/software/genmap/mappability -entry test_genmap_map -c tests/config/nextflow.config
tags:
- genmap
- genmap/mappability
files:
- path: output/genmap/mappability.bedgraph
md5sum: c4203b84a84331282ef8660279f80b26
- path: output/genmap/mappability.txt
md5sum: 602d409493457f92b2e5f075f62ebe30
- path: output/genmap/mappability.wig
md5sum: fd2afb6512ab9e86f9a3b62f8b9d9088