mirror of
https://github.com/MillironX/nf-core_modules.git
synced 2024-12-22 02:58:17 +00:00
add rapidnj module (#421)
* add rapidnj module * remove trailing whitespace * Apply suggestions from code review Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com>
This commit is contained in:
parent
0f53c3b96b
commit
ca776e76a2
6 changed files with 175 additions and 9 deletions
60
software/rapidnj/functions.nf
Normal file
60
software/rapidnj/functions.nf
Normal file
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* -----------------------------------------------------
|
||||
* 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_id = args.publish_by_id ?: false
|
||||
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_id) {
|
||||
path_list.add(args.publish_id)
|
||||
}
|
||||
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"
|
||||
}
|
||||
}
|
||||
}
|
44
software/rapidnj/main.nf
Normal file
44
software/rapidnj/main.nf
Normal file
|
@ -0,0 +1,44 @@
|
|||
// Import generic module functions
|
||||
include { initOptions; saveFiles; getSoftwareName } from './functions'
|
||||
|
||||
params.options = [:]
|
||||
options = initOptions(params.options)
|
||||
|
||||
process RAPIDNJ {
|
||||
label 'process_medium'
|
||||
publishDir "${params.outdir}",
|
||||
mode: params.publish_dir_mode,
|
||||
saveAs: { filename -> saveFiles(filename:filename, options:params.options, publish_dir:getSoftwareName(task.process), publish_id:'') }
|
||||
|
||||
conda (params.enable_conda ? "bioconda::rapidnj=2.3.2 conda-forge::biopython=1.78" : null)
|
||||
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
|
||||
container "https://depot.galaxyproject.org/singularity/mulled-v2-805c6e0f138f952f9c61cdd57c632a1a263ea990:3c52e4c8da6b3e4d69b9ca83fa4d366168898179-0"
|
||||
} else {
|
||||
container "quay.io/biocontainers/mulled-v2-805c6e0f138f952f9c61cdd57c632a1a263ea990:3c52e4c8da6b3e4d69b9ca83fa4d366168898179-0"
|
||||
}
|
||||
|
||||
input:
|
||||
path alignment
|
||||
|
||||
output:
|
||||
path "*.sth" , emit: stockholm_alignment
|
||||
path "*.tre" , emit: phylogeny
|
||||
path "*.version.txt", emit: version
|
||||
|
||||
script:
|
||||
def software = getSoftwareName(task.process)
|
||||
"""
|
||||
python \\
|
||||
-c 'from Bio import SeqIO; SeqIO.convert("$alignment", "fasta", "alignment.sth", "stockholm")'
|
||||
|
||||
rapidnj \\
|
||||
alignment.sth \\
|
||||
$options.args \\
|
||||
-i sth \\
|
||||
-c $task.cpus \\
|
||||
-x rapidnj_phylogeny.tre
|
||||
|
||||
# Doesn't appear to be a way of getting the version number
|
||||
echo 2.3.2 > ${software}.version.txt
|
||||
"""
|
||||
}
|
37
software/rapidnj/meta.yml
Normal file
37
software/rapidnj/meta.yml
Normal file
|
@ -0,0 +1,37 @@
|
|||
name: rapidnj
|
||||
description: Produces a Newick format phylogeny from a multiple sequence alignment using a Neighbour-Joining algorithm. Capable of bacterial genome size alignments.
|
||||
keywords:
|
||||
- phylogeny
|
||||
- newick
|
||||
- neighbour-joining
|
||||
tools:
|
||||
- rapidnj:
|
||||
description: RapidNJ is an algorithmic engineered implementation of canonical neighbour-joining. It uses an efficient search heuristic to speed-up the core computations of the neighbour-joining method that enables RapidNJ to outperform other state-of-the-art neighbour-joining implementations.
|
||||
homepage: https://birc.au.dk/software/rapidnj
|
||||
documentation: https://birc.au.dk/software/rapidnj
|
||||
tool_dev_url: https://github.com/somme89/rapidNJ
|
||||
doi: "doi:10.1007/978-3-540-87361-7_10"
|
||||
licence: ['GPL v2']
|
||||
|
||||
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: "*.{tre}"
|
||||
- stockholm_alignment:
|
||||
type: file
|
||||
description: An alignment in Stockholm format
|
||||
pattern: "*.{sth}"
|
||||
authors:
|
||||
- "@aunderwo"
|
||||
- "@avantonder"
|
|
@ -108,15 +108,6 @@ blast/makeblastdb:
|
|||
- software/blast/makeblastdb/**
|
||||
- tests/software/blast/makeblastdb/**
|
||||
|
||||
bowtie2/align:
|
||||
- software/bowtie2/align/**
|
||||
- software/bowtie2/build/**
|
||||
- tests/software/bowtie2/align/**
|
||||
|
||||
bowtie2/build:
|
||||
- software/bowtie2/build/**
|
||||
- tests/software/bowtie2/build_test/**
|
||||
|
||||
bowtie/align:
|
||||
- software/bowtie/align/**
|
||||
- software/bowtie/build/**
|
||||
|
@ -126,6 +117,15 @@ bowtie/build:
|
|||
- software/bowtie/build/**
|
||||
- tests/software/bowtie/build_test/**
|
||||
|
||||
bowtie2/align:
|
||||
- software/bowtie2/align/**
|
||||
- software/bowtie2/build/**
|
||||
- tests/software/bowtie2/align/**
|
||||
|
||||
bowtie2/build:
|
||||
- software/bowtie2/build/**
|
||||
- tests/software/bowtie2/build_test/**
|
||||
|
||||
bwa/index:
|
||||
- software/bwa/index/**
|
||||
- tests/software/bwa/index/**
|
||||
|
@ -386,6 +386,10 @@ quast:
|
|||
- software/quast/**
|
||||
- tests/software/quast/**
|
||||
|
||||
rapidnj:
|
||||
- software/rapidnj/**
|
||||
- tests/software/rapidnj/**
|
||||
|
||||
salmon/index:
|
||||
- software/salmon/index/**
|
||||
- tests/software/salmon/index/**
|
||||
|
|
12
tests/software/rapidnj/main.nf
Normal file
12
tests/software/rapidnj/main.nf
Normal file
|
@ -0,0 +1,12 @@
|
|||
#!/usr/bin/env nextflow
|
||||
|
||||
nextflow.enable.dsl = 2
|
||||
|
||||
include { RAPIDNJ } from '../../../software/rapidnj/main.nf' addParams( options: [:] )
|
||||
|
||||
workflow test_rapidnj {
|
||||
|
||||
input = [ file(params.test_data['sarscov2']['genome']['informative_sites_fas'], checkIfExists: true) ]
|
||||
|
||||
RAPIDNJ ( input )
|
||||
}
|
9
tests/software/rapidnj/test.yml
Normal file
9
tests/software/rapidnj/test.yml
Normal file
|
@ -0,0 +1,9 @@
|
|||
- name: rapidnj
|
||||
command: nextflow run ./tests/software/rapidnj -entry test_rapidnj -c tests/config/nextflow.config
|
||||
tags:
|
||||
- rapidnj
|
||||
files:
|
||||
- path: output/rapidnj/alignment.sth
|
||||
md5sum: d2e995c5dd3e3a8212a98414ae5b5de7
|
||||
- path: output/rapidnj/rapidnj_phylogeny.tre
|
||||
md5sum: 775909ea40138101976592cfa1814a1d
|
Loading…
Reference in a new issue