mirror of
https://github.com/MillironX/nf-core_modules.git
synced 2024-12-22 02:58:17 +00:00
adding fasttree module (#412)
* adding fasttree module * correct trailing whitespace * using sarscov2 as a test dir * remove TODO * update test data naming * further test data naming updates * remove options in favour of $options.args * ensure non standard exit codes don't cause an issue * update md5sum
This commit is contained in:
parent
a3684d9594
commit
be390a25e5
9 changed files with 172 additions and 2 deletions
60
software/fasttree/functions.nf
Normal file
60
software/fasttree/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"
|
||||
}
|
||||
}
|
||||
}
|
38
software/fasttree/main.nf
Normal file
38
software/fasttree/main.nf
Normal file
|
@ -0,0 +1,38 @@
|
|||
// Import generic module functions
|
||||
include { initOptions; saveFiles; getSoftwareName } from './functions'
|
||||
|
||||
params.options = [:]
|
||||
options = initOptions(params.options)
|
||||
|
||||
process FASTTREE {
|
||||
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::fasttree=2.1.10" : null)
|
||||
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
|
||||
container "https://depot.galaxyproject.org/singularity/fasttree:2.1.10--h516909a_4"
|
||||
} else {
|
||||
container "quay.io/biocontainers/fasttree:2.1.10--h516909a_4"
|
||||
}
|
||||
|
||||
input:
|
||||
path alignment
|
||||
|
||||
output:
|
||||
path "*.tre", emit: phylogeny
|
||||
path "*.version.txt", emit: version
|
||||
|
||||
script:
|
||||
def software = getSoftwareName(task.process)
|
||||
"""
|
||||
fasttree \\
|
||||
$options.args \\
|
||||
-log fasttree_phylogeny.tre.log \\
|
||||
-nt $alignment \\
|
||||
> fasttree_phylogeny.tre
|
||||
|
||||
echo \$(fasttree -help 2>&1) | head -1 | sed 's/^FastTree \\([0-9\\.]*\\) .*\$/\\1/' > ${software}.version.txt
|
||||
"""
|
||||
}
|
32
software/fasttree/meta.yml
Normal file
32
software/fasttree/meta.yml
Normal file
|
@ -0,0 +1,32 @@
|
|||
name: fasttree
|
||||
description: Produces a Newick format phylogeny from a multiple sequence alignment. Capable of bacterial genome size alignments.
|
||||
keywords:
|
||||
- phylogeny
|
||||
- newick
|
||||
tools:
|
||||
- fasttree:
|
||||
description: FastTree infers approximately-maximum-likelihood phylogenetic trees from alignments of nucleotide or protein sequences
|
||||
homepage: http://www.microbesonline.org/fasttree/
|
||||
documentation: http://www.microbesonline.org/fasttree/#Usage
|
||||
tool_dev_url: None
|
||||
doi: ""
|
||||
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}"
|
||||
|
||||
authors:
|
||||
- "@aunderwo"
|
|
@ -178,6 +178,10 @@ fastqc:
|
|||
- software/fastqc/**
|
||||
- tests/software/fastqc/**
|
||||
|
||||
fasttree:
|
||||
- software/fasttree/**
|
||||
- tests/software/fasttree/**
|
||||
|
||||
fgbio_callmolecularconsensusreads:
|
||||
- software/fgbio/callmolecularconsensusreads/**
|
||||
- tests/software/fgbio/callmolecularconsensusreads/**
|
||||
|
|
|
@ -25,8 +25,9 @@ params {
|
|||
kraken2_tar_gz = "${test_data_dir}/genomics/sarscov2/genome/db/kraken2.tar.gz"
|
||||
|
||||
test_wig_gz = "${test_data_dir}/genomics/sarscov2/genome/gcwiggle/test.wig.gz"
|
||||
|
||||
test_fas = "${test_data_dir}/genomics/sarscov2/genome/alignment/test.fas"
|
||||
|
||||
all_sites_fas = "${test_data_dir}/genomics/sarscov2/genome/alignment/all_sites.fas"
|
||||
informative_sites_fas = "${test_data_dir}/genomics/sarscov2/genome/alignment/informative_sites.fas"
|
||||
}
|
||||
'illumina' {
|
||||
test_single_end_bam = "${test_data_dir}/genomics/sarscov2/illumina/bam/test_single_end.bam"
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,8 @@
|
|||
>sample1
|
||||
CCCCAGCCTTNTTGGTTCCTANNTCTACCCCTCTGTGGNCCGAGATGGGTCTAT
|
||||
>sample2
|
||||
TCTTGTATCCCCCGGCCTTCGGCCTCTAGATTCGCCGCNCTTGCTAAACCTGTG
|
||||
>sample3
|
||||
CCCCGGCCTCTCCGGCCCCTACTTCCACGCCTTTGCGGTTCGAGATGGGTCGTT
|
||||
>sample4
|
||||
TTCCGGCCCCTCCTTCCCCTAGCCCCACGCCCCTGCTCCCCGAGATAACCCGTG
|
12
tests/software/fasttree/main.nf
Normal file
12
tests/software/fasttree/main.nf
Normal file
|
@ -0,0 +1,12 @@
|
|||
#!/usr/bin/env nextflow
|
||||
|
||||
nextflow.enable.dsl = 2
|
||||
|
||||
include { FASTTREE } from '../../../software/fasttree/main.nf' addParams( options: [:] )
|
||||
|
||||
workflow test_fasttree {
|
||||
|
||||
input = [ file(params.test_data['sarscov2']['genome']['informative_sites_fas'], checkIfExists: true) ]
|
||||
|
||||
FASTTREE ( input )
|
||||
}
|
7
tests/software/fasttree/test.yml
Normal file
7
tests/software/fasttree/test.yml
Normal file
|
@ -0,0 +1,7 @@
|
|||
- name: fasttree
|
||||
command: nextflow run ./tests/software/fasttree -entry test_fasttree -c tests/config/nextflow.config
|
||||
tags:
|
||||
- fasttree
|
||||
files:
|
||||
- path: output/fasttree/fasttree_phylogeny.tre
|
||||
md5sum: 63a886117535847c1e66fa4487f3b7d2
|
Loading…
Reference in a new issue