mirror of
https://github.com/MillironX/nf-core_modules.git
synced 2025-01-02 20:52:07 -05:00
add clonalframeml module (#974)
* add clonalframeml module * Update main.nf * try recommended gzip * Update main.nf Co-authored-by: Chris Cheshire <chris.j.cheshire@gmail.com>
This commit is contained in:
parent
13b8a16f4a
commit
c2bba7a65d
6 changed files with 226 additions and 1 deletions
78
modules/clonalframeml/functions.nf
Normal file
78
modules/clonalframeml/functions.nf
Normal 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"
|
||||||
|
}
|
||||||
|
}
|
47
modules/clonalframeml/main.nf
Normal file
47
modules/clonalframeml/main.nf
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
// Import generic module functions
|
||||||
|
include { initOptions; saveFiles; getSoftwareName; getProcessName } from './functions'
|
||||||
|
|
||||||
|
params.options = [:]
|
||||||
|
options = initOptions(params.options)
|
||||||
|
|
||||||
|
process CLONALFRAMEML {
|
||||||
|
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::clonalframeml=1.12" : null)
|
||||||
|
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
|
||||||
|
container "https://depot.galaxyproject.org/singularity/clonalframeml:1.12--h7d875b9_1"
|
||||||
|
} else {
|
||||||
|
container "quay.io/biocontainers/clonalframeml:1.12--h7d875b9_1"
|
||||||
|
}
|
||||||
|
|
||||||
|
input:
|
||||||
|
tuple val(meta), path(newick), path(msa)
|
||||||
|
|
||||||
|
output:
|
||||||
|
tuple val(meta), path("*.emsim.txt") , emit: emsim, optional: true
|
||||||
|
tuple val(meta), path("*.em.txt") , emit: em
|
||||||
|
tuple val(meta), path("*.importation_status.txt") , emit: status
|
||||||
|
tuple val(meta), path("*.labelled_tree.newick") , emit: newick
|
||||||
|
tuple val(meta), path("*.ML_sequence.fasta") , emit: fasta
|
||||||
|
tuple val(meta), path("*.position_cross_reference.txt"), emit: pos_ref
|
||||||
|
path "versions.yml" , emit: versions
|
||||||
|
|
||||||
|
script:
|
||||||
|
def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
|
||||||
|
"""
|
||||||
|
ClonalFrameML \\
|
||||||
|
$newick \\
|
||||||
|
<(gzip -cdf $msa) \\
|
||||||
|
$prefix \\
|
||||||
|
$options.args
|
||||||
|
|
||||||
|
cat <<-END_VERSIONS > versions.yml
|
||||||
|
${getProcessName(task.process)}:
|
||||||
|
${getSoftwareName(task.process)}: \$( echo \$(ClonalFrameML -version 2>&1) | sed 's/^.*ClonalFrameML v//' )
|
||||||
|
END_VERSIONS
|
||||||
|
"""
|
||||||
|
}
|
67
modules/clonalframeml/meta.yml
Normal file
67
modules/clonalframeml/meta.yml
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
name: clonalframeml
|
||||||
|
description: Predict recomination events in bacterial genomes
|
||||||
|
keywords:
|
||||||
|
- fasta
|
||||||
|
- multiple sequence alignment
|
||||||
|
- recombination
|
||||||
|
tools:
|
||||||
|
- clonalframeml:
|
||||||
|
description: Efficient inferencing of recombination in bacterial genomes
|
||||||
|
homepage: https://github.com/xavierdidelot/ClonalFrameML
|
||||||
|
documentation: https://github.com/xavierdidelot/clonalframeml/wiki
|
||||||
|
tool_dev_url: https://github.com/xavierdidelot/ClonalFrameML
|
||||||
|
doi: "10.1371/journal.pcbi.1004041"
|
||||||
|
licence: ['GPL v3']
|
||||||
|
|
||||||
|
input:
|
||||||
|
- meta:
|
||||||
|
type: map
|
||||||
|
description: |
|
||||||
|
Groovy Map containing sample information
|
||||||
|
e.g. [ id:'test', single_end:false ]
|
||||||
|
- msa:
|
||||||
|
type: file
|
||||||
|
description: A multiple seqeunce alignmnet in FASTA format
|
||||||
|
pattern: "*.{fasta,fasta.gz,fa,fa.gz,fna,fna.gz}"
|
||||||
|
- newick:
|
||||||
|
type: file
|
||||||
|
description: A Newick formated tree based on multiple sequence alignment
|
||||||
|
pattern: "*.{newick,treefile,dnd}"
|
||||||
|
|
||||||
|
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"
|
||||||
|
- emsim:
|
||||||
|
type: file
|
||||||
|
description: Bootstrapped values for the three parameters R/theta, nu and delta
|
||||||
|
pattern: "*.emsim.txt"
|
||||||
|
- em:
|
||||||
|
type: file
|
||||||
|
description: Point estimates for R/theta, nu, delta and the branch lengths
|
||||||
|
pattern: "*.em.txt"
|
||||||
|
- fasta:
|
||||||
|
type: file
|
||||||
|
description: Sequence reconstructed by maximum likelihood
|
||||||
|
pattern: "*.ML_sequence.fasta"
|
||||||
|
- newick:
|
||||||
|
type: file
|
||||||
|
description: Tree with all nodes labelled
|
||||||
|
pattern: "*.labelled_tree.newick"
|
||||||
|
- pos_ref:
|
||||||
|
type: file
|
||||||
|
description: CSV mapping input sequence files to the sequences in the *.ML_sequence.fasta
|
||||||
|
pattern: "*.position_cross_reference.txt"
|
||||||
|
- status:
|
||||||
|
type: file
|
||||||
|
description: List of reconstructed recombination events
|
||||||
|
pattern: "*.importation_status.txt"
|
||||||
|
|
||||||
|
authors:
|
||||||
|
- "@rpetit3"
|
|
@ -282,6 +282,10 @@ chromap/index:
|
||||||
- modules/chromap/index/**
|
- modules/chromap/index/**
|
||||||
- tests/modules/chromap/index/**
|
- tests/modules/chromap/index/**
|
||||||
|
|
||||||
|
clonalframeml:
|
||||||
|
- modules/clonalframeml/**
|
||||||
|
- tests/modules/clonalframeml/**
|
||||||
|
|
||||||
cmseq/polymut:
|
cmseq/polymut:
|
||||||
- modules/cmseq/polymut/**
|
- modules/cmseq/polymut/**
|
||||||
- tests/modules/cmseq/polymut/**
|
- tests/modules/cmseq/polymut/**
|
||||||
|
@ -1210,7 +1214,7 @@ seacr/callpeak:
|
||||||
seqkit/split2:
|
seqkit/split2:
|
||||||
- modules/seqkit/split2/**
|
- modules/seqkit/split2/**
|
||||||
- tests/modules/seqkit/split2/**
|
- tests/modules/seqkit/split2/**
|
||||||
|
|
||||||
seqsero2:
|
seqsero2:
|
||||||
- modules/seqsero2/**
|
- modules/seqsero2/**
|
||||||
- tests/modules/seqsero2/**
|
- tests/modules/seqsero2/**
|
||||||
|
|
14
tests/modules/clonalframeml/main.nf
Normal file
14
tests/modules/clonalframeml/main.nf
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
#!/usr/bin/env nextflow
|
||||||
|
|
||||||
|
nextflow.enable.dsl = 2
|
||||||
|
|
||||||
|
include { CLONALFRAMEML } from '../../../modules/clonalframeml/main.nf' addParams( options: [:] )
|
||||||
|
|
||||||
|
workflow test_clonalframeml {
|
||||||
|
|
||||||
|
input = [ [ id:'test' ], // meta map
|
||||||
|
file("https://github.com/bactopia/bactopia-tests/raw/main/data/species/haemophilus_influenzae/genome/genome_msa.newick", checkIfExists: true),
|
||||||
|
file("https://github.com/bactopia/bactopia-tests/raw/main/data/species/haemophilus_influenzae/genome/genome_msa.fa.gz", checkIfExists: true),]
|
||||||
|
|
||||||
|
CLONALFRAMEML ( input )
|
||||||
|
}
|
15
tests/modules/clonalframeml/test.yml
Normal file
15
tests/modules/clonalframeml/test.yml
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
- name: clonalframeml test_clonalframeml
|
||||||
|
command: nextflow run tests/modules/clonalframeml -entry test_clonalframeml -c tests/config/nextflow.config
|
||||||
|
tags:
|
||||||
|
- clonalframeml
|
||||||
|
files:
|
||||||
|
- path: output/clonalframeml/test.ML_sequence.fasta
|
||||||
|
md5sum: 1b75cdaea78f5920ebb92125422a2589
|
||||||
|
- path: output/clonalframeml/test.em.txt
|
||||||
|
md5sum: 5439d59897a9a90390bb175207bf2b9b
|
||||||
|
- path: output/clonalframeml/test.importation_status.txt
|
||||||
|
md5sum: 6ce9dbc7746b1c884af042fa02311fba
|
||||||
|
- path: output/clonalframeml/test.labelled_tree.newick
|
||||||
|
md5sum: aa47754eea8a3b6bab56bd7c83ba78db
|
||||||
|
- path: output/clonalframeml/test.position_cross_reference.txt
|
||||||
|
md5sum: 8ff60768b348fc6f7a1e787aca72f596
|
Loading…
Reference in a new issue