diff --git a/conf/modules.config b/conf/modules.config index dafd5469..1fbab603 100755 --- a/conf/modules.config +++ b/conf/modules.config @@ -41,7 +41,7 @@ process { // Files to be used for pretext, likely to be deleted once the hic workflow is complete. // .bed, .hr.pretext, .lr.pretext, needs centromere - withName: 'REFORMAT_INTERSECT|SEQTK_CUTN|GAP_LENGTH|PRETEXT_INGEST_HIRES|PRETEXT_INGEST_SNDRD|COOLER_ZOOMIFY|COV_FOLDER|UCSC_BEDGRAPHTOBIGWIG|BED2BW_NORMAL|BED2BW_AVGCOV|EXTRACT_TELO|JUICER_TOOLS_PRE|SNAPSHOT_SRES|PRETEXT_GRAPH' { + withName: 'REFORMAT_INTERSECT|SEQTK_CUTN|GAP_LENGTH|PRETEXT_INGEST_HIRES|PRETEXT_INGEST_SNDRD|COOLER_ZOOMIFY|COV_FOLDER|UCSC_BEDGRAPHTOBIGWIG|BED2BW_NORMAL|BED2BW_AVGCOV|EXTRACT_TELO|JUICER_TOOLS_PRE|SNAPSHOT_SRES|PRETEXT_GRAPH|SAMTOOLS_MERGE_OUTPUT_BAM' { publishDir = [ path: { "${params.outdir}/hic_files" }, mode: params.publish_dir_mode, @@ -366,6 +366,10 @@ process { ext.prefix = { "${meta.id}_hic_bwamem2_merge" } } + withName: ".*:.*:HIC_BWAMEM2:SAMTOOLS_MERGE_OUTPUT_BAM" { + ext.prefix = { "${meta.id}_hic_bwamem2_merge" } + } + withName: ".*:.*:HIC_MINIMAP2:CRAM_FILTER_MINIMAP2_FILTER5END_FIXMATE_SORT" { ext.args = "" ext.args1 = "" @@ -378,6 +382,10 @@ process { ext.prefix = { "${meta.id}_hic_minimap2_merge" } } + withName: ".*:.*:HIC_MINIMAP2:SAMTOOLS_MERGE_OUTPUT_BAM" { + ext.prefix = { "${meta.id}_hic_minimap2_merge" } + } + withName: ".*:.*:GENERATE_SORTED_GENOME:GNU_SORT" { ext.prefix = { "${meta.id}_len_sorted" } ext.suffix = { "genome" } diff --git a/subworkflows/local/hic_bwamem2.nf b/subworkflows/local/hic_bwamem2.nf index 9409cf7a..e39d0dd6 100755 --- a/subworkflows/local/hic_bwamem2.nf +++ b/subworkflows/local/hic_bwamem2.nf @@ -10,6 +10,7 @@ // include { BWAMEM2_INDEX } from '../../modules/nf-core/bwamem2/index/main' include { CRAM_FILTER_ALIGN_BWAMEM2_FIXMATE_SORT } from '../../modules/local/cram_filter_align_bwamem2_fixmate_sort' +include { SAMTOOLS_MERGE_OUTPUT_BAM } from '../../modules/nf-core/samtools/merge/main' include { SAMTOOLS_MERGE } from '../../modules/nf-core/samtools/merge/main' workflow HIC_BWAMEM2 { @@ -17,6 +18,7 @@ workflow HIC_BWAMEM2 { reference_tuple // Channel: tuple [ val(meta), path( file ) ] csv_ch reference_index + output_bam main: ch_versions = Channel.empty() @@ -73,6 +75,10 @@ workflow HIC_BWAMEM2 { ], file ) + } + .branch{ + output : it[0].output_bam == "true" + no_output : it[0].output_bam != "true" } .set { collected_files_for_merge } @@ -80,14 +86,23 @@ workflow HIC_BWAMEM2 { // MODULE: MERGE POSITION SORTED BAM FILES AND MARK DUPLICATES // SAMTOOLS_MERGE ( - collected_files_for_merge, + collected_files_for_merge.no_output, reference_tuple, reference_index ) ch_versions = ch_versions.mix ( SAMTOOLS_MERGE.out.versions.first() ) + ch_mergedbam = SAMTOOLS_MERGE.out.bam + SAMTOOLS_MERGE_OUTPUT_BAM ( + collected_files_for_merge.output, + reference_tuple, + reference_index + ) + ch_versions = ch_versions.mix ( SAMTOOLS_MERGE_OUTPUT_BAM.out.versions.first() ) + ch_mergedbam = ch_mergedbam.mix( SAMTOOLS_MERGE_OUTPUT_BAM.out.bam ) + emit: - mergedbam = SAMTOOLS_MERGE.out.bam + mergedbam = ch_mergedbam versions = ch_versions.ifEmpty(null) } \ No newline at end of file diff --git a/subworkflows/local/hic_mapping.nf b/subworkflows/local/hic_mapping.nf index e379f49a..d7d91277 100755 --- a/subworkflows/local/hic_mapping.nf +++ b/subworkflows/local/hic_mapping.nf @@ -35,6 +35,7 @@ workflow HIC_MAPPING { avgcoverage_file // Channel: tuple [ val(meta), path( file ) ] telo_file // Channel: tuple [ val(meta), path( file ) ] repeat_density_file // Channel: tuple [ val(meta), path( file ) ] + output_bam // Channel: val workflow_setting // Channel: val( { RAPID | FULL | RAPID_TOL } ) main: @@ -90,7 +91,8 @@ workflow HIC_MAPPING { HIC_MINIMAP2 ( ch_aligner.minimap2, GENERATE_CRAM_CSV.out.csv, - reference_index + reference_index, + output_bam ) ch_versions = ch_versions.mix( HIC_MINIMAP2.out.versions ) mergedbam = HIC_MINIMAP2.out.mergedbam @@ -101,7 +103,8 @@ workflow HIC_MAPPING { HIC_BWAMEM2 ( ch_aligner.bwamem2, GENERATE_CRAM_CSV.out.csv, - reference_index + reference_index, + output_bam ) ch_versions = ch_versions.mix( HIC_BWAMEM2.out.versions ) mergedbam = mergedbam.mix(HIC_BWAMEM2.out.mergedbam) diff --git a/subworkflows/local/hic_minimap2.nf b/subworkflows/local/hic_minimap2.nf index b37ff30d..3032cfcb 100755 --- a/subworkflows/local/hic_minimap2.nf +++ b/subworkflows/local/hic_minimap2.nf @@ -10,6 +10,7 @@ // include { CRAM_FILTER_MINIMAP2_FILTER5END_FIXMATE_SORT } from '../../modules/local/cram_filter_minimap2_filter5end_fixmate_sort' include { SAMTOOLS_MERGE } from '../../modules/nf-core/samtools/merge/main' +include { SAMTOOLS_MERGE_OUTPUT_BAM } from '../../modules/nf-core/samtools/merge/main' include { MINIMAP2_INDEX } from '../../modules/nf-core/minimap2/index/main' @@ -19,6 +20,7 @@ workflow HIC_MINIMAP2 { reference_tuple // Channel: tuple [ val(meta), path( file ) ] csv_ch reference_index + output_bam main: ch_versions = Channel.empty() @@ -83,20 +85,33 @@ workflow HIC_MINIMAP2 { file ) } + .branch{ + output : it[0].output_bam == "true" + no_output : it[0].output_bam != "true" + } .set { collected_files_for_merge } // // MODULE: MERGE POSITION SORTED BAM FILES AND MARK DUPLICATES // SAMTOOLS_MERGE ( - collected_files_for_merge, + collected_files_for_merge.no_output, reference_tuple, reference_index ) ch_versions = ch_versions.mix ( SAMTOOLS_MERGE.out.versions.first() ) + ch_mergedbam = SAMTOOLS_MERGE.out.bam + + SAMTOOLS_MERGE_OUTPUT_BAM ( + collected_files_for_merge.output, + reference_tuple, + reference_index + ) + ch_versions = ch_versions.mix ( SAMTOOLS_MERGE_OUTPUT_BAM.out.versions.first() ) + ch_mergedbam = ch_mergedbam.mix( SAMTOOLS_MERGE_OUTPUT_BAM.out.bam ) emit: - mergedbam = SAMTOOLS_MERGE.out.bam + mergedbam = ch_mergedbam versions = ch_versions.ifEmpty(null) } diff --git a/subworkflows/local/yaml_input.nf b/subworkflows/local/yaml_input.nf index e3ad75da..d7cc2c12 100755 --- a/subworkflows/local/yaml_input.nf +++ b/subworkflows/local/yaml_input.nf @@ -36,6 +36,7 @@ workflow YAML_INPUT { busco_gene: ( data.busco ) teloseq: ( data.telomere ) map_order: ( data.map_order) + output_bam: ( data.output_bam) } .set{ group } @@ -217,6 +218,7 @@ workflow YAML_INPUT { assembly_id = tolid_version reference_ch = ref_ch map_order_ch = group.map_order + output_bam_ch = group.output_bam read_ch = read_ch diff --git a/workflows/treeval.nf b/workflows/treeval.nf index 526075da..8f3a22f8 100755 --- a/workflows/treeval.nf +++ b/workflows/treeval.nf @@ -241,6 +241,7 @@ workflow TREEVAL { READ_COVERAGE.out.ch_covbw_avg, TELO_FINDER.out.bedgraph_file, REPEAT_DENSITY.out.repeat_density, + YAML_INPUT.out.output_bam_ch, params.entry ) ch_versions = ch_versions.mix( HIC_MAPPING.out.versions ) diff --git a/workflows/treeval_rapid.nf b/workflows/treeval_rapid.nf index 8a483b5e..e64ca0f3 100755 --- a/workflows/treeval_rapid.nf +++ b/workflows/treeval_rapid.nf @@ -121,6 +121,7 @@ workflow TREEVAL_RAPID { READ_COVERAGE.out.ch_covbw_avg, TELO_FINDER.out.bedgraph_file, REPEAT_DENSITY.out.repeat_density, + YAML_INPUT.out.output_bam_ch, params.entry ) ch_versions = ch_versions.mix( HIC_MAPPING.out.versions ) diff --git a/workflows/treeval_rapid_tol.nf b/workflows/treeval_rapid_tol.nf index 5d651a1a..420b1f8f 100755 --- a/workflows/treeval_rapid_tol.nf +++ b/workflows/treeval_rapid_tol.nf @@ -130,6 +130,7 @@ workflow TREEVAL_RAPID_TOL { READ_COVERAGE.out.ch_covbw_avg, TELO_FINDER.out.bedgraph_file, REPEAT_DENSITY.out.repeat_density, + YAML_INPUT.out.output_bam_ch, params.entry ) ch_versions = ch_versions.mix( HIC_MAPPING.out.versions )