-
Notifications
You must be signed in to change notification settings - Fork 258
/
findSurfaceCharge.py
146 lines (100 loc) · 3.67 KB
/
findSurfaceCharge.py
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
from __future__ import print_function
from pymol import cmd
def findSurfaceAtoms(selection="all",cutoff=2.5):
"""
Adapted from Jason Vertrees https://pymolwiki.org/index.php/FindSurfaceResidues
DESCRIPTION
Finds those atoms on the surface of a protein
that have at least 'cutoff' exposed A**2 surface area.
USAGE
findSurfaceAtoms [ selection, [ cutoff ]]
SEE ALSO
findSurfaceResidues
"""
cutoff = float(cutoff)
tmpObj = cmd.get_unused_name("_tmp")
cmd.create(tmpObj, "(" + selection + ") and polymer", zoom=0)
cmd.set("dot_solvent", 1, tmpObj)
cmd.get_area(selection=tmpObj, load_b=1)
# threshold on what one considers an "exposed" atom (in A**2):
cmd.remove(tmpObj + " and b < " + str(cutoff))
selName = cmd.get_unused_name("exposed_atm_")
cmd.select(selName, "(" + selection + ") in " + tmpObj)
cmd.delete(tmpObj)
return selName
def _findSurfaceChargeImpl(selection, pH, folded, cutoff):
def get_exposed_residues(selection,cutoff):
cutoff = float(cutoff)
selName = findSurfaceAtoms(selection, cutoff)
tempExposed = set()
cmd.iterate(selName, "tempExposed.add((model,segi,chain,resv,resi,oneletter))", space=locals())
cmd.delete(selName)
tempExposed=sorted(tempExposed) #list of exposed residues
exposed=[]
for res in tempExposed:
exposed.append(res[-1] + res[-2])
return exposed
if folded:
exposed = get_exposed_residues(selection,cutoff)
else:
exposed = get_exposed_residues(selection,0)
pH=float(pH)
#gets all charged amino acids on the surface
exposedAtms=""
K=0
R=0
D=0
H=0
E=0
for r in exposed:
amino=r[0]
if amino not in "KRDHE":
continue
elif amino=='K':
K+=1
elif amino=='R':
R+=1
elif amino=='D':
D+=1
elif amino=="H":
H+=1
elif amino=='E':
E+=1
exposedAtms+=amino
chargedAA=amino
kCharge= 1 / (1 + 10 ** (pH - 10.54))
rCharge= 1 / (1 + 10 ** (pH - 12.48))
dCharge= -(1 / (1 + 10 ** (4.07 - pH)))
eCharge= -(1 / (1 + 10 ** (3.90 - pH)))
hCharge= 1 / (1 + 10 ** (pH - 6.04))
charge=kCharge*K+rCharge*R+hCharge*H+dCharge*D+eCharge*E
chargetx = "%+.2f" % (charge)
if folded:
print ("Exposed charged residues: " +str(exposedAtms))
print ("The expected surface charge of " + selection +" at pH " + str(pH) +" is: " +chargetx)
else:
print ("Charged residues: "+str(exposedAtms))
print ("The expected charge of denatured " + selection +" at pH " +str(pH) +" is: " +chargetx)
return (selection, chargetx)
def findSurfaceCharge(selection="", pH=7.0, folded=True, cutoff=2.5):
"""
DESCRIPTION
Calculates a surface charge at entered pH. Also allows for the charge of an unfolded protein to be calculated.
USAGE
findSurfaceCharge [pH, [folded, [selection ,[cutoff]]]]
ARGUMENTS
pH = The pH value to estimate a surface charge at
folded = Whether the protein is folded (True) or denatured (False)
selection = string: object or selection in which to find exposed
residues {default: empty string - all objects}
cutoff = float: cutoff of what is exposed or not {default: 2.5 Ang**2}
RETURNS
A printout of the estimated surface charge at a given pH
"""
if not selection:
for obj in cmd.get_names():
_findSurfaceChargeImpl(obj, pH, folded, cutoff)
else:
_findSurfaceChargeImpl(selection, pH, folded, cutoff)
cmd.extend("findSurfaceAtoms", findSurfaceAtoms)
cmd.extend("findSurfaceCharge", findSurfaceCharge)