Skip to content

Commit 4fcf977

Browse files
tcwarnerJarrettSJohnson
authored andcommitted
add findSurfaceCharge.py
1 parent a4fce1f commit 4fcf977

File tree

1 file changed

+150
-0
lines changed

1 file changed

+150
-0
lines changed

findSurfaceCharge.py

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
from __future__ import print_function
2+
from pymol import cmd
3+
4+
5+
def findSurfaceAtoms(selection="all",cutoff=2.5):
6+
"""
7+
Adapted from Jason Vertrees https://pymolwiki.org/index.php/FindSurfaceResidues
8+
DESCRIPTION
9+
10+
Finds those atoms on the surface of a protein
11+
that have at least 'cutoff' exposed A**2 surface area.
12+
13+
USAGE
14+
15+
findSurfaceAtoms [ selection, [ cutoff ]]
16+
17+
SEE ALSO
18+
19+
findSurfaceResidues
20+
"""
21+
cutoff = float(cutoff)
22+
23+
tmpObj = cmd.get_unused_name("_tmp")
24+
cmd.create(tmpObj, "(" + selection + ") and polymer", zoom=0)
25+
26+
cmd.set("dot_solvent", 1, tmpObj)
27+
cmd.get_area(selection=tmpObj, load_b=1)
28+
29+
# threshold on what one considers an "exposed" atom (in A**2):
30+
cmd.remove(tmpObj + " and b < " + str(cutoff))
31+
32+
selName = cmd.get_unused_name("exposed_atm_")
33+
34+
cmd.select(selName, "(" + selection + ") in " + tmpObj)
35+
36+
cmd.delete(tmpObj)
37+
38+
return selName
39+
40+
41+
def _findSurfaceChargeImpl(selection, pH, folded, cutoff):
42+
43+
def get_exposed_residues(selection,cutoff):
44+
cutoff = float(cutoff)
45+
46+
47+
selName = findSurfaceAtoms(selection, cutoff)
48+
49+
tempExposed = set()
50+
cmd.iterate(selName, "tempExposed.add((resv,oneletter))", space=locals())
51+
cmd.delete(selName)
52+
53+
tempExposed=sorted(tempExposed) #list of exposed residues
54+
exposed=[]
55+
for res in tempExposed:
56+
exposed.append(res[1]+str(res[0]))
57+
58+
return exposed
59+
60+
if folded:
61+
exposed = get_exposed_residues(selection,cutoff)
62+
else:
63+
exposed = get_exposed_residues(selection,0)
64+
65+
pH=float(pH)
66+
67+
#gets all charged amino acids on the surface
68+
exposedAtms=""
69+
K=0
70+
R=0
71+
D=0
72+
H=0
73+
E=0
74+
75+
for r in exposed:
76+
amino=r[0]
77+
if amino not in "KRDHE":
78+
continue
79+
elif amino=='K':
80+
K+=1
81+
elif amino=='R':
82+
R+=1
83+
elif amino=='D':
84+
D+=1
85+
elif amino=="H":
86+
H+=1
87+
elif amino=='E':
88+
E+=1
89+
exposedAtms+=amino
90+
chargedAA=amino
91+
92+
93+
kCharge= 1 / (1 + 10 ** (pH - 10.54))
94+
rCharge= 1 / (1 + 10 ** (pH - 12.48))
95+
dCharge= -(1 / (1 + 10 ** (4.07 - pH)))
96+
eCharge= -(1 / (1 + 10 ** (3.90 - pH)))
97+
hCharge= 1 / (1 + 10 ** (pH - 6.04))
98+
99+
charge=kCharge*K+rCharge*R+hCharge*H+dCharge*D+eCharge*E
100+
charge=round(charge,2)
101+
if charge>0:
102+
chargetx="+"+str(charge)
103+
else:
104+
chargetx=str(charge)
105+
106+
if folded:
107+
print ("Exposed charged residues: " +str(exposedAtms))
108+
print ("The expected surface charge of " + selection +" at pH " + str(pH) +" is: " +chargetx)
109+
110+
else:
111+
print ("Charged residues: "+str(exposedAtms))
112+
print ("The expected charge of denatured " + selection +" at pH " +str(pH) +" is: " +chargetx)
113+
return (selection, chargetx)
114+
115+
116+
def findSurfaceCharge(selection="", pH=7.0, folded=True, cutoff=2.5):
117+
"""
118+
DESCRIPTION
119+
120+
Calculates a surface charge at entered pH. Also allows for the charge of an unfolded protein to be calculated.
121+
122+
USAGE
123+
124+
findSurfaceCharge [pH, [folded, [selection ,[cutoff]]]]
125+
126+
ARGUMENTS
127+
128+
pH = The pH value to estimate a surface charge at
129+
130+
folded = Whether the protein is folded (True) or denatured (False)
131+
132+
selection = string: object or selection in which to find exposed
133+
residues {default: empty string - all objects}
134+
135+
cutoff = float: cutoff of what is exposed or not {default: 2.5 Ang**2}
136+
137+
RETURNS
138+
139+
A printout of the estimated surface charge at a given pH
140+
141+
"""
142+
if not selection:
143+
for obj in cmd.get_names():
144+
_findSurfaceChargeImpl(obj, pH, folded, cutoff)
145+
else:
146+
_findSurfaceChargeImpl(selection, pH, folded, cutoff)
147+
148+
149+
cmd.extend("findSurfaceAtoms", findSurfaceAtoms)
150+
cmd.extend("findSurfaceCharge", findSurfaceCharge)

0 commit comments

Comments
 (0)