diff --git a/software/quast/quast_noref/functions.nf b/software/quast/quast_noref/functions.nf new file mode 100644 index 00000000..d25eea86 --- /dev/null +++ b/software/quast/quast_noref/functions.nf @@ -0,0 +1,59 @@ +/* + * ----------------------------------------------------- + * 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.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" + } + } +} diff --git a/software/quast/quast_noref/main.nf b/software/quast/quast_noref/main.nf new file mode 100644 index 00000000..2ad9ac79 --- /dev/null +++ b/software/quast/quast_noref/main.nf @@ -0,0 +1,41 @@ +// Import generic module functions +include { initOptions; saveFiles; getSoftwareName } from './functions' + +params.options = [:] +def options = initOptions(params.options) + +process QUAST { + tag "$fasta" + 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::quast=5.0.2' : null) + if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) { + container 'https://depot.galaxyproject.org/singularity/quast:5.0.2--py37pl526hb5aa323_2' + } else { + container 'quay.io/biocontainers/quast:5.0.2--py37pl526hb5aa323_2' + } + + input: + path consensus + + output: + path "${prefix}" , emit: results + path '*.tsv' , emit: tsv + path '*.version.txt', emit: version + + script: + def software = getSoftwareName(task.process) + prefix = options.suffix ?: software + """ + quast.py \\ + --output-dir $prefix \\ + --threads $task.cpus \\ + $options.args \\ + $consensus + ln -s ${prefix}/report.tsv + echo \$(quast.py --version 2>&1) | sed 's/^.*QUAST v//; s/ .*\$//' > ${software}.version.txt + """ +} diff --git a/software/quast/quast_noref/meta.yml b/software/quast/quast_noref/meta.yml new file mode 100644 index 00000000..9b46bf42 --- /dev/null +++ b/software/quast/quast_noref/meta.yml @@ -0,0 +1,54 @@ +name: quast +description: Quality Assessment Tool for Genome Assemblies +keywords: + - quast + - assembly + - quality +tools: + - star: + description: | + QUAST calculate quality metrics for genome assemblies + homepage: http://bioinf.spbau.ru/quast + doi: +params: + - outdir: + type: string + description: | + The pipeline's output directory. By default, the module will + output files into `$params.outdir/` + - publish_dir_mode: + type: string + description: | + Value for the Nextflow `publishDir` mode parameter. + Available: symlink, rellink, link, copy, copyNoFollow, move. + - enable_conda: + type: boolean + description: | + Run the module with Conda using the software specified + via the `conda` directive + - singularity_pull_docker_container: + type: boolean + description: | + Instead of directly downloading Singularity images for use with Singularity, + force the workflow to pull and convert Docker containers instead. + +input: + - consensus: + type: map + description: | + Groovy Map containing sample information + +output: + - report: + type: file + description: The lineage report + pattern: "{prefix}.lineage_report.csv" + + - version: + type: file + description: File containing software version + pattern: "*.{version.txt}" + +authors: + - "@drpatelh" + - "@kevinmenden" diff --git a/software/quast/quast_ref/functions.nf b/software/quast/quast_ref/functions.nf new file mode 100644 index 00000000..d25eea86 --- /dev/null +++ b/software/quast/quast_ref/functions.nf @@ -0,0 +1,59 @@ +/* + * ----------------------------------------------------- + * 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.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" + } + } +} diff --git a/software/quast/quast_ref/main.nf b/software/quast/quast_ref/main.nf new file mode 100644 index 00000000..0a811445 --- /dev/null +++ b/software/quast/quast_ref/main.nf @@ -0,0 +1,46 @@ +// Import generic module functions +include { initOptions; saveFiles; getSoftwareName } from './functions' + +params.options = [:] +def options = initOptions(params.options) + +process QUAST { + tag "$fasta" + 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::quast=5.0.2' : null) + if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) { + container 'https://depot.galaxyproject.org/singularity/quast:5.0.2--py37pl526hb5aa323_2' + } else { + container 'quay.io/biocontainers/quast:5.0.2--py37pl526hb5aa323_2' + } + + input: + path consensus + path fasta + path gff + + output: + path "${prefix}" , emit: results + path '*.tsv' , emit: tsv + path '*.version.txt', emit: version + + script: + def software = getSoftwareName(task.process) + prefix = options.suffix ?: software + def features = params.gff ? "--features $gff" : '' + """ + quast.py \\ + --output-dir $prefix \\ + -r $fasta \\ + $features \\ + --threads $task.cpus \\ + $options.args \\ + ${consensus.join(' ')} + ln -s ${prefix}/report.tsv + echo \$(quast.py --version 2>&1) | sed 's/^.*QUAST v//; s/ .*\$//' > ${software}.version.txt + """ +} diff --git a/software/quast/quast_ref/meta.yml b/software/quast/quast_ref/meta.yml new file mode 100644 index 00000000..a1ca27b3 --- /dev/null +++ b/software/quast/quast_ref/meta.yml @@ -0,0 +1,61 @@ +name: quast +description: Quality Assessment Tool for Genome Assemblies +keywords: + - quast + - assembly + - quality +tools: + - star: + description: | + QUAST calculate quality metrics for genome assemblies + homepage: http://bioinf.spbau.ru/quast + doi: +params: + - outdir: + type: string + description: | + The pipeline's output directory. By default, the module will + output files into `$params.outdir/` + - publish_dir_mode: + type: string + description: | + Value for the Nextflow `publishDir` mode parameter. + Available: symlink, rellink, link, copy, copyNoFollow, move. + - enable_conda: + type: boolean + description: | + Run the module with Conda using the software specified + via the `conda` directive + - singularity_pull_docker_container: + type: boolean + description: | + Instead of directly downloading Singularity images for use with Singularity, + force the workflow to pull and convert Docker containers instead. + +input: + - consensus: + type: map + description: | + Groovy Map containing sample information + - fasta: + type: file + description: | + The genome assembly to be evaluated + - gff: + type: file + description: The genome GFF file + +output: + - report: + type: file + description: The lineage report + pattern: "{prefix}.lineage_report.csv" + + - version: + type: file + description: File containing software version + pattern: "*.{version.txt}" + +authors: + - "@drpatelh" + - "@kevinmenden" diff --git a/tests/software/quast/main.nf b/tests/software/quast/main.nf new file mode 100644 index 00000000..366b0c90 --- /dev/null +++ b/tests/software/quast/main.nf @@ -0,0 +1,20 @@ +#!/usr/bin/env nextflow + +nextflow.enable.dsl = 2 + +include { QUAST as QUAST_NOREF } from '../../../software/quast/quast_noref/main.nf' addParams(options: [:]) +include { QUAST as QUAST_REF } from '../../../software/quast/quast_ref/main.nf' addParams(options: [:]) + +workflow test_quast_noref { + consensus = file("${launchDir}/tests/data/fasta/sarscov2/GCA_011545545.1_ASM1154554v1_genomic.fna", checkIfExists: true) + + QUAST_NOREF( consensus ) +} + +workflow test_quast_ref { + consensus = file("${launchDir}/tests/data/fasta/sarscov2/GCA_011545545.1_ASM1154554v1_cds_from_genomic.fna", checkIfExists: true) + gff = file("${launchDir}/tests/data/gff/sarscov2/GCA_011545545.1_ASM1154554v1_genomic.gtf", checkIfExists: true) + fasta = file("${launchDir}/tests/data/fasta/sarscov2/GCA_011545545.1_ASM1154554v1_genomic.fna", checkIfExists: true) + + QUAST_REF( consensus, fasta, gff ) +} diff --git a/tests/software/quast/test.yml b/tests/software/quast/test.yml new file mode 100644 index 00000000..e69de29b