-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #192 from sanger-tol/subset_juicer
Add subsample and branch hic_mapping
- Loading branch information
Showing
4 changed files
with
173 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
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: subsampled_bam | ||
path "versions.yml", emit: versions | ||
|
||
shell: | ||
def prefix = task.ext.prefix ?: "${meta.id}" | ||
''' | ||
percentage=`wc -c !{mergedbam} | cut -d$' ' -f1 | awk '{printf "%.2f\\n", 50000000000 / $0}'` | ||
samtools view -s $percentage -b !{mergedbam} > !{meta.id}_subsampled.bam | ||
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 | ||
""" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#!/usr/bin/env nextflow | ||
|
||
// This subworkflow takes converts .bam to .bed for the hic_mapping subworkflow. | ||
// It runs markdup, sort and get paired contacts. | ||
// Input - Assembled genomic fasta file, .bam file | ||
// Output - sorted .bed and paired contact .bed | ||
|
||
// | ||
// MODULE IMPORT BLOCK | ||
// | ||
include { SAMTOOLS_MARKDUP } from '../../modules/nf-core/samtools/markdup/main' | ||
include { BAMTOBED_SORT } from '../../modules/local/bamtobed_sort.nf' | ||
include { GET_PAIRED_CONTACT_BED } from '../../modules/local/get_paired_contact_bed' | ||
|
||
|
||
workflow HIC_BAMTOBED { | ||
take: | ||
bam_file // Channel: tuple [ val(meta), path( file ) ] | ||
reference_tuple // Channel: tuple [ val(meta), path( file ) ] | ||
|
||
main: | ||
ch_versions = Channel.empty() | ||
|
||
// | ||
// LOGIC: PREPARE MARKDUP INPUT | ||
// | ||
bam_file | ||
.combine( reference_tuple ) | ||
.multiMap { meta_bam, bam_file, meta_ref, ref -> | ||
bam : tuple(meta_bam, bam_file ) | ||
reference : ref | ||
} | ||
.set { markdup_input } | ||
|
||
// | ||
// MODULE: MERGE POSITION SORTED BAM FILES AND MARK DUPLICATES | ||
// | ||
SAMTOOLS_MARKDUP ( | ||
markdup_input.bam, | ||
markdup_input.reference | ||
) | ||
ch_versions = ch_versions.mix ( SAMTOOLS_MARKDUP.out.versions ) | ||
|
||
// | ||
// MODULE: SAMTOOLS FILTER OUT DUPLICATE READS | BAMTOBED | SORT BED FILE | ||
// | ||
BAMTOBED_SORT( | ||
SAMTOOLS_MARKDUP.out.bam | ||
) | ||
ch_versions = ch_versions.mix( BAMTOBED_SORT.out.versions ) | ||
|
||
// | ||
// MODULE: GENERATE CONTACT PAIRS | ||
// | ||
GET_PAIRED_CONTACT_BED( | ||
BAMTOBED_SORT.out.sorted_bed | ||
) | ||
ch_versions = ch_versions.mix( GET_PAIRED_CONTACT_BED.out.versions ) | ||
|
||
emit: | ||
paired_contacts_bed = GET_PAIRED_CONTACT_BED.out.bed | ||
sorted_bed = BAMTOBED_SORT.out.sorted_bed | ||
versions = ch_versions.ifEmpty(null) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters