Skip to content
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
Binary file not shown.
Binary file not shown.
2 changes: 2 additions & 0 deletions assets/stub/reads_idtumi_mastersheet.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
id,read1,read2
GM24385-AAVS1_site14_1,assets/stub/demux_fastq/LIB074552_22VC5CLT3_S43_L007_R1_001_UMI.fastq.gz,assets/stub/demux_fastq/LIB074552_22VC5CLT3_S43_L007_R2_001_UMI.fastq.gz
6 changes: 2 additions & 4 deletions modules/local/create_fastq_list.nf
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,8 @@ process CREATE_FASTQ_LIST {
runinfo ? "--runinfo ${runinfo}" : "",
].join(' ').trim()
"""
create_fastq_list.py \\
-i ${meta.id} \\
${fastq_list_args}

cp ${projectDir}/assets/stub/demux_fastq/fastq_list.csv ${meta.id}.fastq_list.csv

cat <<-END_VERSIONS > versions.yml
"${task.process}":
python: \$(python --version 2>&1 | awk '{print \$2}')
Expand Down
16 changes: 8 additions & 8 deletions modules/local/dragen_multialign.nf
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ process DRAGEN_MULTIALIGN {
dbsnp ? "--dbsnp ${dbsnp}" : "",
params.alignment_file_format ? "--output-format ${params.alignment_file_format}" : "",
meta.sex?.toLowerCase() in ['male', 'female'] ? "--sample-sex ${meta.sex}" : "",
adapter1 && adapter2 ? "--read-trimmers adapter --trim-adapter-read1 ${adapter1} --trim-adapter-read2 ${adapter2}" : "",
!params.umi && adapter1 && adapter2 ? "--read-trimmers adapter --trim-adapter-read1 ${adapter1} --trim-adapter-read2 ${adapter2}" : "",
annotation_gtf ? "-a ${annotation_gtf}" : "",
params.umi ? "--umi-enable true --umi-library-type=${params.umi}" : "",
params.umi && params.readfamilysize ? "--umi-min-supporting-reads ${readfamilysize}" : "",
params.umi && params.readfamilysize ? "--umi-min-supporting-reads ${params.readfamilysize}" : "",
params.umi && target_bed ? "--umi-metrics-interval-file ${target_bed}" : "",
params.umi && liquid_tumor ? "--vc-enable-umi-liquid true" : "",
params.umi && solid_tumor ? "--vc-enable-umi-solid true" : "",
params.umi && params.liquid_tumor ? "--vc-enable-umi-liquid true" : "",
params.umi && params.solid_tumor ? "--vc-enable-umi-solid true" : "",
hotspots ? "--vc-somatic-hotspots ${hotspots.min{ it.toString().length() }}" : "",
params.variant_caller && target_bed ? "--vc-target-bed ${target_bed}" : "",
snv_noise_file ? "--vc-systematic-noise ${snv_noise_file}" : "",
Expand Down Expand Up @@ -149,12 +149,12 @@ process DRAGEN_MULTIALIGN {
dbsnp ? "--dbsnp ${dbsnp}" : "",
params.alignment_file_format ? "--output-format ${params.alignment_file_format}" : "",
meta.sex?.toLowerCase() in ['male', 'female'] ? "--sample-sex ${meta.sex}" : "",
adapter1 && adapter2 ? "--read-trimmers adapter --trim-adapter-read1 ${adapter1} --trim-adapter-read2 ${adapter2}" : "",
!params.umi && adapter1 && adapter2 ? "--read-trimmers adapter --trim-adapter-read1 ${adapter1} --trim-adapter-read2 ${adapter2}" : "",
params.umi ? "--umi-enable true --umi-library-type=${params.umi}" : "",
params.umi && params.readfamilysize ? "--umi-min-supporting-reads ${readfamilysize}" : "",
params.umi && params.readfamilysize ? "--umi-min-supporting-reads ${params.readfamilysize}" : "",
params.umi && target_bed ? "--umi-metrics-interval-file ${target_bed}" : "",
params.umi && liquid_tumor ? "--vc-enable-umi-liquid true" : "",
params.umi && solid_tumor ? "--vc-enable-umi-solid true" : "",
params.umi && params.liquid_tumor ? "--vc-enable-umi-liquid true" : "",
params.umi && params.solid_tumor ? "--vc-enable-umi-solid true" : "",
hotspots ? "--vc-somatic-hotspots ${hotspots.min{ it.toString().length() }}" : "",
params.variant_caller && target_bed ? "--vc-target-bed ${target_bed}" : "",
snv_noise_file ? "--vc-systematic-noise ${snv_noise_file}" : "",
Expand Down
48 changes: 48 additions & 0 deletions modules/local/trim_adapters.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
process TRIM_ADAPTERS {
tag "${meta.id}"

container "ghcr.io/dhslab/docker-fastp:251229"

input:
tuple val(meta), path(read1file), path(read2file)
path(adapter1)
path(adapter2)

output:
tuple val(meta), path("*.R1_trimmed.fastq.gz"), path("*.R2_trimmed.fastq.gz"), emit: trimmed_fastqs
path("versions.yml") , emit: versions

script:
def command_args = [
read1file ? "-i ${read1file} -o ${read1file.toString().replaceAll(/\.fq$|\.fastq$|\.fq\.gz$|\.fastq\.gz$/, '')}.R1_trimmed.fastq.gz" : "",
read2file ? "-I ${read2file} -O ${read2file.toString().replaceAll(/\.fq$|\.fastq$|\.fq\.gz$|\.fastq\.gz$/, '')}.R2_trimmed.fastq.gz" : ""
].join(' ').trim()
"""
cat ${adapter1} ${adapter2} > adapters.fa

fastp -Q -L --adapter_fasta adapters.fa ${command_args}

cat <<-END_VERSIONS > versions.yml
"${task.process}":
python: \$(python --version 2>&1 | awk '{print \$2}')
\$(create_fastq_list.py -v)
END_VERSIONS
"""

stub:
def command_args = [
read1file ? "-i ${read1file} -o ${read1file.toString().replaceAll(/\.fq$|\.fastq$|\.fq\.gz$|\.fastq\.gz$/, '')}.R1_trimmed.fastq.gz" : "",
read2file ? "-I ${read2file} -O ${read2file.toString().replaceAll(/\.fq$|\.fastq$|\.fq\.gz$|\.fastq\.gz$/, '')}.R2_trimmed.fastq.gz" : ""
].join(' ').trim()
"""
echo fastp ${command_args}
touch \$(basename ${read1file} .fastq.gz).R1_trimmed.fastq.gz
touch \$(basename ${read2file} .fastq.gz).R2_trimmed.fastq.gz

cat <<-END_VERSIONS > versions.yml
"${task.process}":
fastp: 1.0.1
END_VERSIONS
"""

}
39 changes: 33 additions & 6 deletions subworkflows/local/gather_alignment_samples.nf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

include { PARTITION_ALIGNMENT_FILE } from '../../modules/local/partition_alignment_file'
include { CONVERT_ALIGNMENT_FILE_TO_FASTQ } from '../../modules/local/convert_alignment_file_to_fastq'
include { TRIM_ADAPTERS } from '../../modules/local/trim_adapters.nf'
include { CREATE_FASTQ_LIST } from '../../modules/local/create_fastq_list'


Expand All @@ -30,6 +31,16 @@ def parseFastqList(file) {
}
}

// DRAGEN adapter sequences for read 1
ch_adapter1_file = params.adapter1
? Channel.fromPath(params.adapter1, checkIfExists: true).collect()
: Channel.value([])

// DRAGEN adapter sequences for read 2
ch_adapter2_file = params.adapter2
? Channel.fromPath(params.adapter2, checkIfExists: true).collect()
: Channel.value([])

/*
========================================================================================
SUBWORKFLOW TO GATHER ALIGNMENT SAMPLES
Expand All @@ -46,6 +57,7 @@ workflow GATHER_ALIGNMENT_SAMPLES {
main:
ch_versions = Channel.empty()
ch_gathered_fastqs = Channel.empty() // channel: [ val(meta), path(read1), path(read2), path(runinfo.xml) ]
ch_fastqs = Channel.empty() // channel: [ val(meta), path(read1), path(read2), path(runinfo.xml) ]

// This is the output of this subworkflow and is the format for DRAGEN alignment
ch_gathered_samples = Channel.empty() // [ val(sample_info), path(reads), path(fastq_list), path(empty list - placeholder for alignment file) ]
Expand Down Expand Up @@ -172,12 +184,27 @@ workflow GATHER_ALIGNMENT_SAMPLES {
}
.filter{ it!= [] }
)

//
// MODULE: Create fastq_list with local/staged fastq paths and appropriate metadata
//

// Adapter trimming and UMI alignment are not compatible.
// If UMI option is given, then run fastp on FASTQs to trim adapters.
if (params.umi){
TRIM_ADAPTERS (
ch_gathered_fastqs.map { meta, read1, read2, runinfo -> [ meta, read1, read2 ] },
ch_adapter1_file,
ch_adapter2_file
)
ch_versions = ch_versions.mix(TRIM_ADAPTERS.out.versions)

ch_fastqs = TRIM_ADAPTERS.out.trimmed_fastqs
.join(ch_gathered_fastqs)
.map { it -> [ it[0], it[1], it[2], it[5] ] } // regenerate channel with [ meta, trimmed_read1, trimmed_read2, runinfo ]

} else {
ch_fastqs = ch_gathered_fastqs
}

CREATE_FASTQ_LIST (
ch_gathered_fastqs
ch_fastqs
)
ch_versions = ch_versions.mix(CREATE_FASTQ_LIST.out.versions)

Expand All @@ -186,7 +213,7 @@ workflow GATHER_ALIGNMENT_SAMPLES {
//
ch_gathered_samples = ch_gathered_samples
.mix(
ch_gathered_fastqs
ch_fastqs
.filter{ it != [] }
.map{ meta, read1, read2, runinfo -> [ meta, [ read1, read2 ] ] }
.groupTuple()
Expand Down
Loading