Skip to content

Instantly share code, notes, and snippets.

@d0choa
Last active August 11, 2021 10:41
Show Gist options
  • Save d0choa/0de504768f7c5db8657d5ef2db4fd4db to your computer and use it in GitHub Desktop.
Save d0choa/0de504768f7c5db8657d5ef2db4fd4db to your computer and use it in GitHub Desktop.
Overlay variants in NOD2 alphafold model
from pymol import cmd
cmd.load("/Users/ochoa/Downloads/AF-Q9HC29-F1-model_v1.cif")
cmd.bg_color("grey95")
cmd.set_color("veryHigh", [0, 83, 214])
cmd.set_color("confident", [101, 203, 243])
cmd.set_color("low", [255, 219, 19])
cmd.set_color("veryLow", [255, 125, 69])
myspace = {'bfactors': [], 'colors': []}
cmd.iterate('(all)', 'bfactors.append(b)', space=myspace)
for i in range(len(myspace["bfactors"])):
if myspace["bfactors"][i] >= 90:
cmd.color("veryHigh", "id %s"%(i))
if myspace["bfactors"][i] >= 70 and myspace["bfactors"][i] < 90:
cmd.color("confident", "id %s"%(i))
if myspace["bfactors"][i] >= 50 and myspace["bfactors"][i] < 70:
cmd.color("low", "id %s"%(i))
if myspace["bfactors"][i] < 50:
cmd.color("veryLow", "id %s"%(i))
cmd.set_view ('''
0.393646330, 0.902617753, -0.174098119,\
-0.272292942, -0.066398188, -0.959918439,\
-0.878005683, 0.425276071, 0.219640806,\
0.000002455, -0.000060514, -288.063629150,\
13.260636330, -7.507136345, 7.113989830,\
227.110061646, 349.013397217, -20.000000000''')
cmd.scene("F0", "store")
# Common variants
cmd.set_view('''
0.365331203, 0.919453979, 0.145344511,\
0.527212143, -0.075690560, -0.846352756,\
-0.767186105, 0.385828793, -0.512402296,\
0.000002455, -0.000060514, -288.063629150,\
13.260636330, -7.507136345, 7.113989830,\
227.110061646, 349.013397217, -20.000000000 ''')
cmd.color("red", "name ca and resi 702+908")
cmd.show("spheres", "name ca and resi 702+908")
cmd.scene("Common", "store")
cmd.hide("spheres", "name ca and resi 702+908")
# #Behcet's syndrome
cmd.set_view ('''
0.386675328, 0.922169745, 0.008488609,\
0.156637177, -0.056603037, -0.986031234,\
-0.908812225, 0.382605076, -0.166334808,\
0.000002455, -0.000060514, -288.063629150,\
13.260636330, -7.507136345, 7.113989830,\
227.110061646, 349.013397217, -20.000000000''')
cmd.color("red", "name ca and resi 81+349+733+816")
cmd.show("spheres", "name ca and resi 81+349+733+816")
cmd.scene("Behcet", "store")
cmd.hide("spheres", "name ca and resi 81+349+733+816")
# # # Hinge variants
cmd.set_view ('''
0.073372163, 0.926850855, 0.368176132,\
0.970709980, 0.018311813, -0.239545107,\
-0.228766054, 0.374970824, -0.898362696,\
0.000002455, -0.000060514, -288.063629150,\
13.260636330, -7.507136345, 7.113989830,\
227.110061646, 349.013397217, -20.000000000''')
cmd.color("red", "name ca and resi 334+382+383")
cmd.show("spheres", "name ca and resi 334+382+383")
cmd.scene("Hinge", "store")
cmd.hide("spheres", "name ca and resi 334+382+383")
# # # Back variants
cmd.set_view ('''
-0.375553399, 0.917228043, 0.132829159,\
0.353036404, 0.009065011, 0.935561597,\
0.856921792, 0.398250222, -0.327220917,\
0.000002455, -0.000060514, -288.063629150,\
13.260636330, -7.507136345, 7.113989830,\
227.110061646, 349.013397217, -20.000000000''')
cmd.color("red", "name ca and resi 469+495+496+513")
cmd.show("spheres", "name ca and resi 469+495+496+513")
cmd.scene("Back", "store")
cmd.hide("spheres", "name ca and resi 469+495+496+513")
# # #All
cmd.set_view ('''
0.354737908, 0.890810728, 0.283912361,\
0.482070416, 0.085916959, -0.871900439,\
-0.801096201, 0.446167141, -0.398955882,\
0.000002455, -0.000060514, -288.063629150,\
13.260636330, -7.507136345, 7.113989830,\
227.110061646, 349.013397217, -20.000000000''')
cmd.color("red", "name ca and resi ")
cmd.show("spheres", "name ca and resi 81+334+349+382+383+469+495+496+513+702+733+816+908")
cmd.scene("All", "store")
# ## Movie
cmd.mset("1x1200")
cmd.set("movie_loop", 0)
cmd.mview("store", 1, scene="F0")
cmd.mview("store", 240, scene="Common")
cmd.mview("store", 480, scene="Behcet")
cmd.mview("store", 720, scene="Hinge")
cmd.mview("store", 960, scene="Back")
cmd.mview("store", 1200, scene="All")
# set ray_trace_mode, 1
# set ambient, 0.4
# set reflect, 0.5
# set two_sided_lighting, on
# set antialias, 2
# set sphere_scale, 0.6, (all)
# set spec_reflect, 2 #surfaces less glossy
# set spec_power, 1000
# cmd.select("AF-Q9HC29-F1-model_v1/A/A/3")
# cmd.select( "selected","AF-Q9HC29-F1-model_v1/A/A/3")
# cmd.color("AF-Q9HC29-F1-model_v1/A/A/3", "blue")
# stored.colors = {}
# iterate all, stored.colors[chain,resi,name,b] = color
# cmd.iterate(mol, cmd.color(,))
# iterate all, print(color)
# set_color veryHigh, [0, 83, 214]
# set_color confident, [101, 203, 243]
# set_color low, [255, 219, 19]
# set_color veryLow, [255, 125, 69]
# cmd.cartoon("putty", mol)
# cmd.set("cartoon_putty_scale_min", min(bfacts),obj)
# cmd.set("cartoon_putty_scale_max", max(bfacts),obj)
# cmd.set("cartoon_putty_transform", 0,obj)
# cmd.set("cartoon_putty_radius", 100,obj)
# cmd.spectrum("b","rainbow", "%s and n. CA " %mol)
# cmd.recolor()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment