Last active
April 15, 2020 21:21
-
-
Save geetduggal/ca0786137ef6109315cc7a729593bd81 to your computer and use it in GitHub Desktop.
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
workflow bam_chrom_counter { | |
File bam | |
Int i | |
call slice_bam { | |
input : bam = bam | |
} | |
scatter (slice in slice_bam.slices) { | |
call count_bam { | |
input: bam = slice | |
} | |
} | |
output { | |
File bai = slice_bam.bai | |
Array[Int] counts = count_bam.count | |
} | |
} | |
task slice_bam { | |
File bam | |
Int num_chrom = 22 | |
command <<< | |
set -ex | |
samtools index ${bam} | |
mkdir slices/ | |
for i in `seq ${num_chrom}`; do | |
samtools view -b ${bam} -o slices/$i.bam $i | |
done | |
>>> | |
runtime { | |
docker: "quay.io/ucsc_cgl/samtools" | |
} | |
output { | |
File bai = "${bam}.bai" | |
Array[File] slices = glob("slices/*.bam") | |
} | |
} | |
task count_bam { | |
File bam | |
command <<< | |
samtools view -c ${bam} | |
>>> | |
runtime { | |
docker: "quay.io/ucsc_cgl/samtools" | |
} | |
output { | |
Int count = read_int(stdout()) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment