-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcys2cyx.py
More file actions
executable file
·44 lines (40 loc) · 1.12 KB
/
Copy pathcys2cyx.py
File metadata and controls
executable file
·44 lines (40 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/python
import sys,os
usage="""
Modify CYS to CYX if S-S bond exist
Usage $0 in.pdb out.pdb ssbond-map
"""
if len(sys.argv)<4:
print usage
sys.exit()
infile,outfile,ssfile=sys.argv[1:4]
def distance(A,B):
if None in (A,B): return 0
dist=( (A[0]-B[0])**2 + (A[1]-B[1])**2 + (A[2]-B[2])**2 ) ** 0.5
return dist
sgs=dict()
for line in open(infile,"r"):
if line[0:6] not in ("ATOM ","HETATM"): continue
if line[12:16].strip()=="SG" and line[17:20]=="CYS":
index=int(line[22:26])
x,y,z=float(line[30:38]),float(line[38:46]),float(line[46:54])
sgs[index]=(x,y,z)
ssbonds=list()
keys=sgs.keys()
pairs=[(i,j) for i in keys for j in keys if i<j]
ofp=open(ssfile,"w")
for (i,j) in pairs:
dist=distance(sgs[i],sgs[j])
if dist<2.5:
ofp.write("%d %d\n"%(i,j))
ssbonds.append(i)
ssbonds.append(j)
ofp.close()
ofp=open(outfile,"w")
for line in open(infile,"r"):
if len(line)>20 and line[17:20]=="CYS":
index=int(line[22:26])
if index in ssbonds:
line="%sCYX%s"%(line[0:17],line[20:])
ofp.write(line)
ofp.close()