I am trying to count the number of hits a value in one file(column) falls between an interval from another file (two columns).
I am completely stuck on how to map it.
I tried something like this:
for line in file1:
if line[0]=line2[0] and line2[1]<line[1]<line2[2]:
print line
I'm not sure if this is correct.
file 1:
elem1 39887
elem1 72111
file 2:
elem1 1 57898
elem1 57899 69887
elem2 69888 82111
In file1 elem1 is an element in my project. the value 39887 is the start coordinate.
In file2 elem1 is still an element in my project, but the values are start and end coordinates. File2 is only a reference file.
For every line in file2, I want to see if the "elem#"=="elem#" in file 1. If the elem# in file1 is equal to elem# in file2, then I want to continue in this loop and see if the corresponding value in file1 is between the start and end positions in file2.
For instance, in the first line of file1, elem1==elem1 in the first line of file2. Since they are equal, is 39887 between 1 and 57898? Yes it is, therefore count it. I need to do this for every line in file2.
In the end, I want to see how many elements are within each group of coordinates from file2.