mirror of
https://github.com/MillironX/nf-core_modules.git
synced 2024-11-10 20:23:10 +00:00
add module for fastq-scan (#935)
* add module for fastq-scan * change fastq to reads * remove uncompressed support Co-authored-by: Gregor Sturm <mail@gregor-sturm.de> Co-authored-by: FriederikeHanssen <Friederike.hanssen@qbic.uni-tuebingen.de>
This commit is contained in:
parent
7be60774b6
commit
b5b3ff16ce
6 changed files with 185 additions and 0 deletions
78
modules/fastqscan/functions.nf
Normal file
78
modules/fastqscan/functions.nf
Normal file
|
@ -0,0 +1,78 @@
|
|||
//
|
||||
// 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()
|
||||
}
|
||||
|
||||
//
|
||||
// Extract name of module from process name using $task.process
|
||||
//
|
||||
def getProcessName(task_process) {
|
||||
return task_process.tokenize(':')[-1]
|
||||
}
|
||||
|
||||
//
|
||||
// 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) {
|
||||
def ioptions = initOptions(args.options)
|
||||
def path_list = [ ioptions.publish_dir ?: args.publish_dir ]
|
||||
|
||||
// Do not publish versions.yml unless running from pytest workflow
|
||||
if (args.filename.equals('versions.yml') && !System.getenv("NF_CORE_MODULES_TEST")) {
|
||||
return null
|
||||
}
|
||||
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
modules/fastqscan/main.nf
Normal file
40
modules/fastqscan/main.nf
Normal file
|
@ -0,0 +1,40 @@
|
|||
// Import generic module functions
|
||||
include { initOptions; saveFiles; getSoftwareName; getProcessName } from './functions'
|
||||
|
||||
params.options = [:]
|
||||
options = initOptions(params.options)
|
||||
|
||||
process FASTQSCAN {
|
||||
tag "$meta.id"
|
||||
label 'process_low'
|
||||
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::fastq-scan=0.4.4" : null)
|
||||
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
|
||||
container "https://depot.galaxyproject.org/singularity/fastq-scan:0.4.4--h7d875b9_0"
|
||||
} else {
|
||||
container "quay.io/biocontainers/fastq-scan:0.4.4--h7d875b9_0"
|
||||
}
|
||||
|
||||
input:
|
||||
tuple val(meta), path(reads)
|
||||
|
||||
output:
|
||||
tuple val(meta), path("*.json"), emit: json
|
||||
path "versions.yml" , emit: versions
|
||||
|
||||
script:
|
||||
def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
|
||||
"""
|
||||
zcat $reads | \\
|
||||
fastq-scan \\
|
||||
$options.args > ${prefix}.json
|
||||
|
||||
cat <<-END_VERSIONS > versions.yml
|
||||
${getProcessName(task.process)}:
|
||||
${getSoftwareName(task.process)}: \$( echo \$(fastq-scan -v 2>&1) | sed 's/^.*fastq-scan //' )
|
||||
END_VERSIONS
|
||||
"""
|
||||
}
|
43
modules/fastqscan/meta.yml
Normal file
43
modules/fastqscan/meta.yml
Normal file
|
@ -0,0 +1,43 @@
|
|||
name: fastqscan
|
||||
description: FASTQ summary statistics in JSON format
|
||||
keywords:
|
||||
- fastq
|
||||
- summary
|
||||
- statistics
|
||||
tools:
|
||||
- fastqscan:
|
||||
description: FASTQ summary statistics in JSON format
|
||||
homepage: https://github.com/rpetit3/fastq-scan
|
||||
documentation: https://github.com/rpetit3/fastq-scan
|
||||
tool_dev_url: https://github.com/rpetit3/fastq-scan
|
||||
doi: ""
|
||||
licence: ['MIT']
|
||||
|
||||
input:
|
||||
- meta:
|
||||
type: map
|
||||
description: |
|
||||
Groovy Map containing sample information
|
||||
e.g. [ id:'test', single_end:false ]
|
||||
- reads:
|
||||
type: file
|
||||
description: FASTQ file
|
||||
pattern: "*.{fastq.gz,fq.gz}"
|
||||
|
||||
output:
|
||||
- meta:
|
||||
type: map
|
||||
description: |
|
||||
Groovy Map containing sample information
|
||||
e.g. [ id:'test', single_end:false ]
|
||||
- versions:
|
||||
type: file
|
||||
description: File containing software versions
|
||||
pattern: "versions.yml"
|
||||
- json:
|
||||
type: file
|
||||
description: JSON formatted file of summary statistics
|
||||
pattern: "*.json"
|
||||
|
||||
authors:
|
||||
- "@rpetit3"
|
|
@ -394,6 +394,10 @@ fastqc:
|
|||
- modules/fastqc/**
|
||||
- tests/modules/fastqc/**
|
||||
|
||||
fastqscan:
|
||||
- modules/fastqscan/**
|
||||
- tests/modules/fastqscan/**
|
||||
|
||||
fasttree:
|
||||
- modules/fasttree/**
|
||||
- tests/modules/fasttree/**
|
||||
|
|
13
tests/modules/fastqscan/main.nf
Normal file
13
tests/modules/fastqscan/main.nf
Normal file
|
@ -0,0 +1,13 @@
|
|||
#!/usr/bin/env nextflow
|
||||
|
||||
nextflow.enable.dsl = 2
|
||||
|
||||
include { FASTQSCAN } from '../../../modules/fastqscan/main.nf' addParams( options: [ args: "-g 30000"] )
|
||||
|
||||
workflow test_fastqscan {
|
||||
|
||||
input = [ [ id:'test', single_end:true ], // meta map
|
||||
file(params.test_data['sarscov2']['illumina']['test_1_fastq_gz'], checkIfExists: true) ]
|
||||
|
||||
FASTQSCAN ( input )
|
||||
}
|
7
tests/modules/fastqscan/test.yml
Normal file
7
tests/modules/fastqscan/test.yml
Normal file
|
@ -0,0 +1,7 @@
|
|||
- name: fastqscan test_fastqscan
|
||||
command: nextflow run tests/modules/fastqscan -entry test_fastqscan -c tests/config/nextflow.config
|
||||
tags:
|
||||
- fastqscan
|
||||
files:
|
||||
- path: output/fastqscan/test.json
|
||||
md5sum: b9d59a36fe85e556b5a80573ea0b0266
|
Loading…
Reference in a new issue