add seqsero2 module (#1016)

* add seqsero2 module

* correct lint errors

* Update modules/seqsero2/main.nf

Co-authored-by: Sébastien Guizard <sguizard@ed.ac.uk>

* set output directory

Co-authored-by: Sébastien Guizard <sguizard@ed.ac.uk>
This commit is contained in:
Robert A. Petit III 2021-11-04 01:49:30 -06:00 committed by GitHub
parent 08b71fa85f
commit fc4f3e8822
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 207 additions and 4 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"
}
}

45
modules/seqsero2/main.nf Normal file
View file

@ -0,0 +1,45 @@
// Import generic module functions
include { initOptions; saveFiles; getSoftwareName; getProcessName } from './functions'
params.options = [:]
options = initOptions(params.options)
process SEQSERO2 {
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::seqsero2=1.2.1" : null)
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
container "https://depot.galaxyproject.org/singularity/seqsero2:1.2.1--py_0"
} else {
container "quay.io/biocontainers/seqsero2:1.2.1--py_0"
}
input:
tuple val(meta), path(seqs)
output:
tuple val(meta), path("results/*_log.txt") , emit: log
tuple val(meta), path("results/*_result.tsv"), emit: tsv
tuple val(meta), path("results/*_result.txt"), emit: txt
path "versions.yml" , emit: versions
script:
def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
"""
SeqSero2_package.py \\
$options.args \\
-d results/ \\
-n $prefix \\
-p $task.cpus \\
-i $seqs
cat <<-END_VERSIONS > versions.yml
${getProcessName(task.process)}:
${getSoftwareName(task.process)}: \$( echo \$( SeqSero2_package.py --version 2>&1) | sed 's/^.*SeqSero2_package.py //' )
END_VERSIONS
"""
}

52
modules/seqsero2/meta.yml Normal file
View file

@ -0,0 +1,52 @@
name: seqsero2
description: Salmonella serotype prediction from reads and assemblies
keywords:
- fasta
- fastq
- salmonella
- sertotype
tools:
- seqsero2:
description: Salmonella serotype prediction from genome sequencing data
homepage: https://github.com/denglab/SeqSero2
documentation: https://github.com/denglab/SeqSero2
tool_dev_url: https://github.com/denglab/SeqSero2
doi: "10.1128/AEM.01746-19"
licence: ['GPL v2']
input:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- seqs:
type: file
description: FASTQ or FASTA formated sequences
pattern: "*.{fq.gz,fastq.gz,fna.gz,fna,fasta.gz,fasta,fa.gz,fa}"
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"
- log:
type: file
description: A log of serotype antigen results
pattern: "*_log.txt"
- tsv:
type: file
description: Tab-delimited summary of the SeqSero2 results
pattern: "*_result.tsv"
- txt:
type: file
description: Detailed summary of the SeqSero2 results
pattern: "*_result.txt"
authors:
- "@rpetit3"

View file

@ -446,14 +446,14 @@ gatk4/fastqtosam:
- modules/gatk4/fastqtosam/**
- tests/modules/gatk4/fastqtosam/**
gatk4/genomicsdbimport:
- modules/gatk4/genomicsdbimport/**
- tests/modules/gatk4/genomicsdbimport/**
gatk4/filtermutectcalls:
- modules/gatk4/filtermutectcalls/**
- tests/modules/gatk4/filtermutectcalls/**
gatk4/genomicsdbimport:
- modules/gatk4/genomicsdbimport/**
- tests/modules/gatk4/genomicsdbimport/**
gatk4/getpileupsummaries:
- modules/gatk4/getpileupsummaries/**
- tests/modules/gatk4/getpileupsummaries/**
@ -1083,6 +1083,10 @@ seqkit/split2:
- modules/seqkit/split2/**
- tests/modules/seqkit/split2/**
seqsero2:
- modules/seqsero2/**
- tests/modules/seqsero2/**
seqtk/mergepe:
- modules/seqtk/mergepe/**
- tests/modules/seqtk/mergepe/**

View file

@ -0,0 +1,13 @@
#!/usr/bin/env nextflow
nextflow.enable.dsl = 2
include { SEQSERO2 } from '../../../modules/seqsero2/main.nf' addParams( options: [args: '-m k -t 4'] )
workflow test_seqsero2 {
input = [ [ id:'test', single_end:false ], // meta map
file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true) ]
SEQSERO2 ( input )
}

View file

@ -0,0 +1,11 @@
- name: seqsero2 test_seqsero2
command: nextflow run tests/modules/seqsero2 -entry test_seqsero2 -c tests/config/nextflow.config
tags:
- seqsero2
files:
- path: output/seqsero2/results/SeqSero_log.txt
md5sum: d00242dfa734b5abb3622a6048f0b4fb
- path: output/seqsero2/results/SeqSero_result.tsv
contains: ['Sample', 'Predicted', 'Note']
- path: output/seqsero2/results/SeqSero_result.txt
contains: ['Sample', 'Predicted', 'Note']