18 lines
539 B
Python
18 lines
539 B
Python
from frst.dependences import pybam
|
|
|
|
def parse_bam(bam_file):
|
|
cov = {}
|
|
cov_val = 0
|
|
for alignment in pybam.read(bam_file):
|
|
#pos 1 based (see Pybam doc)
|
|
start_pos = alignment.sam_pos1
|
|
end_pos = alignment.sam_pos1 + alignment.sam_block_size
|
|
if start_pos not in cov:
|
|
cov[start_pos] = 0
|
|
if end_pos not in cov:
|
|
cov[end_pos] = 0
|
|
# add a weight on the start and lower on the end
|
|
cov[start_pos] = cov_val +1
|
|
cov[end_pos] = cov_val -1
|
|
return cov
|