Skip to content

Commit

Permalink
Merge pull request #145 from mirpedrol/fix-paired-end-bug
Browse files Browse the repository at this point in the history
Fix paired end bug
  • Loading branch information
mirpedrol committed May 29, 2024
2 parents 7ff5a04 + 081ca39 commit c8a2179
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 18 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed

- Adapt cutadapt module to work with single-end and paired-end reads again ([#121](https://github.com/nf-core/crisprseq/pull/121))
- Fix premature completion of the pipeline when paired-end reads were merged ([#145](https://github.com/nf-core/crisprseq/pull/145))
- Create empty \*-QC-indels.csv file if alignments not found. ([#138](https://github.com/nf-core/crisprseq/pull/138))
- Fix `--reference_fasta` and `--protospacer` parameters ([#144](https://github.com/nf-core/crisprseq/pull/144))

## [v2.1.1 - Jamon Salas - patch](https://github.com/nf-core/crisprseq/releases/tag/2.1.1) - [14.12.2023]

Expand Down
2 changes: 2 additions & 0 deletions nextflow_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@
},
"protospacer": {
"type": "string",
"pattern": "^[ACGTacgt]+$",
"errorMessage": "The protospacer must be a valid DNA sequence.",
"fa_icon": "fas fa-grip-lines",
"description": "Provide the same protospacer sequence for all samples. Will override protospacer sequences provided by an input samplesheet."
}
Expand Down
105 changes: 87 additions & 18 deletions workflows/crisprseq_targeted.nf
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,50 @@ workflow CRISPRSEQ_TARGETED {
.set { ch_pear_fastq }
ch_versions = ch_versions.mix(PEAR.out.versions)

// Change reference, protospacer and template channels to have the same meta information as the reads
ch_pear_fastq
.map {meta, reads ->
// save single_end value and remove the key from the meta map
single_end = meta.single_end
return [ meta - meta.subMap('single_end'), reads, single_end ]
}
.tap { no_single_end }
.join(
ORIENT_REFERENCE.out.reference
.map {meta, reference ->
// Remove single_end from the meta map to allow joining two channels with different single_end values
return [ meta - meta.subMap('single_end'), reference ]
}
)
.map {meta, reads, single_end, reference ->
// Add the correct single_end value to the reference meta map.
return [ meta + ["single_end": single_end], reference ]
}
.tap{ ch_oriented_reference }
no_single_end
.join(
INITIALISATION_CHANNEL_CREATION_TARGETED.out.template
.map {meta, template ->
return [ meta - meta.subMap('single_end'), template ]
}
)
.map {meta, reads, single_end, template ->
return [ meta + ["single_end": single_end], template ]
}
.set{ ch_template }
no_single_end
.join(
INITIALISATION_CHANNEL_CREATION_TARGETED.out.reference_protospacer
.map {meta, reference, protospacer ->
return [ meta - meta.subMap('single_end'), protospacer ]
}
)
.map {meta, reads, single_end, protospacer ->
return [ meta + ["single_end": single_end], protospacer ]
}
.set{ ch_protospacer }


//
// MODULE: Run FastQC
//
Expand Down Expand Up @@ -223,25 +267,50 @@ workflow CRISPRSEQ_TARGETED {
ch_cat_fastq.paired
.mix(ch_cat_fastq.single)
.join(PEAR.out.assembled, remainder: true)
.join(SEQTK_SEQ_MASK.out.fastx)
.join(CUTADAPT.out.log)
.map { meta, reads, assembled, masked, trimmed ->
.map { meta, reads, assembled ->
// Remove the single_end key from the meta map to allow joining channels with different single_end values
return [ meta - meta.subMap('single_end'), reads, assembled]
}
.join(
SEQTK_SEQ_MASK.out.fastx
.map { meta, masked ->
single_end = meta.single_end
return [ meta - meta.subMap('single_end'), masked, single_end]
}
)
.join(
CUTADAPT.out.log
.map { meta, trimmed ->
return [ meta - meta.subMap('single_end'), trimmed]
}
)
.map { meta, reads, assembled, masked, single_end, trimmed ->
if (assembled == null) {
assembled = []
}
return [ meta, reads, assembled, masked, trimmed ]
return [ meta + ["single_end": single_end], reads, assembled, masked, trimmed ]
}
.set { ch_preprocessing_summary_data }
} else {
ch_cat_fastq.paired
.mix(ch_cat_fastq.single)
.join(PEAR.out.assembled, remainder: true)
.join(SEQTK_SEQ_MASK.out.fastx)
.map { meta, reads, assembled, masked ->
.map { meta, reads, assembled ->
// Remove the single_end key from the meta map to allow joining channels with different single_end values
return [ meta - meta.subMap('single_end'), reads, assembled]
}
.join(
SEQTK_SEQ_MASK.out.fastx
.map { meta, masked ->
single_end = meta.single_end
return [ meta - meta.subMap('single_end'), masked, single_end]
}
)
.map { meta, reads, assembled, masked, single_end ->
if (assembled == null) {
assembled = []
}
return [ meta, reads, assembled, masked, [] ]
return [ meta + ["single_end": single_end], reads, assembled, masked, [] ]
}
.set { ch_preprocessing_summary_data }
}
Expand Down Expand Up @@ -494,7 +563,7 @@ workflow CRISPRSEQ_TARGETED {
if (params.aligner == "minimap2") {
MINIMAP2_ALIGN_ORIGINAL (
ch_preprocess_reads
.join(ORIENT_REFERENCE.out.reference),
.join(ch_oriented_reference),
true,
false,
true
Expand All @@ -508,7 +577,7 @@ workflow CRISPRSEQ_TARGETED {
//
if (params.aligner == "bwa") {
BWA_INDEX (
ORIENT_REFERENCE.out.reference
ch_oriented_reference
)
ch_versions = ch_versions.mix(BWA_INDEX.out.versions)
BWA_MEM (
Expand All @@ -525,7 +594,7 @@ workflow CRISPRSEQ_TARGETED {
//
if (params.aligner == "bowtie2") {
BOWTIE2_BUILD (
ORIENT_REFERENCE.out.reference
ch_oriented_reference
)
ch_versions = ch_versions.mix(BOWTIE2_BUILD.out.versions)
BOWTIE2_ALIGN (
Expand Down Expand Up @@ -561,8 +630,8 @@ workflow CRISPRSEQ_TARGETED {
// MODULE: Obtain a new reference with the template modification
//
TEMPLATE_REFERENCE (
ORIENT_REFERENCE.out.reference
.join(INITIALISATION_CHANNEL_CREATION_TARGETED.out.template)
ch_oriented_reference
.join(ch_template)
)
ch_versions = ch_versions.mix(TEMPLATE_REFERENCE.out.versions.first())

Expand All @@ -572,7 +641,7 @@ workflow CRISPRSEQ_TARGETED {
//
MINIMAP2_ALIGN_TEMPLATE (
TEMPLATE_REFERENCE.out.fasta
.join(ORIENT_REFERENCE.out.reference),
.join(ch_oriented_reference),
true,
false,
true
Expand All @@ -583,9 +652,9 @@ workflow CRISPRSEQ_TARGETED {

ch_mapped_bam
.join(SAMTOOLS_INDEX.out.bai)
.join(ORIENT_REFERENCE.out.reference)
.join(ch_input_protospacer)
.join(INITIALISATION_CHANNEL_CREATION_TARGETED.out.template, remainder: true)
.join(ch_oriented_reference)
.join(ch_protospacer)
.join(ch_template, remainder: true)
.join(ch_template_bam, remainder: true)
.join(TEMPLATE_REFERENCE.out.fasta, remainder: true)
.join(ALIGNMENT_SUMMARY.out.summary)
Expand Down Expand Up @@ -621,8 +690,8 @@ workflow CRISPRSEQ_TARGETED {
//
CRISPRSEQ_PLOTTER (
CIGAR_PARSER.out.indels
.join(ORIENT_REFERENCE.out.reference)
.join(ch_input_protospacer)
.join(ch_oriented_reference)
.join(ch_protospacer)
)
ch_versions = ch_versions.mix(CRISPRSEQ_PLOTTER.out.versions.first())

Expand Down

0 comments on commit c8a2179

Please sign in to comment.