* bbmap/align done

* Tests for single end and prebuilt index

* Write bam file directly

* Forgot to use all cpus for bbmap

* Test md5sums

* Added pigz support

* Update modules/bbmap/align/meta.yml

Co-authored-by: James A. Fellows Yates <jfy133@gmail.com>

* process_medium and fastq

* cat/cat module

* Remove filter from CAT_CAT

Co-authored-by: James A. Fellows Yates <jfy133@gmail.com>
Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com>
This commit is contained in:
Daniel Lundin 2021-09-20 22:02:22 +02:00 committed by GitHub
parent 60d8bd7c04
commit b32c46c6a2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 223 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"
}
}
}

39
modules/cat/cat/main.nf Normal file
View file

@ -0,0 +1,39 @@
// Import generic module functions
include { initOptions; saveFiles; getSoftwareName } from './functions'
params.options = [:]
options = initOptions(params.options)
process CAT_CAT {
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:[:], publish_by_meta:[]) }
conda (params.enable_conda ? "conda-forge::pigz=2.3.4" : null)
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
container "https://depot.galaxyproject.org/singularity/pigz:2.3.4"
} else {
container "quay.io/biocontainers/pigz:2.3.4"
}
input:
path files
output:
path "file*" , emit: file
path "*.version.txt", emit: version
script:
def software = getSoftwareName(task.process)
cpus = Math.floor(task.cpus/2).toInteger()
// Use options.suffix if specified, otherwise .out; add .gz if first input file has it
suffix = options.suffix ? "${options.suffix}" : ".out"
suffix += files[0].name =~ /\.gz/ ? '.gz' : ''
"""
cat ${options.args} $files ${options.args2} > file${suffix}
cat --version | grep 'GNU coreutils' | sed 's/cat (GNU coreutils) //' > ${software}.version.txt
"""
}

33
modules/cat/cat/meta.yml Normal file
View file

@ -0,0 +1,33 @@
name: cat_cat
description: A module for concatenation of gzipped or uncompressed files, optionally filtering the output
keywords:
- concatenate
- gzip
- filter
tools:
- cat:
description: Just concatenation
homepage: None
documentation: None
tool_dev_url: None
doi: ""
licence: ""
input:
- files:
type: file
description: Gzipped or not files
pattern: "*"
output:
- version:
type: file
description: File containing version of the pigz software
pattern: "*.{version.txt}"
- bam:
type: file
description: Concatenated, optionally filtered, file, gzipped if input was, otherwise not
pattern: "file*"
authors:
- "@erikrikarddaniel"

View file

@ -230,6 +230,10 @@ bwameth/index:
- modules/bwameth/index/**
- tests/modules/bwameth/index/**
cat/cat:
- modules/cat/cat/**
- tests/modules/cat/cat/**
cat/fastq:
- modules/cat/fastq/**
- tests/modules/cat/fastq/**

View file

@ -0,0 +1,46 @@
#!/usr/bin/env nextflow
nextflow.enable.dsl = 2
include { CAT_CAT } from '../../../../modules/cat/cat/main.nf' addParams( options: [:] )
include { CAT_CAT as CAT_CAT_SUFFIX } from '../../../../modules/cat/cat/main.nf' addParams( options: [suffix: ".fna"] )
workflow test_cat_ungzipped {
input = [
file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true),
file(params.test_data['sarscov2']['genome']['genome_sizes'], checkIfExists: true)
]
CAT_CAT ( input )
}
workflow test_cat_gzipped {
input = [
file(params.test_data['sarscov2']['genome']['genome_gff3_gz'], checkIfExists: true),
file(params.test_data['sarscov2']['genome']['contigs_genome_maf_gz'], checkIfExists: true)
]
CAT_CAT ( input )
}
workflow test_cat_ungzipped_fna {
input = [
file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true),
file(params.test_data['sarscov2']['genome']['genome_sizes'], checkIfExists: true)
]
CAT_CAT_SUFFIX ( input )
}
workflow test_cat_gzipped_fna {
input = [
file(params.test_data['sarscov2']['genome']['genome_gff3_gz'], checkIfExists: true),
file(params.test_data['sarscov2']['genome']['contigs_genome_maf_gz'], checkIfExists: true)
]
CAT_CAT_SUFFIX ( input )
}

View file

@ -0,0 +1,33 @@
- name: cat ungzipped
command: nextflow run ./tests/modules/cat/cat -entry test_cat_ungzipped -c tests/config/nextflow.config
tags:
- cat
- cat/cat
files:
- path: output/cat/file.out
md5sum: f44b33a0e441ad58b2d3700270e2dbe2
- name: cat gzipped
command: nextflow run ./tests/modules/cat/cat -entry test_cat_gzipped -c tests/config/nextflow.config
tags:
- cat
- cat/cat
files:
- path: output/cat/file.out.gz
- name: cat ungzipped suffix
command: nextflow run ./tests/modules/cat/cat -entry test_cat_ungzipped_fna -c tests/config/nextflow.config
tags:
- cat
- cat/cat
files:
- path: output/cat/file.fna
md5sum: f44b33a0e441ad58b2d3700270e2dbe2
- name: cat gzipped suffix
command: nextflow run ./tests/modules/cat/cat -entry test_cat_gzipped_fna -c tests/config/nextflow.config
tags:
- cat
- cat/cat
files:
- path: output/cat/file.fna.gz