def find_next(start, stop, i2hits):
if start not in i2hits and stop in i2hits:<EOL><INDENT>index = stop<EOL><DEDENT>elif stop not in i2hits and start in i2hits:<EOL><INDENT>index = start<EOL><DEDENT>elif start not in i2hits and stop not in i2hits:<EOL><INDENT>index = choice([start, stop])<EOL>i2hits[index] = [[False]]<EOL><DEDENT>else:<EOL><INDENT>A, B = i2hits[start][<NUM_LIT:0>], i2hits[stop][<NUM_LIT:0>]<EOL>if B[<NUM_LIT:10>] <= A[<NUM_LIT:10>]:<EOL><INDENT>index = stop<EOL><DEDENT>else:<EOL><INDENT>index = start<EOL><DEDENT><DEDENT>if index == start:<EOL><INDENT>nstart = start - <NUM_LIT:1><EOL>nstop = stop<EOL><DEDENT>else:<EOL><INDENT>nstop = stop + <NUM_LIT:1><EOL>nstart = start<EOL><DEDENT>match = i2hits[index][<NUM_LIT:0>]<EOL>rp = match[-<NUM_LIT:1>]<EOL>return index, nstart, nstop, rp, match<EOL>
which protein has the best hit, the one to the 'right' or to the 'left?'