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
22 changes: 19 additions & 3 deletions subworkflows/nf-core/fastq_align_chromap/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
* Map reads, sort, index BAM file and run samtools stats, flagstat and idxstats
*/

include { CHROMAP_CHROMAP } from '../../../modules/nf-core/chromap/chromap/main'
include { BAM_SORT_STATS_SAMTOOLS } from '../bam_sort_stats_samtools/main'
include { CHROMAP_CHROMAP } from '../../../modules/nf-core/chromap/chromap/main'
include { PICARD_ADDORREPLACEREADGROUPS } from '../../../modules/nf-core/picard/addorreplacereadgroups/main'
include { BAM_SORT_STATS_SAMTOOLS } from '../bam_sort_stats_samtools/main'

workflow FASTQ_ALIGN_CHROMAP {
take:
Expand All @@ -14,9 +15,13 @@ workflow FASTQ_ALIGN_CHROMAP {
ch_whitelist // channel (optional): [ whitelist ]
ch_chr_order // channel (optional): [ chr_order ]
ch_pairs_chr_order // channel (optional): [ pairs_chr_order ]
update_readgroups // boolean (optional): true or false controls whether readgroups should be updated post alignment

main:

ch_bam = channel.empty()
def add_readgroups = update_readgroups ?: false

//
// Remap ch_fasta_fai to ch_fasta
//
Expand All @@ -27,10 +32,21 @@ workflow FASTQ_ALIGN_CHROMAP {
//
CHROMAP_CHROMAP(ch_reads, ch_fasta, ch_index, ch_barcodes, ch_whitelist, ch_chr_order, ch_pairs_chr_order)

//
// Update read groups
//
PICARD_ADDORREPLACEREADGROUPS(CHROMAP_CHROMAP.out.bam, ch_fasta_fai)

if (add_readgroups == true) {
ch_bam = PICARD_ADDORREPLACEREADGROUPS.out.bam
} else {
ch_bam = CHROMAP_CHROMAP.out.bam
}

//
// Sort, index BAM file and run samtools stats, flagstat and idxstats
//
BAM_SORT_STATS_SAMTOOLS(CHROMAP_CHROMAP.out.bam, ch_fasta_fai)
BAM_SORT_STATS_SAMTOOLS(ch_bam, ch_fasta_fai)

emit:
bam = BAM_SORT_STATS_SAMTOOLS.out.bam // channel: [ val(meta), [ bam ] ]
Expand Down
8 changes: 7 additions & 1 deletion subworkflows/nf-core/fastq_align_chromap/meta.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/subworkflows/yaml-schema.json
name: "fastq_align_chromap"
description: Align high throughput chromatin profiles using Chromap then sort with samtools
description: Align high throughput chromatin profiles using Chromap, updating readgroups if neccessary and then sort with samtools
keywords:
- align
- fasta
Expand All @@ -12,6 +12,7 @@ keywords:
- hic
components:
- chromap/chromap
- picard/addorreplacereadgroups
- samtools/sort
- samtools/index
- samtools/stats
Expand Down Expand Up @@ -67,6 +68,11 @@ input:
description: |
Structure: [path(pairs_chr_order)]
Natural chromosome order for pairs flipping
- update_readgroups:
type: boolean
description: |
Boolean controling whether the readgroups should be added or updated
after chromap alignment
output:
- meta:
type: map
Expand Down
74 changes: 71 additions & 3 deletions subworkflows/nf-core/fastq_align_chromap/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ nextflow_workflow {
tag "chromap"
tag "chromap/chromap"
tag "chromap/index"
tag "picard/addorreplacereadgroups"
tag "fastq_align_chromap"
tag "subworkflows/fastq_align_chromap"
tag "subworkflows/bam_sort_stats_samtools"
Expand Down Expand Up @@ -46,16 +47,18 @@ nextflow_workflow {
input[4] = []
input[5] = []
input[6] = []
input[7] = false
"""
}
}
then {
assertAll(
{ assert workflow.success },
{ assert snapshot(workflow.out).match() }
{ assert snapshot(sanitizeOutput(workflow.out)).match() }
)
}
}

test("test_fastq_align_chromap_paired_end") {
when {
workflow {
Expand All @@ -77,13 +80,77 @@ nextflow_workflow {
input[4] = []
input[5] = []
input[6] = []
input[7] = false
"""
}
}
then {
assertAll(
{ assert workflow.success },
{ assert snapshot(sanitizeOutput(workflow.out)).match() }
)
}
}

test("test_fastq_align_chromap_single_end_add_readgroups") {
when {
workflow {
"""
input[0] = [
[id:'test', single_end:true],
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test_1.fastq.gz', checkIfExists:true)
]
input[1] = CHROMAP_INDEX.out.index
input[2] = Channel.of([
[id:'test'],
file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta', checkIfExists:true),
file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta.fai', checkIfExists:true)
])
input[3] = []
input[4] = []
input[5] = []
input[6] = []
input[7] = true
"""
}
}
then {
assertAll(
{ assert workflow.success },
{ assert snapshot(sanitizeOutput(workflow.out)).match() }
)
}
}

test("test_fastq_align_chromap_paired_end_add_readgroups") {
when {
workflow {
"""
input[0] = [
[id:'test', single_end:false],
[
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test_1.fastq.gz', checkIfExists:true),
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test_2.fastq.gz', checkIfExists:true)
]
]
input[1] = CHROMAP_INDEX.out.index
input[2] = Channel.of([
[id:'test'],
file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta', checkIfExists:true),
file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta.fai', checkIfExists:true)
])
input[3] = []
input[4] = []
input[5] = []
input[6] = []
input[7] = true
"""
}
}
then {
assertAll(
{ assert workflow.success },
{ assert snapshot(workflow.out).match() }
{ assert snapshot(sanitizeOutput(workflow.out)).match() }
)
}
}
Expand All @@ -110,13 +177,14 @@ nextflow_workflow {
input[4] = []
input[5] = []
input[6] = []
input[7] = false
"""
}
}
then {
assertAll(
{ assert workflow.success },
{ assert snapshot(workflow.out).match() }
{ assert snapshot(sanitizeOutput(workflow.out)).match() }
)
}
}
Expand Down
Loading