def pretty_solv(selection="(all)", _self=cmd): cmd = _self s = tmp_sele cmd.select(s, selection) polar_contacts = _get_polar_contacts_name(s, _self) _prepare(s, polar_contacts, _self=cmd) cmd.dss(s, preserve=1) cmd.cartoon("auto", s) cmd.show("cartoon", s) cmd.show("sticks", "(" + lig_sele + " and (" + s + "))") cmd.show("nb_spheres", "((" + lig_sele + "|resn hoh+wat+h2o) and (" + s + "))") util.cbc("(" + lig_sele + " and (" + s + "))", _self=cmd) util.cbac("(" + lig_sele + " and (" + s + ") and not elem c)", _self=cmd) cmd.spectrum("count", selection="(elem c and (" + s + ") and not " + lig_sele + ")") cmd.set("cartoon_highlight_color", -1, selection) cmd.set("cartoon_fancy_helices", 0, selection) cmd.set("cartoon_smooth_loops", 0, selection) cmd.set("cartoon_flat_sheets", 1, selection) cmd.set("cartoon_side_chain_helper", 0, selection) if polar_contacts in cmd.get_names(): cmd.disable(polar_contacts) if cmd.count_atoms(s): cmd.zoom(s)
def ligand_sites_hq(selection="(all)", _self=cmd): cmd = _self ligand_sites(selection, _self) s = tmp_sele cmd.select(s, selection) cmd.set("surface_quality", "1", selection) cmd.set("surface_type", 0, selection)
def ligand_sites_hq(selection="(all)",_self=cmd): cmd=_self ligand_sites(selection,_self) s = tmp_sele cmd.select(s,selection) cmd.set("surface_quality","1",selection) cmd.set("surface_type",0,selection)
def _prepare(selection, polar_contacts=None, _self=cmd): cmd = _self # this function should undo everything that is done by any preset function in this module # (except for coloring) s = tmp_sele cmd.select(s, selection) cmd.cartoon("auto", s) cmd.hide("everything", s) cmd.set("two_sided_lighting", 0) # global cmd.unset("transparency", s) cmd.unset("dot_normals", s) cmd.unset("mesh_normals", s) cmd.unset("surface_quality", s) cmd.unset("surface_type", selection) cmd.unset("sphere_scale", selection) cmd.unset_bond("stick_radius", s, s) cmd.unset_bond("stick_color", s, s) cmd.unset("cartoon_highlight_color", selection) cmd.unset("cartoon_fancy_helices", selection) cmd.unset("cartoon_smooth_loops", selection) cmd.unset("cartoon_flat_sheets", selection) cmd.unset("cartoon_side_chain_helper", selection) cmd.unset("mesh_normals", s) cmd.unset("dot_normals", s) if polar_contacts == None: polar_contacts = _get_polar_contacts_name(s, _self) if polar_contacts in cmd.get_names('objects'): cmd.delete(polar_contacts)
def _prepare(selection,polar_contacts=None,_self=cmd): cmd=_self # this function should undo everything that is done by any preset function in this module # (except for coloring) s = tmp_sele cmd.select(s,selection) cmd.cartoon("auto",s) cmd.hide("everything",s) cmd.set("two_sided_lighting",0) # global cmd.unset("transparency",s) cmd.unset("dot_normals",s) cmd.unset("mesh_normals",s) cmd.unset("surface_quality",s) cmd.unset("surface_type",selection) cmd.unset("sphere_scale",selection) cmd.unset_bond("stick_radius",s,s) cmd.unset_bond("stick_color",s,s) cmd.unset("cartoon_highlight_color",selection) cmd.unset("cartoon_fancy_helices",selection) cmd.unset("cartoon_smooth_loops",selection) cmd.unset("cartoon_flat_sheets",selection) cmd.unset("cartoon_side_chain_helper",selection) cmd.unset("mesh_normals",s) cmd.unset("dot_normals",s) if polar_contacts == None: polar_contacts = _get_polar_contacts_name(s,_self) if polar_contacts in cmd.get_names('objects'): cmd.delete(polar_contacts)
def ligand_cartoon(selection="(all)", _self=cmd): cmd = _self ligand_sites(selection, _self) s = tmp_sele cmd.select(s, selection) cmd.set("cartoon_side_chain_helper", 1, selection) cmd.show("cartoon", "rep ribbon") cmd.hide("ribbon") cmd.hide("surface")
def ligand_cartoon(selection="(all)",_self=cmd): cmd=_self ligand_sites(selection,_self) s = tmp_sele cmd.select(s,selection) cmd.set("cartoon_side_chain_helper",1,selection) cmd.show("cartoon","rep ribbon") cmd.hide("ribbon") cmd.hide("surface")
def b_factor_putty(selection="(name ca or name p)",_self=cmd): cmd=_self s = tmp_sele cmd.select(s,selection) _prepare(s,_self=cmd) cmd.select(s,"(name ca or name p) and ("+selection+")") cmd.show("cartoon",s) cmd.set("cartoon_flat_sheets",0,selection) cmd.cartoon("putty",s) cmd.spectrum("b",selection=s)
def b_factor_putty(selection="(name ca or name p)", _self=cmd): cmd = _self s = tmp_sele cmd.select(s, selection) _prepare(s, _self=cmd) cmd.select(s, "(name ca or name p) and (" + selection + ")") cmd.show("cartoon", s) cmd.set("cartoon_flat_sheets", 0, selection) cmd.cartoon("putty", s) cmd.spectrum("b", selection=s)
def pub_solv(selection="(all)", _self=cmd): cmd = _self pretty_solv(selection, _self) s = tmp_sele cmd.select(s, selection) cmd.set("cartoon_smooth_loops", 1, selection) cmd.set("cartoon_highlight_color", "grey50", selection) cmd.set("cartoon_fancy_helices", 1, selection) cmd.set("cartoon_flat_sheets", 1, selection) cmd.set("cartoon_side_chain_helper", 0, selection) if cmd.count_atoms(s): cmd.zoom(s)
def pub_solv(selection="(all)",_self=cmd): cmd=_self pretty_solv(selection,_self) s = tmp_sele cmd.select(s,selection) cmd.set("cartoon_smooth_loops",1,selection) cmd.set("cartoon_highlight_color","grey50",selection) cmd.set("cartoon_fancy_helices",1,selection) cmd.set("cartoon_flat_sheets",1,selection) cmd.set("cartoon_side_chain_helper",0,selection) if cmd.count_atoms(s): cmd.zoom(s)
def colors(scheme="",_self=cmd): pymol=_self._pymol cmd=_self if scheme=="jmol": cmd.set("auto_color",0) cmd.set_color("hydrogen",[1.000,1.000,1.000]) cmd.set_color("carbon",[0.567,0.567,0.567]) cmd.set_color("nitrogen",[0.189,0.315,0.976]) cmd.set_color("oxygen",[1.000,0.051,0.051]) cmd.set_color("fluorine",[0.567,0.882,0.314]) cmd.set_color("sulfur",[1.000,1.000,0.189]) cmd.color("carbon","elem c") cmd.recolor()
def x(st): print st cmd.set("raise_exceptions",0) valu = eval(st) print valu if cmd.is_error(valu): cmd.set("raise_exceptions",1) try: print eval(st) except pymol.CmdException: print "CmdException raised." except cmd.QuietException: print "QuietException raised."
def protein_vacuum_esp(selection, mode=2, border=10.0, quiet = 1, _self=cmd): pymol=_self._pymol cmd=_self if ((string.split(selection)!=[selection]) or selection not in cmd.get_names('objects')): print " Error: must provide an object name" raise cmd.QuietException obj_name = selection + "_e_chg" map_name = selection + "_e_map" pot_name = selection + "_e_pot" cmd.disable(selection) cmd.delete(obj_name) cmd.delete(map_name) cmd.delete(pot_name) cmd.create(obj_name,"((polymer and ("+selection+ ") and (not resn A+C+T+G+U)) or ((bymol (polymer and ("+ selection+"))) and resn NME+NHE+ACE)) and (not hydro)") # try to just get protein... protein_assign_charges_and_radii(obj_name,_self=_self) ext = cmd.get_extent(obj_name) max_length = max(abs(ext[0][0] - ext[1][0]),abs(ext[0][1] - ext[1][1]),abs(ext[0][2]-ext[1][2])) + 2*border # compute an grid with a maximum dimension of 50, with 10 A borders around molecule, and a 1.0 A minimum grid sep = max_length/50.0 if sep<1.0: sep = 1.0 print " Util: Calculating electrostatic potential..." if mode==0: # absolute, no cutoff cmd.map_new(map_name,"coulomb",sep,obj_name,border) elif mode==1: # neutral, no cutoff cmd.map_new(map_name,"coulomb_neutral",sep,obj_name,border) else: # local, with cutoff cmd.map_new(map_name,"coulomb_local",sep,obj_name,border) cmd.ramp_new(pot_name, map_name, selection=obj_name,zero=1) cmd.hide("everything",obj_name) cmd.show("surface",obj_name) cmd.set("surface_color",pot_name,obj_name) cmd.set("surface_ramp_above_mode",1,obj_name)
def technical(selection="(all)",_self=cmd): cmd=_self s = tmp_sele cmd.select(s,selection) polar_contacts = _get_polar_contacts_name(s,_self) _prepare(s,polar_contacts,_self=cmd) util.chainbow(s,_self=cmd) util.cbc("("+lig_sele+" and ("+s+"))",_self=cmd) util.cbac("(("+s+") and not elem c)",_self=cmd) cmd.show("nonbonded",s) cmd.show("lines","((("+s+") and not "+lig_sele+") extend 1)") cmd.show("sticks","("+lig_sele+" and ("+s+"))") cmd.show("ribbon",s) cmd.dist(polar_contacts,s,s,mode=2,label=0,reset=1) # hbonds if polar_contacts in cmd.get_names(): cmd.enable(polar_contacts) cmd.set("dash_width",1.5,polar_contacts) cmd.hide("labels",polar_contacts) cmd.show("dashes",polar_contacts) cmd.show("nonbonded","(("+lig_sele+"|resn hoh+wat+h2o) and ("+s+"))")
def technical(selection="(all)", _self=cmd): cmd = _self s = tmp_sele cmd.select(s, selection) polar_contacts = _get_polar_contacts_name(s, _self) _prepare(s, polar_contacts, _self=cmd) util.chainbow(s, _self=cmd) util.cbc("(" + lig_sele + " and (" + s + "))", _self=cmd) util.cbac("((" + s + ") and not elem c)", _self=cmd) cmd.show("nonbonded", s) cmd.show("lines", "(((" + s + ") and not " + lig_sele + ") extend 1)") cmd.show("sticks", "(" + lig_sele + " and (" + s + "))") cmd.show("ribbon", s) cmd.dist(polar_contacts, s, s, mode=2, label=0, reset=1) # hbonds if polar_contacts in cmd.get_names(): cmd.enable(polar_contacts) cmd.set("dash_width", 1.5, polar_contacts) cmd.hide("labels", polar_contacts) cmd.show("dashes", polar_contacts) cmd.show("nonbonded", "((" + lig_sele + "|resn hoh+wat+h2o) and (" + s + "))")
def pretty_solv(selection="(all)",_self=cmd): cmd=_self s = tmp_sele cmd.select(s,selection) polar_contacts = _get_polar_contacts_name(s,_self) _prepare(s,polar_contacts,_self=cmd) cmd.dss(s,preserve=1) cmd.cartoon("auto",s) cmd.show("cartoon",s) cmd.show("sticks","("+lig_sele+" and ("+s+"))") cmd.show("nb_spheres","(("+lig_sele+"|resn hoh+wat+h2o) and ("+s+"))") util.cbc("("+lig_sele+" and ("+s+"))",_self=cmd) util.cbac("("+lig_sele+" and ("+s+") and not elem c)",_self=cmd) cmd.spectrum("count",selection="(elem c and ("+s+") and not "+lig_sele+")") cmd.set("cartoon_highlight_color",-1,selection) cmd.set("cartoon_fancy_helices",0,selection) cmd.set("cartoon_smooth_loops",0,selection) cmd.set("cartoon_flat_sheets",1,selection) cmd.set("cartoon_side_chain_helper",0,selection) if polar_contacts in cmd.get_names(): cmd.disable(polar_contacts) if cmd.count_atoms(s): cmd.zoom(s)
def ligand_sites_dots(selection="(all)",_self=cmd): cmd=_self ligand_sites(selection,_self) s = tmp_sele cmd.select(s,selection) cmd.show("sticks",s+" and rep lines") cmd.hide("lines",s+" and rep lines") cmd.set("surface_type","1",selection) cmd.set("surface_quality","1",selection) cmd.set("dot_normals",0,s)
def ligand_sites_dots(selection="(all)", _self=cmd): cmd = _self ligand_sites(selection, _self) s = tmp_sele cmd.select(s, selection) cmd.show("sticks", s + " and rep lines") cmd.hide("lines", s + " and rep lines") cmd.set("surface_type", "1", selection) cmd.set("surface_quality", "1", selection) cmd.set("dot_normals", 0, s)
def ligand_sites_trans_hq(selection="(all)",_self=cmd): cmd=_self ligand_sites(selection,_self) s = tmp_sele cmd.select(s,selection) cmd.show("sticks",s+" and rep lines") cmd.hide("lines",s+" and rep lines") cmd.set("transparency","0.33",s) cmd.set("surface_type",0,selection) cmd.set("surface_quality",1,selection)
def ligand_sites_trans_hq(selection="(all)", _self=cmd): cmd = _self ligand_sites(selection, _self) s = tmp_sele cmd.select(s, selection) cmd.show("sticks", s + " and rep lines") cmd.hide("lines", s + " and rep lines") cmd.set("transparency", "0.33", s) cmd.set("surface_type", 0, selection) cmd.set("surface_quality", 1, selection)
def ligand_sites_mesh(selection="(all)",_self=cmd): cmd=_self ligand_sites(selection,_self) s = tmp_sele cmd.select(s,selection) cmd.show("sticks",s+" and rep lines") cmd.hide("lines",s+" and rep lines") cmd.set("surface_type","2",selection) cmd.set("surface_quality","0",selection) cmd.set("mesh_normals",0,s) cmd.delete(s)
def ligand_sites(selection="(all)",_self=cmd): cmd=_self try: s = tmp_sele cmd.select(s,selection) polar_contacts = _get_polar_contacts_name(s,_self) _prepare(s,polar_contacts,_self=cmd) host = "_preset_host" solvent = "_preset_solvent" near_solvent = "_preset_solvent" lig = "_preset_lig" cmd.select(host,s+" and "+prot_and_dna_sele) cmd.select(solvent,s+" and "+solv_sele) cmd.select(lig,s+" and "+lig_sele) cmd.select(near_solvent,s+" and ("+solvent+" within 4 of "+lig+")") cmd.flag("ignore",host,"clear") cmd.flag("ignore",lig+"|"+solvent,"set") util.chainbow(host,_self=cmd) util.cbc(lig,_self=cmd) util.cbac("(("+s+") and not elem c)",_self=cmd) cmd.hide("everything",s) cmd.show("ribbon",host) cmd.show("lines","("+s+" and byres ("+host+" within 5 of "+lig+"))") cmd.show("surface","("+s+" and ((rep lines expand 4) within 6 of "+lig+"))") cmd.set("two_sided_lighting",1) # global setting cmd.set("transparency",0,s) cmd.set("surface_quality",0,s) cmd.show("sticks",lig) cmd.show("sticks",solvent+" and neighbor "+lig) cmd.show("lines","("+s+" and (rep lines extend 1) and "+lig+")") if cmd.count_atoms(lig): cmd.dist(polar_contacts,host+"|"+near_solvent,lig+"|"+near_solvent,mode=2,quiet=1,label=0,reset=1) # hbonds if polar_contacts in cmd.get_names(): cmd.enable(polar_contacts) cmd.hide("labels",polar_contacts) cmd.show("dashes",polar_contacts) else: cmd.delete(polar_contacts) cmd.show("nb_spheres",lig+"|"+host+"|"+near_solvent) if cmd.count_atoms(lig): cmd.zoom(lig,3) cmd.delete(host) cmd.delete(solvent) cmd.delete(near_solvent) cmd.delete(lig) except: traceback.print_exc() cmd.delete(s)
def ball_and_stick(selection="(all)",mode=1,_self=cmd): cmd=_self s = tmp_sele cmd.select(s,selection) _prepare(s,_self=cmd) if mode == 1: cmd.hide("everything",s) cmd.set_bond("stick_color","white",s,s) cmd.set_bond("stick_radius","0.14",s,s) cmd.set("sphere_scale","0.25",s) cmd.show("sticks",s) cmd.show("spheres",s) elif mode == 2: cmd.hide("everything",s) cmd.set_bond("stick_color","white",s,s) cmd.set_bond("stick_radius","-0.14",s,s) cmd.set("stick_ball","1") cmd.set("stick_ball_ratio",-1.0) cmd.set("stick_ball_color","atomic") cmd.show("sticks",s)
def ball_and_stick(selection="(all)", mode=1, _self=cmd): cmd = _self s = tmp_sele cmd.select(s, selection) _prepare(s, _self=cmd) if mode == 1: cmd.hide("everything", s) cmd.set_bond("stick_color", "white", s, s) cmd.set_bond("stick_radius", "0.14", s, s) cmd.set("sphere_scale", "0.25", s) cmd.show("sticks", s) cmd.show("spheres", s) elif mode == 2: cmd.hide("everything", s) cmd.set_bond("stick_color", "white", s, s) cmd.set_bond("stick_radius", "-0.14", s, s) cmd.set("stick_ball", "1") cmd.set("stick_ball_ratio", -1.0) cmd.set("stick_ball_color", "atomic") cmd.show("sticks", s)
def performance(mode,_self=cmd): pymol=_self._pymol cmd=_self mode = int(mode) if mode==0: # maximum quality cmd.set('line_smooth',1) cmd.set('depth_cue',1) cmd.set('specular',1) cmd.set('surface_quality',1) cmd.set('stick_quality',15) cmd.set('sphere_quality',2) cmd.set('cartoon_sampling',14) cmd.set('ribbon_sampling',10) cmd.set('transparency_mode',2) cmd.set('stick_ball',1) cmd.do("rebuild") elif mode==33: cmd.set('line_smooth',1) cmd.set('depth_cue',1) cmd.set('specular',1) cmd.set('surface_quality',0) cmd.set('stick_quality',8) cmd.set('sphere_quality',1) cmd.set('cartoon_sampling',7) cmd.set('ribbon_sampling',1) cmd.set('transparency_mode',2) cmd.set('stick_ball',0) cmd.do("rebuild") elif mode==66: # good perfomance cmd.set('line_smooth',0) cmd.set('depth_cue',0) cmd.set('specular',1) cmd.set('surface_quality',0) cmd.set('stick_quality',8) cmd.set('sphere_quality',1) cmd.set('cartoon_sampling',6) cmd.set('ribbon_sampling',1) cmd.set('transparency_mode',2) cmd.set('stick_ball',0.0) cmd.do("rebuild") else: # maximum performance cmd.set('line_smooth',0) cmd.set('depth_cue',0) cmd.set('specular',0) cmd.set('surface_quality',-1) # new cmd.set('stick_quality',5) cmd.set('sphere_quality',0) cmd.set('ribbon_sampling',1) cmd.set('cartoon_sampling',3) cmd.set('transparency_mode',0) cmd.set('stick_ball',0.0) cmd.do("rebuild")
def ray_shadows(mode,_self=cmd): pymol=_self._pymol cmd=_self # adjustment factors for new lighting model in 0.99 reflect_scale = 0.5 direct_scale = 1.8 gamma_scale = 1/1.3 ambient_scale = 1.16 if mode=='none': cmd.set('ray_shadows',0) else: cmd.set('ray_shadows',1) if mode=='light': cmd.set('light_count',2) cmd.set("light","[-0.4,-0.4,-1.0]") cmd.set('ambient',0.14) cmd.set('direct',0.65) cmd.set('reflect',0.25) cmd.set('shininess',40) cmd.set('power',1.0) cmd.set('specular_intensity',0.5) cmd.set('spec_direct',0) cmd.set('spec_count',-1) cmd.set('ray_shadow_decay_factor',0) elif mode=='matte': cmd.set('light_count',4) cmd.set("light","[-0.4,-0.4,-1.0]") cmd.set("light2","[-0.3,-0.4,-1.0]") cmd.set("light3","[-0.3,-0.3,-1.0]") cmd.set("light4","[-0.4,-0.3,-1.0]") cmd.set('ambient',0.14) cmd.set('direct',0.45) cmd.set('reflect',0.45) cmd.set('shininess',25) cmd.set('power',1.25) cmd.set('spec_count',-1) cmd.set('specular_intensity',0.2) cmd.set('spec_direct',0) cmd.set('ray_shadow_decay_factor',0) elif mode=='soft': cmd.set('light_count',10) cmd.set("light","[-0.4,-0.4,-1.0]") cmd.set("light2","[-0.3,-0.4,-1.0]") cmd.set("light3","[-0.3,-0.3,-1.0]") cmd.set("light4","[-0.4,-0.3,-1.0]") cmd.set("light5","[-0.4,-0.5,-1.0]") cmd.set("light6","[-0.5,-0.5,-1.0]") cmd.set("light7","[-0.5,-0.4,-1.0]") cmd.set("light8","[-0.5,-0.3,-1.0]") cmd.set("light9","[-0.3,-0.5,-1.0]") cmd.set('ambient',0.14) cmd.set('direct',0.40) cmd.set('reflect',0.50) cmd.set('specular_intensity',0.5) cmd.set('spec_count',1) cmd.set('shininess',55) cmd.set('power',1.0) cmd.set('spec_direct',0) cmd.set('ray_shadow_decay_factor',0.1) cmd.set('ray_shadow_decay_range',1.8) elif mode=='occlusion': cmd.set('light_count',9) cmd.set("light" ,"[-0.2,-0.2,-1.0]") cmd.set("light2","[-0.2, 0.0,-1.0]") cmd.set("light3","[-0.2, 0.2,-1.0]") cmd.set("light4","[ 0.0, 0.2,-1.0]") cmd.set("light5","[ 0.2, 0.2,-1.0]") cmd.set("light6","[ 0.2, 0.0,-1.0]") cmd.set("light7","[ 0.2,-0.2,-1.0]") cmd.set("light8","[ 0.0,-0.2,-1.0]") cmd.set('ambient',0.18) cmd.set('direct',0.10) cmd.set('reflect',0.80) cmd.set('shininess',10) cmd.set('spec_count',-1) cmd.set('power',1.0) cmd.set('specular_intensity',0) cmd.set('spec_direct',0.25) cmd.set('ray_shadow_decay_factor',0.1) cmd.set('ray_shadow_decay_range',5.0) elif mode=='medium': cmd.set('light_count',2) cmd.set("light","[-0.4,-0.4,-1.0]") cmd.set('ambient',0.14) cmd.set('direct',0.45) cmd.set('reflect',0.45) cmd.set('shininess',55) cmd.set('spec_count',-1) cmd.set('power',1.0) cmd.set('specular_intensity',0.5) cmd.set('spec_direct',0) cmd.set('ray_shadow_decay_factor',0) elif mode=='heavy': cmd.set('light_count',2) cmd.set("light","[-0.4,-0.4,-1.0]") cmd.set('ambient',0.05) cmd.set('direct',0.20) cmd.set('reflect',0.85) cmd.set('spec_count',-1) cmd.set('shininess',90) cmd.set('power',1.0) cmd.set('specular_intensity',0.5) cmd.set('spec_direct',0) cmd.set('ray_shadow_decay_factor',0) elif mode=='black': # best for light backgrounds cmd.set('light_count',2) cmd.set("light","[-0.4,-0.4,-1.0]") cmd.set('ambient',0.001) cmd.set('direct',0.0) cmd.set('reflect',1.1) cmd.set('spec_count',-1) cmd.set('power',1.0) cmd.set('shininess',90) cmd.set('specular_intensity',0.5) cmd.set('spec_direct',0) cmd.set('ray_shadow_decay_factor',0)
def setup_alignment_contexts(context_info): # Author: Warren DeLano (list,dict) = context_info[0:2] doc_list = ['\888Legend:'] obj_name_dict = {} for a in list: sf = string.find(a,"_") if sf>=0: object_name = a[0:sf] if not obj_name_dict.has_key(object_name): obj_name_dict[object_name] = 1 col_index = cmd.get_object_color_index(object_name) if col_index>=0: col_tup = cmd.get_color_tuple(col_index) if is_tuple(col_tup): col_int = map(lambda x:int(x*9+0.49999),col_tup) col_str = string.join(map(lambda x:chr(ord('0')+x),col_int),'') doc_list.append("\\"+col_str+object_name+"\\---") key_list = [ 'F1','F2','F3','F4','F5','F6','F7','F8','F9','F10', #,'F11','F12', 'SHFT-F1','SHFT-F2','SHFT-F3','SHFT-F4','SHFT-F5','SHFT-F6','SHFT-F7', 'SHFT-F8','SHFT-F9','SHFT-F10']# ,'SHFT-F11','SHFT-F12'] doc_list.append("") doc_list.append("\\888Toggles:") zoom_context = 1 global labels,ligands,waters,sites,cgos,zooms,dashes labels = 1 ligands = 1 waters = 1 sites = 1 cgos = 0 zooms = 0 dashes = 1 global m4x_sites,m4x_ligands,m4x_waters m4x_sites = "m4x_sites" m4x_ligands = "m4x_ligands" m4x_waters = "m4x_waters" cmd.select(m4x_sites,"none") cmd.select(m4x_ligands,"none") cmd.select(m4x_waters,"none") if len(key_list): key = key_list.pop(0) cmd.set_key(key,toggle_zooms) doc_list.append(key+": Zoom") if len(key_list): key = key_list.pop(0) cmd.set_key(key,toggle_sites) doc_list.append(key+": Sites") if len(key_list): key = key_list.pop(0) cmd.set_key(key,toggle_waters) doc_list.append(key+": Waters") if len(key_list): key = key_list.pop(0) cmd.set_key(key,toggle_dashes) doc_list.append(key+": H-Bonds") if len(key_list): key = key_list.pop(0) cmd.set_key(key,toggle_cgos) doc_list.append(key+": Fits") if len(key_list): key = key_list.pop(0) cmd.set_key(key,toggle_ligands) doc_list.append(key+": Ligands") if len(key_list): key = key_list.pop(0) cmd.set_key(key,toggle_labels) doc_list.append(key+": HB-Dists") for a in list: include_flag = 0 water = a+"_water" ligand = a+"_ligand" site = a+"_site" hbond = a+"_hbond" if cmd.count_atoms(site): if cmd.count_atoms(site+" & m4x_aligned"): include_flag = 1 if cmd.count_atoms(ligand): if cmd.count_atoms(ligand+" & m4x_nearby"): include_flag = 1 if include_flag: name_list = dict[a] if water in name_list: cmd.select(m4x_waters,m4x_waters+"|"+water) if ligand in name_list: cmd.select(m4x_ligands,m4x_ligands+"|"+ligand) if site in name_list: cmd.select(m4x_sites,m4x_sites+"|"+site+ "|((byres (neighbor ("+site+" and name c))) and name n+ca)"+ "|((byres (neighbor ("+site+" and name n))) and name c+ca+o)") cmd.wizard("fedora",doc_list) toggle_cgos(1) toggle_labels(0) toggle_dashes(0) toggle_ligands(1) toggle_sites(0) toggle_waters(0) toggle_cgos(1) cmd.deselect() # cmd.feedback("enable","python","output") cmd.feedback("enable","objectmolecule","results") cmd.set("internal_feedback",1) cmd.set("internal_prompt",0) cmd.feedback("disable","selector","actions") cmd.feedback("disable","scene","actions")
def ligand_sites(selection="(all)", _self=cmd): cmd = _self try: s = tmp_sele cmd.select(s, selection) polar_contacts = _get_polar_contacts_name(s, _self) _prepare(s, polar_contacts, _self=cmd) host = "_preset_host" solvent = "_preset_solvent" near_solvent = "_preset_solvent" lig = "_preset_lig" cmd.select(host, s + " and " + prot_and_dna_sele) cmd.select(solvent, s + " and " + solv_sele) cmd.select(lig, s + " and " + lig_sele) cmd.select(near_solvent, s + " and (" + solvent + " within 4 of " + lig + ")") cmd.flag("ignore", host, "clear") cmd.flag("ignore", lig + "|" + solvent, "set") util.chainbow(host, _self=cmd) util.cbc(lig, _self=cmd) util.cbac("((" + s + ") and not elem c)", _self=cmd) cmd.hide("everything", s) cmd.show("ribbon", host) cmd.show( "lines", "(" + s + " and byres (" + host + " within 5 of " + lig + "))") cmd.show( "surface", "(" + s + " and ((rep lines expand 4) within 6 of " + lig + "))") cmd.set("two_sided_lighting", 1) # global setting cmd.set("transparency", 0, s) cmd.set("surface_quality", 0, s) cmd.show("sticks", lig) cmd.show("sticks", solvent + " and neighbor " + lig) cmd.show("lines", "(" + s + " and (rep lines extend 1) and " + lig + ")") if cmd.count_atoms(lig): cmd.dist(polar_contacts, host + "|" + near_solvent, lig + "|" + near_solvent, mode=2, quiet=1, label=0, reset=1) # hbonds if polar_contacts in cmd.get_names(): cmd.enable(polar_contacts) cmd.hide("labels", polar_contacts) cmd.show("dashes", polar_contacts) else: cmd.delete(polar_contacts) cmd.show("nb_spheres", lig + "|" + host + "|" + near_solvent) if cmd.count_atoms(lig): cmd.zoom(lig, 3) cmd.delete(host) cmd.delete(solvent) cmd.delete(near_solvent) cmd.delete(lig) except: traceback.print_exc()
def setup_contexts(context_info): # Author: Warren DeLano (list,dict) = context_info[0:2] key_list = [ 'F1','F2','F3','F4','F5','F6','F7','F8','F9','F10', #,'F11','F12', 'SHFT-F1','SHFT-F2','SHFT-F3','SHFT-F4','SHFT-F5','SHFT-F6','SHFT-F7', 'SHFT-F8','SHFT-F9','SHFT-F10']# ,'SHFT-F11','SHFT-F12'] doc_list = ["Keys"] zoom_context = 1 global labels labels = 1 if len(key_list): key = key_list.pop(0) cmd.set_key(key,toggle_labels) doc_list.append(key+": Toggle Dist") if len(key_list): key = key_list.pop(0) cmd.set_key(key,lambda :(cmd.zoom(),toggle_labels(0))) doc_list.append(key+": Zoom All") for a in list: water = a+"_water" ligand = a+"_ligand" site = a+"_site" hbond = a+"_hbond" name_list = dict[a] zoom_list = [] if water in name_list: cmd.show("nonbonded",water) util.cbac(water) zoom_list.append(water) if ligand in name_list: cmd.show("sticks",ligand) cmd.hide("cartoon",ligand) util.cbag(ligand) zoom_list.append(ligand) if site in name_list: cmd.show("sticks",site) util.cbac(site) zoom_list.append(site) # replace cartoon with explicit atoms for "site" atoms cmd.hide("cartoon",site) cmd.show("sticks","(byres (neighbor ("+site+" and name c))) and name n+ca") cmd.show("sticks","(byres (neighbor ("+site+" and name n))) and name c+ca+o") if len(zoom_list): if len(key_list): key = key_list.pop(0) zoom_str = string.join(zoom_list,' or ') if zoom_context == 1: zoom_context = zoom_str elif zoom_context not in (0,1): zoom_context = 0 cmd.set_key(key,lambda x=zoom_str:(cmd.zoom(x))) mo = re.search("_([^_]+)$",a) if mo: cont_name = mo.groups()[0] else: cont_name = a doc_list.append(key+": Zoom "+cont_name) if hbond in name_list: cmd.show("dashes",hbond) cmd.show("labels",hbond) cmd.wizard("fedora",doc_list) if zoom_context not in (0,1): cmd.zoom(zoom_context) toggle_labels(0) # cmd.feedback("enable","python","output") cmd.feedback("enable","objectmolecule","results") cmd.feedback("disable","selector","actions") cmd.feedback("disable","scene","actions") cmd.set("internal_feedback",1) cmd.set("internal_prompt",0)
def setup_contexts(context_info): # Author: Warren DeLano (list, dict) = context_info[0:2] key_list = [ 'F1', 'F2', 'F3', 'F4', 'F5', 'F6', 'F7', 'F8', 'F9', 'F10', #,'F11','F12', 'SHFT-F1', 'SHFT-F2', 'SHFT-F3', 'SHFT-F4', 'SHFT-F5', 'SHFT-F6', 'SHFT-F7', 'SHFT-F8', 'SHFT-F9', 'SHFT-F10' ] # ,'SHFT-F11','SHFT-F12'] doc_list = ["Keys"] zoom_context = 1 global labels labels = 1 if len(key_list): key = key_list.pop(0) cmd.set_key(key, toggle_labels) doc_list.append(key + ": Toggle Dist") if len(key_list): key = key_list.pop(0) cmd.set_key(key, lambda: (cmd.zoom(), toggle_labels(0))) doc_list.append(key + ": Zoom All") for a in list: water = a + "_water" ligand = a + "_ligand" site = a + "_site" hbond = a + "_hbond" name_list = dict[a] zoom_list = [] if water in name_list: cmd.show("nonbonded", water) util.cbac(water) zoom_list.append(water) if ligand in name_list: cmd.show("sticks", ligand) cmd.hide("cartoon", ligand) util.cbag(ligand) zoom_list.append(ligand) if site in name_list: cmd.show("sticks", site) util.cbac(site) zoom_list.append(site) # replace cartoon with explicit atoms for "site" atoms cmd.hide("cartoon", site) cmd.show( "sticks", "(byres (neighbor (" + site + " and name c))) and name n+ca") cmd.show( "sticks", "(byres (neighbor (" + site + " and name n))) and name c+ca+o") if len(zoom_list): if len(key_list): key = key_list.pop(0) zoom_str = string.join(zoom_list, ' or ') if zoom_context == 1: zoom_context = zoom_str elif zoom_context not in (0, 1): zoom_context = 0 cmd.set_key(key, lambda x=zoom_str: (cmd.zoom(x))) mo = re.search("_([^_]+)$", a) if mo: cont_name = mo.groups()[0] else: cont_name = a doc_list.append(key + ": Zoom " + cont_name) if hbond in name_list: cmd.show("dashes", hbond) cmd.show("labels", hbond) cmd.wizard("fedora", doc_list) if zoom_context not in (0, 1): cmd.zoom(zoom_context) toggle_labels(0) # cmd.feedback("enable","python","output") cmd.feedback("enable", "objectmolecule", "results") cmd.feedback("disable", "selector", "actions") cmd.feedback("disable", "scene", "actions") cmd.set("internal_feedback", 1) cmd.set("internal_prompt", 0)
def setup_alignment_contexts(context_info): # Author: Warren DeLano (list, dict) = context_info[0:2] doc_list = ['\888Legend:'] obj_name_dict = {} for a in list: sf = string.find(a, "_") if sf >= 0: object_name = a[0:sf] if not obj_name_dict.has_key(object_name): obj_name_dict[object_name] = 1 col_index = cmd.get_object_color_index(object_name) if col_index >= 0: col_tup = cmd.get_color_tuple(col_index) if is_tuple(col_tup): col_int = map(lambda x: int(x * 9 + 0.49999), col_tup) col_str = string.join( map(lambda x: chr(ord('0') + x), col_int), '') doc_list.append("\\" + col_str + object_name + "\\---") key_list = [ 'F1', 'F2', 'F3', 'F4', 'F5', 'F6', 'F7', 'F8', 'F9', 'F10', #,'F11','F12', 'SHFT-F1', 'SHFT-F2', 'SHFT-F3', 'SHFT-F4', 'SHFT-F5', 'SHFT-F6', 'SHFT-F7', 'SHFT-F8', 'SHFT-F9', 'SHFT-F10' ] # ,'SHFT-F11','SHFT-F12'] doc_list.append("") doc_list.append("\\888Toggles:") zoom_context = 1 global labels, ligands, waters, sites, cgos, zooms, dashes labels = 1 ligands = 1 waters = 1 sites = 1 cgos = 0 zooms = 0 dashes = 1 global m4x_sites, m4x_ligands, m4x_waters m4x_sites = "m4x_sites" m4x_ligands = "m4x_ligands" m4x_waters = "m4x_waters" cmd.select(m4x_sites, "none") cmd.select(m4x_ligands, "none") cmd.select(m4x_waters, "none") if len(key_list): key = key_list.pop(0) cmd.set_key(key, toggle_zooms) doc_list.append(key + ": Zoom") if len(key_list): key = key_list.pop(0) cmd.set_key(key, toggle_sites) doc_list.append(key + ": Sites") if len(key_list): key = key_list.pop(0) cmd.set_key(key, toggle_waters) doc_list.append(key + ": Waters") if len(key_list): key = key_list.pop(0) cmd.set_key(key, toggle_dashes) doc_list.append(key + ": H-Bonds") if len(key_list): key = key_list.pop(0) cmd.set_key(key, toggle_cgos) doc_list.append(key + ": Fits") if len(key_list): key = key_list.pop(0) cmd.set_key(key, toggle_ligands) doc_list.append(key + ": Ligands") if len(key_list): key = key_list.pop(0) cmd.set_key(key, toggle_labels) doc_list.append(key + ": HB-Dists") for a in list: include_flag = 0 water = a + "_water" ligand = a + "_ligand" site = a + "_site" hbond = a + "_hbond" if cmd.count_atoms(site): if cmd.count_atoms(site + " & m4x_aligned"): include_flag = 1 if cmd.count_atoms(ligand): if cmd.count_atoms(ligand + " & m4x_nearby"): include_flag = 1 if include_flag: name_list = dict[a] if water in name_list: cmd.select(m4x_waters, m4x_waters + "|" + water) if ligand in name_list: cmd.select(m4x_ligands, m4x_ligands + "|" + ligand) if site in name_list: cmd.select( m4x_sites, m4x_sites + "|" + site + "|((byres (neighbor (" + site + " and name c))) and name n+ca)" + "|((byres (neighbor (" + site + " and name n))) and name c+ca+o)") cmd.wizard("fedora", doc_list) toggle_cgos(1) toggle_labels(0) toggle_dashes(0) toggle_ligands(1) toggle_sites(0) toggle_waters(0) toggle_cgos(1) cmd.deselect() # cmd.feedback("enable","python","output") cmd.feedback("enable", "objectmolecule", "results") cmd.set("internal_feedback", 1) cmd.set("internal_prompt", 0) cmd.feedback("disable", "selector", "actions") cmd.feedback("disable", "scene", "actions")