import pandas as pd
gffname = "D:/circos/MLA.final/h1_h1.gff"
####MCScanX用的gff
collinearity = "D:/circos/MLA.final/h1_h1_20.collinearity"
####MCScanX产生的collinerity文件
gff = pd.read_csv(gffname,sep='\t',header=None)
print(gff)
with open(collinearity,'r') as r:
lines=r.readlines()
tmp_collinearity = collinearity + '.tmp'
with open(tmp_collinearity,'w') as w:
for l in lines:
if '#' not in l:
w.write(l)
coll = pd.read_csv(tmp_collinearity,sep='\t',header=None)
print(coll)
fileresult = collinearity + '.link'
f = open(fileresult , "w")
for index,row in coll.iterrows():
gene1 = gff.loc[gff[1]==row[1]][[0,2,3]]
gene1_str = ""
for i in [0,2,3]:
if i != 3:
gene1_str += gene1[i].to_string(header=False, index=False).strip() + "\t"
else:
gene1_str += gene1[i].to_string(header=False, index=False).strip()
gene2 = gff.loc[gff[1]==row[2]][[0,2,3]]
gene2_str = ""
for i in [0,2,3]:
if i != 3:
gene2_str += gene2[i].to_string(header=False, index=False).strip() + "\t"
else:
gene2_str += gene2[i].to_string(header=False, index=False).strip()
if index < 2:
print(gene1_str + "\t" + gene2_str +"\n" )
f.write(gene1_str + "\t" + gene2_str +"\n")
将MCScanX文件转化为circos用的link文件
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...