forked from Pymol-Scripts/Pymol-script-repo
-
Notifications
You must be signed in to change notification settings - Fork 11
/
findSurfaceResidues.py
90 lines (59 loc) · 2.25 KB
/
findSurfaceResidues.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
'''
http://pymolwiki.org/index.php/FindSurfaceResidues
'''
from pymol import cmd
def findSurfaceAtoms(selection="all", cutoff=2.5, quiet=1):
"""
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, quiet = float(cutoff), int(quiet)
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)
if not quiet:
print "Exposed atoms are selected in: " + selName
return selName
def findSurfaceResidues(selection="all", cutoff=2.5, doShow=0, quiet=1):
"""
DESCRIPTION
Finds those residues on the surface of a protein
that have at least 'cutoff' exposed A**2 surface area.
USAGE
findSurfaceResidues [ selection, [ cutoff, [ doShow ]]]
ARGUMENTS
selection = string: object or selection in which to find exposed
residues {default: all}
cutoff = float: cutoff of what is exposed or not {default: 2.5 Ang**2}
RETURNS
(list: (chain, resv ) )
A Python list of residue numbers corresponding
to those residues w/more exposure than the cutoff.
"""
cutoff, doShow, quiet = float(cutoff), int(doShow), int(quiet)
selName = findSurfaceAtoms(selection, cutoff, quiet)
exposed = set()
cmd.iterate(selName, "exposed.add((chain,resv))", space=locals())
selNameRes = cmd.get_unused_name("exposed_res_")
cmd.select(selNameRes, "byres " + selName)
if not quiet:
print "Exposed residues are selected in: " + selNameRes
if doShow:
cmd.show_as("spheres", "(" + selection + ") and polymer")
cmd.color("white", selection)
cmd.color("yellow", selNameRes)
cmd.color("red", selName)
return sorted(exposed)
cmd.extend("findSurfaceAtoms", findSurfaceAtoms)
cmd.extend("findSurfaceResidues", findSurfaceResidues)