add roary module (#776)

* add module roary

* Update meta.yml

* Update meta.yml

* Update meta.yml

* Update meta.yml

* Update main.nf

* Update meta.yml

* Apply suggestions from code review

Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com>
This commit is contained in:
Robert A. Petit III 2021-10-05 15:08:47 -06:00 committed by GitHub
parent 8d04c34934
commit 0ba88fb869
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 227 additions and 0 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"
}
}

43
modules/roary/main.nf Normal file
View file

@ -0,0 +1,43 @@
// Import generic module functions
include { initOptions; saveFiles; getSoftwareName; getProcessName } from './functions'
params.options = [:]
options = initOptions(params.options)
process ROARY {
tag "$meta.id"
label 'process_medium'
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::roary=3.13.0" : null)
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
container "https://depot.galaxyproject.org/singularity/roary:3.13.0--pl526h516909a_0"
} else {
container "quay.io/biocontainers/roary:3.13.0--pl526h516909a_0"
}
input:
tuple val(meta), path(gff)
output:
tuple val(meta), path("results/*") , emit: results
tuple val(meta), path("results/*.aln"), optional: true, emit: aln
path "versions.yml" , emit: versions
script:
def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
"""
roary \\
$options.args \\
-p $task.cpus \\
-f results/ \\
$gff
cat <<-END_VERSIONS > versions.yml
${getProcessName(task.process)}:
${getSoftwareName(task.process)}: \$( roary --version )
END_VERSIONS
"""
}

47
modules/roary/meta.yml Normal file
View file

@ -0,0 +1,47 @@
name: roary
description: Calculate pan-genome from annotated bacterial assemblies in GFF3 format
keywords:
- gff
- pan-genome
- alignment
tools:
- roary:
description: Rapid large-scale prokaryote pan genome analysis
homepage: http://sanger-pathogens.github.io/Roary/
documentation: http://sanger-pathogens.github.io/Roary/
tool_dev_url: https://github.com/sanger-pathogens/Roary/
doi: "http://dx.doi.org/10.1093/bioinformatics/btv421"
licence: ['GPL v3']
input:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- gff:
type: file
description: A set of GFF3 formatted files
pattern: "*.{gff}"
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"
- results:
type: directory
description: Directory containing Roary result files
pattern: "*/*"
- aln:
type: file
description: Core-genome alignment produced by Roary (Optional)
pattern: "*.{aln}"
authors:
- "@rpetit3"

View file

@ -811,6 +811,10 @@ raxmlng:
- modules/raxmlng/**
- tests/modules/raxmlng/**
roary:
- modules/roary/**
- tests/modules/roary/**
rsem/calculateexpression:
- modules/rsem/calculateexpression/**
- tests/modules/rsem/calculateexpression/**

View file

@ -0,0 +1,16 @@
#!/usr/bin/env nextflow
nextflow.enable.dsl = 2
include { ROARY } from '../../../modules/roary/main.nf' addParams( options: [:] )
workflow test_roary {
input = [ [ id:'test', single_end:false ], // meta map
[ file("https://github.com/bactopia/bactopia-tests/raw/main/data/reference/gff/GCF_000292685.gff", checkIfExists: true),
file("https://github.com/bactopia/bactopia-tests/raw/main/data/reference/gff/GCF_000298385.gff", checkIfExists: true),
file("https://github.com/bactopia/bactopia-tests/raw/main/data/reference/gff/GCF_002849995.gff", checkIfExists: true) ]
]
ROARY ( input )
}

View file

@ -0,0 +1,39 @@
- name: roary test_roary
command: nextflow run tests/modules/roary -entry test_roary -c tests/config/nextflow.config
tags:
- roary
files:
- path: output/roary/results/accessory.header.embl
contains: ['ID Genome standard; DNA; PRO; 1234 BP.']
- path: output/roary/results/accessory.tab
contains: ['FT']
- path: output/roary/results/accessory_binary_genes.fa
md5sum: 0baeea4947bf17a2bf29d43a44f0278f
- path: output/roary/results/accessory_binary_genes.fa.newick
md5sum: b1f8c76ab231bd38b850c1f8d3c1584b
- path: output/roary/results/accessory_graph.dot
contains: ['/* list of nodes */']
- path: output/roary/results/blast_identity_frequency.Rtab
md5sum: 829baa25c3fad94b1af207265452a692
- path: output/roary/results/clustered_proteins
contains: ['JKHLNHAL_00087']
- path: output/roary/results/core_accessory.header.embl
contains: ['ID Genome standard; DNA; PRO; 1234 BP.']
- path: output/roary/results/core_accessory.tab
contains: ['FT /taxa="GCF_000292685 GCF_000298385 GCF_002849995"']
- path: output/roary/results/core_accessory_graph.dot
contains: ['/* list of nodes */']
- path: output/roary/results/gene_presence_absence.Rtab
contains: ['Gene']
- path: output/roary/results/gene_presence_absence.csv
contains: ['"Gene","Non-unique Gene name","Annotation","No. isolates","No. sequences"']
- path: output/roary/results/number_of_conserved_genes.Rtab
contains: ['279']
- path: output/roary/results/number_of_genes_in_pan_genome.Rtab
contains: ['279']
- path: output/roary/results/number_of_new_genes.Rtab
contains: ['279']
- path: output/roary/results/number_of_unique_genes.Rtab
contains: ['279']
- path: output/roary/results/summary_statistics.txt
md5sum: 3921b5445df6a7ed59408119b8860a58