我有一个变异位置文件和一个外显子区域文件
1 242600263
12 54757526
11 45853978
外显子区域文件如下所示
1:11861218-11861456 MTHFR-001_2
22:44280101-44280243 PNPLA5-201_7
两个文件都有大约100000行
现在,我将外显子区域文件写入一个字典,使用该区域作为键
当循环遍历变量文件时,检查此位置是否位于外显子字典的任何键中
for i in F1: <- loop through exon file
chrpos, exon, check=i
exondict[chrpos]=exon
for j in F2: <- loop through variant file
chr=j[0]
if chr=="11": <- get chr 11 first
variant=j[1]
for chrpos in exondict.keys():
chr, pos= chrpos.split(':')
start, stop= pos.split('-')
chr, start, stop
if int(start)<=int(variant)<=int(stop):
newlist=[exondict[chrpos]]+ j
W.writerow(newlist)
基本上,我得到了我想要的
只是想知道是否有更优雅的方式来做到这一点
谢谢大家!
例如,可变位置为chr11:108164047,位于11:108164040-108164204 ATM-20131范围内
目前没有回答
相关问题 更多 >
编程相关推荐