def __call__(self): if self.name not in cmd.get_names('objects'): cmd.delete(self.callback_name) cmd.set_key("pgup", lambda: None) cmd.set_key("pgdn", lambda: None) return tmp = cmd.get_position() r = cpv.distance_sq(self.center, tmp) if (r > 0.3): # increase this number if it is too slow self.update()
def cleanup(self): # save current state in global vars... global default_object,default_browse,static_dict default_object = self.object default_browse = self.browse static_dict = self.dict # restore key actions cmd.set_key('F1',None) cmd.set_key('F2',None) cmd.set_key('F3',None) cmd.set_key('right',cmd.forward) cmd.set_key('left',cmd.backward)
def cleanup(self): # save current state in global vars... global default_object, default_browse, static_dict default_object = self.object default_browse = self.browse static_dict = self.dict # restore key actions cmd.set_key("F1", None) cmd.set_key("F2", None) cmd.set_key("F3", None) cmd.set_key("right", cmd.forward) cmd.set_key("left", cmd.backward)
def testSetKey(self): if testing.PYMOL_VERSION[1] > 1.84: cmd.set('auto_show_classified', 0) cmd.fragment('gly') N = cmd.count_atoms() self.assertEqual(0, cmd.count_atoms('rep sticks | rep spheres')) cmd.set_key('F3', cmd.show, ('sticks', )) cmd._special(3, 0, 0) self.assertEqual(N, cmd.count_atoms('rep sticks')) cmd.do('set_key F3, hide sticks; show spheres') cmd._special(3, 0, 0) self.assertEqual(0, cmd.count_atoms('rep sticks')) self.assertEqual(N, cmd.count_atoms('rep spheres'))
def testSetKey(self): if testing.PYMOL_VERSION[1] > 1.84: cmd.set('auto_show_classified', 0) cmd.fragment('gly') N = cmd.count_atoms() self.assertEqual(0, cmd.count_atoms('rep sticks | rep spheres')) cmd.set_key('F3', cmd.show, ('sticks',)) cmd._special(3, 0, 0) self.assertEqual(N, cmd.count_atoms('rep sticks')) cmd.do('set_key F3, hide sticks; show spheres') cmd._special(3, 0, 0) self.assertEqual(0, cmd.count_atoms('rep sticks')) self.assertEqual(N, cmd.count_atoms('rep spheres'))
def series_resfile(color="orange"): # Main PDB File Name object = cmd.get_names()[0] counter = 0 # Read Rosetta Resfile for fname in glob.glob('*.resfile'): counter += 1 if counter == 1: fname_rem = fname cmd.copy(fname, object) for line in open(fname): # Split Resfile Line by Tab data = line.split('\t') # Only Consider Lines that Start with Residue Numbers if data[0].isdigit(): # Get Revalent Data pos = data[0] chain = data[1] mut = data[3] # Generate Mutation Label label = mut label_list = list(label) label_list.insert(1, "%s" % (pos)) label = ''.join(label_list) # PyMOL Color and Label cmd.color(color, "resi %s and chain %s and %s" % (pos, chain, fname)) cmd.label( "resi %s and chain %s and name ca and %s" % (pos, chain, fname), "\'%s\'" % (label)) # Output Comments to the Console elif line[:1] == "#": # Remove newline feeds line.rstrip("\n") print "\n%s" % (line) cmd.disable('all') cmd.enable(fname_rem) cmd.orient cmd.set_key('pgup', move_up) cmd.set_key('pgdn', move_down)
def __init__(self,_self=cmd): # initialize parent class Wizard.__init__(self,_self) self.update_object_menu() # restore previous state from global storage self.dict = static_dict self.object = default_object if default_object in self.avail_objects else None self.browse = default_browse self.state_dict = {} # if we don't have a current object, choose the first multi-state object if not self.object and self.avail_objects: self.object = self.avail_objects[0] # menu for self.menu['browse'] = [ [2, 'Browse Mode',''], [1, 'Browse All','cmd.get_wizard().set_browse(1)'], [1, 'Browse Accepted','cmd.get_wizard().set_browse(2)'], [1, 'Browse Rejected','cmd.get_wizard().set_browse(3)'], [1, 'Browse Deferred','cmd.get_wizard().set_browse(4)'], [1, 'Browse Remaining','cmd.get_wizard().set_browse(5)'], ] self.menu['create'] = [ [2, 'Create Filtered Object', ''], [1, 'Accepted','cmd.get_wizard().create_object("Accept")'], [1, 'Rejected','cmd.get_wizard().create_object("Reject")'], [1, 'Deferred','cmd.get_wizard().create_object("Defer")'], ] self.count_object() self.load_state_dict() self.update_object_menu() cmd.set_key('F1',lambda s=self:s.accept()) cmd.set_key('F2',lambda s=self:s.reject()) cmd.set_key('F3',lambda s=self:s.defer()) cmd.set_key('right',lambda s=self:s.forward()) cmd.set_key('left',lambda s=self:s.backward())
def y(): print "translate or rotate about the y axis" print "F1 = translate positive" print "F2 = translate negative" print "F3 = rotate positive" print "F4 = rotate negative" cmd.set_key('F1', cmd.translate, ("[0,1,0]", "protein")) cmd.set_key('F2', cmd.translate, ("[0,-1,0]", "protein")) cmd.set_key('F3', cmd.rotate, ('y', 1, "protein")) cmd.set_key('F4', cmd.rotate, ('y', -1, "protein"))
def z(): print "translate or rotate about the z axis" print "F1 = translate positive" print "F2 = translate negative" print "F3 = rotate positive" print "F4 = rotate negative" cmd.set_key('F1', cmd.translate, ("[0,0,1]", "protein")) cmd.set_key('F2', cmd.translate, ("[0,0,-1]", "protein")) cmd.set_key('F3', cmd.rotate, ('z', 1, "protein")) cmd.set_key('F4', cmd.rotate, ('z', -1, "protein")) cmd.clip("atoms", 5, "all") cmd.set("depth_cue", 0)
def __init__(self, _self=cmd): # initialize parent class Wizard.__init__(self, _self) # restore previous state from global storage self.dict = static_dict self.object = default_object self.browse = default_browse self.avail_objects = [] self.state_dict = {} # if we don't have a current object, choose the first multi-state object if self.object == None: for a in cmd.get_names("objects"): if cmd.get_type(a) == "object:molecule": if cmd.count_states(a) > 1: self.object = a break # menu for self.menu["browse"] = [ [2, "Browse Mode", ""], [1, "Browse All", "cmd.get_wizard().set_browse(1)"], [1, "Browse Accepted", "cmd.get_wizard().set_browse(2)"], [1, "Browse Rejected", "cmd.get_wizard().set_browse(3)"], [1, "Browse Deferred", "cmd.get_wizard().set_browse(4)"], [1, "Browse Remaining", "cmd.get_wizard().set_browse(5)"], ] self.count_object() self.load_state_dict() self.update_object_menu() cmd.set_key("F1", lambda s=self: s.accept()) cmd.set_key("F2", lambda s=self: s.reject()) cmd.set_key("F3", lambda s=self: s.defer()) cmd.set_key("right", lambda s=self: s.forward()) cmd.set_key("left", lambda s=self: s.backward())
def __init__(self, _self=cmd): # initialize parent class Wizard.__init__(self, _self) # restore previous state from global storage self.dict = static_dict self.object = default_object self.browse = default_browse self.avail_objects = [] self.state_dict = {} # if we don't have a current object, choose the first multi-state object if self.object == None: for a in cmd.get_names('objects'): if cmd.get_type(a) == 'object:molecule': if cmd.count_states(a) > 1: self.object = a break # menu for self.menu['browse'] = [ [2, 'Browse Mode', ''], [1, 'Browse All', 'cmd.get_wizard().set_browse(1)'], [1, 'Browse Accepted', 'cmd.get_wizard().set_browse(2)'], [1, 'Browse Rejected', 'cmd.get_wizard().set_browse(3)'], [1, 'Browse Deferred', 'cmd.get_wizard().set_browse(4)'], [1, 'Browse Remaining', 'cmd.get_wizard().set_browse(5)'], ] self.count_object() self.load_state_dict() self.update_object_menu() cmd.set_key('F1', lambda s=self: s.accept()) cmd.set_key('F2', lambda s=self: s.reject()) cmd.set_key('F3', lambda s=self: s.defer()) cmd.set_key('right', lambda s=self: s.forward()) cmd.set_key('left', lambda s=self: s.backward())
def __init__(self, map_name, level, radius, name, sym_source): self.level = level self.radius = radius self.map_name = map_name self.name = name self.center_name = cmd.get_unused_name('_center') self.callback_name = cmd.get_unused_name('_cb') cmd.set("auto_zoom", 0) cmd.pseudoatom(self.center_name) cmd.hide("everything", self.center_name) symmetry = cmd.get_symmetry(sym_source or map_name) if symmetry: cmd.set("map_auto_expand_sym", 1) cmd.set_symmetry(self.center_name, *symmetry) cmd.set_key("pgup", self.contour_plus) cmd.set_key("pgdn", self.contour_minus) self.update()
all_objs = cmd.get_names("objects",enabled_only=0) for obj in enabled_objs: cmd.disable(obj) last_obj=obj for i in range(0,len(all_objs)): if all_objs[i] == obj: if i+1 >= len(all_objs): cmd.enable( all_objs[0] ) else: cmd.enable( all_objs[i+1] ) cmd.orient def move_up(): enabled_objs = cmd.get_names("objects",enabled_only=1) all_objs = cmd.get_names("objects",enabled_only=0) for obj in enabled_objs: cmd.disable(obj) last_obj=obj for i in range(0,len(all_objs)): if all_objs[i] == obj: if i-1 < 0: cmd.enable( all_objs[-1] ) else: cmd.enable( all_objs[i-1] ) cmd.orient cmd.set_key('pgup', move_up) cmd.set_key('pgdn', move_down) #cmd.set_key('up', move_up) #cmd.set_key('down', move_down) #cmd.set_key('left', move_up) #cmd.set_key('right', move_down)
# from glob import glob import threading import time from pymol import cmd import sys, os, os.path import pymol ent_dir = "pdb" pymol.run = 1 cmd.set_key('F1', lambda p=pymol: (setattr(p, 'run', 0))) cmd.set_key('F2', lambda p=pymol: (setattr(p, 'run', 1))) def load(): r = 0 rep = [ "simple", "technical", "ligands", "ligand_sites", "ligand_sites_trans", "ligand_sites_mesh", "pretty", "publication" ] list = glob("pdb/*/*") # while list[0]!="pdb/f8/pdb1f8u": # list.pop(0) for file in list: print file cmd.delete('pdb')
# -c from pymol import cmd print "BEGIN-LOG" print cmd.set_key('F1',lambda :cmd.turn('x',10)) print cmd.set_key('F12',lambda :cmd.turn('x',10)) print cmd.set_key('left',lambda :cmd.turn('x',10)) print cmd.set_key('right',lambda :cmd.turn('x',10)) print cmd.set_key('pgup',lambda :cmd.turn('x',10)) print cmd.set_key('pgdn',lambda :cmd.turn('x',10)) print cmd.set_key('home',lambda :cmd.turn('x',10)) print cmd.set_key('insert',lambda :cmd.turn('x',10)) print cmd.set_key('ALT-A',lambda :cmd.turn('y',10)) print cmd.set_key('CTRL-C',lambda :cmd.turn('z',10)) print cmd.set_key('SHFT-F1', lambda :cmd.turn('z',10)) print cmd.set_key('ALT-F1', lambda :cmd.turn('y',10)) print cmd.set_key('CTRL-F8', lambda :cmd.move('x',1)) print "END-LOG"
def spawnPDBDirCycler(target_dir='.',lite=False): if lite: viewing.cycler = PDBDirCyclerLite(target_dir) else: viewing.cycler = PDBDirCycler(target_dir) cmd.set_key('left',prev_pdb) cmd.set_key('right',next_pdb)
button_list.remove(butt) button_list.remove(butt) cmd.util.cbag ('all') elif butt != button_list[0]: button_list.remove(button_list[0]) cmd.util.cbag ('all') curSel = col2 else: cmd.util.cbag ('all') curSel = col2 # colouring selection with specified colour scheme cmd.set_color('siff', curSel ) cmd.color('siff', InteractionButton[InteractionName.index(butt)]+'_'+butt ) butt=[] cmd.extend('read_siftp', read_siftp) cmd.set_key( 'F1' , add_color, (any_i, 'any_i' ) ) cmd.set_key( 'F2' , add_color, (backb, 'backb' ) ) cmd.set_key( 'F3' , add_color, (sidec, 'sidec' ) ) cmd.set_key( 'F4' , add_color, (polar, 'polar' ) ) cmd.set_key( 'F5' , add_color, (hphob, 'hphob' ) ) cmd.set_key( 'F6' , add_color, (hbacc, 'hbacc' ) ) cmd.set_key( 'F7' , add_color, (hbdon, 'hbdon' ) ) cmd.set_key( 'F8' , add_color, (aroma, 'aroma' ) ) cmd.set_key( 'F9' , add_color, (charg, 'charg' ) )
def spawnObjectCycler(): viewing.cycler = ObjectCycler() cmd.set_key('left', prev_pdb) cmd.set_key('right', next_pdb)
def __init__(self): #MAIN self.menuBar.addcascademenu('Plugin','SuperSym') #DEFAULT SET BUILD self.menuBar.addmenuitem('SuperSym', 'command', 'Default Symmetry Partner Set', label = 'Default Symmetry Partner Set', command = lambda s = self: symDialog(s, 0)) #UNIT CELL BUILD self.menuBar.addmenuitem('SuperSym', 'command', 'Draw Unit Cell', label = 'Draw Unit Cell', command = lambda s = self: cellDialog(s)) #SYM SUBMENU self.menuBar.addcascademenu('SuperSym', 'Build Symmetry Partners') self.menuBar.addmenuitem('Build Symmetry Partners', 'command', 'Cell [0,0,0] (default)', label = 'Cell [0,0,0] (default)', command = lambda s = self: symDialog(s, 0)) self.menuBar.addmenuitem('Build Symmetry Partners', 'command', 'Cell [x,y,z] (custom)', label = 'Cell [x,y,z] (custom)', command = lambda s = self: symDialog(s, 1)) self.menuBar.addmenuitem('Build Symmetry Partners', 'command', '2x2x2 Block', label = '2x2x2 Block', command = lambda s = self: symDialog(s, 2)) self.menuBar.addmenuitem('Build Symmetry Partners', 'command', '3x3x3 Block', label = '3x3x3 Block', command = lambda s = self: symDialog(s, 3)) self.menuBar.addmenuitem('Build Symmetry Partners', 'command', 'By Partner', label = 'By Partner', command = lambda s = self: symDialog(s, 4)) #COLOR SUBMENU self.menuBar.addcascademenu('SuperSym', 'Coloring') self.menuBar.addmenuitem('Coloring', 'command', 'Default Rainbow', label = 'Default Rainbow', command = lambda s = self: colorDialog(s, 0)) self.menuBar.addmenuitem('Coloring', 'command', 'Select color for each operation', label = 'Select color for each operation', command = lambda s = self: colorDialog(s, 1)) self.menuBar.addmenuitem('Coloring', 'command', 'Select one color for custom set of operations', label = 'Select one color for custom set of operations', command = lambda s = self: colorDialog(s, 2)) #GRAPHICS SUBMENU self.menuBar.addcascademenu('SuperSym', 'Graphics') self.menuBar.addmenuitem('Graphics', 'command', 'Lines', label = 'Lines', command = lambda s = self: graphicsDialog(s, 0)) self.menuBar.addmenuitem('Graphics', 'command', 'Ribbon', label = 'Ribbon', command = lambda s = self: graphicsDialog(s, 1)) self.menuBar.addmenuitem('Graphics', 'command', 'Cartoon', label = 'Cartoon', command = lambda s = self: graphicsDialog(s, 2)) self.menuBar.addmenuitem('Graphics', 'command', 'Sphere Surface (best for printing)', label = 'Sphere Surface (best for printing)', command = lambda s = self: graphicsDialog(s, 3)) self.menuBar.addmenuitem('Graphics', 'command', 'Surface (high load render)', label = 'Surface (high load render)', command = lambda s = self: graphicsDialog(s, 4)) #SYM AXES SUBMENU self.menuBar.addcascademenu('SuperSym', 'Symmetry Axes') self.menuBar.addmenuitem('Symmetry Axes', 'command', 'Build Axes', label = 'Build Axes', command = lambda s = self: axesDialog(s)) #ADD OTHER SYMMETRY AXES OPTION HERE self.menuBar.addmenuitem('SuperSym', 'command', 'Move symmetry partners', label = 'Move symmetry partners', command = lambda s = self: cellShiftInfo(s)) self.menuBar.addmenuitem('SuperSym', 'command', 'About', label = 'About', command = lambda s = self: aboutInfo(s)) self.menuBar.addmenuitem('SuperSym', 'command', 'Help', label = 'Help', command = lambda s = self: helpInfo(s)) cmd.cell_shift = cell_shift cmd.get_operations = get_operations cmd.get_matrix = get_orthogonalization_matrix cmd.symset = symset cmd.cell_shift_helper = cell_shift_helper cmd.set_key("ALT-6", cell_shift_proxyX1) cmd.set_key("ALT-4", cell_shift_proxyX2) cmd.set_key("ALT-8", cell_shift_proxyY1) cmd.set_key("ALT-2", cell_shift_proxyY2) cmd.set_key("ALT-5", cell_shift_proxyZ1) cmd.set_key("ALT-1", cell_shift_proxyZ2)
def __init__(self): #MAIN self.menuBar.addcascademenu('Plugin', 'SuperSym') #DEFAULT SET BUILD self.menuBar.addmenuitem('SuperSym', 'command', 'Default Symmetry Partner Set', label='Default Symmetry Partner Set', command=lambda s=self: symDialog(s, 0)) #UNIT CELL BUILD self.menuBar.addmenuitem('SuperSym', 'command', 'Draw Unit Cell', label='Draw Unit Cell', command=lambda s=self: cellDialog(s)) #SYM SUBMENU self.menuBar.addcascademenu('SuperSym', 'Build Symmetry Partners') self.menuBar.addmenuitem('Build Symmetry Partners', 'command', 'Cell [0,0,0] (default)', label='Cell [0,0,0] (default)', command=lambda s=self: symDialog(s, 0)) self.menuBar.addmenuitem('Build Symmetry Partners', 'command', 'Cell [x,y,z] (custom)', label='Cell [x,y,z] (custom)', command=lambda s=self: symDialog(s, 1)) self.menuBar.addmenuitem('Build Symmetry Partners', 'command', '2x2x2 Block', label='2x2x2 Block', command=lambda s=self: symDialog(s, 2)) self.menuBar.addmenuitem('Build Symmetry Partners', 'command', '3x3x3 Block', label='3x3x3 Block', command=lambda s=self: symDialog(s, 3)) self.menuBar.addmenuitem('Build Symmetry Partners', 'command', 'By Partner', label='By Partner', command=lambda s=self: symDialog(s, 4)) #COLOR SUBMENU self.menuBar.addcascademenu('SuperSym', 'Coloring') self.menuBar.addmenuitem('Coloring', 'command', 'Default Rainbow', label='Default Rainbow', command=lambda s=self: colorDialog(s, 0)) self.menuBar.addmenuitem('Coloring', 'command', 'Select color for each operation', label='Select color for each operation', command=lambda s=self: colorDialog(s, 1)) self.menuBar.addmenuitem( 'Coloring', 'command', 'Select one color for custom set of operations', label='Select one color for custom set of operations', command=lambda s=self: colorDialog(s, 2)) #GRAPHICS SUBMENU self.menuBar.addcascademenu('SuperSym', 'Graphics') self.menuBar.addmenuitem('Graphics', 'command', 'Lines', label='Lines', command=lambda s=self: graphicsDialog(s, 0)) self.menuBar.addmenuitem('Graphics', 'command', 'Ribbon', label='Ribbon', command=lambda s=self: graphicsDialog(s, 1)) self.menuBar.addmenuitem('Graphics', 'command', 'Cartoon', label='Cartoon', command=lambda s=self: graphicsDialog(s, 2)) self.menuBar.addmenuitem('Graphics', 'command', 'Sphere Surface (best for printing)', label='Sphere Surface (best for printing)', command=lambda s=self: graphicsDialog(s, 3)) self.menuBar.addmenuitem('Graphics', 'command', 'Surface (high load render)', label='Surface (high load render)', command=lambda s=self: graphicsDialog(s, 4)) #SYM AXES SUBMENU self.menuBar.addcascademenu('SuperSym', 'Symmetry Axes') self.menuBar.addmenuitem('Symmetry Axes', 'command', 'Build Axes', label='Build Axes', command=lambda s=self: axesDialog(s)) #ADD OTHER SYMMETRY AXES OPTION HERE self.menuBar.addmenuitem('SuperSym', 'command', 'Move symmetry partners', label='Move symmetry partners', command=lambda s=self: cellShiftInfo(s)) self.menuBar.addmenuitem('SuperSym', 'command', 'About', label='About', command=lambda s=self: aboutInfo(s)) self.menuBar.addmenuitem('SuperSym', 'command', 'Help', label='Help', command=lambda s=self: helpInfo(s)) cmd.cell_shift = cell_shift cmd.get_operations = get_operations cmd.get_matrix = get_orthogonalization_matrix cmd.symset = symset cmd.cell_shift_helper = cell_shift_helper cmd.set_key("ALT-6", cell_shift_proxyX1) cmd.set_key("ALT-4", cell_shift_proxyX2) cmd.set_key("ALT-8", cell_shift_proxyY1) cmd.set_key("ALT-2", cell_shift_proxyY2) cmd.set_key("ALT-5", cell_shift_proxyZ1) cmd.set_key("ALT-1", cell_shift_proxyZ2)
def spawnPDBListFileCycler(list_file,lite=False): if lite: viewing.cycler = PDBListFileCyclerLite(list_file) else: viewing.cycler = PDBListFileCycler(list_file) cmd.set_key('left',prev_pdb) cmd.set_key('right',next_pdb)
def spawnObjectCycler(): viewing.cycler = ObjectCycler() cmd.set_key('left',prev_pdb) cmd.set_key('right',next_pdb)
def switch(): cmd.orient cmd.set_key('pgup', move_up) cmd.set_key('pgdn', move_down)
print('p - prepare seq for printing') print('rp - rna present, object names only click to get compact legend') print('rp17') print('get_pdb') print('rna_cartoon') print('rs') print('rcomp') print('color_obj') print('color_rbw') print('aa') print("""spli - color snRNAs of the spliceosome: green: U2, blue: U5, red:U6, orange:U2""") print('RNA_PDB_TOOLS env variable used: ' + RNA_PDB_TOOLS) #cmd.set_key('CTRL-S', cmd.save, ['/home/magnus/Desktop/tmp.pse']) cmd.set_key('CTRL-S', sav_tmp) cmd.set_key('CTRL-Z', load_tmp) # ostatni wrzucam tutaj #cmd.load, ['/home/magnus/Desktop/tmp.pse']) # main code # cmd.extend('rp17', rp17) cmd.extend('rp17csrv', rp17csrv) cmd.extend('rp', rp) cmd.extend('p', p) cmd.extend('pdb', pdb) cmd.extend('seq', seq) cmd.extend('rna_cartoon', rna_cartoon) cmd.extend('rs', rs) cmd.extend('ino', ino) cmd.extend('rcomp', rcomp)
def spawnPDBDirCycler(target_dir='.', lite=False): if lite: viewing.cycler = PDBDirCyclerLite(target_dir) else: viewing.cycler = PDBDirCycler(target_dir) cmd.set_key('left', prev_pdb) cmd.set_key('right', next_pdb)
def spawnPDBListFileCycler(list_file, lite=False): if lite: viewing.cycler = PDBListFileCyclerLite(list_file) else: viewing.cycler = PDBListFileCycler(list_file) cmd.set_key('left', prev_pdb) cmd.set_key('right', next_pdb)
# Copyright 2020 Carlos Eduardo Sequeiros Borja <*****@*****.**> from pymol import cmd cmd.set_key("CTRL-W", cmd.reinitialize) cmd.set_key("CTRL-D", cmd.quit)
all_objs = cmd.get_names("objects",enabled_only=0) for i in cmd.get_object_list(): cmd.hide("everything", i) cmd.show("cartoon", i) cmd.set("cartoon_flat_sheets", 0) #cmd.show("surface", i) cmd.show("lines", i) if i != 'peptide_on_target-keep': cmd.show("stick", "resname CYS and not name c+n+o") cmd.hide("everything", "symbol H") #cmd.set("surface_cavity_mode", 1) #cmd.set("surface_type",2) def hide_chain_b(): cmd.hide("everything","chain b") cmd.hide("everything","resn hoh") cmd.orient cmd.set_key('pgup', move_up) cmd.set_key('pgdn', move_down) # # PG add #cmd.set_key( 'F1' , make_it_blue, [ "object1" ] ) cmd.set_key('right',gv)#hide_chain_b) cmd.set_key('left',align_structure) #cmd.set_key('up', move_up) #cmd.set_key('down', gv) #cmd.set_key('left', move_up) #cmd.set_key('right', move_down)
pdb_list.append(line[:5]) # remove header #pdb_list = pdb_list[1:] print(len(pdb_list) - 1) #print(pdb_list[0]) def load_next(): global i i += 1 if (i < len(pdb_list)): print("i=%s\tentry=%s" % (str(i), pdb_list[i])) show_chain_in_PDB(pdb_list[i]) else: print("fin") cmd.set_key('right', load_next) def show_chain_in_PDB(entry): PDB = entry[:4] chain = entry[-1:] cmd.reinitialize('everything') cmd.do('@~/.pymolrc') cmd.set("bg_rgb", "white") cmd.run("%s/strands_%s.py" % (PyMOL_script_dir, PDB)) cmd.show("cartoon", "all") cmd.set("cartoon_transparency", .85, PDB) cmd.set("cartoon_transparency", 0.05, "%s_barrel" % PDB)
print(' findN') print(' savt - save_transformed <object>, <file>') print(' select br. all within 20 of (sele) #within with aa') #print(' spl - color snRNAs of the spliceosome:' # green: U2, blue: U5, red:U6, orange:U2""") print('\_ RNA_TOOLS_PATH env variable used: ' + RNA_TOOLS_PATH) try: from pymol import cmd except ImportError: print("PyMOL Python lib is missing") else: quickref() #cmd.set_key('CTRL-S', cmd.save, ['/home/magnus/Desktop/tmp.pse']) cmd.set_key('CTRL-S', sav_tmp) cmd.set_key('CTRL-Z', load_tmp) # ostatni wrzucam tutaj #cmd.load, ['/home/magnus/Desktop/tmp.pse']) # main code # cmd.extend('quickref', quickref) cmd.extend('qr', quickref) cmd.extend('rg2', g2) cmd.extend('x', g2) cmd.extend('rp', rp) cmd.extend('p', p) cmd.extend('pdb', pdb) cmd.extend('seq', seq) cmd.extend('rseq', seq) cmd.extend('rna_cartoon', rna_cartoon)
# -c from pymol import cmd print "BEGIN-LOG" print cmd.set_key('F1', lambda: cmd.turn('x', 10)) print cmd.set_key('F12', lambda: cmd.turn('x', 10)) print cmd.set_key('left', lambda: cmd.turn('x', 10)) print cmd.set_key('right', lambda: cmd.turn('x', 10)) print cmd.set_key('pgup', lambda: cmd.turn('x', 10)) print cmd.set_key('pgdn', lambda: cmd.turn('x', 10)) print cmd.set_key('home', lambda: cmd.turn('x', 10)) print cmd.set_key('insert', lambda: cmd.turn('x', 10)) print cmd.set_key('ALT-A', lambda: cmd.turn('y', 10)) print cmd.set_key('CTRL-C', lambda: cmd.turn('z', 10)) print cmd.set_key('SHFT-F1', lambda: cmd.turn('z', 10)) print cmd.set_key('ALT-F1', lambda: cmd.turn('y', 10)) print cmd.set_key('CTRL-F8', lambda: cmd.move('x', 1)) print "END-LOG"
import time import math from pymol import cmd import sys, os, os.path last1 = "" last2 = "" ent_dir = "pdb" def adjust(delay): global cycle_time cycle_time = delay cmd.set_key("F1", adjust, (0,)) cmd.set_key("F2", adjust, (1,)) cmd.set_key("F3", adjust, (2,)) cmd.set_key("F4", adjust, (3,)) cmd.set_key("F5", adjust, (7,)) cmd.set_key("F6", adjust, (10,)) cmd.set_key("F7", adjust, (15,)) cmd.set_key("F8", adjust, (30,)) cmd.set_key("F9", adjust, (60,)) cmd.set_key("F10", adjust, (120,)) cycle_time = 2.0 cmd.set("line_width", "2") cmd.set("cartoon_tube_radius", "0.2") cmd.set("cartoon_side_chain_helper")
def move_down(): enabled_objs = cmd.get_names("object",enabled_only=1) all_objs = cmd.get_names("object",enabled_only=0) for obj in enabled_objs: cmd.disable(obj) last_obj=obj for i in range(0,len(all_objs)): if all_objs[i] == obj: if i+1 >= len(all_objs): cmd.enable( all_objs[0] ) else: cmd.enable( all_objs[i+1] ) cmd.orient def move_up(): enabled_objs = cmd.get_names("object",enabled_only=1) all_objs = cmd.get_names("object",enabled_only=0) for obj in enabled_objs: cmd.disable(obj) last_obj=obj for i in range(0,len(all_objs)): if all_objs[i] == obj: if i-1 < 0: cmd.enable( all_objs[-1] ) else: cmd.enable( all_objs[i-1] ) cmd.orient cmd.set_key('left', move_up) cmd.set_key('right', move_down)
from pymol import cmd # Define aliases for mapping in [x,y,z] rotations and translations into a single Powermate # dial. Toggling between the three is possible if you then assign these to special keys. # Functions for x,y,z rotations and translations using Powermate dial # Program F1 and F2 for Rotate Right and Rotate Left # Program F3 and F4 for Click & Rotate Right and Click & Rotate Left # Program F5 for Click (to toggle between dialsets) # dialset = 2 def dialx(): \ global dialset \ dialset = 1 \ cmd.set_key ('F1', cmd.turn,('x',-2.0)) \ cmd.set_key ('F2', cmd.turn,('x',2.0)) \ cmd.set_key ('F3', cmd.move,('x',-0.5)) \ cmd.set_key ('F4', cmd.move,('x',0.5)) \ print "dialset ", dialset, " [ X ]\n" \ return dialset def dialy(): \ global dialset \ dialset = 2 \ cmd.set_key ('F1', cmd.turn,('y',-2.0)) \ cmd.set_key ('F2', cmd.turn,('y',2.0)) \ cmd.set_key ('F3', cmd.move,('y',-0.5)) \ cmd.set_key ('F4', cmd.move,('y',0.5)) \ print "dialset ", dialset, " [ Y ]\n" \ return dialset
import time import math from pymol import cmd import sys, os, os.path last1 = '' last2 = '' ent_dir = "pdb" def adjust(delay): global cycle_time cycle_time = delay cmd.set_key("F1", adjust, (0, )) cmd.set_key("F2", adjust, (1, )) cmd.set_key("F3", adjust, (2, )) cmd.set_key("F4", adjust, (3, )) cmd.set_key("F5", adjust, (7, )) cmd.set_key("F6", adjust, (10, )) cmd.set_key("F7", adjust, (15, )) cmd.set_key("F8", adjust, (30, )) cmd.set_key("F9", adjust, (60, )) cmd.set_key("F10", adjust, (120, )) cycle_time = 2.0 cmd.set("line_width", "2") cmd.set("cartoon_tube_radius", "0.2") cmd.set("cartoon_side_chain_helper")
cmd.extend('hot_spot_hide', hot_spot_hide) def interface_analyse_multi(dist=10): cmd.disable('all') all_objects = cmd.get_object_list() for obj in all_objects: print 'analysing', obj interface_analyser(obj, dist, animate=False) cmd.disable(obj) cmd.disable(obj + '_h.bonds') cmd.do('order *, yes') cmd.zoom(all_objects[0], animate=-1) cmd.orient(all_objects[0], animate=-1) cmd.enable(all_objects[0]) cmd.enable(all_objects[0] + '_h.bonds') cmd.extend('interface_analyse_multi', interface_analyse_multi) def test_function(): print 'git is working' pass cmd.extend('test_function', test_function) cmd.set_key('ALT-H', hot_spot_spheres) cmd.set_key('ALT-G', hot_spot_hide)
def inner_lddt(interface=False): # Save the camera save_view = cmd.get_view(output=1, quiet=1) pdbname = cmd.get_object_list()[0] file_path = os.path.join(my_lddt_path, pdbname + ".npz") if ( not os.path.exists(file_path) ): print("Could not find npz file: %s"%file_path) return dat = np.load(file_path) ### Stuff from Nao digitizations = [-20.0, -15.0, -10.0, -4.0, -2.0, -1.0, -0.5, 0.5, 1.0, 2.0, 4.0, 10.0, 15.0, 20.0] masses = [digitizations[0]]+[(digitizations[i]+digitizations[i+1])/2 for i in range(len(digitizations)-1)]+[digitizations[-1]] def get_lddt(estogram, mask, center=7, weights=[1,1,1,1]): # Remove diagonal from the mask. mask = np.multiply(mask, np.ones(mask.shape)-np.eye(mask.shape[0])) # Masking the estogram except for the last cahnnel masked = np.transpose(np.multiply(np.transpose(estogram, [2,0,1]), mask), [1,2,0]) p0 = np.sum(masked[:,:,center], axis=-1) p1 = np.sum(masked[:,:,center-1]+masked[:,:,center+1], axis=-1) p2 = np.sum(masked[:,:,center-2]+masked[:,:,center+2], axis=-1) p3 = np.sum(masked[:,:,center-3]+masked[:,:,center+3], axis=-1) p4 = np.sum(mask, axis=-1) p4[p4==0] = 1 # Only work on parts where interaction happen output = np.divide((weights[0]*p0 + weights[1]*(p0+p1) + weights[2]*(p0+p1+p2) + weights[3]*(p0+p1+p2+p3))/np.sum(weights), p4) return output ##### # if interface, mask out the binder and the target to get individual lddts if ( interface ): blen = len(cmd.get_coords('name CA and chain A', 1)) mask2 = np.zeros(dat['mask'].shape) mask2[:blen, blen:] = 1 mask2[blen:, :blen] = 1 my_lddt = get_lddt(dat['estogram'].transpose([1,2,0]), np.multiply(dat['mask'], mask2)) else: my_lddt = get_lddt(dat['estogram'].transpose([1,2,0]), dat['mask']) print("========== Mean LDDT: %.2f"%np.mean(my_lddt)) # colorspace for lddt visualization max_color = 121 min_color = 0 # interpolate on RGB so we don't see every color in between # set saturation to 0.5 so that we can distinguish from cylinders max_rgb = colorsys.hsv_to_rgb(max_color/360, 0.5, 1) min_rgb = colorsys.hsv_to_rgb(min_color/360, 0.5, 1) max_lddt = 1.0 min_lddt = 0.5 # color each residue the corresponding lddt color for seqpos in range(1, len(dat['mask'])): this_lddt = my_lddt[seqpos-1] r = np.interp(this_lddt, [min_lddt, max_lddt], [min_rgb[0], max_rgb[0]]) * 255 g = np.interp(this_lddt, [min_lddt, max_lddt], [min_rgb[1], max_rgb[1]]) * 255 b = np.interp(this_lddt, [min_lddt, max_lddt], [min_rgb[2], max_rgb[2]]) * 255 color = "0x%02x%02x%02x"%(int(r), int(g), int(b)) colorCPK("resi %i"%seqpos, color) # cmd.color(color, "resi %i"%seqpos,) # get 1 indexed ca positions cas = np.r_[ [[0, 0, 0]], cmd.get_coords('name CA', 1)] # max radius of cylinders (A) max_rad = 0.25 # standard cylinder drawing function. color in HSV def get_cyl(start, end, rad_frac=1.0, color=[360, 0, 1]): rgb = colorsys.hsv_to_rgb(color[0]/360, color[1], color[2]) radius = max_rad * rad_frac cyl = [ # Tail of cylinder cgo.CYLINDER, start[0], start[1], start[2] , end[0], end[1], end[2] , radius, rgb[0], rgb[1], rgb[2], rgb[0], rgb[1], rgb[2] # Radius and RGB for each cylinder tail ] return cyl def obj_exists(sele): return sele in cmd.get_names("objects") # clear out the old ones if we ran this twice for name in cmd.get_names("objects"): if (name.startswith("esto_res")): cmd.delete(name) estogram = np.transpose(dat['estogram'], [1, 2, 0]) # parameters for cylinder colors # Since the lddt calculation maxes out at 4, we do so too # Also, fade near-0 to white so that we don't see sharp edges close_range_colors = [58, 0] far_range_colors = [167, 296] max_range = 4 white_fade = 0.2 # interpolate in hue space so that we do see all colors in-between def dist_to_color(dist): dist = np.clip(dist, -max_range, max_range) # dist = 2 if ( dist < 0 ): bounds = close_range_colors dist = - dist else: bounds = far_range_colors hue = np.interp(dist, [0, max_range], bounds) sat = np.interp(dist, [0, white_fade], [0, 1]) return [hue, sat, 1] # Mask is how likely the model things two residues are within 15A of each other # Don't draw cylinders for super distant residues min_mask = 0.1 # actually draw the cylinders for seqpos in range(1, len(cas)): # pull out the estogram and mask for this position esto = estogram[seqpos-1] # shape (N x 15) mask = dat['mask'][seqpos-1] # shape (N) this_cgo = [] for other in range(1, len(cas)): mask_edge = mask[other-1] if ( mask_edge < min_mask ): continue # estogram is a histogram of distances # this method comes directly from nao and takes the "center_of_mass" of that histogram esto_dist = np.sum(esto[other-1]*masses) color = dist_to_color(esto_dist) this_cgo += get_cyl(cas[seqpos], cas[other], rad_frac=mask_edge, color=color) if ( len(this_cgo) > 0): name = "esto_res%i"%seqpos cmd.load_cgo(this_cgo, name) cmd.disable(name) # disables all estograms and then enables the ones you've selected def enable_selected(): selected = list(set([int(x.resi) for x in cmd.get_model("sele").atom])) for name in cmd.get_names("objects"): if (name.startswith("esto_res")): cmd.disable(name) for seqpos in selected: name = "esto_res%i"%seqpos cmd.enable(name) cmd.delete("sele") cmd.set_key( 'CTRL-C' , enable_selected ) # restore the camera cmd.set_view(save_view)
from glob import glob import threading import time from pymol import cmd import sys, os, os.path import pymol ent_dir = "pdb" pymol.run = 1 cmd.set_key('F1',lambda p=pymol:(setattr(p,'run',0))) cmd.set_key('F2',lambda p=pymol:(setattr(p,'run',1))) def load(): r = 0 rep = [ "simple", "technical", "ligands", "ligand_sites","ligand_sites_trans","ligand_sites_mesh","pretty", "publication" ] list = glob("pdb/*/*") # while list[0]!="pdb/f8/pdb1f8u": # list.pop(0) for file in list: print file cmd.delete('pdb') cmd.load(file,'pdb') cmd.orient('pdb') cur_rep = rep.pop(0) rep = rep + [cur_rep]
button_list.remove(button_list[0]) cmd.util.cbag ('all') curSel = col2 else: cmd.util.cbag ('all') curSel = col2 # colouring selection with specified colour scheme cmd.set_color('siff', curSel ) #cmd.color('siff', InteractionButton[InteractionName.index(butt)]+'_' + t_ + '_'+butt ) cmd.color('siff', butt ) butt=[] cmd.extend('read_siftp', read_siftp) cmd.set_key( 'F1' , add_color, (any_i_exists, 'any_i_exists' ) ) cmd.set_key( 'F2' , add_color, (backb_exists, 'backb_exists' ) ) cmd.set_key( 'F3' , add_color, (sidec_exists, 'sidec_exists' ) ) cmd.set_key( 'F4' , add_color, (polar_exists, 'polar_exists' ) ) cmd.set_key( 'F5' , add_color, (hphob_exists, 'hphob_exists' ) ) cmd.set_key( 'F6' , add_color, (hbacc_exists, 'hbacc_exists' ) ) cmd.set_key( 'F7' , add_color, (hbdon_exists, 'hbdon_exists' ) ) cmd.set_key( 'F8' , add_color, (aroma_exists, 'aroma_exists' ) ) cmd.set_key( 'F9' , add_color, (charg_exists, 'charg_exists' ) ) cmd.set_key( 'F10' , add_color, (charg_exists, 'env_polar_exists' ) ) cmd.set_key( 'F11' , add_color, (charg_exists, 'env_hydrophobic_exists' ) ) cmd.set_key( 'F12' , add_color, (charg_exists, 'env_aromatic_exists' ) ) cmd.set_key( 'left' , add_color, (charg_exists, 'env_charged_exists' ) ) cmd.set_key( 'F1' , add_color, (any_i_strong, 'any_i_strong' ) ) cmd.set_key( 'F2' , add_color, (backb_strong, 'backb_strong' ) )