Skip to content

Commit

Permalink
Adding a few more commonly used modules
Browse files Browse the repository at this point in the history
  • Loading branch information
marchoeppner committed Mar 7, 2024
1 parent d0bd621 commit df11c9b
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 2 deletions.
36 changes: 36 additions & 0 deletions modules/cat_fastq/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
process CAT_FASTQ {
tag "$meta.sample_id"
label 'process_single'

conda 'conda-forge::sed=4.7'
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://depot.galaxyproject.org/singularity/ubuntu:20.04' :
'ubuntu:20.04' }"

input:
tuple val(meta), path(reads, stageAs: 'input*/*')

output:
tuple val(meta), path('*.merged.fastq.gz'), emit: reads
path 'versions.yml' , emit: versions

when:
task.ext.when == null || task.ext.when

script:
def prefix = meta.sample_id
def readList = reads instanceof List ? reads.collect { r -> r.toString() } : [reads.toString()]

def read1 = []
def read2 = []
readList.eachWithIndex { v, ix -> (ix & 1 ? read2 : read1) << v }
"""
zcat ${read1.join(' ')} > ${prefix}_1.merged.fastq.gz
zcat ${read2.join(' ')} > ${prefix}_2.merged.fastq.gz
cat <<-END_VERSIONS > versions.yml
"${task.process}":
cat: \$(echo \$(cat --version 2>&1) | sed 's/^.*coreutils) //; s/ .*\$//')
END_VERSIONS
"""
}
5 changes: 3 additions & 2 deletions modules/fastp/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ process FASTP {
path('versions.yml'), emit: versions

script:
r1 = file(reads[0])

def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: r1.getBaseName()
Expand All @@ -25,6 +24,8 @@ process FASTP {
json = prefix + '.fastp.json'
html = prefix + '.fastp.html'

r1 = reads[0]

if (meta.single_end) {
r1_trim = r1.getBaseName() + suffix
"""
Expand All @@ -40,7 +41,7 @@ process FASTP {
END_VERSIONS
"""
} else {
r2 = file(reads[1])
r2 = reads[1]
r1_trim = r1.getBaseName() + suffix
r2_trim = r2.getBaseName() + suffix
"""
Expand Down
35 changes: 35 additions & 0 deletions modules/gunzip/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
process GUNZIP {
tag "${meta.target}|${zipped}"

label 'medium_serial'

publishDir "${params.outdir}/${meta.target}/${meta.tool}", mode: 'copy'

conda 'sed=4.7'
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://depot.galaxyproject.org/singularity/ubuntu:20.04' :
'ubuntu:20.04' }"

input:
tuple val(meta), path(zipped)

output:
tuple val(meta), path(unzipped), emit: gunzip
path("versions.yml"), emit: versions

script:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: zipped.getBaseName()

unzipped = prefix

"""
gunzip $args -c $zipped > $unzipped
cat <<-END_VERSIONS > versions.yml
"${task.process}":
gunzip: \$(echo \$(gunzip --version 2>&1) | sed 's/^.*(gzip) //; s/ Copyright.*\$//')
END_VERSIONS
"""
}

0 comments on commit df11c9b

Please sign in to comment.