diff --git a/src/nf_modules/fastp/fastp_paired.config b/src/nf_modules/fastp/fastp_paired.config new file mode 100644 index 0000000000000000000000000000000000000000..561a3afa0d4aea85daaf76ea2d2bf0f488cce718 --- /dev/null +++ b/src/nf_modules/fastp/fastp_paired.config @@ -0,0 +1,35 @@ +profiles { + docker { + docker.temp = 'auto' + docker.enabled = true + process { + withName: fastp_fastq { + container = "fastp:0.19.7" + cpus = 1 + } + } + } + singularity { + singularity.enabled = true + process { + withName: fastp_fastq { + cpus = 1 + container = "file://bin/fastp:0.19.7.sif" + } + } + } + psmn { + process{ + withName: fastp_fastq { + beforeScript = "source /usr/share/lmod/lmod/init/bash; module use ~/privatemodules" + module = "fastp/0.19.7" + executor = "sge" + clusterOptions = "-cwd -V" + cpus = 1 + memory = "20GB" + time = "12h" + queue = 'monointeldeb128' + } + } + } +} diff --git a/src/nf_modules/fastp/fastp_paired.nf b/src/nf_modules/fastp/fastp_paired.nf new file mode 100644 index 0000000000000000000000000000000000000000..88d6710bc93061804681bcceea1bce7ce10cd669 --- /dev/null +++ b/src/nf_modules/fastp/fastp_paired.nf @@ -0,0 +1,34 @@ +params.fastq = "$baseDir/data/fastq/*_{1,2}.fastq" + +log.info "fastq files : ${params.fastq}" + +Channel + .fromFilePairs( params.fastq ) + .ifEmpty { error "Cannot find any fastq files matching: ${params.fastq}" } + .set { fastq_files } + +process fastp_fastq { + tag "$pair_id" + publishDir "results/fastq/fastp/", mode: 'copy' + + input: + set pair_id, file(reads) from fastq_files + + output: + file "*.{zip,html}" into fastp_report + set pair_id, file "*.fastq.gz" fastq_trim_files + + script: +""" +fastp --thread ${task.cpus} \ +--qualified_quality_phred 20 \ +--disable_length_filtering \ +--detect_adapter_for_pe \ +--in1 ${reads[0]} \ +--in2 ${reads[1]} \ +--out1 ${pair_id}_R1_trim.fastq.gz \ +--out2 ${pair_id}_R2_trim.fastq.gz \ +--html ${pair_id}.html \ +--report_title ${pair_id} +""" +} diff --git a/src/nf_modules/fastp/fastp_single.config b/src/nf_modules/fastp/fastp_single.config new file mode 100644 index 0000000000000000000000000000000000000000..561a3afa0d4aea85daaf76ea2d2bf0f488cce718 --- /dev/null +++ b/src/nf_modules/fastp/fastp_single.config @@ -0,0 +1,35 @@ +profiles { + docker { + docker.temp = 'auto' + docker.enabled = true + process { + withName: fastp_fastq { + container = "fastp:0.19.7" + cpus = 1 + } + } + } + singularity { + singularity.enabled = true + process { + withName: fastp_fastq { + cpus = 1 + container = "file://bin/fastp:0.19.7.sif" + } + } + } + psmn { + process{ + withName: fastp_fastq { + beforeScript = "source /usr/share/lmod/lmod/init/bash; module use ~/privatemodules" + module = "fastp/0.19.7" + executor = "sge" + clusterOptions = "-cwd -V" + cpus = 1 + memory = "20GB" + time = "12h" + queue = 'monointeldeb128' + } + } + } +} diff --git a/src/nf_modules/fastp/fastp_single.nf b/src/nf_modules/fastp/fastp_single.nf new file mode 100644 index 0000000000000000000000000000000000000000..31262172f8e45376b09293b98bdd4fa5403c9b0c --- /dev/null +++ b/src/nf_modules/fastp/fastp_single.nf @@ -0,0 +1,32 @@ +params.fastq = "$baseDir/data/fastq/*.fastq" + +log.info "fastq files : ${params.fastq}" + +Channel + .fromPath( params.fastq ) + .ifEmpty { error "Cannot find any fastq files matching: ${params.fastq}" } + .map { it -> [(it.baseName =~ /([^\.]*)/)[0][1], it]} + .set { fastq_files } + +process fastp_fastq { + tag "$file_id" + publishDir "results/fastq/fastp/", mode: 'copy' + + input: + set file_id, file(reads) from fastq_files + + output: + file "*.{zip,html}" into fastp_report + set file_id, file "*.fastq.gz" fastq_trim_files + + script: +""" +fastp --thread ${task.cpus} \ +--qualified_quality_phred 20 \ +--disable_length_filtering \ +--in1 ${reads} \ +--out1 ${file_id}_R1_trim.fastq.gz \ +--html ${file_id}.html \ +--report_title ${file_id} +""" +} diff --git a/src/nf_modules/fastp/tests.sh b/src/nf_modules/fastp/tests.sh new file mode 100755 index 0000000000000000000000000000000000000000..fae4f08a92c56752b4d467b5c31aca629eb2aac3 --- /dev/null +++ b/src/nf_modules/fastp/tests.sh @@ -0,0 +1,25 @@ +./nextflow src/nf_modules/fastp/fastp_paired.nf \ + -c src/nf_modules/fastp/fastp_paired.config \ + -profile docker \ + --fastq "data/tiny_dataset/fastq/tiny_R{1,2}.fastq" \ + -resume + +./nextflow src/nf_modules/fastp/fastp_single.nf \ + -c src/nf_modules/fastp/fastp_single.config \ + -profile docker \ + --fastq "data/tiny_dataset/fastq/tiny_S.fastq" \ + -resume + +if [ -x "$(command -v singularity)" ]; then +./nextflow src/nf_modules/fastp/fastp_paired.nf \ + -c src/nf_modules/fastp/fastp_paired.config \ + -profile singularity \ + --fastq "data/tiny_dataset/fastq/tiny_R{1,2}.fastq" \ + -resume + +./nextflow src/nf_modules/fastp/fastp_single.nf \ + -c src/nf_modules/fastp/fastp_single.config \ + -profile singularity \ + --fastq "data/tiny_dataset/fastq/tiny_S.fastq" \ + -resume +fi