mirror of
https://github.com/MillironX/nf-core_modules.git
synced 2024-12-22 11:08:17 +00:00
Add pycoqc module (#424)
* Add pycoqc module * Adding pycoqc module tests * Update pycoqc wilth new functions.nf * Update tests to check for json report content
This commit is contained in:
parent
575df10781
commit
2c43c39ccc
6 changed files with 185 additions and 0 deletions
70
software/pycoqc/functions.nf
Normal file
70
software/pycoqc/functions.nf
Normal file
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
* -----------------------------------------------------
|
||||
* 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"
|
||||
}
|
||||
}
|
||||
}
|
40
software/pycoqc/main.nf
Normal file
40
software/pycoqc/main.nf
Normal file
|
@ -0,0 +1,40 @@
|
|||
// Import generic module functions
|
||||
include { initOptions; saveFiles; getSoftwareName } from './functions'
|
||||
|
||||
params.options = [:]
|
||||
options = initOptions(params.options)
|
||||
|
||||
process PYCOQC {
|
||||
tag "$summary"
|
||||
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::pycoqc=2.5.2" : null)
|
||||
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
|
||||
container "https://depot.galaxyproject.org/singularity/pycoqc:2.5.2--py_0"
|
||||
} else {
|
||||
container "quay.io/biocontainers/pycoqc:2.5.2--py_0"
|
||||
}
|
||||
|
||||
input:
|
||||
path summary
|
||||
|
||||
output:
|
||||
path "*.html" , emit: html
|
||||
path "*.json" , emit: json
|
||||
path "*.version.txt", emit: version
|
||||
|
||||
script:
|
||||
def software = getSoftwareName(task.process)
|
||||
"""
|
||||
pycoQC \\
|
||||
$options.args \\
|
||||
-f $summary \\
|
||||
-o pycoqc.html \\
|
||||
-j pycoqc.json
|
||||
|
||||
echo \$(pycoQC --version 2>&1) | sed 's/^.*pycoQC v//; s/ .*\$//' > ${software}.version.txt
|
||||
"""
|
||||
}
|
48
software/pycoqc/meta.yml
Normal file
48
software/pycoqc/meta.yml
Normal file
|
@ -0,0 +1,48 @@
|
|||
name: pycoqc
|
||||
description: write your description here
|
||||
keywords:
|
||||
- qc
|
||||
- quality control
|
||||
- sequencing
|
||||
- nanopore
|
||||
tools:
|
||||
- pycoqc:
|
||||
description: PycoQC computes metrics and generates interactive QC plots for Oxford Nanopore technologies sequencing data
|
||||
homepage: https://github.com/tleonardi/pycoQC
|
||||
documentation: https://tleonardi.github.io/pycoQC/
|
||||
tool_dev_url: https://github.com/tleonardi/pycoQC
|
||||
doi: "10.21105/joss.01236"
|
||||
licence: ['GNU General Public v3 (GPL v3)']
|
||||
|
||||
input:
|
||||
- meta:
|
||||
type: map
|
||||
description: |
|
||||
Groovy Map containing sample information
|
||||
e.g. [ id:'test', single_end:false ]
|
||||
- summary:
|
||||
type: file
|
||||
description: sequencing summary file
|
||||
pattern: "*.{txt}"
|
||||
|
||||
output:
|
||||
- meta:
|
||||
type: map
|
||||
description: |
|
||||
Groovy Map containing sample information
|
||||
e.g. [ id:'test', single_end:false ]
|
||||
- html:
|
||||
type: file
|
||||
description: Results in HTML format
|
||||
- json:
|
||||
type: file
|
||||
description: Results in JSON format
|
||||
pattern: "*.{json}"
|
||||
- version:
|
||||
type: file
|
||||
description: File containing software version
|
||||
pattern: "*.{version.txt}"
|
||||
|
||||
authors:
|
||||
- "@joseespinosa"
|
||||
- "@drpatelh"
|
|
@ -386,6 +386,10 @@ prokka:
|
|||
- software/prokka/**
|
||||
- tests/software/prokka/**
|
||||
|
||||
pycoqc:
|
||||
- software/pycoqc/**
|
||||
- tests/software/pycoqc/**
|
||||
|
||||
qualimap/bamqc:
|
||||
- software/qualimap/bamqc/**
|
||||
- tests/software/qualimap/bamqc/**
|
||||
|
|
12
tests/software/pycoqc/main.nf
Normal file
12
tests/software/pycoqc/main.nf
Normal file
|
@ -0,0 +1,12 @@
|
|||
#!/usr/bin/env nextflow
|
||||
|
||||
nextflow.enable.dsl = 2
|
||||
|
||||
include { PYCOQC } from '../../../software/pycoqc/main.nf' addParams ( options: ['args' : '--min_pass_qual 0'] )
|
||||
|
||||
workflow test_pycoqc {
|
||||
|
||||
input = [ file(params.test_data['sarscov2']['nanopore']['test_sequencing_summary'], checkIfExists: true) ]
|
||||
|
||||
PYCOQC ( input )
|
||||
}
|
11
tests/software/pycoqc/test.yml
Normal file
11
tests/software/pycoqc/test.yml
Normal file
|
@ -0,0 +1,11 @@
|
|||
- name: pycoqc
|
||||
command: nextflow run ./tests/software/pycoqc -entry test_pycoqc -c tests/config/nextflow.config
|
||||
tags:
|
||||
- pycoqc
|
||||
files:
|
||||
- path: output/pycoqc/pycoqc.json
|
||||
contains:
|
||||
- '"reads_number": 100,'
|
||||
- '"bases_number": 1160,'
|
||||
- '"N50": 12,'
|
||||
- path: output/pycoqc/pycoqc.html
|
Loading…
Reference in a new issue