from pybedtools.contrib.bigwig import bam_to_bigwig bam_to_bigwig(bam='path/to/bam', genome='hg19', output='path/to/bigwig')
Unfortunately, my genome of interested in not hosted at UCSC, so I needed to alter bam_to_bigwig slightly. In addition, I’ve replaced the read counting function
mapped_read_count with my own implementation that rely on BAM index and therefore return number of alignments nearly instantly. This reduces the time by some minutes for large BAMs.
bam2bigwig.py -i SOME.BAM -g GENOME.fa -o SOME.BAM.bw