-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGPSSpyMOL.py
418 lines (361 loc) · 18.6 KB
/
GPSSpyMOL.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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
#############################################################################################################
# Global Protein Surface Survey (GPSS) PyMOL Plugin
#
# Author: T.A. Binkowski ([email protected])
# Date: July 20, 2006
#
#
# Description: The GPSS PyMOL allows for the visualization of precomputed
# surface features from protein structures in the Protein
# Data Bank. The plugin was developed from a suggestion by
# Sebestien Moretti.
#
# Acknowledgements: The following publically available sources provide data
# for the plugin:
# * Computed Atlas of Surface Topography of Proteins (CASTp, http://cast.engr.uic.edu)
# * Catalytic Site Atlas (CSA, http://www.ebi.ac.uk/thornton-srv/databases/CSA/)
#
#
# Copyright Information: The Global Protein Surface Survey (GPSS) Pymol
# Plugin source code is Copyright (c) 2006 by
# T. Andrew Binkowski ([email protected]).
#
# All Rights Reserved
#
# Permission to use, copy, modify, distribute, and distribute modified
# versions of this software and its documentation for any purpose and
# without fee is hereby granted, provided that the above copyright
# notice appear in all copies and that both the copyright notice and
# this permission notice appear in supporting documentation, and that
# the name(s) of the author(s) not be used in advertising or publicity
# pertaining to distribution of the software without specific, written
# prior permission.
#
# THE AUTHOR(S) DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
# NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR
# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
# USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
#
#
#
# More Information: Information and documentation can be found
# at http://gpss.mcsg.anl.gov.
#
#
#############################################################################################################
import tkSimpleDialog
import tkMessageBox
import tkFileDialog
from pymol import cmd
import sys, urllib, urllib2, zlib, os
def __init__(self):
self.menuBar.addcascademenu('Plugin',
'GPSS',
'GPSS',
label = 'Global Protein Surface Survey')
self.menuBar.addmenuitem('GPSS',
'command',
'GPSS All',
label = 'GPSS Sufaces (All)',
command = lambda s=self : gpssAllDialog(s))
self.menuBar.addmenuitem('GPSS',
'command',
'CASTp',
label = 'CASTp Surfaces',
command = lambda s=self : gpssCastpDialog(s))
self.menuBar.addmenuitem('GPSS',
'command',
'Ligand',
label = 'Ligand Binding Surfaces',
command = lambda s=self : gpssLigandDialog(s))
self.menuBar.addmenuitem('GPSS',
'command',
'Metal',
label = 'Metal Binding Surfaces',
command = lambda s=self : gpssMetalDialog(s))
self.menuBar.addmenuitem('GPSS',
'command',
'Peptide',
label = 'Peptide Binding Surfaces',
command = lambda s=self : gpssPeptideDialog(s))
self.menuBar.addmenuitem('GPSS',
'command',
'DNA',
label = 'DNA Binding Surfaces',
command = lambda s=self : gpssDnaDialog(s))
self.menuBar.addmenuitem('GPSS',
'command',
'Sites',
label = 'Functional Sites',
command = lambda s=self : gpssSitesDialog(s))
self.menuBar.addmenuitem('GPSS','separator')
self.menuBar.addmenuitem('GPSS',
'command',
'File Upload',
label = 'File Upload',
command = lambda s=self : gpssFileUploadDialog(s))
self.menuBar.addmenuitem('GPSS','separator')
self.menuBar.addmenuitem('GPSS',
'command',
'Help',
label = 'Help',
command = lambda s=self : gpssHelpDialog(s))
########################################################################
# gpssVersionCheck
#
########################################################################
def _gpssVersionCheck(version):
versionCheck = urllib2.urlopen('http://gpss.mcsg.anl.gov/webservices/'+
'gpssServerVersionCheck.php').read()
if versionCheck!=version:
tkMessageBox.showinfo('GPSS - Help ',
'There is a newer version of the GPSS Plugin available at'+
' http://gpss.mcsg.anl.gov.');
########################################################################
# _gpssLoadPdb
#
########################################################################
def _gpssLoadPdb(pdbCode,reinitialize):
pdbCode = pdbCode.lower()
_gpssVersionCheck('0.3');
if cmd.get_names().count('GPSS-'+pdbCode) < 1:
if reinitialize==1:
cmd.do('reinitialize')
pdbFile = urllib2.urlopen('http://gpss.mcsg.anl.gov/webservices/'+
'gpssServerPymol.php?pdbId='+
pdbCode + '&mode=pdbFile').read()
if pdbFile:
pdbFile = urllib2.urlopen('http://gpss.mcsg.anl.gov/webservices/'+
'gpssServerPymol.php?pdbId='+
pdbCode + '&mode=pdbFile')
cmd.read_pdbstr(pdbFile.read(),'GPSS-'+pdbCode)
# Make structure pretty
cmd.do('set bg_rgb=[1,1,1]')
cmd.do('hide everything')
cmd.do('dss')
cmd.do('show cartoon, GPSS-' + pdbCode)
cmd.do('color gray')
return True
else:
tkMessageBox.showerror('GPSS ',
pdbCode + ' was not found on the GPSS server.')
cmd.do('zoom GPSS-'+pdbCode)
else:
return True
########################################################################
# gpssAll
#
########################################################################
def gpssAllDialog(app):
pdbCode = tkSimpleDialog.askstring('GPSS - All ',
'Please enter a 4-digit pdb code:',
parent=app.root)
if pdbCode:
gpssAll(pdbCode)
def gpssAll(pdbCode):
gpssLigand(pdbCode,1)
gpssMetal(pdbCode,0)
gpssPeptide(pdbCode,0)
gpssDna(pdbCode,0)
gpssSitesCsa(pdbCode,0)
gpssCastp(pdbCode,0)
########################################################################
# gpssCastp
#
########################################################################
def gpssCastpDialog(app):
pdbCode = tkSimpleDialog.askstring('GPSS - CastP ',
'Please enter a 4-digit pdb code:',
parent=app.root)
if pdbCode:
gpssCastp(pdbCode,1)
def gpssCastp(pdbCode,reinitialize):
if _gpssLoadPdb(pdbCode,reinitialize):
# Get pocket count
castpInfo = urllib2.urlopen('http://gpss.mcsg.anl.gov/webservices/'+
'gpssServerPymol.php?pdbId='+
pdbCode + '&mode=castpInfo')
castpLength = int(castpInfo.readlines()[-1][13:16])
# Get pocket atoms
while castpLength > 0:
castpSurfaceFile = urllib2.urlopen('http://gpss.mcsg.anl.gov/webservices/'+
'gpssServerPymol.php?pdbId='+
pdbCode + '&surfaceId='+str(castpLength)+
'&mode=castpSurface')
objectId = 'CASTp-'+str(castpLength)
cmd.read_pdbstr(castpSurfaceFile.read(),objectId)
cmd.do('hide everything,' + objectId)
cmd.do('show surface,' + objectId)
cmd.do('set transparency=0.2,'+ objectId)
castpLength-=1
cmd.do('zoom GPSS-'+pdbCode)
########################################################################
# gpssLigand
#
########################################################################
def gpssLigandDialog(app):
pdbCode = tkSimpleDialog.askstring('GPSS - Ligand ',
'Please enter a 4-digit pdb code:',
parent=app.root)
if pdbCode:
gpssLigand(pdbCode,0)
def gpssLigand(pdbCode,reinitialize):
if _gpssLoadPdb(pdbCode,reinitialize):
# Get ligand surfaces
ligandInfo = urllib2.urlopen('http://gpss.mcsg.anl.gov/webservices/'+
'gpssServerPymol.php?pdbId='+
pdbCode + '&mode=ligandInfo').read()
if ligandInfo:
ligandInfoArray = ligandInfo.split(':')
# Get pocket atoms
for ligandSurface in ligandInfoArray:
ligandSurfaceFile = urllib2.urlopen('http://gpss.mcsg.anl.gov/webservices/'+
'gpssServerPymol.php?pdbId='+ pdbCode +
'&surfaceId=' + ligandSurface +
'&mode=ligandSurface')
ligandId = ligandSurface.split('.')
objectId = 'Ligand-' + ligandId[1] + '.' + ligandId[2] + '.' + ligandId[3]
cmd.read_pdbstr(ligandSurfaceFile.read(),objectId)
cmd.do('hide everything,' + objectId)
cmd.do('show surface,' + objectId)
cmd.do('show sticks,' + objectId + ' and resn ' + ligandId[1])
cmd.do('zoom GPSS-'+pdbCode)
########################################################################
# gpssMetal
#
########################################################################
def gpssMetalDialog(app):
pdbCode = tkSimpleDialog.askstring('GPSS - Metal ',
'Please enter a 4-digit pdb code:',
parent=app.root)
if pdbCode:
gpssMetal(pdbCode,0)
def gpssMetal(pdbCode,reinitialize):
if _gpssLoadPdb(pdbCode,reinitialize):
# Get ligand surfaces
metalInfo = urllib2.urlopen('http://gpss.mcsg.anl.gov/webservices/'+
'gpssServerPymol.php?pdbId='+
pdbCode + '&mode=metalInfo').read()
if metalInfo:
metalInfoArray = metalInfo.split(':')
# Get pocket atoms
for metalSurface in metalInfoArray:
metalSurfaceFile = urllib2.urlopen('http://gpss.mcsg.anl.gov/webservices/'+
'gpssServerPymol.php?pdbId='+ pdbCode +
'&surfaceId=' + metalSurface +
'&mode=metalSurface')
metalId = metalSurface.split('.')
objectId = 'Metal-' + metalId[1] + '.' + metalId[2] + '.' + metalId[3]
cmd.read_pdbstr(metalSurfaceFile.read(),objectId)
cmd.do('hide everything,' + objectId)
cmd.do('show surface,' + objectId)
cmd.do('show sphere,' + objectId + ' and resn ' + metalId[1])
cmd.do('zoom GPSS-'+pdbCode)
########################################################################
# gpssPeptide
#
########################################################################
def gpssPeptideDialog(app):
pdbCode = tkSimpleDialog.askstring('GPSS - Peptide ',
'Please enter a 4-digit pdb code:',
parent=app.root)
if pdbCode:
gpssPeptide(pdbCode,0)
def gpssPeptide(pdbCode,reinitialize):
if _gpssLoadPdb(pdbCode,reinitialize):
# Get ligand surfaces
peptideInfo = urllib2.urlopen('http://gpss.mcsg.anl.gov/webservices/'+
'gpssServerPymol.php?pdbId='+
pdbCode + '&mode=peptideInfo')
# Get pocket atoms
for peptideSurface in peptideInfo:
peptideSurfaceFile = urllib2.urlopen('http://gpss.mcsg.anl.gov/webservices/'+
'gpssServerPymol.php?pdbId='+ pdbCode +
'&surfaceId=' + peptideSurface +
'&mode=peptideSurface')
peptideId = peptideSurface.split('.')
objectId = 'Peptide-' + peptideId[1]
cmd.read_pdbstr(peptideSurfaceFile.read(),objectId)
cmd.do('hide everything,' + objectId)
cmd.do('show surface,' + objectId)
cmd.do('set transparency=0.2,'+ objectId)
cmd.do('zoom GPSS-'+pdbCode)
########################################################################
# gpssDna
#
########################################################################
def gpssDnaDialog(app):
pdbCode = tkSimpleDialog.askstring('GPSS - DNA ',
'Please enter a 4-digit pdb code:',
parent=app.root)
if pdbCode:
gpssDna(pdbCode,0)
def gpssDna(pdbCode,reinitialize):
if _gpssLoadPdb(pdbCode,reinitialize):
# Get sites
dna = urllib2.urlopen('http://gpss.mcsg.anl.gov/webservices/'+
'gpssServerPymol.php?pdbId='+
pdbCode + '&mode=dnaSurface').read()
if dna:
objectId = 'DNA-'+pdbCode;
cmd.read_pdbstr(dna,objectId)
cmd.do('hide everything,' + objectId)
cmd.do('show surface,' + objectId)
cmd.do('set transparency=0.2,'+ objectId)
cmd.do('zoom GPSS-'+pdbCode)
########################################################################
# gpssCsa
#
########################################################################
def gpssSitesDialog(app):
pdbCode = tkSimpleDialog.askstring('GPSS - Sites ',
'Please enter a 4-digit pdb code:',
parent=app.root)
if pdbCode:
gpssSitesCsa(pdbCode,0)
def gpssSitesCsa(pdbCode,reinitialize):
if _gpssLoadPdb(pdbCode,reinitialize):
# Get sites
sites = urllib2.urlopen('http://gpss.mcsg.anl.gov/webservices/'+
'gpssServerPymol.php?pdbId='+
pdbCode + '&mode=sitesCsa').read()
if sites:
objectId = 'SITES-CSA-'+pdbCode;
cmd.read_pdbstr(sites,objectId)
cmd.do('hide everything,' + objectId)
cmd.do('show spheres,' + objectId)
cmd.do('color yellow,' + objectId)
cmd.do('zoom GPSS-'+pdbCode)
########################################################################
# gpssFileUpload
#
########################################################################
def gpssFileUploadDialog(app):
file = tkFileDialog.askopenfile(parent=app.root,
mode='rb',
title='GPSS - File Upload')
if file != None:
data = file.read()
file.close()
email = tkSimpleDialog.askstring('GPSS - File Upload ',
'Please enter you email address.\n\nYou will be notified when your structure is available to be viewed.',
parent=app.root)
params = urllib.urlencode({'email': email,'userfile':file.name,'file':data})
response = urllib.urlopen('http://gpss.mcsg.anl.gov/webservices/gpssServerFileUpload2.php',
params)
if response:
tkMessageBox.showinfo('GPSS - File Upload',response.readlines())
else:
tkMessageBox.showerror('GPSS - File Upload',"There was a problem connecting to the server, please try again.")
########################################################################
# gpssHelp
#
########################################################################
def gpssHelpDialog(app):
tkMessageBox.showinfo('GPSS - Help ',
'Global Protein Surface Survey\nPymol Plugin v0.1\n\nT. Andrew Binkowski\nArgonne National Laboratory\n\n\nFor more information visit http://gpss.mcsg.anl.gov');
# Extend pymol functionality
#cmd.extend('gpssAll', gpssAll)