目的:给定一个 PDB 文件,打印出在三级蛋白质结构中形成二硫键的所有半胱氨酸残基对。许可证:GNU GPL 编写者:Eric Miller
#!/usr/bin/env python
import math
def getDistance((x1,y1,z1),(x2,y2,z2)):
d = math.sqrt(pow((x1-x2),2)+pow((y1-y2),2)+pow((z1-z2),2));
return round(d,3);
def prettyPrint(dsBonds):
print "Residue 1\tResidue 2\tDistance";
for (r1,r2,d) in dsBonds:
print " {0}\t\t {1}\t\t {2}".format(r1,r2,d);
def main():
pdbFile = open('2v5t.pdb','r');
maxBondDist = 2.5;
isCysLine = lambda line: (line[0:4] == "ATOM" and line[13:15] == "SG");
cysLines = [line for line in pdbFile if isCysLine(line)];
pdbFile.close();
getCoords = lambda line:(float(line[31:38]),
float(line[39:46]),float(line[47:54]));
cysCoords = map(getCoords, cysLines);
dsBonds = [];
for i in range(len(cysCoords)-1):
for j in range(i+1,len(cysCoords)):
dist = getDistance(cysCoords[i],cysCoords[j]);
residue1 = int(cysLines[i][23:27]);
residue2 = int(cysLines[j][23:27]);
if (dist < maxBondDist):
dsBonds.append((residue1,residue2,dist));
prettyPrint(dsBonds);
if __name__ == "__main__":
main()
当我尝试运行这个脚本时,我遇到了缩进问题。我的工作目录中有 2v5t.pdb(运行上述脚本所需)。有什么解决办法吗?