Add leehom module (#1052)

* Specify more guidelines on input channels

* Linting

* Updates based on code review

* Update README.md

* Fix broken sentence

* feat: add megahit module, currently decompressed output

* Update main.nf

* Update tests/modules/megahit/test.yml

Co-authored-by: Maxime Borry <maxibor@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com>

* feat: compress all outputs, remove md5sums due to gz stochasicity

* fix: wrong conda channel for pigz

* fix: broken singleend tests and update meta.yml

* Missed one

* Apply suggestions from code review

Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com>

* fix: pigz formatting

* Apply suggestions from code review

Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com>

* Apply suggestions from code review

* Add leeHom module

* Update modules/leehom/main.nf

Co-authored-by: FriederikeHanssen <Friederike.hanssen@qbic.uni-tuebingen.de>

* Update modules/leehom/main.nf

Co-authored-by: FriederikeHanssen <Friederike.hanssen@qbic.uni-tuebingen.de>

* Update modules/leehom/main.nf

Co-authored-by: FriederikeHanssen <Friederike.hanssen@qbic.uni-tuebingen.de>

* Update modules/leehom/main.nf

Co-authored-by: FriederikeHanssen <Friederike.hanssen@qbic.uni-tuebingen.de>

Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com>
Co-authored-by: Maxime Borry <maxibor@users.noreply.github.com>
Co-authored-by: FriederikeHanssen <Friederike.hanssen@qbic.uni-tuebingen.de>
This commit is contained in:
James A. Fellows Yates 2021-11-15 15:26:06 +01:00 committed by GitHub
parent b012b349c1
commit 2c3c87a10f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 331 additions and 9 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"
}
}

85
modules/leehom/main.nf Normal file
View file

@ -0,0 +1,85 @@
// Import generic module functions
include { initOptions; saveFiles; getSoftwareName; getProcessName } from './functions'
params.options = [:]
options = initOptions(params.options)
def VERSION="1.2.15"
process LEEHOM {
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::leehom=1.2.15" : null)
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
container "https://depot.galaxyproject.org/singularity/leehom:1.2.15--h29e30f7_1"
} else {
container "quay.io/biocontainers/leehom:1.2.15--h29e30f7_1"
}
input:
tuple val(meta), path(reads)
output:
tuple val(meta), path("${prefix}.bam") , optional: true, emit: bam
tuple val(meta), path("${prefix}.fq.gz") , optional: true, emit: fq_pass
tuple val(meta), path("${prefix}.fail.fq.gz") , optional: true, emit: fq_fail
tuple val(meta), path("${prefix}_r1.fq.gz") , optional: true, emit: unmerged_r1_fq_pass
tuple val(meta), path("${prefix}_r1.fail.fq.gz"), optional: true, emit: unmerged_r1_fq_fail
tuple val(meta), path("${prefix}_r2.fq.gz") , optional: true, emit: unmerged_r2_fq_pass
tuple val(meta), path("${prefix}_r2.fail.fq.gz"), optional: true, emit: unmerged_r2_fq_fail
tuple val(meta), path("*.log") , emit: log
path "versions.yml" , emit: versions
script:
prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
if ( reads.toString().endsWith('.bam') ) {
"""
leeHom \\
$options.args \\
-t $task.cpus \\
-o ${prefix}.bam \\
--log ${prefix}.log \\
$reads
cat <<-END_VERSIONS > versions.yml
${getProcessName(task.process)}:
${getSoftwareName(task.process)}: \$( echo $VERSION )
END_VERSIONS
"""
} else if ( meta.single_end ) {
"""
leeHom \\
$options.args \\
-t $task.cpus \\
-fq1 $reads \\
-fqo ${prefix} \\
--log ${prefix}.log
cat <<-END_VERSIONS > versions.yml
${getProcessName(task.process)}:
${getSoftwareName(task.process)}: \$( echo $VERSION )
END_VERSIONS
"""
} else {
"""
leeHom \\
$options.args \\
-t $task.cpus \\
-fq1 ${reads[0]} \\
-fq2 ${reads[1]} \\
-fqo ${prefix} \\
--log ${prefix}.log
cat <<-END_VERSIONS > versions.yml
${getProcessName(task.process)}:
${getSoftwareName(task.process)}: \$( echo $VERSION )
END_VERSIONS
"""
}
}

77
modules/leehom/meta.yml Normal file
View file

@ -0,0 +1,77 @@
name: leehom
description: Bayesian reconstruction of ancient DNA fragments
keywords:
- ancient DNA
- adapter removal
- clipping
- trimming
- merging
- collapsing
- preprocessing
- bayesian
tools:
- leehom:
description: Bayesian reconstruction of ancient DNA fragments
homepage: "https://grenaud.github.io/leeHom/"
documentation: "https://github.com/grenaud/leeHom"
tool_dev_url: "https://github.com/grenaud/leeHom"
doi: "10.1093/nar/gku699"
licence: ['GPL v3']
input:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- reads:
type: file
description: Unaligned BAM or one or two gzipped FASTQ file(s)
pattern: "*.{bam,fq.gz,fastq.gz}"
output:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- versions:
type: file
description: File containing software versions
pattern: "versions.yml"
- bam:
type: file
description: BAM file
pattern: "*.bam"
- fq_pass:
type: file
description: Trimmed and merged FASTQ
pattern: "*.fq.gz"
- fq_fail:
type: file
description: Failed trimmed and merged FASTQs
pattern: "*.fail.fq.gz"
- unmerged_r1_fq_pass:
type: file
description: Passed unmerged R1 FASTQs
pattern: "*.r1.fq.gz"
- unmerged_r1_fq_fail:
type: file
description: Failed unmerged R1 FASTQs
pattern: "*.r1.fail.fq.gz"
- unmerged_r2_fq_pass:
type: file
description: Passed unmerged R1 FASTQs
pattern: "*.r2.fq.gz"
- unmerged_r2_fq_pass:
type: file
description: Failed unmerged R1 FASTQs
pattern: "*.r2.fail.fq.gz"
- log:
type: file
description: Log file of command
pattern: "*.log"
authors:
- "@jfy133"

View file

@ -621,14 +621,14 @@ homer/makeucscfile:
- modules/homer/makeucscfile/**
- tests/modules/homer/makeucscfile/**
imputeme/vcftoprs:
- modules/imputeme/vcftoprs/**
- tests/modules/imputeme/vcftoprs/**
idr:
- modules/idr/**
- tests/modules/idr/**
imputeme/vcftoprs:
- modules/imputeme/vcftoprs/**
- tests/modules/imputeme/vcftoprs/**
iqtree:
- modules/iqtree/**
- tests/modules/iqtree/**
@ -718,6 +718,10 @@ last/train:
- modules/last/train/**
- tests/modules/last/train/**
leehom:
- modules/leehom/**
- tests/modules/leehom/**
lima:
- modules/lima/**
- tests/modules/lima/**
@ -786,6 +790,10 @@ megahit:
- modules/megahit/**
- tests/modules/megahit/**
meningotype:
- modules/meningotype/**
- tests/modules/meningotype/**
metabat2/jgisummarizebamcontigdepths:
- modules/metabat2/jgisummarizebamcontigdepths/**
- tests/modules/metabat2/jgisummarizebamcontigdepths/**
@ -794,11 +802,6 @@ metabat2/metabat2:
- modules/metabat2/metabat2/**
- tests/modules/metabat2/metabat2/**
meningotype:
- modules/meningotype/**
- tests/modules/meningotype/**
metaphlan3:
- modules/metaphlan3/**
- tests/modules/metaphlan3/**

View file

@ -0,0 +1,36 @@
#!/usr/bin/env nextflow
nextflow.enable.dsl = 2
include { LEEHOM } from '../../../modules/leehom/main.nf' addParams( options: [:] )
include { SAMTOOLS_VIEW } from '../../../modules/samtools/view/main.nf' addParams( options: [args: "-f4 -b"] )
workflow test_leehom_bam {
input = [ [ id:'test', single_end:false ], // meta map
file(params.test_data['homo_sapiens']['illumina']['test_paired_end_sorted_bam'], checkIfExists: true) ]
fasta = []
SAMTOOLS_VIEW ( input, fasta )
LEEHOM ( SAMTOOLS_VIEW.out.bam )
}
workflow test_leehom_se_fq {
input = [ [ id:'test', single_end:true ], // meta map
file(params.test_data['sarscov2']['illumina']['test_1_fastq_gz'], checkIfExists: true) ]
LEEHOM ( input )
}
workflow test_leehom_pe_fq {
input = [ [ id:'test', single_end:false ], // meta map
[
file(params.test_data['sarscov2']['illumina']['test_1_fastq_gz'], checkIfExists: true),
file(params.test_data['sarscov2']['illumina']['test_2_fastq_gz'], checkIfExists: true)
] ]
LEEHOM ( input )
}

View file

@ -0,0 +1,43 @@
- name: leehom test_leehom_bam
command: nextflow run tests/modules/leehom -entry test_leehom_bam -c tests/config/nextflow.config
tags:
- leehom
files:
- path: output/leehom/test.bam
md5sum: 19a1bf95714523868791f1d4d3aaee73
- path: output/leehom/test.log
md5sum: d1f5da273eb69f41babda510797c7671
- path: output/samtools/test.bam
md5sum: 25d13b3b31b147bb3836dea9932c38dd
- name: leehom test_leehom_se_fq
command: nextflow run tests/modules/leehom -entry test_leehom_se_fq -c tests/config/nextflow.config
tags:
- leehom
files:
- path: output/leehom/test.fail.fq.gz
md5sum: 7029066c27ac6f5ef18d660d5741979a
- path: output/leehom/test.fq.gz
md5sum: ed10c4bbf5c3082ca68823535b91e1e2
- path: output/leehom/test.log
md5sum: 59aa280cb72dfbea05ba913cb89db143
- name: leehom test_leehom_pe_fq
command: nextflow run tests/modules/leehom -entry test_leehom_pe_fq -c tests/config/nextflow.config
tags:
- leehom
files:
- path: output/leehom/test.fail.fq.gz
md5sum: 7029066c27ac6f5ef18d660d5741979a
- path: output/leehom/test.fq.gz
md5sum: 84929b78e3f89371ecd3b4c915b9ec33
- path: output/leehom/test.log
md5sum: 800b5a88dc0822886bfbb271029e2a4a
- path: output/leehom/test_r1.fail.fq.gz
md5sum: 7029066c27ac6f5ef18d660d5741979a
- path: output/leehom/test_r1.fq.gz
md5sum: e9258420fa712e8536106995a7d1d97a
- path: output/leehom/test_r2.fail.fq.gz
md5sum: 7029066c27ac6f5ef18d660d5741979a
- path: output/leehom/test_r2.fq.gz
md5sum: 27230bcc5eae81ec5c1701798d39c1af