mirror of
https://github.com/MillironX/nf-core_modules.git
synced 2025-01-02 20:52:07 -05:00
add new iqtree module (#427)
* add new iqtree module * Resolve suggests after PR review * add newline to functions
This commit is contained in:
parent
65a3422686
commit
575df10781
6 changed files with 175 additions and 0 deletions
70
software/iqtree/functions.nf
Normal file
70
software/iqtree/functions.nf
Normal 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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
44
software/iqtree/main.nf
Normal file
44
software/iqtree/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 IQTREE {
|
||||||
|
tag "$variant_alignment"
|
||||||
|
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::iqtree=2.1.2" : null)
|
||||||
|
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
|
||||||
|
container "https://depot.galaxyproject.org/singularity/iqtree:2.1.2--h56fc30b_0"
|
||||||
|
} else {
|
||||||
|
container "quay.io/biocontainers/iqtree:2.1.2--h56fc30b_0"
|
||||||
|
}
|
||||||
|
|
||||||
|
input:
|
||||||
|
path alignment
|
||||||
|
val constant_sites
|
||||||
|
|
||||||
|
output:
|
||||||
|
path "*.treefile", emit: phylogeny
|
||||||
|
path "*.version.txt", emit: version
|
||||||
|
|
||||||
|
script:
|
||||||
|
def software = getSoftwareName(task.process)
|
||||||
|
def fconst_args = constant_sites ? '-fconst $constant_sites' : ''
|
||||||
|
def memory = task.memory.toString().replaceAll(' ', '')
|
||||||
|
"""
|
||||||
|
iqtree \\
|
||||||
|
$fconst_args \\
|
||||||
|
$options.args \\
|
||||||
|
-s $alignment \\
|
||||||
|
-nt AUTO \\
|
||||||
|
-ntmax $task.cpus \\
|
||||||
|
-mem $memory \\
|
||||||
|
|
||||||
|
echo \$(iqtree -version 2>&1) | sed 's/^IQ-TREE multicore version \\([0-9\\.]*\\) .*\$/\\1/' > ${software}.version.txt
|
||||||
|
"""
|
||||||
|
}
|
34
software/iqtree/meta.yml
Normal file
34
software/iqtree/meta.yml
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
name: iqtree
|
||||||
|
description: Produces a Newick format phylogeny from a multiple sequence alignment using the maxium likelihood algorithm. Capable of bacterial genome size alignments.
|
||||||
|
keywords:
|
||||||
|
- phylogeny
|
||||||
|
- newick
|
||||||
|
- maximum likelihood
|
||||||
|
tools:
|
||||||
|
- iqtree:
|
||||||
|
description: Efficient phylogenomic software by maximum likelihood.
|
||||||
|
homepage: http://www.iqtree.org
|
||||||
|
documentation: http://www.iqtree.org/doc
|
||||||
|
tool_dev_url: https://github.com/iqtree/iqtree2
|
||||||
|
doi: doi.org/10.1093/molbev/msaa015
|
||||||
|
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: "*.{treefile}"
|
||||||
|
|
||||||
|
authors:
|
||||||
|
- "@avantonder"
|
||||||
|
- "@aunderwo"
|
|
@ -277,6 +277,10 @@ homer/annotatepeaks:
|
||||||
- software/homer/annotatepeaks/**
|
- software/homer/annotatepeaks/**
|
||||||
- tests/software/homer/annotatepeaks/**
|
- tests/software/homer/annotatepeaks/**
|
||||||
|
|
||||||
|
iqtree:
|
||||||
|
- software/iqtree/**
|
||||||
|
- tests/software/iqtree/**
|
||||||
|
|
||||||
ivar/consensus:
|
ivar/consensus:
|
||||||
- software/ivar/consensus/**
|
- software/ivar/consensus/**
|
||||||
- tests/software/ivar/consensus/**
|
- tests/software/ivar/consensus/**
|
||||||
|
|
12
tests/software/iqtree/main.nf
Normal file
12
tests/software/iqtree/main.nf
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
#!/usr/bin/env nextflow
|
||||||
|
|
||||||
|
nextflow.enable.dsl = 2
|
||||||
|
|
||||||
|
include { IQTREE } from '../../../software/iqtree/main.nf' addParams( options: [:] )
|
||||||
|
|
||||||
|
workflow test_iqtree {
|
||||||
|
|
||||||
|
input = [ file(params.test_data['sarscov2']['genome']['informative_sites_fas'], checkIfExists: true) ]
|
||||||
|
|
||||||
|
IQTREE ( input, '' )
|
||||||
|
}
|
11
tests/software/iqtree/test.yml
Normal file
11
tests/software/iqtree/test.yml
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
- name: iqtree
|
||||||
|
command: nextflow run ./tests/software/iqtree -entry test_iqtree -c tests/config/nextflow.config
|
||||||
|
tags:
|
||||||
|
- iqtree
|
||||||
|
files:
|
||||||
|
- path: output/iqtree/informative_sites.fas.treefile
|
||||||
|
contains:
|
||||||
|
- '(sample1:0.002'
|
||||||
|
- '(sample2:0.005'
|
||||||
|
- 'sample3:0.0005'
|
||||||
|
- 'sample4:0.001'
|
Loading…
Reference in a new issue