add: MALTEXTRACT (#725)

* Specify more guidelines on input channels

* Linting

* Updates based on code review

* Update README.md

* Fix broken sentence

* Start maltextract module

* start tests

* Get tests working now we have test data

* Apply suggestions from code review

Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com>

* Changes after review

* Update tests/modules/maltextract/main.nf

Co-authored-by: Jose Espinosa-Carrasco <kadomu@gmail.com>

* Update tests/modules/maltextract/main.nf

Co-authored-by: Jose Espinosa-Carrasco <kadomu@gmail.com>

* Update tests/modules/maltextract/main.nf

Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com>
Co-authored-by: Jose Espinosa-Carrasco <kadomu@gmail.com>
This commit is contained in:
James A. Fellows Yates 2021-09-21 20:57:27 +02:00 committed by GitHub
parent 1d6f47ce54
commit 7830a4a80c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 208 additions and 1 deletions

View file

@ -0,0 +1,68 @@
//
// 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"
}
}
}

View file

@ -0,0 +1,44 @@
// Import generic module functions
include { initOptions; saveFiles; getSoftwareName } from './functions'
params.options = [:]
options = initOptions(params.options)
process MALTEXTRACT {
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::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 rma6
path taxon_list
path ncbi_dir
output:
path "results" , emit: results
path "*.version.txt", emit: version
script:
def software = getSoftwareName(task.process)
"""
MaltExtract \\
-Xmx${task.memory.toGiga()}g \\
-p $task.cpus \\
-i ${rma6.join(' ')} \\
-t $taxon_list \\
-r $ncbi_dir \\
-o results/ \\
$options.args
echo \$(MaltExtract --help | head -n 2 | tail -n 1) | sed 's/MaltExtract version//' > ${software}.version.txt
"""
}

View file

@ -0,0 +1,51 @@
name: maltextract
description: Tool for evaluation of MALT results for true positives of ancient metagenomic taxonomic screening
keywords:
- malt
- MaltExtract
- HOPS
- alignment
- metagenomics
- ancient DNA
- aDNA
- palaeogenomics
- archaeogenomics
- microbiome
- authentication
- damage
- edit distance
tools:
- maltextract:
description: Java tool to work with ancient metagenomics
homepage: https://github.com/rhuebler/hops
documentation: https://github.com/rhuebler/hops
tool_dev_url: https://github.com/rhuebler/hops
doi: "https://doi.org/10.1186/s13059-019-1903-0"
licence: ['GPL 3']
input:
- rma6:
type: file
description: RMA6 files from MALT
pattern: "*.rma6"
- taxon_list:
type: file
description: List of target taxa to evaluate
pattern: "*.txt"
- ncbi_dir:
type: directory
description: Directory containing NCBI taxonomy map and tre files
pattern: "${ncbi_dir}/"
output:
- version:
type: file
description: File containing software version
pattern: "*.{version.txt}"
- results:
type: directory
description: Directory containing MaltExtract text results files
pattern: "*.rma6"
authors:
- "@jfy133"

View file

@ -562,6 +562,10 @@ malt/run:
- modules/malt/run/** - modules/malt/run/**
- tests/modules/malt/run/** - tests/modules/malt/run/**
maltextract:
- modules/maltextract/**
- tests/modules/maltextract/**
mash/sketch: mash/sketch:
- modules/mash/sketch/** - modules/mash/sketch/**
- tests/modules/mash/sketch/** - tests/modules/mash/sketch/**

View file

@ -7,7 +7,6 @@ params {
'genome' { 'genome' {
genome_fasta = "${test_data_dir}/genomics/sarscov2/genome/genome.fasta" genome_fasta = "${test_data_dir}/genomics/sarscov2/genome/genome.fasta"
genome_fasta_fai = "${test_data_dir}/genomics/sarscov2/genome/genome.fasta.fai" genome_fasta_fai = "${test_data_dir}/genomics/sarscov2/genome/genome.fasta.fai"
genome_fasta_zip = "${test_data_dir}/genomics/sarscov2/genome/genome.fasta.zip"
genome_dict = "${test_data_dir}/genomics/sarscov2/genome/genome.dict" genome_dict = "${test_data_dir}/genomics/sarscov2/genome/genome.dict"
genome_gff3 = "${test_data_dir}/genomics/sarscov2/genome/genome.gff3" genome_gff3 = "${test_data_dir}/genomics/sarscov2/genome/genome.gff3"
genome_gff3_gz = "${test_data_dir}/genomics/sarscov2/genome/genome.gff3.gz" genome_gff3_gz = "${test_data_dir}/genomics/sarscov2/genome/genome.gff3.gz"
@ -25,6 +24,9 @@ params {
kraken2 = "${test_data_dir}/genomics/sarscov2/genome/db/kraken2" kraken2 = "${test_data_dir}/genomics/sarscov2/genome/db/kraken2"
kraken2_tar_gz = "${test_data_dir}/genomics/sarscov2/genome/db/kraken2.tar.gz" kraken2_tar_gz = "${test_data_dir}/genomics/sarscov2/genome/db/kraken2.tar.gz"
ncbi_taxmap_zip = "${test_data_dir}/genomics/sarscov2/genome/db/maltextract/ncbi_taxmap.zip"
taxon_list_txt = "${test_data_dir}/genomics/sarscov2/genome/db/maltextract/taxon_list.txt"
all_sites_fas = "${test_data_dir}/genomics/sarscov2/genome/alignment/all_sites.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" informative_sites_fas = "${test_data_dir}/genomics/sarscov2/genome/alignment/informative_sites.fas"

View file

@ -0,0 +1,27 @@
#!/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: [:] )
workflow test_maltextract {
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)
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)
}

View file

@ -0,0 +1,11 @@
- name: maltextract
command: nextflow run ./tests/modules/maltextract -entry test_maltextract -c tests/config/nextflow.config
tags:
- maltextract
files:
- path: output/maltextract/results/error.txt
md5sum: d41d8cd98f00b204e9800998ecf8427e
- path: output/maltextract/results/error.txt
- path: output/maltextract/results/log.txt
contains:
- "INFO: Peak memory"