mirror of
https://github.com/MillironX/nf-core_modules.git
synced 2024-12-22 02:58:17 +00:00
add Amps (#768)
* Specify more guidelines on input channels * Linting * Updates based on code review * Update README.md * Fix broken sentence * Start work, continue once on non-mobile internet * finished and working on conda * Update modules/amps/main.nf Co-authored-by: Jose Espinosa-Carrasco <kadomu@gmail.com> * Apply suggestions from code review Co-authored-by: Jose Espinosa-Carrasco <kadomu@gmail.com> Co-authored-by: Jose Espinosa-Carrasco <kadomu@gmail.com>
This commit is contained in:
parent
216dc8c984
commit
01cc326c23
6 changed files with 238 additions and 0 deletions
78
modules/amps/functions.nf
Normal file
78
modules/amps/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/amps/main.nf
Normal file
47
modules/amps/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 AMPS {
|
||||
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:[:], publish_by_meta:[]) }
|
||||
|
||||
conda (params.enable_conda ? "bioconda::hops=0.35" : null)
|
||||
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
|
||||
container "https://depot.galaxyproject.org/singularity/hops:0.35--hdfd78af_1"
|
||||
} else {
|
||||
container "quay.io/biocontainers/hops:0.35--hdfd78af_1"
|
||||
}
|
||||
|
||||
input:
|
||||
path maltextract_results
|
||||
path taxon_list
|
||||
val filter
|
||||
|
||||
output:
|
||||
path "results/heatmap_overview_Wevid.json" , emit: json
|
||||
path "results/heatmap_overview_Wevid.pdf" , emit: summary_pdf
|
||||
path "results/heatmap_overview_Wevid.tsv" , emit: tsv
|
||||
path "results/pdf_candidate_profiles/" , emit: candidate_pdfs
|
||||
path "versions.yml" , emit: version
|
||||
|
||||
script:
|
||||
"""
|
||||
postprocessing.AMPS.r \\
|
||||
-r $maltextract_results \\
|
||||
-n $taxon_list \\
|
||||
-m $filter \\
|
||||
-t $task.cpus \\
|
||||
-j \\
|
||||
$options.args
|
||||
|
||||
cat <<-END_VERSIONS > versions.yml
|
||||
${getProcessName(task.process)}:
|
||||
amps: \$(echo \$(hops --version 2>&1) | sed 's/HOPS version//')
|
||||
END_VERSIONS
|
||||
"""
|
||||
}
|
66
modules/amps/meta.yml
Normal file
66
modules/amps/meta.yml
Normal file
|
@ -0,0 +1,66 @@
|
|||
name: amps
|
||||
description: Post-processing script of the MaltExtract component of the HOPS package
|
||||
keywords:
|
||||
- malt
|
||||
- MaltExtract
|
||||
- HOPS
|
||||
- amps
|
||||
- alignment
|
||||
- metagenomics
|
||||
- ancient DNA
|
||||
- aDNA
|
||||
- palaeogenomics
|
||||
- archaeogenomics
|
||||
- microbiome
|
||||
- authentication
|
||||
- damage
|
||||
- edit distance
|
||||
- post Post-processing
|
||||
- visualisation
|
||||
tools:
|
||||
- amps:
|
||||
description: Post-processing script of the MaltExtract tool for ancient metagenomics
|
||||
homepage: "https://github.com/rhuebler/HOPS"
|
||||
documentation: "https://github.com/keyfm/amps"
|
||||
tool_dev_url: "https://github.com/keyfm/amps"
|
||||
doi: "10.1186/s13059-019-1903-0"
|
||||
licence: ['GPL >=3']
|
||||
|
||||
input:
|
||||
- maltextract_results:
|
||||
type: directory
|
||||
description: MaltExtract output directory
|
||||
pattern: "results/"
|
||||
- taxon_list:
|
||||
type: file
|
||||
description: List of target taxa to evaluate used in MaltExtract
|
||||
pattern: "*.txt"
|
||||
- filter:
|
||||
type: string
|
||||
description: The filter mode used in MaltExtract
|
||||
pattern: "def_anc|default|scan|ancient|crawl"
|
||||
|
||||
output:
|
||||
- version:
|
||||
type: file
|
||||
description: File containing software version
|
||||
pattern: "versions.yml"
|
||||
- json:
|
||||
type: file
|
||||
description: Candidate summary heatmap in MultiQC compatible JSON format
|
||||
pattern: "heatmap_overview_Wevid.json"
|
||||
- summary_pdf:
|
||||
type: file
|
||||
description: Candidate summary heatmap in PDF format
|
||||
pattern: "heatmap_overview_Wevid.pdf"
|
||||
- tsv:
|
||||
type: file
|
||||
description: Candidate summary heatmap in TSV format
|
||||
pattern: "heatmap_overview_Wevid.tsv"
|
||||
- candidate_pdfs:
|
||||
type: directory
|
||||
description: Directory of per sample output PDFs organised by reference
|
||||
pattern: "pdf_candidate_profiles/"
|
||||
|
||||
authors:
|
||||
- "@jfy133"
|
|
@ -14,6 +14,10 @@ allelecounter:
|
|||
- modules/allelecounter/**
|
||||
- tests/modules/allelecounter/**
|
||||
|
||||
amps:
|
||||
- modules/amps/**
|
||||
- tests/modules/amps/**
|
||||
|
||||
arriba:
|
||||
- modules/arriba/**
|
||||
- tests/modules/arriba/**
|
||||
|
|
32
tests/modules/amps/main.nf
Normal file
32
tests/modules/amps/main.nf
Normal file
|
@ -0,0 +1,32 @@
|
|||
#!/usr/bin/env nextflow
|
||||
|
||||
nextflow.enable.dsl = 2
|
||||
|
||||
include { UNZIP as UNZIP_MALT } from '../../../modules/unzip/main.nf' addParams( options: [:] )
|
||||
include { UNZIP as UNZIP_MALTEXTRACT } from '../../../modules/unzip/main.nf' addParams( options: [:] )
|
||||
include { MALT_BUILD } from '../../../modules/malt/build/main.nf' addParams( options: [:] )
|
||||
include { MALT_RUN } from '../../../modules/malt/run/main.nf' addParams( options: [:] )
|
||||
include { MALTEXTRACT } from '../../../modules/maltextract/main.nf' addParams( options: [args: "-f def_anc"] )
|
||||
include { AMPS } from '../../../modules/amps/main.nf' addParams( options: [:] )
|
||||
|
||||
|
||||
workflow test_amps {
|
||||
|
||||
fastas = file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true)
|
||||
gff = []
|
||||
seq_type = "DNA"
|
||||
map_db = file("https://software-ab.informatik.uni-tuebingen.de/download/megan6/megan-nucl-Jan2021.db.zip", checkIfExists: true)
|
||||
input = file(params.test_data['sarscov2']['illumina']['test_1_fastq_gz'], checkIfExists: true)
|
||||
mode = "BlastN"
|
||||
taxon_list = file(params.test_data['sarscov2']['genome']['taxon_list_txt'], checkIfExists: true)
|
||||
ncbi_dir = file(params.test_data['sarscov2']['genome']['ncbi_taxmap_zip'], checkIfExists: true)
|
||||
filter = "def_anc"
|
||||
|
||||
UNZIP_MALT ( map_db )
|
||||
UNZIP_MALTEXTRACT ( ncbi_dir )
|
||||
MALT_BUILD ( fastas, seq_type, gff, UNZIP_MALT.out.unzipped_archive )
|
||||
MALT_RUN ( input, mode, MALT_BUILD.out.index )
|
||||
MALTEXTRACT ( MALT_RUN.out.rma6, taxon_list, UNZIP_MALTEXTRACT.out.unzipped_archive)
|
||||
|
||||
AMPS ( MALTEXTRACT.out.results, taxon_list, filter )
|
||||
}
|
11
tests/modules/amps/test.yml
Normal file
11
tests/modules/amps/test.yml
Normal file
|
@ -0,0 +1,11 @@
|
|||
- name: amps
|
||||
command: nextflow run ./tests/modules/amps -entry test_amps -c tests/config/nextflow.config
|
||||
tags:
|
||||
- amps
|
||||
files:
|
||||
- path: output/amps/results/heatmap_overview_Wevid.json
|
||||
md5sum: 82f484d02a9e3d0cc3d5bcdcc2965e44
|
||||
- path: output/amps/results/heatmap_overview_Wevid.pdf
|
||||
- path: output/amps/results/heatmap_overview_Wevid.tsv
|
||||
md5sum: 1a7d565a37ef4d6054f7ade63fbadc2f
|
||||
- path: output/amps/results/pdf_candidate_profiles/Severe_acute_respiratory_syndrome_coronavirus_2/stp1_test_1.rma6_Severe_acute_respiratory_syndrome_coronavirus_2_summary.pdf
|
Loading…
Reference in a new issue