def bestPairs(pairdata, reportall):
best = []
for k,v in itertools.groupby(pairdata, key=lambda x: x['pair']):
allcalls = list(v)
nonNA = [r for r in allcalls if r['verdict'] != 'na']
if not nonNA:
if reportall:
best.append(allcalls[0])
continue
verdict = nonNA[-1]['verdict']
if verdict == 'MZ twins':
nonNA.sort(key=lambda x: (-round(x['MZp'], 1), x['percentile']))
elif verdict == 'Parent-child' or reportall:
nonNA.sort(key=lambda x: (-round(x['POp'], 1), x['percentile']))
else:
continue
best.append(nonNA[0])
return pairwise_table(best)
评论列表
文章目录