I have two bed files ( lets say B1.bed, B2.bed ) to be queried against another file ( A.bed ).
1 1 10 1 30 40 1 80 100 1 110 130
1 1 10 reg1 1 1 10 reg2 1 30 40 reg3 1 30 40 reg4
1 30 40 reg1 1 60 70 reg2 1 80 100 reg3 1 110 130 reg4
I would like to know what would be the way to get an output regions such that the reg1 of B1 and reg1 of B2 both are intersecting a feature in A, and so on for ref2, reg3, reg4.
if reg of B1 and reg of B2 intersects with A: print
I could use the pybedtools:
False# Because reg2 of B2.bed does not intersect with A.bed True True
Here I do not see an option that A.intersect could read data as string, hence I have to convert every interval to a bed file before using it, which might be taking very very long time for the script to run on large data sets.
Is there any other way to do it or to optimize my snippet ? For me its more or less sounds like checking if both the fragments are mapped to same regions, using bedtools
P.S: I dont know how to title this question.