Last active
December 16, 2019 08:35
-
-
Save endrebak/10deff3fba017cbdb61d5da795f7b331 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
index1 = 0 | |
index2 = 0 | |
while index1 < len(posin): | |
pos = posin[index1] | |
rs = rsin[index1] | |
if pos == mappos[index2]: | |
#the 1000 Genomes site was genotyped as part of the map | |
results.append((rs, pos, mapgpos[index2])) | |
index1 = index1 + 1 | |
elif pos < mappos[index2]: | |
#current position in interpolation before marker | |
if index2 == 0: | |
#before the first site in the map (genetic position = 0) | |
results.append((rs, pos, mapgpos[index2])) | |
index1 = index1 + 1 | |
else: | |
#interpolate | |
prevg = mapgpos[index2 - 1] | |
prevpos = mappos[index2] | |
frac = (float(pos) - float(mappos[index2 - 1]))/ (float(mappos[index2]) - float(mappos[index2 - 1])) | |
tmpg = prevg + frac * (mapgpos[index2] - prevg) | |
results.append((rs, pos, tmpg)) | |
index1 = index1 + 1 | |
elif pos > mappos[index2]: | |
#current position in interpolation after marker | |
if index2 == len(mappos) - 1: | |
#after the last site in the map (genetic position = maximum in map, note could try to extrapolate based | |
# on rate instead) | |
results.append((rs, pos, mapgpos[index2])) | |
index1 = index1 + 1 | |
else: | |
#increment the marker | |
index2 = index2 + 1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment