Skip to content

Commit

Permalink
Merge pull request #172 from replikation/trimbam
Browse files Browse the repository at this point in the history
merge changes and testing into master
  • Loading branch information
replikation committed Jan 13, 2022
2 parents 6ff7652 + 8dbc0c3 commit 9ba98fe
Show file tree
Hide file tree
Showing 7 changed files with 625 additions and 241 deletions.
2 changes: 1 addition & 1 deletion configs/local.config
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ process {
withLabel: artic { cpus = params.cores }
withLabel: bwa { cpus = params.cores }
withLabel: covarplot { cpus = 1 }
withLabel: demultiplex { cpus = params.cores }
withLabel: demultiplex { cpus = params.max_cores }
withLabel: fastcov { cpus = params.cores }
withLabel: ggplot2 { cpus = params.cores }
withLabel: guppy_cpu { cpus = params.max_cores }
Expand Down
816 changes: 601 additions & 215 deletions data/figures/index.html

Large diffs are not rendered by default.

8 changes: 2 additions & 6 deletions modules/filter_fastq_by_length.nf
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,11 @@ process filter_fastq_by_length {
read_max_length = params.maxLength

if ( params.primerV.matches('V1200')) {
if ( !params.minLength ) { read_min_length = 500 }
if ( !params.maxLength ) { read_max_length = 1500 }
}
else if (params.rapid) {
if ( !params.minLength ) { read_min_length = 100 }
if ( !params.maxLength ) { read_max_length = 700 }
if ( !params.maxLength ) { read_max_length = 1500 }
}
else {
if ( !params.minLength ) { read_min_length = 350 }
if ( !params.minLength ) { read_min_length = 100 }
if ( !params.maxLength ) { read_max_length = 700 }
}

Expand Down
22 changes: 9 additions & 13 deletions poreCov.nf
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ if ( params.help ) { exit 0, helpMSG() }
else { exit 1, "No executer selected: -profile EXECUTER,ENGINE" }

if (workflow.profile.contains('local')) {
println "\033[2m Using $params.cores/$params.max_cores CPU threads [--max_cores]\u001B[0m"
println "\033[2m Using $params.cores/$params.max_cores CPU threads per process for a local run [--max_cores]\u001B[0m"
println " "
}
if ( workflow.profile.contains('singularity') ) {
Expand Down Expand Up @@ -468,10 +468,10 @@ ${c_yellow}Parameters - SARS-CoV-2 genome reconstruction (optional)${c_reset}
--primerV Supported primer variants - choose one [default: ${params.primerV}]
${c_dim}ARTIC:${c_reset} V1, V2, V3, V4, V4.1
${c_dim}NEB:${c_reset} VarSkipV1a
${c_dim}Other:${c_reset} V1200
--rapid use rapid-barcoding-kit [default: ${params.rapid}]
--minLength min length filter raw reads [default: 350 (primer-scheme: V1-4); 500 (primer-scheme: V1200)]
--maxLength max length filter raw reads [default: 700 (primer-scheme: V1-4); 1500 (primer-scheme: V1200)]
${c_dim}Other:${c_reset} V1200 ${c_dim}(also called midnight)${c_reset}
--rapid rapid-barcoding-kit was used [default: ${params.rapid}]
--minLength min length filter raw reads [default: 100]
--maxLength max length filter raw reads [default: 700 (primer-scheme: V1-4, rapid); 1500 (primer-scheme: V1200)]
--min_depth nucleotides below min depth will be masked to "N" [default ${params.min_depth}]
--medaka_model medaka model for the artic workflow [default: ${params.medaka_model}]
e.g. "r941_min_hac_g507" or "r941_min_sup_g507"
Expand Down Expand Up @@ -550,7 +550,7 @@ def defaultMSG(){
def basecalling() {
log.info """
Basecalling options:
\033[2mUse local guppy? $params.localguppy [--localguppy]
\033[2mUse local guppy? $params.localguppy [--localguppy]
One end demultiplexing? $params.one_end [--one_end]
Basecalling via CPUs? $params.guppy_cpu [--guppy_cpu]
Basecalling modell: $params.guppy_model [--guppy_model]
Expand All @@ -576,18 +576,14 @@ def read_length() {
log_msg_read_max_length = params.maxLength

if ( params.primerV.matches('V1200')) {
if ( !params.minLength ) { log_msg_read_min_length = 500 }
if ( !params.minLength ) { log_msg_read_min_length = 400 }
if ( !params.maxLength ) { log_msg_read_max_length = 1500 }
}
else if (params.rapid) {
if ( !params.minLength ) { log_msg_read_min_length = 100 }
if ( !params.maxLength ) { log_msg_read_max_length = 700 }
}
else {
if ( !params.minLength ) { log_msg_read_min_length = 350 }
if ( !params.minLength ) { log_msg_read_min_length = 200 }
if ( !params.maxLength ) { log_msg_read_max_length = 700 }
}
if (log_msg_read_max_length < log_msg_read_min_length) {exit 5, "Please choose [--maxLength] of [${log_msg_read_max_length}] greater than the [--minlength] of [${log_msg_read_min_length}]."}
if (log_msg_read_max_length < log_msg_read_min_length) {exit 5, "--maxLength ${log_msg_read_max_length} needs to be greater than --minlength ${log_msg_read_min_length}."}

log.info """
Primerscheme: $params.primerV [--primerV]
Expand Down
12 changes: 9 additions & 3 deletions workflows/process/artic.nf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ process artic_medaka {
label 'artic'
publishDir "${params.output}/${params.genomedir}/${name}/", mode: 'copy', pattern: "*.consensus.fasta"
publishDir "${params.output}/${params.genomedir}/${name}/", mode: 'copy', pattern: "${name}_mapped_*.primertrimmed.sorted.bam*"
publishDir "${params.output}/${params.genomedir}/${name}/", mode: 'copy', pattern: "${name}.trimmed.rg.sorted.bam"
publishDir "${params.output}/${params.genomedir}/all_consensus_sequences/", mode: 'copy', pattern: "*.consensus.fasta"

input:
Expand All @@ -11,6 +12,7 @@ process artic_medaka {
tuple val(name), path("${name}_mapped_*.primertrimmed.sorted.bam"), path("${name}_mapped_*.primertrimmed.sorted.bam.bai"), emit: reference_bam
tuple val(name), path("SNP_${name}.pass.vcf"), emit: vcf
tuple val(name), path("${name}.pass.vcf.gz"), path("${name}.coverage_mask.txt.*1.depths"), path("${name}.coverage_mask.txt.*2.depths"), emit: covarplot
tuple val(name), path("${name}.trimmed.rg.sorted.bam"), emit: fullbam
script:
"""
artic minion --medaka \
Expand Down Expand Up @@ -45,14 +47,16 @@ process artic_medaka {
SNP_${name}.pass.vcf \
${name}.pass.vcf.gz \
${name}.coverage_mask.txt.nCoV-2019_1.depths \
${name}.coverage_mask.txt.nCoV-2019_2.depths
${name}.coverage_mask.txt.nCoV-2019_2.depths \
${name}.trimmed.rg.sorted.bam
"""
}

process artic_nanopolish {
label 'artic'
publishDir "${params.output}/${params.genomedir}/${name}/", mode: 'copy', pattern: "*.consensus.fasta"
publishDir "${params.output}/${params.genomedir}/${name}/", mode: 'copy', pattern: "${name}_mapped_*.primertrimmed.sorted.bam*"
publishDir "${params.output}/${params.genomedir}/${name}/", mode: 'copy', pattern: "${name}.trimmed.rg.sorted.bam"
publishDir "${params.output}/${params.genomedir}/all_consensus_sequences/", mode: 'copy', pattern: "*.consensus.fasta"

input:
Expand All @@ -62,6 +66,7 @@ process artic_nanopolish {
tuple val(name), path("${name}_mapped_*.primertrimmed.sorted.bam"), path("${name}_mapped_*.primertrimmed.sorted.bam.bai"), emit: reference_bam
tuple val(name), path("SNP_${name}.pass.vcf"), emit: vcf
tuple val(name), path("${name}.pass.vcf.gz"), path("${name}.coverage_mask.txt.*1.depths"), path("${name}.coverage_mask.txt.*2.depths"), emit: covarplot
tuple val(name), path("${name}.trimmed.rg.sorted.bam"), emit: fullbam
script:
"""
artic minion --minimap2 --normalise 500 \
Expand Down Expand Up @@ -95,10 +100,11 @@ process artic_nanopolish {
SNP_${name}.pass.vcf \
${name}.pass.vcf.gz \
${name}.coverage_mask.txt.nCoV-2019_1.depths \
${name}.coverage_mask.txt.nCoV-2019_2.depths
${name}.coverage_mask.txt.nCoV-2019_2.depths \
${name}.trimmed.rg.sorted.bam
"""
}



// --min-depth
// --min-depth
2 changes: 1 addition & 1 deletion workflows/process/collect_fastq.nf
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ process collect_fastq {
BARCODE_DIRS=\$(find -L ${dir} -name "barcode??" -type d)
if [ -z "\${BARCODE_DIRS}" ]; then
guppy_barcoder -t ${task.cpus} -r ${barcoding_option} -i ${dir} -s fastq_porecov --arrangements_files "${guppy_arrangement_files}"
guppy_barcoder -t ${task.cpus} -r ${barcoding_option} -i ${dir} -s fastq_porecov --detect_mid_strand_barcodes --min_score_mid_barcodes 50 --arrangements_files "${guppy_arrangement_files}"
for barcodes in fastq_porecov/barcode??; do
find -L \${barcodes} -name '*.fastq' -exec cat {} + | gzip >> \${barcodes##*/}.fastq.gz
Expand Down
4 changes: 2 additions & 2 deletions workflows/process/guppy.nf
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ process guppy_gpu {
else
"""
guppy_basecaller -c ${params.guppy_model} -i ${dir} -s fastq_tmp -x auto -r --disable_pings
guppy_barcoder -t ${task.cpus} -r ${barcoding_option} -i fastq_tmp -s fastq --arrangements_files "${guppy_arrangement_files}" --disable_pings
guppy_barcoder -t ${task.cpus} -r ${barcoding_option} -i fastq_tmp -s fastq --detect_mid_strand_barcodes --min_score_mid_barcodes 50 --arrangements_files "${guppy_arrangement_files}" --disable_pings
for barcodes in fastq/barcode??; do
find -L \${barcodes} -name '*.fastq' -exec cat {} + | gzip > \${barcodes##*/}.fastq.gz
Expand Down Expand Up @@ -115,7 +115,7 @@ process guppy_cpu {
else
"""
guppy_basecaller -c ${params.guppy_model} -i ${dir} -s fastq_tmp --num_callers ${task.cpus} --cpu_threads_per_caller 1 -r --disable_pings
guppy_barcoder -t ${task.cpus} -r ${barcoding_option} -i fastq_tmp -s fastq --arrangements_files "${guppy_arrangement_files}" --disable_pings
guppy_barcoder -t ${task.cpus} -r ${barcoding_option} -i fastq_tmp -s fastq --detect_mid_strand_barcodes --min_score_mid_barcodes 50 --arrangements_files "${guppy_arrangement_files}" --disable_pings
for barcodes in fastq/barcode??; do
find -L \${barcodes} -name '*.fastq' -exec cat {} + | gzip > \${barcodes##*/}.fastq.gz
Expand Down

0 comments on commit 9ba98fe

Please sign in to comment.