From a0f0fb7ac7b75a553e4d78bfffc9c1520f060039 Mon Sep 17 00:00:00 2001 From: William Eagles Date: Tue, 19 Dec 2023 16:23:49 +0000 Subject: [PATCH 1/4] Add subsample bam --- modules/local/subsample_bam.nf | 45 +++++++++++++++++++++++++++++++ subworkflows/local/hic_mapping.nf | 9 +++++++ 2 files changed, 54 insertions(+) create mode 100755 modules/local/subsample_bam.nf diff --git a/modules/local/subsample_bam.nf b/modules/local/subsample_bam.nf new file mode 100755 index 00000000..575b58fe --- /dev/null +++ b/modules/local/subsample_bam.nf @@ -0,0 +1,45 @@ +process SUBSAMPLE_BAM { + tag "${meta.id}" + label 'process_tiny' + + conda "bioconda::samtools=1.17" + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/samtools:1.17--h00cdaf9_0' : + 'biocontainers/samtools:1.17--h00cdaf9_0' }" + + input: + tuple val(meta), path(mergedbam) + + output: + tuple val(meta), path('*.bam'), emit: csv + path "versions.yml", emit: versions + + script: + def prefix = task.ext.prefix ?: "${meta.id}" + $/ + bamsize=`wc -c "${file}" | cut -d$' ' -f1` + percentage=`50000000000/bamsize` + + if [[ $percentage -lt 1 ]] + then + samtools view -s $percentage -b ${mergedbam} > ${prefix}_subsampled.bam + else + mv ${mergedbam} ${prefix}_subsampled.bam + fi + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + samtools: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//' ) + END_VERSIONS + /$ + + stub: + """ + touch ${meta.id}_subsampled.bam + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + samtools: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//' ) + END_VERSIONS + """ +} diff --git a/subworkflows/local/hic_mapping.nf b/subworkflows/local/hic_mapping.nf index c9a31a4b..72d70456 100755 --- a/subworkflows/local/hic_mapping.nf +++ b/subworkflows/local/hic_mapping.nf @@ -22,6 +22,7 @@ include { GENERATE_CRAM_CSV } from '../../modules/local/ include { CRAM_FILTER_ALIGN_BWAMEM2_FIXMATE_SORT } from '../../modules/local/cram_filter_align_bwamem2_fixmate_sort' include { JUICER_TOOLS_PRE } from '../../modules/local/juicer_tools_pre' include { GET_PAIRED_CONTACT_BED } from '../../modules/local/get_paired_contact_bed' +include { SUBSAMPLE_BAM } from '../../modules/local/subsample_bam.nf' include { PRETEXT_INGESTION as PRETEXT_INGEST_SNDRD } from '../../subworkflows/local/pretext_ingestion' include { PRETEXT_INGESTION as PRETEXT_INGEST_HIRES } from '../../subworkflows/local/pretext_ingestion' @@ -209,6 +210,14 @@ workflow HIC_MAPPING { // SNAPSHOT_HRES ( PRETEXTMAP_HIGHRES.out.pretext ) // ch_versions = ch_versions.mix ( SNAPSHOT_HRES.out.versions ) + // + // MODULE: SUBSAMPLE BAM IF OVER 50G + // + SUBSAMPLE_BAM ( + SAMTOOLS_MERGE.out.bam + ) + ch_versions = ch_versions.mix ( SUBSAMPLE_BAM.out.versions ) + // // MODULE: MERGE POSITION SORTED BAM FILES AND MARK DUPLICATES // From 6a5d453175c29d431d37c4137d029678bec07e20 Mon Sep 17 00:00:00 2001 From: William Eagles Date: Thu, 4 Jan 2024 13:19:52 +0000 Subject: [PATCH 2/4] Update CAT_CAT prefix --- conf/modules.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/modules.config b/conf/modules.config index de920d84..8a5578c5 100755 --- a/conf/modules.config +++ b/conf/modules.config @@ -345,7 +345,7 @@ process { // // SUBWORKFLOW: KMER // - withName: CAT_CAT { + withName: ".*:.*:FASTK_FASTK:CAT_CAT" { ext.prefix = { "${meta.id}_merged.fasta.gz" } } From 8b219123479385bbe5eda6d4c93abec16815281d Mon Sep 17 00:00:00 2001 From: William Eagles Date: Thu, 4 Jan 2024 13:32:24 +0000 Subject: [PATCH 3/4] Cleanup subsample --- modules/local/subsample_bam.nf | 45 ------------------------------- subworkflows/local/hic_mapping.nf | 9 ------- 2 files changed, 54 deletions(-) delete mode 100755 modules/local/subsample_bam.nf diff --git a/modules/local/subsample_bam.nf b/modules/local/subsample_bam.nf deleted file mode 100755 index 575b58fe..00000000 --- a/modules/local/subsample_bam.nf +++ /dev/null @@ -1,45 +0,0 @@ -process SUBSAMPLE_BAM { - tag "${meta.id}" - label 'process_tiny' - - conda "bioconda::samtools=1.17" - container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? - 'https://depot.galaxyproject.org/singularity/samtools:1.17--h00cdaf9_0' : - 'biocontainers/samtools:1.17--h00cdaf9_0' }" - - input: - tuple val(meta), path(mergedbam) - - output: - tuple val(meta), path('*.bam'), emit: csv - path "versions.yml", emit: versions - - script: - def prefix = task.ext.prefix ?: "${meta.id}" - $/ - bamsize=`wc -c "${file}" | cut -d$' ' -f1` - percentage=`50000000000/bamsize` - - if [[ $percentage -lt 1 ]] - then - samtools view -s $percentage -b ${mergedbam} > ${prefix}_subsampled.bam - else - mv ${mergedbam} ${prefix}_subsampled.bam - fi - - cat <<-END_VERSIONS > versions.yml - "${task.process}": - samtools: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//' ) - END_VERSIONS - /$ - - stub: - """ - touch ${meta.id}_subsampled.bam - - cat <<-END_VERSIONS > versions.yml - "${task.process}": - samtools: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//' ) - END_VERSIONS - """ -} diff --git a/subworkflows/local/hic_mapping.nf b/subworkflows/local/hic_mapping.nf index 72d70456..c9a31a4b 100755 --- a/subworkflows/local/hic_mapping.nf +++ b/subworkflows/local/hic_mapping.nf @@ -22,7 +22,6 @@ include { GENERATE_CRAM_CSV } from '../../modules/local/ include { CRAM_FILTER_ALIGN_BWAMEM2_FIXMATE_SORT } from '../../modules/local/cram_filter_align_bwamem2_fixmate_sort' include { JUICER_TOOLS_PRE } from '../../modules/local/juicer_tools_pre' include { GET_PAIRED_CONTACT_BED } from '../../modules/local/get_paired_contact_bed' -include { SUBSAMPLE_BAM } from '../../modules/local/subsample_bam.nf' include { PRETEXT_INGESTION as PRETEXT_INGEST_SNDRD } from '../../subworkflows/local/pretext_ingestion' include { PRETEXT_INGESTION as PRETEXT_INGEST_HIRES } from '../../subworkflows/local/pretext_ingestion' @@ -210,14 +209,6 @@ workflow HIC_MAPPING { // SNAPSHOT_HRES ( PRETEXTMAP_HIGHRES.out.pretext ) // ch_versions = ch_versions.mix ( SNAPSHOT_HRES.out.versions ) - // - // MODULE: SUBSAMPLE BAM IF OVER 50G - // - SUBSAMPLE_BAM ( - SAMTOOLS_MERGE.out.bam - ) - ch_versions = ch_versions.mix ( SUBSAMPLE_BAM.out.versions ) - // // MODULE: MERGE POSITION SORTED BAM FILES AND MARK DUPLICATES // From ab544f11ec64674db254b5cfb3e7226b45bc1d4e Mon Sep 17 00:00:00 2001 From: William Eagles Date: Thu, 4 Jan 2024 15:03:39 +0000 Subject: [PATCH 4/4] Update cat_cat config --- conf/modules.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/modules.config b/conf/modules.config index 8a5578c5..343957da 100755 --- a/conf/modules.config +++ b/conf/modules.config @@ -345,7 +345,7 @@ process { // // SUBWORKFLOW: KMER // - withName: ".*:.*:FASTK_FASTK:CAT_CAT" { + withName: ".*:.*:KMER:CAT_CAT" { ext.prefix = { "${meta.id}_merged.fasta.gz" } }