Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add merge_bams process #248

Merged
merged 3 commits into from
Jul 17, 2020
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
18 changes: 18 additions & 0 deletions main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,12 @@ if (params.sentieon) log.warn "[nf-core/sarek] Sentieon will be used, only works
================================================================================
*/


include { BWAMEM2_MEM } from './modules/local/bwamem2_mem.nf'
include { GET_SOFTWARE_VERSIONS } from './modules/local/get_software_versions'
include { OUTPUT_DOCUMENTATION } from './modules/local/output_documentation'
include { TRIM_GALORE } from './modules/local/trim_galore.nf'
include { MERGE_BAM_MAPPED } from './modules/local/merge_mapped_bam' addParams(params)

/*
================================================================================
Expand Down Expand Up @@ -360,6 +362,22 @@ workflow {
BWAMEM2_MEM(input_sample, bwa, fasta, fai)
}

BWAMEM2_MEM.out.groupTuple(by:[0, 1])
.branch {
single: it[2].size() == 1
multiple: it[2].size() > 1
}.set { bam }
bam.single.map {
idPatient, idSample, idRun, bam ->
[idPatient, idSample, bam]
}

bam.single.view()
bam.multiple.view()

//multipleBam = multipleBam.mix(multipleBamSentieon)
MERGE_BAM_MAPPED(bam.multiple)

OUTPUT_DOCUMENTATION(
output_docs,
output_docs_images)
Expand Down
16 changes: 16 additions & 0 deletions modules/local/merge_mapped_bam.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
process MERGE_BAM_MAPPED {
label 'cpus'

tag "${idPatient}-${idSample}"

input:
tuple idPatient, idSample, idRun, path(bam), path(bai)// from multiple

output:
tuple idPatient, idSample, path("${idSample}.bam") //into bam_mapped_merged

script:
"""
samtools merge --threads ${task.cpus} ${idSample}.bam ${bam}
"""
}