Merge pull request #28 from FelixKrueger/trim_galore

Added functional Trim Galore module
This commit is contained in:
Phil Ewels 2020-07-11 13:24:09 +02:00 committed by GitHub
commit 36c4cfb3b0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 124 additions and 44 deletions

View file

@ -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
container 'quay.io/biocontainers/trim-galore:0.6.5--0'
params.singlecell = ''
params.rrbs = ''
params.pbat = ''
params.single_end = false
input:
tuple sample_id, path(reads)
params.trim_nextseq = 0
output:
tuple name, path("*fq.gz")
path "*trimming_report.txt"
path "*_fastqc.{zip,html}"
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"
input:
tuple val (name), path (reads)
val (outdir)
val (trim_galore_args)
val (verbose)
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
// }
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
"""
}

View file

@ -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
tools/trim_galore/test/main.nf Normal file → Executable file
View file

@ -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!'
"""
}

View file

@ -0,0 +1,2 @@
// docker.enabled = true
params.outdir = './results'