|
1
|
|
|
from pymol import cmd,util |
|
2
|
|
|
import inspect |
|
3
|
|
|
import tempfile |
|
4
|
|
|
from glob import glob |
|
5
|
|
|
from tempfile import NamedTemporaryFile |
|
6
|
|
|
# Pymol commands used by the Das Lab |
|
7
|
|
|
# (C) R. Das 2010-2013. |
|
8
|
|
|
# |
|
9
|
|
|
# Some documentation and sample images available at: |
|
10
|
|
|
# |
|
11
|
|
|
# https://docs.google.com/document/d/1uWeEEGPjAceaw07ESf9bec-FrxW4Bx6jGaBqoHbSXuo/edit |
|
12
|
|
|
# |
|
13
|
|
|
|
|
14
|
|
|
print('rp06() -- colors for helices of rp06') |
|
15
|
|
|
print('rp14() -- colors for helices of rp14') |
|
16
|
|
|
print('sa -- superimpose all') |
|
17
|
|
|
print('aa -- align all -- full atom RMSD!') |
|
18
|
|
|
print('rcd() # flat ribbon with sticks') |
|
19
|
|
|
|
|
20
|
|
|
def sa(intra=False,rainbow=True): |
|
21
|
|
|
""" |
|
22
|
|
|
Superimpose all open models onto the first one. |
|
23
|
|
|
This may not work well with selections. |
|
24
|
|
|
Option intra can be set to True to enable intra_fit first, for working with multi-state (nmr) pdbs. |
|
25
|
|
|
[Thanks to Kyle Beauchamp for this one] |
|
26
|
|
|
""" |
|
27
|
|
|
AllObj=cmd.get_names("all") |
|
28
|
|
|
for x in AllObj: |
|
29
|
|
|
print(AllObj[0],x) |
|
30
|
|
|
if intra==True: |
|
31
|
|
|
cmd.intra_fit(x) |
|
32
|
|
|
if rainbow==True: |
|
33
|
|
|
cmd.util.chainbow(x) |
|
34
|
|
|
cmd.align(x,AllObj[0]) |
|
35
|
|
|
cmd.zoom() |
|
36
|
|
|
|
|
37
|
|
|
def superimpose_all(intra=False,rainbow=True): |
|
38
|
|
|
sa( intra, rainbow ); |
|
39
|
|
|
|
|
40
|
|
|
def chainbow(): |
|
41
|
|
|
""" |
|
42
|
|
|
run chainbow on all molecules, one by one. |
|
43
|
|
|
""" |
|
44
|
|
|
AllObj=cmd.get_names("all") |
|
45
|
|
|
for x in AllObj: |
|
46
|
|
|
print(AllObj[0],x) |
|
47
|
|
|
cmd.util.chainbow(x) |
|
48
|
|
|
|
|
49
|
|
|
def color_by_data( filename, offset = 0, min_val=-1.0, max_val = 0.0 ): |
|
50
|
|
|
""" |
|
51
|
|
|
Read in a text file with rows like: |
|
52
|
|
|
|
|
53
|
|
|
125 0.12 |
|
54
|
|
|
126 1.50 |
|
55
|
|
|
|
|
56
|
|
|
and color specified residue numbers by scalar values. |
|
57
|
|
|
Takes advantage of B-factor column, and color by temperature |
|
58
|
|
|
function in pymol. Note that coloring is scaled/offset based |
|
59
|
|
|
on lowest/highest scalar value. |
|
60
|
|
|
""" |
|
61
|
|
|
lines = open( filename ).readlines() |
|
62
|
|
|
data = {} |
|
63
|
|
|
data_backbone = {} |
|
64
|
|
|
|
|
65
|
|
|
avg_data = 0.0 |
|
66
|
|
|
min_data = 0.0 |
|
67
|
|
|
max_data = 0.0 |
|
68
|
|
|
for line in lines: |
|
69
|
|
|
cols = string.split( line ) |
|
|
|
|
|
|
70
|
|
|
dataval = float( cols[1] ) |
|
71
|
|
|
if min_val >= 0 and dataval < min_val: dataval = min_val |
|
72
|
|
|
if max_val > 0 and dataval > max_val: dataval = max_val |
|
73
|
|
|
data[ int( cols[0] ) ] = dataval |
|
|
|
|
|
|
74
|
|
|
avg_data = avg_data + dataval |
|
75
|
|
|
if ( dataval < min_data ): min_data = dataval |
|
76
|
|
|
if ( dataval > max_data ): max_data = dataval |
|
77
|
|
|
|
|
78
|
|
|
if len( cols ) > 2: |
|
79
|
|
|
dataval2 = float( cols[2] ) |
|
80
|
|
|
if min_val >= 0 and dataval2 < min_val: dataval2 = min_val |
|
81
|
|
|
if max_val > 0 and dataval2 > max_val: dataval2 = max_val |
|
82
|
|
|
data_backbone[ int( cols[0] ) ] = dataval2 |
|
83
|
|
|
|
|
84
|
|
|
|
|
85
|
|
|
avg_data /= len( data.keys() ) |
|
86
|
|
|
|
|
87
|
|
|
cmd.alter( 'all', 'b=%6.3f' % avg_data ) |
|
88
|
|
|
|
|
89
|
|
|
for i in data.keys(): |
|
90
|
|
|
cmd.alter( 'resi \\%d' % (i+int(offset)), 'b=%6.3f' % data[i] ) |
|
91
|
|
|
|
|
92
|
|
|
backbone_tag = " and (name o1p+o2p+o3p+p+op1+op2+'c1*'+'c2*'+'c3*'+'c5*'+'o2*'+'o3*'+'o4*'+'o5*'+'c1*'+'c2*'+'c3*'+'c4*'+'o2*'+'o4*'+c1'+c2'+c3'+c5'+o2'+o3'+o4'+o5'+c1'+c2'+c3'+c4'+o2'+o4') and (not name c1+c2+c3+c4+c5+o2+o3+o4+o5)" |
|
93
|
|
|
for i in data_backbone.keys(): |
|
94
|
|
|
cmd.alter( 'resi \\%d %s' % (i+int(offset),backbone_tag), 'b=%6.3f' % data_backbone[i] ) |
|
95
|
|
|
|
|
96
|
|
|
if ( min_val < 0 ): min_val = min_data |
|
97
|
|
|
if ( max_val < 0 ): max_val = max_data |
|
98
|
|
|
|
|
99
|
|
|
cmd.spectrum( "b", "rainbow","all",min_val,max_val ) |
|
100
|
|
|
#cmd.ramp_new("ramp_obj", "1gid_RNAA", range=[0, 0, max_val], color="[blue, white, red ]") |
|
101
|
|
|
|
|
102
|
|
|
def align_all( subset = [] ): |
|
103
|
|
|
""" |
|
104
|
|
|
Superimpose all open models onto the first one. |
|
105
|
|
|
This may not work well with selections. |
|
106
|
|
|
""" |
|
107
|
|
|
PATH_BAR_CHAT = '/Users/magnus/Documents/GTD/software/data_hacks/bar_chart.py' |
|
108
|
|
|
|
|
109
|
|
|
print("""This returns a list with 7 items: |
|
110
|
|
|
|
|
111
|
|
|
RMSD after refinement |
|
112
|
|
|
Number of aligned atoms after refinement |
|
113
|
|
|
Number of refinement cycles |
|
114
|
|
|
RMSD before refinement |
|
115
|
|
|
Number of aligned atoms before refinement |
|
116
|
|
|
Raw alignment score |
|
117
|
|
|
Number of residues aligned """) |
|
118
|
|
|
|
|
119
|
|
|
AllObj=cmd.get_names("all") |
|
120
|
|
|
report = [] |
|
121
|
|
|
for x in AllObj[1:]: |
|
122
|
|
|
#print(AllObj[0],x) |
|
123
|
|
|
subset_tag = '' |
|
124
|
|
|
if isinstance( subset, int ): |
|
125
|
|
|
subset_tag = ' and resi %d' % subset |
|
126
|
|
|
elif isinstance( subset, list ) and len( subset ) > 0: |
|
127
|
|
|
subset_tag = ' and resi %d' % (subset[0]) |
|
128
|
|
|
for m in range( 1,len(subset)): subset_tag += '+%d' % subset[m] |
|
129
|
|
|
elif isinstance( subset, str ) and len( subset ) > 0: |
|
130
|
|
|
subset_tag = ' and %s' % subset |
|
131
|
|
|
values = cmd.align(x+subset_tag,AllObj[0]+subset_tag) |
|
132
|
|
|
print(AllObj[0], x, ' '.join([str(v) for v in values]), '-- RMSD', values[3], ' of ', values[6], 'residues') |
|
133
|
|
|
print(AllObj[0], x, 'RMSD: ', values[3], ' of ', values[6], 'residues') |
|
134
|
|
|
report.append([AllObj[0], x, values[3], values[6]]) |
|
135
|
|
|
cmd.zoom() |
|
136
|
|
|
|
|
137
|
|
|
|
|
138
|
|
|
print('==== SUMMARY =====') |
|
139
|
|
|
f = NamedTemporaryFile(delete=False) |
|
140
|
|
|
for i in report: |
|
141
|
|
|
if not i[1].startswith('_align'): |
|
142
|
|
|
# rp14_5ddp_bound_clean_ligand rp14_farna_eloop_nol2fixed_cst.out.1 RMSD: 4.49360132217 of 52 residues |
|
143
|
|
|
if i[1] not in ['sele', 'rov_pc']: # skip them |
|
144
|
|
|
print(i[0], i[1], 'RMSD:', round(i[2],2), str(i[3]) + 'nt') |
|
145
|
|
|
#f.write(i[0] + '-' + i[1] + ' ' + str(i[2]) + '\n') |
|
146
|
|
|
print() |
|
147
|
|
|
#print f.name |
|
148
|
|
|
#x = 'cat ' + f.name + ' | python ' + PATH_BAR_CHAT + ' -A -k -v --dot =' |
|
149
|
|
|
#f.close() |
|
150
|
|
|
#print x |
|
151
|
|
|
#print commands.getoutput(x) |
|
152
|
|
|
|
|
153
|
|
|
|
|
154
|
|
|
def render_molecules(): |
|
155
|
|
|
rd() |
|
156
|
|
|
|
|
157
|
|
View Code Duplication |
def rd(): |
|
|
|
|
|
|
158
|
|
|
""" |
|
159
|
|
|
rhiju's favorite coloring of proteins and generic molecules |
|
160
|
|
|
side chains are all-heavy-atom and colored CPK, backbone is |
|
161
|
|
|
rainbow cartoon from N to C terminus. |
|
162
|
|
|
""" |
|
163
|
|
|
cmd.bg_color( "white" ) |
|
164
|
|
|
AllObj=cmd.get_names("all") |
|
165
|
|
|
|
|
166
|
|
|
for x in AllObj: |
|
167
|
|
|
#print(AllObj[0],x) |
|
168
|
|
|
print(x) |
|
169
|
|
|
cmd.show( "cartoon", x ) |
|
170
|
|
|
cmd.hide( "line", x ) |
|
171
|
|
|
cmd.color( "white", x+" and elem C" ) |
|
172
|
|
|
cmd.color( "blue", x+" and elem N" ) |
|
173
|
|
|
cmd.color( "red", x+" and elem O" ) |
|
174
|
|
|
cmd.color( "yellow", x+" and elem S" ) |
|
175
|
|
|
cmd.spectrum( "count", "rainbow", x+" and name CA+C" ) |
|
176
|
|
|
cmd.show( "sticks", x +" and not elem H and not name C+N+O" ) |
|
177
|
|
|
cmd.show( "sticks", x +" and resn PRO and name N" ) |
|
178
|
|
|
cmd.show( "sticks", x + " and name NR+CR+CS+CP+CQ" ) |
|
179
|
|
|
cmd.show( "sticks", x + " and not elem H and neighbor name NR+CQ+CR+CS+CP" ) |
|
180
|
|
|
cmd.show( "sticks", x + " and not elem H and neighbor neighbor name NR+CQ+CR+CS+CP" ) |
|
181
|
|
|
cmd.set( "cartoon_oval_width", 0.1 ) |
|
182
|
|
|
cmd.set( "cartoon_oval_length", 0.5 ) |
|
183
|
|
|
|
|
184
|
|
|
def rx(): |
|
185
|
|
|
""" |
|
186
|
|
|
rhiju's favorite coloring of proteins, more details -- |
|
187
|
|
|
no cartoon; heavy backbone |
|
188
|
|
|
""" |
|
189
|
|
|
cmd.bg_color( "white" ) |
|
190
|
|
|
AllObj=cmd.get_names("all") |
|
191
|
|
|
|
|
192
|
|
|
for x in AllObj: |
|
193
|
|
|
#print(AllObj[0],x) |
|
194
|
|
|
print(x) |
|
195
|
|
|
cmd.hide( "line", x ) |
|
196
|
|
|
cmd.color( "white", x+" and elem C" ) |
|
197
|
|
|
cmd.color( "blue", x+" and elem N" ) |
|
198
|
|
|
cmd.color( "red", x+" and elem O" ) |
|
199
|
|
|
cmd.color( "yellow", x+" and elem S" ) |
|
200
|
|
|
cmd.spectrum( "count", "rainbow", x+" and name CA+C" ) |
|
201
|
|
|
#cmd.show( "sticks", x +" and not elem H and not name C+N+O" ) |
|
202
|
|
|
|
|
203
|
|
|
cmd.select('backbone','name o+c+ca+n') |
|
204
|
|
|
cmd.show('sticks','not elem H') |
|
205
|
|
|
|
|
206
|
|
|
if not x.count( 'BACKBONE' ): |
|
207
|
|
|
cmd.create( x+"_BACKBONE", x+" and not element H and backbone" ) |
|
208
|
|
|
|
|
209
|
|
|
|
|
210
|
|
|
cmd.set('stick_radius', '0.5', "*BACKBONE" ) |
|
211
|
|
|
|
|
212
|
|
|
def render_x(): |
|
213
|
|
|
rx() |
|
214
|
|
|
|
|
215
|
|
View Code Duplication |
def rj(): |
|
|
|
|
|
|
216
|
|
|
""" |
|
217
|
|
|
rhiju's residue-level favorite coloring of proteins |
|
218
|
|
|
""" |
|
219
|
|
|
cmd.bg_color( "white" ) |
|
220
|
|
|
AllObj=cmd.get_names("all") |
|
221
|
|
|
|
|
222
|
|
|
for x in AllObj: |
|
223
|
|
|
#print(AllObj[0],x) |
|
224
|
|
|
print(x) |
|
225
|
|
|
cmd.show( "cartoon", x ) |
|
226
|
|
|
#cmd.hide( "line", x ) |
|
227
|
|
|
cmd.show( "line", x ) |
|
228
|
|
|
cmd.color( "gray", x+" and resn trp+phe+ala+val+leu+ile+pro+met" ) |
|
229
|
|
|
cmd.color( "orange", x+" and resn gly" ) |
|
230
|
|
|
cmd.color( "red", x+" and resn asp+glu" ) |
|
231
|
|
|
cmd.color( "blue", x+" and resn lys+arg+his" ) |
|
232
|
|
|
cmd.color( "purple", x+" and resn cys" ) |
|
233
|
|
|
cmd.color( "forest", x+" and resn tyr+thr+ser+gln+asn" ) |
|
234
|
|
|
#cmd.spectrum( "count", "rainbow", x+" and name CA" ) |
|
235
|
|
|
cmd.show( "sticks", x +" and not elem H and not name C+N+O" ) |
|
236
|
|
|
cmd.show( "sticks", x +" and resn PRO and name N" ) |
|
237
|
|
|
cmd.hide( "sticks", x + " and name NR+CR+CS+CP+CQ" ) |
|
238
|
|
|
cmd.show( "sticks", x + " and not elem H and neighbor name NR+CQ+CR+CS+CP" ) |
|
239
|
|
|
cmd.set( "cartoon_rect_length", 0.75 ) |
|
240
|
|
|
cmd.set( "cartoon_rect_width", 0.1 ) |
|
241
|
|
|
cmd.set( "cartoon_oval_length", 0.6 ) |
|
242
|
|
|
cmd.set( "cartoon_oval_width", 0.2 ) |
|
243
|
|
|
|
|
244
|
|
|
def render_rhiju(): |
|
245
|
|
|
rj() |
|
246
|
|
|
|
|
247
|
|
|
|
|
248
|
|
|
|
|
249
|
|
View Code Duplication |
def rg(rainbow=False): |
|
|
|
|
|
|
250
|
|
|
""" |
|
251
|
|
|
rhiju's favorite coloring of RNA |
|
252
|
|
|
with 2' OH as spheres, |
|
253
|
|
|
bases as filled rings, and backbone as cartoon |
|
254
|
|
|
ribbons, rainbow colored from 5' to 3'. No hydrogens, |
|
255
|
|
|
|
|
256
|
|
|
change: don't color the backbone |
|
257
|
|
|
""" |
|
258
|
|
|
# cmd.bg_color( "white" ) |
|
259
|
|
|
|
|
260
|
|
|
# cmd.hide('everything' ) # don't hide |
|
261
|
|
|
cmd.show('sticks','not elem H') |
|
262
|
|
|
|
|
263
|
|
|
#cmd.color( 'red','resn rG+G+DG') |
|
264
|
|
|
#cmd.color( 'forest','resn rC+C+DC') |
|
265
|
|
|
#cmd.color( 'orange','resn rA+A+DA') |
|
266
|
|
|
#cmd.color( 'blue','resn rU+U+DT+BRU') |
|
267
|
|
|
|
|
268
|
|
|
#cmd.set( 'cartoon_ring_color', 'red','resn rG+G+DG') |
|
269
|
|
|
#cmd.set( 'cartoon_ring_color', 'forest','resn rC+C+DC') |
|
270
|
|
|
#cmd.set( 'cartoon_ring_color', 'orange','resn rA+A+DA') |
|
271
|
|
|
#cmd.set( 'cartoon_ring_color', 'blue','resn rU+U+DT+BRU') |
|
272
|
|
|
|
|
273
|
|
|
#cmd.set( 'cartoon_ring_color', 'red','resn RG+G+DG+RG3+RG5') |
|
274
|
|
|
#cmd.set( 'cartoon_ring_color', 'forest','resn rC+C+DC+RC+RC3+RC5') |
|
275
|
|
|
#cmd.set( 'cartoon_ring_color', 'orange','resn rA+A+DA+RA+RA3+RA5') |
|
276
|
|
|
#cmd.set( 'cartoon_ring_color', 'blue','resn rU+U+DT+BRU+RU+RU3+RU5') |
|
277
|
|
|
|
|
278
|
|
|
cmd.select('bases','name c2+c4+c5+c6+c8+n1+n2+n3+n4+n6+n7+n9+o2+o4+o6+n1p') |
|
279
|
|
|
cmd.select('backbone_', 'name o1p+o2p+o3p+p+c1*+c2*+c3*+c5*+o2*+o3*+o4*+o5*') |
|
280
|
|
|
cmd.select('sugar', 'name c1*+c2*+c3*+c4*+o2*+o4*') |
|
281
|
|
|
AllObj=cmd.get_names("all") |
|
282
|
|
|
|
|
283
|
|
|
cmd.color( 'gray','resn RG+G+RG3+RG5 and name N1+C6+O6+C5+C4+N7+C8+N9+N3+C2+N1+N2') |
|
284
|
|
|
cmd.color( 'gray','resn rC+C+RC+RC3+RC5 and name N1+C2+O2+N3+C4+N4+C5+C6') |
|
285
|
|
|
cmd.color( 'gray','resn rA+A+RA+RA3+RA5 and name N1+C6+N6+C5+N7+C8+N9+C4+N3+C2') |
|
286
|
|
|
cmd.color( 'gray','resn rU+U+RU+RU3+RU5 and name N3+C4+O4+C5+C6+N1+C2+O2') |
|
287
|
|
|
cmd.color('gray', "name c1*+c2*+c3*+c4*+o2*+o4*+C1'+C2'+C3'+C4'+O2'+O4'") |
|
288
|
|
|
cmd.select( 'backbone_', " (name o1p+o2p+o3p+p+op1+op2+'c1*'+'c2*'+'c3*'+'c5*'+'o2*'+'o3*'+'o4*'+'o5*'+'c1*'+'c2*'+'c3*'+'c4*'+'o2*'+'o4*'+c1'+c2'+c3'+c5'+o2'+o3'+o4'+o5'+c1'+c2'+c3'+c4'+o2'+o4') and (not name c1+c2+c3+c4+c5+o2+o3+o4+o5) ") |
|
289
|
|
|
|
|
290
|
|
|
for x in AllObj: |
|
291
|
|
|
cmd.show( "cartoon", x ) |
|
292
|
|
|
#cmd.spectrum( "count", "rainbow", x+" and backbone" ) |
|
293
|
|
|
#cmd.color( 'white', 'backbone' ) |
|
294
|
|
|
|
|
295
|
|
|
cmd.cartoon("tube", "backbone" ) |
|
296
|
|
|
|
|
297
|
|
|
cmd.set( "cartoon_ring_mode", 3 ) |
|
298
|
|
|
cmd.set( "cartoon_ring_transparency", 0.0 ) |
|
299
|
|
|
#CMD.set( "cartoon_tube_radius", 0.8) |
|
300
|
|
|
|
|
301
|
|
|
cmd.hide( "sticks", "backbone" ) |
|
302
|
|
|
cmd.alter( "name o2*","vdw=0.5" ) |
|
303
|
|
|
cmd.show( "spheres", "name o2'+'o2*' and not name o2" ) |
|
304
|
|
|
cmd.show( "sticks", "name 'o2*'+'c2*'" ) |
|
305
|
|
|
|
|
306
|
|
|
cmd.alter( "resn mg", "vdw=1.0") |
|
307
|
|
|
cmd.alter( "resn hoh", "vdw=0.5") |
|
308
|
|
|
cmd.show( "spheres", "resn mg+sr+co+zn") |
|
309
|
|
|
|
|
310
|
|
|
# clean up |
|
311
|
|
|
cmd.delete('backbone_') |
|
312
|
|
|
cmd.delete('bases') |
|
313
|
|
|
cmd.delete('sugar') |
|
314
|
|
|
|
|
315
|
|
|
cmd.extend('rg', rg) |
|
316
|
|
|
|
|
317
|
|
View Code Duplication |
def rr(rainbow=False): |
|
|
|
|
|
|
318
|
|
|
""" |
|
319
|
|
|
rhiju's favorite coloring of RNA |
|
320
|
|
|
with 2' OH as spheres, |
|
321
|
|
|
bases as filled rings, and backbone as cartoon |
|
322
|
|
|
ribbons, rainbow colored from 5' to 3'. No hydrogens, |
|
323
|
|
|
|
|
324
|
|
|
change: don't color the backbone |
|
325
|
|
|
""" |
|
326
|
|
|
# cmd.bg_color( "white" ) |
|
327
|
|
|
|
|
328
|
|
|
# cmd.hide('everything' ) # don't hide |
|
329
|
|
|
cmd.show('sticks','not elem H') |
|
330
|
|
|
|
|
331
|
|
|
#cmd.color( 'red','resn rG+G+DG') |
|
332
|
|
|
#cmd.color( 'forest','resn rC+C+DC') |
|
333
|
|
|
#cmd.color( 'orange','resn rA+A+DA') |
|
334
|
|
|
#cmd.color( 'blue','resn rU+U+DT+BRU') |
|
335
|
|
|
|
|
336
|
|
|
#cmd.set( 'cartoon_ring_color', 'red','resn rG+G+DG') |
|
337
|
|
|
#cmd.set( 'cartoon_ring_color', 'forest','resn rC+C+DC') |
|
338
|
|
|
#cmd.set( 'cartoon_ring_color', 'orange','resn rA+A+DA') |
|
339
|
|
|
#cmd.set( 'cartoon_ring_color', 'blue','resn rU+U+DT+BRU') |
|
340
|
|
|
|
|
341
|
|
|
#cmd.set( 'cartoon_ring_color', 'red','resn RG+G+DG+RG3+RG5') |
|
342
|
|
|
#cmd.set( 'cartoon_ring_color', 'forest','resn rC+C+DC+RC+RC3+RC5') |
|
343
|
|
|
#cmd.set( 'cartoon_ring_color', 'orange','resn rA+A+DA+RA+RA3+RA5') |
|
344
|
|
|
#cmd.set( 'cartoon_ring_color', 'blue','resn rU+U+DT+BRU+RU+RU3+RU5') |
|
345
|
|
|
|
|
346
|
|
|
cmd.select('bases','name c2+c4+c5+c6+c8+n1+n2+n3+n4+n6+n7+n9+o2+o4+o6+n1p') |
|
347
|
|
|
cmd.select('backbone_', 'name o1p+o2p+o3p+p+c1*+c2*+c3*+c5*+o2*+o3*+o4*+o5*') |
|
348
|
|
|
cmd.select('sugar', 'name c1*+c2*+c3*+c4*+o2*+o4*') |
|
349
|
|
|
AllObj=cmd.get_names("all") |
|
350
|
|
|
|
|
351
|
|
|
cmd.color( 'red','resn RG+G+RG3+RG5 and name N1+C6+O6+C5+C4+N7+C8+N9+N3+C2+N1+N2') |
|
352
|
|
|
cmd.color( 'forest','resn rC+C+RC+RC3+RC5 and name N1+C2+O2+N3+C4+N4+C5+C6') |
|
353
|
|
|
cmd.color( 'orange','resn rA+A+RA+RA3+RA5 and name N1+C6+N6+C5+N7+C8+N9+C4+N3+C2') |
|
354
|
|
|
cmd.color( 'blue','resn rU+U+RU+RU3+RU5 and name N3+C4+O4+C5+C6+N1+C2+O2') |
|
355
|
|
|
|
|
356
|
|
|
cmd.select( 'backbone_', " (name o1p+o2p+o3p+p+op1+op2+'c1*'+'c2*'+'c3*'+'c5*'+'o2*'+'o3*'+'o4*'+'o5*'+'c1*'+'c2*'+'c3*'+'c4*'+'o2*'+'o4*'+c1'+c2'+c3'+c5'+o2'+o3'+o4'+o5'+c1'+c2'+c3'+c4'+o2'+o4') and (not name c1+c2+c3+c4+c5+o2+o3+o4+o5) ") |
|
357
|
|
|
|
|
358
|
|
|
for x in AllObj: |
|
359
|
|
|
cmd.show( "cartoon", x ) |
|
360
|
|
|
#cmd.spectrum( "count", "rainbow", x+" and backbone" ) |
|
361
|
|
|
#cmd.color( 'white', 'backbone' ) |
|
362
|
|
|
|
|
363
|
|
|
cmd.cartoon("tube", "backbone" ) |
|
364
|
|
|
|
|
365
|
|
|
cmd.set( "cartoon_ring_mode", 3 ) |
|
366
|
|
|
cmd.set( "cartoon_ring_transparency", 0.0 ) |
|
367
|
|
|
#CMD.set( "cartoon_tube_radius", 0.8) |
|
368
|
|
|
|
|
369
|
|
|
cmd.hide( "sticks", "backbone" ) |
|
370
|
|
|
cmd.alter( "name o2*","vdw=0.5" ) |
|
371
|
|
|
cmd.show( "spheres", "name o2'+'o2*' and not name o2" ) |
|
372
|
|
|
cmd.show( "sticks", "name 'o2*'+'c2*'" ) |
|
373
|
|
|
|
|
374
|
|
|
cmd.alter( "resn mg", "vdw=1.0") |
|
375
|
|
|
cmd.alter( "resn hoh", "vdw=0.5") |
|
376
|
|
|
cmd.show( "spheres", "resn mg+sr+co+zn") |
|
377
|
|
|
|
|
378
|
|
|
# clean up |
|
379
|
|
|
cmd.delete('backbone_') |
|
380
|
|
|
cmd.delete('bases') |
|
381
|
|
|
cmd.delete('sugar') |
|
382
|
|
|
|
|
383
|
|
|
def render_rna(): |
|
384
|
|
|
rr() |
|
385
|
|
|
|
|
386
|
|
|
def rrs(): |
|
387
|
|
|
""") |
|
388
|
|
|
rhiju's favorite coloring of RNA, showing |
|
389
|
|
|
all heavy atoms as sticks -- more detail than rr(). |
|
390
|
|
|
""" |
|
391
|
|
|
rr() |
|
392
|
|
|
cmd.show( 'sticks', 'not elem H' ) |
|
393
|
|
|
|
|
394
|
|
|
def render_rna_sticks(): |
|
395
|
|
|
rr() |
|
396
|
|
|
|
|
397
|
|
|
def rr2(): |
|
398
|
|
|
""" |
|
399
|
|
|
rhiju's favorite coloring of RNA, showing |
|
400
|
|
|
all heavy atoms as sticks -- more detail than rr(). |
|
401
|
|
|
""" |
|
402
|
|
|
rr() |
|
403
|
|
|
cmd.hide( 'spheres' ) |
|
404
|
|
|
cmd.hide( 'sticks' ) |
|
405
|
|
|
cmd.set( "cartoon_ring_mode", 0 ) |
|
406
|
|
|
|
|
407
|
|
|
def render_rna2(): |
|
408
|
|
|
rr2() |
|
409
|
|
|
|
|
410
|
|
|
|
|
411
|
|
|
def get_residue_colors( sele ): |
|
412
|
|
|
""" |
|
413
|
|
|
Get RGB color values associated with a selection. |
|
414
|
|
|
Useful if you want to exactly match coloring of 3D models |
|
415
|
|
|
with coloring in, say, a MATLAB script. |
|
416
|
|
|
""" |
|
417
|
|
|
pymol.stored.colors = [] |
|
|
|
|
|
|
418
|
|
|
cmd.iterate( sele, "stored.colors.append( (chain, resi, name, color))") |
|
419
|
|
|
res_colors = {} |
|
420
|
|
|
for chain, resi, name, color in pymol.stored.colors: |
|
421
|
|
|
if name == 'CA': # c-alpha atom |
|
422
|
|
|
res_colors[(chain, resi)] = cmd.get_color_tuple(color) |
|
423
|
|
|
print(res_colors) |
|
424
|
|
|
return res_colors |
|
425
|
|
|
|
|
426
|
|
|
def spr(): |
|
427
|
|
|
""" |
|
428
|
|
|
Load up these commands again after, say, an edit. |
|
429
|
|
|
""" |
|
430
|
|
|
|
|
431
|
|
|
cmd.do( 'run '+inspect.getfile(inspect.currentframe()) ) |
|
432
|
|
|
|
|
433
|
|
|
def source_pymol_rhiju(): |
|
434
|
|
|
""" |
|
435
|
|
|
Load up these commands again after, say, an edit. |
|
436
|
|
|
""" |
|
437
|
|
|
spr() |
|
438
|
|
|
|
|
439
|
|
|
|
|
440
|
|
|
def loop_color( start, end, native=None, zoom=False ): |
|
441
|
|
|
""" |
|
442
|
|
|
Used for rendering protein loop modeling puzzles. |
|
443
|
|
|
White in background, colored red/blue over loop. |
|
444
|
|
|
""" |
|
445
|
|
|
|
|
446
|
|
|
rd() |
|
447
|
|
|
|
|
448
|
|
|
cmd.color( "white", "not resi %d-%d" % (start,end) ) |
|
449
|
|
|
#cmd.hide( "cartoon", "resi %d-%d" % (start,end) ) |
|
450
|
|
|
#cmd.show( "sticks", "not elem H and resi %d-%d" % (start,end) ) |
|
451
|
|
|
|
|
452
|
|
|
#before_start = start - 1 |
|
453
|
|
|
#cmd.show( "sticks", "name C and resi %d" % (before_start) ) |
|
454
|
|
|
#after_end = end + 1 |
|
455
|
|
|
#cmd.show( "sticks", "name N and resi %d" % (after_end) ) |
|
456
|
|
|
|
|
457
|
|
|
cmd.color( "salmon", "elem C and resi %d-%d" % (start,end) ) |
|
458
|
|
|
|
|
459
|
|
|
#cmd.show( "lines", "not elem H" ) |
|
460
|
|
|
#cmd.hide( "cartoon", "resi %d-%d" % (start,end) ) |
|
461
|
|
|
#cmd.show( "sticks", "name C+N+CA+O and resi %d-%d" % (start,end) ) |
|
462
|
|
|
cmd.hide( "sticks", "resi %d-%d and name C+N+O" % (start,end) ) |
|
463
|
|
|
cmd.show( "sticks", "resn PRO and name N") |
|
464
|
|
|
cmd.show( "sticks", x +" and ( not elem H and neighbor name NR+CR+CS+CP+CQ )" ) |
|
|
|
|
|
|
465
|
|
|
|
|
466
|
|
|
|
|
467
|
|
|
if native: |
|
468
|
|
|
|
|
469
|
|
|
# reassign colors based on native -- spectrum colors by atom count and |
|
470
|
|
|
# messes up loop coloring on small loop subsegments. |
|
471
|
|
|
#colors = get_residue_colors( "%s and resi %d-%d" % (native,start,end) ) |
|
472
|
|
|
#for x in AllObj: |
|
473
|
|
|
#for m in range( start, end+1): |
|
474
|
|
|
#cmd.set_color( 'color%d' % m, colors[ ('','%d' % m) ] ) |
|
475
|
|
|
#cmd.color( 'color%d' % m, 'elem C and resi %d' % m ) |
|
476
|
|
|
|
|
477
|
|
|
|
|
478
|
|
|
cmd.color( "white", native + " and not resi %d-%d" % (start,end) ) |
|
479
|
|
|
#cmd.color( "palecyan", native+" and not name C+N+CA+O") |
|
480
|
|
|
cmd.color( "skyblue", native+" and elem C and resi %d-%d" % (start,end) ) |
|
481
|
|
|
|
|
482
|
|
|
if zoom: cmd.zoom( "resi %d-%d" % (start,end) ) |
|
483
|
|
|
|
|
484
|
|
|
|
|
485
|
|
|
def rb(): |
|
486
|
|
|
""" |
|
487
|
|
|
basic cartoon coloring |
|
488
|
|
|
""" |
|
489
|
|
|
|
|
490
|
|
|
AllObj=cmd.get_names("all") |
|
491
|
|
|
cmd.bg_color( "white" ) |
|
492
|
|
|
cmd.hide( "ev" ) |
|
493
|
|
|
cmd.show( "cartoon" ) |
|
494
|
|
|
cmd.cartoon( "rectangle" ) |
|
495
|
|
|
cmd.set( "cartoon_ring_mode", 1 ) |
|
496
|
|
|
cmd.set( "cartoon_rect_length", 0.7 ) |
|
497
|
|
|
cmd.set( "cartoon_rect_width", 0.2 ) |
|
498
|
|
|
for x in AllObj: |
|
499
|
|
|
print(AllObj[0],x) |
|
500
|
|
|
cmd.spectrum( "count", "rainbow", x ) |
|
501
|
|
|
|
|
502
|
|
|
def atomcolor(): |
|
503
|
|
|
""" |
|
504
|
|
|
atom coloring |
|
505
|
|
|
""" |
|
506
|
|
|
|
|
507
|
|
|
cmd.bg_color( "white" ) |
|
508
|
|
|
cmd.hide( "ev" ) |
|
509
|
|
|
cmd.show( "sticks", "not elem H" ) |
|
510
|
|
|
cmd.show( "lines", "elem H" ) |
|
511
|
|
|
util.cbag() |
|
512
|
|
|
cmd.color( "white", "elem C" ) |
|
513
|
|
|
|
|
514
|
|
View Code Duplication |
def rc(): |
|
|
|
|
|
|
515
|
|
|
""" |
|
516
|
|
|
tube coloring for large RNA comparisons |
|
517
|
|
|
""" |
|
518
|
|
|
cmd.bg_color( "white" ) |
|
519
|
|
|
cmd.hide( 'everything' ) |
|
520
|
|
|
|
|
521
|
|
|
cmd.color( 'red','resn rG+G+DG') |
|
522
|
|
|
cmd.color( 'forest','resn rC+C+DC') |
|
523
|
|
|
cmd.color( 'orange','resn rA+A+DA') |
|
524
|
|
|
cmd.color( 'blue','resn rU+U+DT+BRU') |
|
525
|
|
|
|
|
526
|
|
|
AllObj=cmd.get_names("all") |
|
527
|
|
|
|
|
528
|
|
|
cmd.select( 'backbone', " (name o1p+o2p+o3p+p+op1+op2+'c1*'+'c2*'+'c3*'+'c5*'+'o2*'+'o3*'+'o4*'+'o5*'+'c1*'+'c2*'+'c3*'+'c4*'+'o2*'+'o4*'+c1'+c2'+c3'+c5'+o2'+o3'+o4'+o5'+c1'+c2'+c3'+c4'+o2'+o4') and (not name c1+c2+c3+c4+c5+o2+o3+o4+o5) ") |
|
529
|
|
|
|
|
530
|
|
|
for x in AllObj: |
|
531
|
|
|
print(x) |
|
532
|
|
|
cmd.show( "cartoon", x ) |
|
533
|
|
|
cmd.spectrum( "count", "rainbow", x+" and backbone" ) |
|
534
|
|
|
|
|
535
|
|
|
cmd.cartoon( "tube", "backbone" ) |
|
536
|
|
|
|
|
537
|
|
|
cmd.set( "cartoon_ring_mode", 0 ) |
|
538
|
|
|
cmd.set( "cartoon_ring_transparency", 0.0 ) |
|
539
|
|
|
cmd.set( "cartoon_tube_radius", 1.0 ) |
|
540
|
|
|
|
|
541
|
|
|
cmd.color( 'red','resn rG+G and name n1+c6+o6+c5+c4+n7+c8+n9+n3+c2+n1+n2') |
|
542
|
|
|
cmd.color( 'forest','resn rC+C and name n1+c2+o2+n3+c4+n4+c5+c6') |
|
543
|
|
|
cmd.color( 'orange','resn rA+A and name n1+c6+n6+c5+n7+c8+n9+c4+n3+c2') |
|
544
|
|
|
cmd.color( 'blue','resn rU+U and name n3+c4+o4+c5+c6+n1+c2+o2') |
|
545
|
|
|
|
|
546
|
|
|
cmd.delete('backbone') |
|
547
|
|
|
|
|
548
|
|
View Code Duplication |
def rcm(): |
|
|
|
|
|
|
549
|
|
|
""" |
|
550
|
|
|
tube coloring for large RNA comparisons |
|
551
|
|
|
""" |
|
552
|
|
|
#cmd.bg_color( "white" ) |
|
553
|
|
|
cmd.hide( 'everything' ) |
|
554
|
|
|
|
|
555
|
|
|
cmd.set('cartoon_ladder_mode', 0 ) |
|
556
|
|
|
|
|
557
|
|
|
cmd.color( 'red','resn rG+G+DG') |
|
558
|
|
|
cmd.color( 'forest','resn rC+C+DC') |
|
559
|
|
|
cmd.color( 'orange','resn rA+A+DA') |
|
560
|
|
|
cmd.color( 'blue','resn rU+U+DT+BRU') |
|
561
|
|
|
|
|
562
|
|
|
AllObj=cmd.get_names("all") |
|
563
|
|
|
|
|
564
|
|
|
cmd.select( 'backbone', " (name o1p+o2p+o3p+p+op1+op2+'c1*'+'c2*'+'c3*'+'c5*'+'o2*'+'o3*'+'o4*'+'o5*'+'c1*'+'c2*'+'c3*'+'c4*'+'o2*'+'o4*'+c1'+c2'+c3'+c5'+o2'+o3'+o4'+o5'+c1'+c2'+c3'+c4'+o2'+o4') and (not name c1+c2+c3+c4+c5+o2+o3+o4+o5) ") |
|
565
|
|
|
|
|
566
|
|
|
for x in AllObj: |
|
567
|
|
|
print(x) |
|
568
|
|
|
cmd.show( "cartoon", x ) |
|
569
|
|
|
cmd.spectrum( "count", "rainbow", x+" and backbone" ) |
|
570
|
|
|
|
|
571
|
|
|
cmd.cartoon( "tube", "backbone" ) |
|
572
|
|
|
|
|
573
|
|
|
cmd.set( "cartoon_ring_mode", 0 ) |
|
574
|
|
|
cmd.set( "cartoon_ring_transparency", 0.0 ) |
|
575
|
|
|
cmd.set( "cartoon_tube_radius", 1.0 ) |
|
576
|
|
|
|
|
577
|
|
|
cmd.color( 'red','resn rG+G and name n1+c6+o6+c5+c4+n7+c8+n9+n3+c2+n1+n2') |
|
578
|
|
|
cmd.color( 'forest','resn rC+C and name n1+c2+o2+n3+c4+n4+c5+c6') |
|
579
|
|
|
cmd.color( 'orange','resn rA+A and name n1+c6+n6+c5+n7+c8+n9+c4+n3+c2') |
|
580
|
|
|
cmd.color( 'blue','resn rU+U and name n3+c4+o4+c5+c6+n1+c2+o2') |
|
581
|
|
|
|
|
582
|
|
|
cmd.delete('backbone') |
|
583
|
|
|
|
|
584
|
|
|
|
|
585
|
|
|
def rcd(): |
|
586
|
|
|
""" |
|
587
|
|
|
fancy ribbon coloring for large RNA comparisons |
|
588
|
|
|
""" |
|
589
|
|
|
rc() |
|
590
|
|
|
cmd.cartoon( 'dumbbell') |
|
591
|
|
|
cmd.set( 'cartoon_dumbbell_radius', 0.5 ) |
|
592
|
|
|
|
|
593
|
|
|
def render_cartoon(): |
|
594
|
|
|
rc() |
|
595
|
|
|
|
|
596
|
|
|
def bx(): |
|
597
|
|
|
txt = """color black, all |
|
598
|
|
|
color pink, resi 3-5+132-134 # p1 |
|
599
|
|
|
color forest, resi 12-13+129-130 # p3 |
|
600
|
|
|
color orange, resi 17-33 # p4 |
|
601
|
|
|
color green, resi 36-45 # p5 |
|
602
|
|
|
color blue, resi 47-124 # p6color |
|
603
|
|
|
""" |
|
604
|
|
|
for t in txt.split('\n'): |
|
605
|
|
|
color, resi = t.replace('color ', '').split(',') |
|
606
|
|
|
print(color, resi) |
|
607
|
|
|
cmd.color(color.strip(), resi.strip()) |
|
608
|
|
|
|
|
609
|
|
|
def color_by_text(txt): |
|
610
|
|
|
for t in txt.strip().split('\n'): |
|
611
|
|
|
color, resi = t.replace('color ', '').split(',') |
|
612
|
|
|
print(color, resi) |
|
613
|
|
|
cmd.color(color.strip(), resi.strip()) |
|
614
|
|
|
|
|
615
|
|
|
|
|
616
|
|
|
|
|
617
|
|
|
|
|
618
|
|
|
from multiprocessing import Process |
|
619
|
|
|
|
|
620
|
|
|
cmd.extend('rib', rcm) |
|
621
|
|
|
#cmd.extend('clr_', clr) |
|
622
|
|
|
cmd.extend('aaa', align_all) |
|
623
|
|
|
cmd.extend('rr', rr) |
|
624
|
|
|
cmd.extend('rcd', rcd) |
|
625
|
|
|
|