mirror of
https://github.com/MillironX/nf-core_modules.git
synced 2024-11-10 20:23:10 +00:00
add qcat module (from nanoseq modules) (#469)
* add qcat module * remove md5sum(nom-reproducible)
This commit is contained in:
parent
3f804ee667
commit
05f479f03a
7 changed files with 181 additions and 0 deletions
70
software/qcat/functions.nf
Normal file
70
software/qcat/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"
|
||||
}
|
||||
}
|
||||
}
|
44
software/qcat/main.nf
Normal file
44
software/qcat/main.nf
Normal file
|
@ -0,0 +1,44 @@
|
|||
// Import generic module functions
|
||||
include { initOptions; saveFiles; getSoftwareName } from './functions'
|
||||
|
||||
params.options = [:]
|
||||
def options = initOptions(params.options)
|
||||
|
||||
process QCAT {
|
||||
tag "$meta.id"
|
||||
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:meta, publish_by_meta:['id']) }
|
||||
|
||||
conda (params.enable_conda ? "bioconda::qcat=1.1.0" : null)
|
||||
container "quay.io/biocontainers/qcat:1.1.0--py_0"
|
||||
|
||||
input:
|
||||
tuple val(meta), path(input_path)
|
||||
val(barcode_kit)
|
||||
|
||||
output:
|
||||
tuple val(meta), path("fastq/*.fastq.gz") , emit: fastq
|
||||
path "*.version.txt" , emit: version
|
||||
|
||||
script:
|
||||
"""
|
||||
## Unzip fastq file
|
||||
## qcat doesnt support zipped files yet
|
||||
FILE=$input_path
|
||||
if [[ \$FILE == *.gz ]]
|
||||
then
|
||||
zcat $input_path > unzipped.fastq
|
||||
FILE=unzipped.fastq
|
||||
fi
|
||||
qcat \\
|
||||
-f \$FILE \\
|
||||
-b ./fastq \\
|
||||
--kit $barcode_kit
|
||||
|
||||
## Zip fastq files (cannot find pigz command)
|
||||
gzip fastq/*
|
||||
qcat --version &> qcat.version.txt
|
||||
"""
|
||||
}
|
38
software/qcat/meta.yml
Normal file
38
software/qcat/meta.yml
Normal file
|
@ -0,0 +1,38 @@
|
|||
name: qcat
|
||||
description: Demultiplexer for Nanopore samples
|
||||
keywords:
|
||||
- demultiplex
|
||||
|
||||
tools:
|
||||
- qcat:
|
||||
description: |
|
||||
A demultiplexer for Nanopore samples
|
||||
homepage: https://github.com/nanoporetech/qcat
|
||||
documentation: https://github.com/nanoporetech/qcat#qcat
|
||||
input:
|
||||
- meta:
|
||||
type: map
|
||||
description: |
|
||||
Groovy Map containing sample information
|
||||
e.g. [ id:'test', single_end:false ]
|
||||
- input_path:
|
||||
type: file
|
||||
description: |
|
||||
Non-demultiplexed Nanopore sequencing sample.
|
||||
|
||||
output:
|
||||
- meta:
|
||||
type: map
|
||||
description: |
|
||||
Groovy Map containing sample information
|
||||
e.g. [ id:'test', single_end:false ]
|
||||
- fastq:
|
||||
type: file
|
||||
description: Demultiplexed fastq samples
|
||||
pattern: "*.fastq.gz"
|
||||
- version:
|
||||
type: file
|
||||
description: File containing software version
|
||||
pattern: "*.{version.txt}"
|
||||
authors:
|
||||
- "@yuukiiwa"
|
|
@ -439,6 +439,10 @@ pycoqc:
|
|||
- software/pycoqc/**
|
||||
- tests/software/pycoqc/**
|
||||
|
||||
qcat:
|
||||
- software/qcat/**
|
||||
- tests/software/qcat/**
|
||||
|
||||
qualimap/bamqc:
|
||||
- software/qualimap/bamqc/**
|
||||
- tests/software/qualimap/bamqc/**
|
||||
|
|
|
@ -146,6 +146,9 @@ params {
|
|||
test2_genome_vcf_gz_tbi = "${test_data_dir}/genomics/homo_sapiens/illumina/gvcf/test2.genome.vcf.gz.tbi"
|
||||
test2_genome_vcf_idx = "${test_data_dir}/genomics/homo_sapiens/illumina/gvcf/test2.genome.vcf.idx"
|
||||
}
|
||||
'nanopore' {
|
||||
non_demultiplexed_fastq = "https://github.com/nf-core/test-datasets/raw/nanoseq/fastq/nondemultiplexed/sample_nobc_dx.fastq.gz"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
14
tests/software/qcat/main.nf
Normal file
14
tests/software/qcat/main.nf
Normal file
|
@ -0,0 +1,14 @@
|
|||
#!/usr/bin/env nextflow
|
||||
|
||||
nextflow.enable.dsl = 2
|
||||
|
||||
include { QCAT } from '../../../software/qcat/main.nf' addParams( options: [:] )
|
||||
|
||||
workflow test_qcat {
|
||||
def input = []
|
||||
input = [ [ id:'test' ], // meta map
|
||||
[ file(params.test_data['homo_sapiens']['nanopore']['non_demultiplexed_fastq'], checkIfExists: true) ]
|
||||
]
|
||||
barcode_kit = 'NBD103/NBD104'
|
||||
QCAT ( input, barcode_kit )
|
||||
}
|
8
tests/software/qcat/test.yml
Normal file
8
tests/software/qcat/test.yml
Normal file
|
@ -0,0 +1,8 @@
|
|||
- name: qcat
|
||||
command: nextflow run ./tests/software/qcat -entry test_qcat -c tests/config/nextflow.config
|
||||
tags:
|
||||
- qcat
|
||||
files:
|
||||
- path: ./output/qcat/fastq/barcode06.fastq.gz
|
||||
- path: ./output/qcat/fastq/barcode12.fastq.gz
|
||||
- path: ./output/qcat/fastq/none.fastq.gz
|
Loading…
Reference in a new issue