There may already be a recipe for this, so asking first before reinventing the wheel:
I would like to create a bed file where the score is the average mapQ from the reads of the
input.bam file. I think
bedops are the way to go:
Other than simply running
bam2bed, I would like to be able to define a sliding window size and step for the windows, of say, size=1000 and step=200.
I also would like to generate the bam2bed information only from a list of regions in
regions.bed. E.g., something like:
mapq_sliding_windows --bam input.bam --wsize 1000 -wstep 200 --regions regions.bed > mapq_sliding_windows.bed
Thank you Aaron for you answer. I got it working but it's slow for my 30x WGS bams:
mysql --user=genome --host=genome-mysql.cse.ucsc.edu -A -e "select chrom, size from hg19.chromInfo" > hg19.genome bedtools makewindows -g hg19.genome -w 1000 -s 200 > hg19.windows.bed bedtools map -a hg19.windows.bed -b <(bedtools bamtobed -i input.bam | grep -v chrM) -c 5 -o mean > input.mapq.bed
Last step is taking 6 hours and still running on an 86G bam. Any possible ways to make it faster?