I'm trying to do a chained comparison between two files and printing/writing out the result if it's in the specified interval.
This is what I have so far.
test1 file:
A0AUZ9,7,17 #just this one line
test 2 file:
A0AUZ8, DOC_PP1_RVXF_1, 8, 16, PF00149, O24930
A0AUZ9, LIG_BRCT_BRCA1_2, 127, 134, PF00533, O25336
A0AUZ9, LIG_BRCT_BRCA1_1, 127, 132, PF00533, O25336
A0AUZ9, DOC_PP1_RVXF_1, 8, 16, PF00149, O25685
A0AUZ9, DOC_PP1_RVXF_1, 8, 16, PF00149, O25155
And the script itself:
results = []
with open('test1', 'r') as disorder:
for lines in disorder:
cells = lines.strip().split(',')
with open('test2', 'r') as helpy:
for lines in helpy:
blocks = lines.strip().split(',')
if blocks[0] != cells[0]:
continue
elif cells[1] <= blocks[2] and blocks[3] <= cells[2]:
results.append(blocks)
with open('test3','wt') as outfile:
for i in results:
outfile.write("%s\n" % i)
My preferred output would be to only have the rows in test3, that:
have matching ids in the first column
the two numerical values in columns 3 and 4 are between the values given in the test1 file
I get no output, and I'm not sure where it goes wrong.