* new raxml module

* new raxml module

* pass in args for bootstrap and add test for support file

* remove unnecessary tag

* ensure tags meet guidleines

* Apply suggestions from code review

* Update to latest functions file

Co-authored-by: avantonder <avt@sanger.ac.uk>
Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com>
This commit is contained in:
Anthony Underwood 2021-04-14 08:38:59 +01:00 committed by GitHub
parent 750bd8c3e3
commit 2ed9b6ae28
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 214 additions and 0 deletions

View file

@ -0,0 +1,70 @@
/*
* -----------------------------------------------------
* 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"
}
}
}

43
software/raxmlng/main.nf Normal file
View file

@ -0,0 +1,43 @@
// Import generic module functions
include { initOptions; saveFiles; getSoftwareName } from './functions'
params.options = [:]
options = initOptions(params.options)
process RAXMLNG {
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:[:], publish_by_meta:[]) }
conda (params.enable_conda ? "bioconda::raxml-ng=1.0.2" : null)
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
container "https://depot.galaxyproject.org/singularity/raxml-ng:1.0.2--h7447c1b_0"
} else {
container "quay.io/biocontainers/raxml-ng:1.0.2--h7447c1b_0"
}
input:
path alignment
output:
path "*.raxml.bestTree", emit: phylogeny
path "*.raxml.support" , optional:true, emit: phylogeny_bootstrapped
path "*.version.txt" , emit: version
script:
def software = getSoftwareName(task.process)
if (options.args.contains('--bs-trees')) {
options.args = "--all ${options.args}"
}
"""
raxml-ng \\
$options.args \\
--msa $alignment \\
--threads $task.cpus \\
--prefix output
echo \$(raxml-ng --version 2>&1) | sed 's/^.*RAxML-NG v. //; s/released.*\$//' > ${software}.version.txt
"""
}

38
software/raxmlng/meta.yml Normal file
View file

@ -0,0 +1,38 @@
name: raxmlng
description: RAxML-NG is a phylogenetic tree inference tool which uses maximum-likelihood (ML) optimality criterion.
keywords:
- phylogeny
- newick
- maximum likelihood
tools:
- raxmlng:
description: RAxML-NG is a phylogenetic tree inference tool which uses maximum-likelihood (ML) optimality criterion.
homepage: https://github.com/amkozlov/raxml-ng
documentation: https://github.com/amkozlov/raxml-ng/wiki
tool_dev_url: https://github.com/amkozlov/raxml-ng
doi: doi.org/10.1093/bioinformatics/btz305
licence: ['GPL v2-or-later']
input:
- alignment:
type: file
description: A FASTA format multiple sequence alignment file
pattern: "*.{fasta,fas,fa,mfa}"
output:
- version:
type: file
description: File containing software version
pattern: "*.{version.txt}"
- phylogeny:
type: file
description: A phylogeny in Newick format
pattern: "*.{raxml.bestTree}"
- phylogeny_bootstrapped:
type: file
description: A phylogeny in Newick format with bootstrap values
pattern: "*.{raxml.support}"
authors:
- "@avantonder"
- "@aunderwo"

View file

@ -427,6 +427,10 @@ rasusa:
- software/rasusa/** - software/rasusa/**
- tests/software/rasusa/** - tests/software/rasusa/**
raxmlng:
- software/raxmlng/**
- tests/software/raxmlng/**
rseqc/bamstat: rseqc/bamstat:
- software/rseqc/bamstat/** - software/rseqc/bamstat/**
- tests/software/rseqc/bamstat/** - tests/software/rseqc/bamstat/**

View file

@ -0,0 +1,28 @@
#!/usr/bin/env nextflow
nextflow.enable.dsl = 2
include { RAXMLNG as RAXMLNG_NO_BOOTSTRAP } from '../../../software/raxmlng/main.nf' addParams( options: [args:'--model GTR+G'] )
include { RAXMLNG as RAXMLNG_BOOTSTRAP } from '../../../software/raxmlng/main.nf' addParams( options: [args:'--model GTR+G --bs-trees 1000'] )
/*
* Test without bootstrapping
*/
workflow test_raxmlng_no_bootstrap {
input = [ file(params.test_data['sarscov2']['genome']['informative_sites_fas'], checkIfExists: true) ]
RAXMLNG_NO_BOOTSTRAP ( input )
}
/*
* Test with bootstrapping
*/
workflow test_raxmlng_bootstrap {
input = [ file(params.test_data['sarscov2']['genome']['informative_sites_fas'], checkIfExists: true) ]
RAXMLNG_BOOTSTRAP ( input )
}

View file

@ -0,0 +1,31 @@
- name: raxmlng no_bootstrap
command: nextflow run ./tests/software/raxmlng -entry test_raxmlng_no_bootstrap -c tests/config/nextflow.config
tags:
- raxmlng
files:
- path: output/raxmlng/output.raxml.bestTree
contains:
- 'sample1:0.359'
- 'sample2:1.50'
- 'sample3:0.000001'
- 'sample4:0.111'
- name: raxmlng bootstrap
command: nextflow run ./tests/software/raxmlng -entry test_raxmlng_bootstrap -c tests/config/nextflow.config
tags:
- raxmlng
files:
- path: output/raxmlng/output.raxml.bestTree
contains:
- 'sample1:0.359'
- 'sample2:1.50'
- 'sample3:0.000001'
- 'sample4:0.111'
- path: output/raxmlng/output.raxml.support
contains:
- 'sample1:0.359'
- 'sample2:1.50'
- 'sample3:0.000001'
- 'sample4:0.111'
contains_regex:
- '\)[89]\d:'