-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement cutadapt for Illumina, add read tracking, and tidy pacbio c…
…utadapt
- Loading branch information
Showing
8 changed files
with
194 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
process ILLUMINA_CUTADAPT { | ||
tag "$meta.id" | ||
label 'process_medium' | ||
|
||
container 'quay.io/biocontainers/cutadapt:5.0--py39hbcbf7aa_0' | ||
|
||
input: | ||
tuple val(meta), path(reads) | ||
val(for_primer) | ||
val(rev_primer) | ||
val(for_primer_rc) | ||
val(rev_primer_rc) | ||
|
||
output: | ||
tuple val(meta), path("${meta.id}.R1.filtered.fastq.gz"), optional: true, emit: trimmed_R1 | ||
tuple val(meta), path("${meta.id}.R2.filtered.fastq.gz"), optional: true, emit: trimmed_R2 | ||
tuple val(meta), path("${meta.id}.R[12].filtered.fastq.gz"), optional: true, emit: trimmed | ||
path("${meta.id}.cutadapt.out"), emit: trimmed_report // to merging data | ||
path("${meta.id}.cutadapt.json"), emit: cutadapt_json // to MultiQC | ||
|
||
when: | ||
task.ext.when == null || task.ext.when | ||
|
||
script: | ||
// def args = task.ext.args ?: '' | ||
// def prefix = task.ext.prefix ?: "${meta.id}" | ||
maxN = params.maxN >=0 ? "--max-n ${params.maxN}" : "" | ||
maxEE = "--max-ee ${[params.maxEE_for,params.maxEE_rev].max()}" | ||
min_len = params.min_read_len ? "-m ${params.min_read_len}" : "-m 50" | ||
max_len = params.max_read_len != "Inf" ? "-M ${params.max_read_len}" : "" | ||
outr2 = meta.single_end ? '' : "-p ${meta.id}.R2.filtered.fastq.gz" | ||
p2 = meta.single_end ? '' : "-G ${rev_primer} -A ${for_primer_rc}" | ||
polyG = params.illumina_twocolor ? "--nextseq-trim=2" : "" | ||
|
||
""" | ||
cutadapt --report=minimal \\ | ||
--json=${meta.id}.cutadapt.json \\ | ||
-g ${for_primer} -a ${rev_primer_rc} ${p2} \\ | ||
--cores ${task.cpus} \\ | ||
-n 2 ${maxEE} ${min_len} ${max_len} ${maxN} ${polyG} \\ | ||
-o ${meta.id}.R1.filtered.fastq.gz ${outr2} \\ | ||
${reads} > ${meta.id}.cutadapt.out | ||
# is the FASTQ file empty? | ||
if [ -n "\$(gunzip <${meta.id}.R1.filtered.fastq.gz | head -c 1 | tr '\\0\\n' __)" ]; then | ||
echo "Sequences present" | ||
else | ||
rm ${meta.id}.R[12].filtered.fastq.gz | ||
fi | ||
""" | ||
|
||
// stub: | ||
// def args = task.ext.args ?: '' | ||
// def prefix = task.ext.prefix ?: "${meta.id}" | ||
// """ | ||
// """ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,43 @@ | ||
// TODO: this is currently a local module; we should try to set this up | ||
// to use the standard nf-core module | ||
process PACBIO_CUTADAPT { | ||
tag "${meta.id}" | ||
|
||
container 'quay.io/biocontainers/cutadapt:4.1--py310h1425a21_1' | ||
container 'quay.io/biocontainers/cutadapt:5.0--py39hbcbf7aa_0' | ||
|
||
input: | ||
// TODO: Note the channel name here should probably be changed | ||
tuple val(meta), path(reads) | ||
val(for_primer) | ||
val(rev_primer_rc) | ||
|
||
output: | ||
tuple val(meta), file("${meta.id}.noprimer.fastq.gz"), optional: true, emit: cutadapt_trimmed | ||
// file("${meta.id}.cutadapt.out"), emit: cutadapt_report | ||
// file("${meta.id}.untrimmed.fastq.gz"), emit: cutadapt_untrimmed | ||
tuple val(meta), file("${meta.id}.filtered.fastq.gz"), optional: true, emit: cutadapt_trimmed | ||
file("${meta.id}.cutadapt.out"), emit: trimmed_report // to merging data | ||
file("${meta.id}.untrimmed.fastq.gz"), emit: cutadapt_untrimmed | ||
file("${meta.id}.cutadapt.json"), emit: cutadapt_json // to MultiQC | ||
|
||
// when: | ||
// !(params.precheck) | ||
when: | ||
task.ext.when == null || task.ext.when | ||
|
||
script: | ||
strictness = params.pacbio_strict_match ? '-g' : '-a' | ||
maxN = params.maxN >=0 ? "--max-n ${params.maxN} " : "" | ||
maxEE = [params.max_ee_for,params.max_ee_rev].max() == 0 ? "--max-ee ${[params.max_ee_for,params.max_ee_rev].max()}" : "" | ||
min_len = params.min_read_len ? "-m ${params.min_read_len}" : "-m 50" | ||
max_len = params.max_read_len != "Inf" ? "-M ${params.max_read_len}" : "" | ||
""" | ||
# Logic: we should trim out the HiFi reads and require *both* primers be present (-g). | ||
# This should also reorient the sequence to match the primers (--rc). | ||
# Keep anything longer than 50bp, and allow users to filter their data by length later | ||
revprimer_rc=\$( echo -n ${params.rev_primer} | tr "[ATGCUNYRSWKMBDHV]" "[TACGANRYSWMKVHDB]" | rev ) | ||
cutadapt --rc \\ | ||
${strictness} "${params.for_primer}...\${revprimer_rc}" \\ | ||
-m 50 \\ | ||
-j ${task.cpus} \\ | ||
--report=minimal \\ | ||
${strictness} "${for_primer}...${rev_primer_rc}" \\ | ||
-j ${task.cpus} ${min_len} ${max_len} ${maxEE} ${max_N} \\ | ||
--untrimmed-output "${meta.id}.untrimmed.fastq.gz" \\ | ||
-o "${meta.id}.noprimer.fastq.gz" \\ | ||
--json=${meta.id}.cutadapt.json \\ | ||
-o "${meta.id}.filtered.fastq.gz" \\ | ||
${reads} > "${meta.id}.cutadapt.out" | ||
# is the FASTQ file empty? | ||
if [ -n "\$(gunzip <${meta.id}.filtered.fastq.gz | head -c 1 | tr '\\0\\n' __)" ]; then | ||
echo "Sequences present" | ||
else | ||
rm ${meta.id}.filtered.fastq.gz | ||
fi | ||
""" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.