daler / pybedtools

Python wrapper -- and more -- for BEDTools (bioinformatics tools for "genome arithmetic")
http://daler.github.io/pybedtools
Other
297 stars 103 forks source link

total_coverage giving a incorrect value #409

Open duartemolha opened 1 month ago

duartemolha commented 1 month ago

Hi... I wonder if you can help me with this. I have tested this with pybedtools=0.10.0 and bedtools v2.31.0

from pybedtools import BedTool

string_of_intervals='1\t1199\t1800\tENST000001\t0\t+\n1\t1299\t1900\tENST000002\t0\t+\n'
value = BedTool(string_of_intervals, from_string=True).sort().merge().total_coverage()  
print(value)
#value printed our is 701

this could be calculating the length of the merged interval created the merged interval is 1 1199 1900

since bed files use zero-based half-open intervals intervals this should correspond to an interval of length 700 bp, however total_coverage method produces 701

Can you please explain if I am missing something?

Many thanks

Duarte