Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added functional Trim Galore module #28

Merged
merged 1 commit into from
Jul 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 95 additions & 29 deletions tools/trim_galore/main.nf
Original file line number Diff line number Diff line change
@@ -1,35 +1,101 @@
process trim_galore {
tag "$sample_id"
publishDir "${params.outdir}/trim_galore", mode: 'copy',
saveAs: {filename ->
if (filename.indexOf("_fastqc") > 0) "FastQC/$filename"
else if (filename.indexOf("trimming_report.txt") > 0) "logs/$filename"
else filename
}
nextflow.preview.dsl=2

params.singlecell = ''
params.rrbs = ''
params.pbat = ''
params.single_end = false

params.trim_nextseq = 0

params.clip_r1 = 0
params.clip_r2 = 0
params.three_prime_clip_r1 = 0
params.three_prime_clip_r2 = 0


process TRIM_GALORE {

// container 'quay.io/biocontainers/trim-galore:0.6.5--0' // maybe later
// tag "$sample_id"

container 'quay.io/biocontainers/trim-galore:0.6.5--0'
input:
tuple val (name), path (reads)
val (outdir)
val (trim_galore_args)
val (verbose)

input:
tuple sample_id, path(reads)
output:
tuple val(name), path ("*fq.gz"), emit: reads
path "*trimming_report.txt", optional: true, emit: report

// Trimming reports are not generated for e.g. --hardtrim5, --clock etc
// saveAs: {filename ->
// else if (filename.indexOf("trimming_report.txt") > 0) "logs/$filename"
// else filename
// }

output:
tuple name, path("*fq.gz")
path "*trimming_report.txt"
path "*_fastqc.{zip,html}"
publishDir "${outdir}/trim_galore",
mode: "copy", overwrite: true

script:
c_r1 = clip_r1 > 0 ? "--clip_r1 ${clip_r1}" : ''
c_r2 = clip_r2 > 0 ? "--clip_r2 ${clip_r2}" : ''
tpc_r1 = three_prime_clip_r1 > 0 ? "--three_prime_clip_r1 ${three_prime_clip_r1}" : ''
tpc_r2 = three_prime_clip_r2 > 0 ? "--three_prime_clip_r2 ${three_prime_clip_r2}" : ''
nextseq = params.trim_nextseq > 0 ? "--nextseq ${params.trim_nextseq}" : ''
if (params.singleEnd) {
"""
trim_galore --fastqc --gzip $c_r1 $tpc_r1 $nextseq $reads
"""
} else {
"""
trim_galore --paired --fastqc --gzip $c_r1 $c_r2 $tpc_r1 $tpc_r2 $nextseq $reads
"""
}
if (verbose){
println ("[MODULE] TRIM GALORE ARGS: " + trim_galore_args)
}

trim_galore_args += " --gzip " // we like small files

pairedString = 0
if (reads instanceof List) {
pairedString = 1
trim_galore_args += " --paired "
}

if (params.clip_r1 > 0){
trim_galore_args += " --clip_r1 ${params.clip_r1} "
}
if (params.clip_r2 > 0){
trim_galore_args += " --clip_r2 ${params.clip_r2} "
}
if (params.three_prime_clip_r1> 0){
trim_galore_args += " --three_prime_clip_r1 ${params.three_prime_clip_r1} "
}
if (params.three_prime_clip_r2 > 0){
trim_galore_args += " --three_prime_clip_r2 ${params.three_prime_clip_r2} "
}

if (params.trim_nextseq > 0){
trim_galore_args += " --nextseq ${params.trim_nextseq} "
}


// Pre-set parameters for certain bisulfite-seq applications
if (params.singlecell){
trim_galore_args += " --clip_r1 6 "
if (pairedString == 1){
trim_galore_args += " --clip_r2 6 "
}
}
if (params.rrbs){
trim_galore_args += " --rrbs "
}
if (params.pbat){
trim_galore_args += " --clip_r1 $params.pbat "
if (pairedString == 1){
trim_galore_args += " --clip_r2 $params.pbat "
}
}

"""
module load trim_galore
trim_galore $trim_galore_args $reads
"""

}








10 changes: 4 additions & 6 deletions tools/trim_galore/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,8 @@ output:
type: file
description: Trim Galore! trimming report
pattern: *trimming_report.txt
-
- fastqc_report:
type: file
description: FastQC report
pattern: *_fastqc.{zip,html}

authors:
- @ewels
-
- @ewels
- @FelixKrueger
32 changes: 23 additions & 9 deletions tools/trim_galore/test/main.nf
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
#!/usr/bin/env nextflow
echo true
nextflow.preview.dsl=2

cheers = Channel.from 'Bonjour', 'Ciao', 'Hello', 'Hola'
params.outdir = "." // gets set in the nextflow.config files (to './results/trim_galore')
params.verbose = false
params.trim_galore_args = ''
// trim_galore_args are best passed into the workflow in the following manner, e.g.:
// --trim_galore_args="--clip_r1 10 --clip_r2 15 -j 2"

if (params.verbose){
println ("[WORKFLOW] TRIM GALORE ARGS: " + params.trim_galore_args)
}

// TODO: check the output files in some way
// include '../../../nf-core/module_testing/check_process_outputs.nf'
include '../main.nf' // params (clip_r1: 6, clip_r2: 10) // how to pass additional parameters

ch_read_files = Channel
.fromFilePairs('../../../test-datasets/test*{1,2}.fastq.gz',size:-1)
// .view() // to check whether the input channel works

workflow {

main:
TRIM_GALORE (ch_read_files, params.outdir, params.trim_galore_args, params.verbose)

process sayHello {
input:
val x from cheers
script:
"""
echo '$x world!'
"""
}
2 changes: 2 additions & 0 deletions tools/trim_galore/test/nextflow.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// docker.enabled = true
params.outdir = './results'