def sort_breakend_order(svs):
'''
per sv, ensure chrom1, chrom2 and pos1, pos2 are ordered
'''
svs = svs.copy()
for sv in np.nditer(svs, op_flags=['readwrite']):
if sv['chr1'] == sv['chr2']:
if sv['pos1'] > sv['pos2']:
ts = sv.copy()
sv['pos1'], sv['dir1'] = ts['pos2'], ts['dir2']
sv['pos2'], sv['dir2'] = ts['pos1'], ts['dir1']
else:
chrs = [str(sv['chr1']), str(sv['chr2'])]
if not np.all(np.array(chrs) == np.array(nice_sort(chrs))):
ts = sv.copy()
sv['chr1'], sv['pos1'], sv['dir1'] = ts['chr2'], ts['pos2'], ts['dir2']
sv['chr2'], sv['pos2'], sv['dir2'] = ts['chr1'], ts['pos1'], ts['dir1']
return svs
评论列表
文章目录