mirror of
https://github.com/MillironX/nf-core_modules.git
synced 2024-12-22 11:08:17 +00:00
started adding quast modules
This commit is contained in:
parent
29ce4e670f
commit
10bb80743a
8 changed files with 340 additions and 0 deletions
59
software/quast/quast_noref/functions.nf
Normal file
59
software/quast/quast_noref/functions.nf
Normal file
|
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
41
software/quast/quast_noref/main.nf
Normal file
41
software/quast/quast_noref/main.nf
Normal file
|
@ -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
|
||||
"""
|
||||
}
|
54
software/quast/quast_noref/meta.yml
Normal file
54
software/quast/quast_noref/meta.yml
Normal file
|
@ -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/<SOFTWARE>`
|
||||
- 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"
|
59
software/quast/quast_ref/functions.nf
Normal file
59
software/quast/quast_ref/functions.nf
Normal file
|
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
46
software/quast/quast_ref/main.nf
Normal file
46
software/quast/quast_ref/main.nf
Normal file
|
@ -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
|
||||
"""
|
||||
}
|
61
software/quast/quast_ref/meta.yml
Normal file
61
software/quast/quast_ref/meta.yml
Normal file
|
@ -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/<SOFTWARE>`
|
||||
- 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"
|
20
tests/software/quast/main.nf
Normal file
20
tests/software/quast/main.nf
Normal file
|
@ -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 )
|
||||
}
|
0
tests/software/quast/test.yml
Normal file
0
tests/software/quast/test.yml
Normal file
Loading…
Reference in a new issue