This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Length of Bases in Overlapping Regions Calculated By BEDOPS

Hi, I have 2 bed files.

File 1: ref.bed

chr9    9383800    9493700    REGION

File 2: map.bed

chr9    9387448    9387482    PTPRD_EXON

I want to calculate a length of bases in an area overlapping between ref.bed and map.bed

So I used BEDOPS bedmap function as follows, and got the following result file.

$ bedmap --echo --bases  ref.bed map.bed > result.bed
$ cat result.bed
chr9    9383800    9493700    REGION|34

Thus, this result file indicates that the length of bases in an overlapping area is "34bp".

However, I think the length might be incorrect.

Because, in this case, the overlapping area is chr9:9387448..9387482.

So, the length of overlapping area is 9387482-9387448+1 = "35bp".

Could you tell me whether my opinion is right?

bed

1 answer

BED files are zero-based. This means that the number of bases in a BED element is simply the difference of the stop and start coordinates. See: What Are The Advantages/Disadvantages Of One-Based Vs. Zero-Based Genome Coordinate Systems

Thank you for your answer.

I could learn very important point about BED file.

BEDOPS is very useful tool. I want to continue utilizing that.

Log in to answer this question.