outfile2 = open('cordrandm.pdb', 'w')
for kk in text1:
if kk != '':
outfile2.write(kk)
outfile2.write('\n')
for alcord in alistcoord:
uacoord = alcord[1]
for blcord in blistcoord:
ubcoord = blcord[1]
for arang in range(1000):
arang = arang + 1
x,y,z = uacoord
x1,y1,z1 = (uniform(x-3.5,x+3.5), uniform(y-3.5,y+3.5), uniform(z-3.5,z+3.5))
pacord = [x1,y1,z1]
dist_pap = euDist(uacoord, pacord)
if 3.5 > dist_pap > 2.5:
dist_pap1 = dist_pap
outfile2.write('ATOM OW HOH X %6.3f %6.3f %6.3f\n' % (pacord[0], pacord[1], pacord[2]))
outfile2.close()
从这段代码我得到这样的输出文件
1------10 11-----20 21------30-----so on
123456789012345678901234567890123456789012345678901234
ATOM OW HOH X 10.533 22.567 61.777
ATOM OW HOH X 5.655 23.758 61.221
ATOM OW HOH X 10.125 20.476 68.503
ATOM OW HOH X 11.222 16.810 69.267
ATOM OW HOH X 4.351 18.904 66.256
ATOM OW HOH X 9.194 22.065 67.714
ATOM OW HOH X 4.347 16.527 68.278
我想为每一行“HOH”插入计数器并像这样输出
ATOM OW HOH X 1 10.533 22.567 61.777
ATOM OW HOH X 2 5.655 23.758 61.221
ATOM OW HOH X 10 10.125 20.476 68.503
ATOM OW HOH X 100 11.222 16.810 69.267
ATOM OW HOH X 101 4.351 18.904 66.256
ATOM OW HOH X 102 9.194 22.065 67.714
ATOM OW HOH X1000 4.347 16.527 68.278
表示列范围 23-26 指定 HOH 的序列号。我将如何在不会改变我的输出 fromat 的特定列中插入 HOH 的计数。
提前致谢