mirror of
https://github.com/MillironX/nf-core_modules.git
synced 2024-12-22 11:08:17 +00:00
Add cat fastq module
This commit is contained in:
parent
27be87ac72
commit
6e8b63fc26
6 changed files with 212 additions and 0 deletions
4
.github/filters.yml
vendored
4
.github/filters.yml
vendored
|
@ -92,6 +92,10 @@ bwa_mem:
|
|||
- software/bwa/mem/**
|
||||
- tests/software/bwa/mem/**
|
||||
|
||||
cat_fastq:
|
||||
- software/cat/fastq/**
|
||||
- tests/software/cat/fastq/**
|
||||
|
||||
cutadapt:
|
||||
- software/cutadapt/**
|
||||
- tests/software/cutadapt/**
|
||||
|
|
59
software/cat/fastq/functions.nf
Normal file
59
software/cat/fastq/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/cat/fastq/main.nf
Normal file
46
software/cat/fastq/main.nf
Normal file
|
@ -0,0 +1,46 @@
|
|||
// Import generic module functions
|
||||
include { initOptions; saveFiles } from './functions'
|
||||
|
||||
params.options = [:]
|
||||
def options = initOptions(params.options)
|
||||
|
||||
process CAT_FASTQ {
|
||||
tag "$meta.id"
|
||||
publishDir "${params.outdir}",
|
||||
mode: params.publish_dir_mode,
|
||||
saveAs: { filename -> saveFiles(filename:filename, options:params.options, publish_dir:'merged_fastq', publish_id:meta.id) }
|
||||
|
||||
conda (params.enable_conda ? "conda-forge::sed=4.7=h1bed415_1000" : null)
|
||||
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
|
||||
container "https://containers.biocontainers.pro/s3/SingImgsRepo/biocontainers/v1.2.0_cv1/biocontainers_v1.2.0_cv1.img"
|
||||
} else {
|
||||
container "biocontainers/biocontainers:v1.2.0_cv1"
|
||||
}
|
||||
|
||||
input:
|
||||
tuple val(meta), path(reads)
|
||||
|
||||
output:
|
||||
tuple val(meta), path("*.merged.fastq.gz"), emit: reads
|
||||
|
||||
script:
|
||||
def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
|
||||
def readList = reads.collect{ it.toString() }
|
||||
if (meta.single_end) {
|
||||
if (readList.size > 1) {
|
||||
"""
|
||||
cat ${readList.sort().join(' ')} > ${prefix}.merged.fastq.gz
|
||||
"""
|
||||
}
|
||||
} else {
|
||||
if (readList.size > 2) {
|
||||
def read1 = []
|
||||
def read2 = []
|
||||
readList.eachWithIndex{ v, ix -> ( ix & 1 ? read2 : read1 ) << v }
|
||||
"""
|
||||
cat ${read1.sort().join(' ')} > ${prefix}_1.merged.fastq.gz
|
||||
cat ${read2.sort().join(' ')} > ${prefix}_2.merged.fastq.gz
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
55
software/cat/fastq/meta.yml
Normal file
55
software/cat/fastq/meta.yml
Normal file
|
@ -0,0 +1,55 @@
|
|||
name: cat_fastq
|
||||
description: Concatenates fastq files
|
||||
keywords:
|
||||
- fastq
|
||||
- concatenate
|
||||
tools:
|
||||
- cat:
|
||||
description: |
|
||||
The cat utility reads files sequentially, writing them to the standard output.
|
||||
documentation: https://www.gnu.org/software/coreutils/manual/html_node/cat-invocation.html
|
||||
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:
|
||||
input:
|
||||
- meta:
|
||||
type: map
|
||||
description: |
|
||||
Groovy Map containing sample information
|
||||
e.g. [ id:'test', single_end:false ]
|
||||
- reads:
|
||||
type: list
|
||||
description: |
|
||||
List of input FastQ files to be concatenated.
|
||||
output:
|
||||
- meta:
|
||||
type: map
|
||||
description: |
|
||||
Groovy Map containing sample information
|
||||
e.g. [ id:'test', single_end:false ]
|
||||
- reads:
|
||||
type: file
|
||||
description: Merged fastq file
|
||||
pattern: "*.{merged.fastq.gz}"
|
||||
authors:
|
||||
- "@joseespinosa"
|
||||
- "@drpatelh"
|
27
tests/software/cat/fastq/main.nf
Normal file
27
tests/software/cat/fastq/main.nf
Normal file
|
@ -0,0 +1,27 @@
|
|||
#!/usr/bin/env nextflow
|
||||
|
||||
nextflow.enable.dsl = 2
|
||||
|
||||
include { CAT_FASTQ } from '../../../../software/cat/fastq/main.nf' addParams( options: [:] )
|
||||
|
||||
workflow test_cat_fastq_single_end {
|
||||
|
||||
def input = []
|
||||
input = [ [ id:'test', single_end:true ], // meta map
|
||||
[ file("${launchDir}/tests/data/fastq/rna/test_R1_val_1.fq.gz", checkIfExists: true),
|
||||
file("${launchDir}/tests/data/fastq/rna/test_R1.fastq.gz", checkIfExists: true) ]]
|
||||
|
||||
CAT_FASTQ ( input )
|
||||
}
|
||||
|
||||
workflow test_cat_fastq_paired_end {
|
||||
|
||||
def input = []
|
||||
input = [ [ id:'test', single_end:false ], // meta map
|
||||
[ file("${launchDir}/tests/data/fastq/rna/test_R1_val_1.fq.gz", checkIfExists: true),
|
||||
file("${launchDir}/tests/data/fastq/rna/test_R2_val_2.fq.gz", checkIfExists: true),
|
||||
file("${launchDir}/tests/data/fastq/rna/test_R1.fastq.gz", checkIfExists: true),
|
||||
file("${launchDir}/tests/data/fastq/rna/test_R2.fastq.gz", checkIfExists: true) ]]
|
||||
|
||||
CAT_FASTQ ( input )
|
||||
}
|
21
tests/software/cat/fastq/test.yml
Normal file
21
tests/software/cat/fastq/test.yml
Normal file
|
@ -0,0 +1,21 @@
|
|||
- name: cat fastq single-end
|
||||
command: nextflow run ./tests/software/cat/fastq -entry test_cat_fastq_single_end -c tests/config/nextflow.config
|
||||
tags:
|
||||
- cat
|
||||
- fastq
|
||||
- cat_fastqc_single_end
|
||||
files:
|
||||
- path: output/merged_fastq/test.merged.fastq.gz
|
||||
md5sum: 7f753b793e5b0872758b1574db84d767
|
||||
|
||||
- name: cat fastq fastqc_paired_end
|
||||
command: nextflow run ./tests/software/cat/fastq -entry test_cat_fastq_paired_end -c tests/config/nextflow.config
|
||||
tags:
|
||||
- cat
|
||||
- fastq
|
||||
- cat_fastqc_paired_end
|
||||
files:
|
||||
- path: output/merged_fastq/test_1.merged.fastq.gz
|
||||
md5sum: 7f753b793e5b0872758b1574db84d767
|
||||
- path: output/merged_fastq/test_2.merged.fastq.gz
|
||||
md5sum: c71ff917e002b1e852916a021d52921d
|
Loading…
Reference in a new issue