def reps(self, cleanup=0): rep_list = [ "lines", "sticks", "spheres", "surface", "mesh", "dots", "ribbon", "cartoon" ] try: if not cleanup: self.cmd.disable() self.cmd.set("suspend_updates", 1, quiet=1) self.cmd.mset() self.cmd.set("movie_panel", 0) self.cmd.load("$PYMOL_DATA/demo/pept.pdb", "rep1") self.cmd.alter("rep1///1-5+8-13/", "ss='S'") self.cmd.cartoon("auto") self.cmd.hide("everything", "rep1") for a in range(2, 9): self.cmd.create("rep%d" % a, "rep1") for y, x in enumerate(rep_list, 1): self.cmd.show(x, "rep%d" % y) self.cmd.reset() self.cmd.zoom("rep1", 24) util.cbay("rep2", _self=self.cmd) util.cbac("rep3", _self=self.cmd) util.cbas("rep4", _self=self.cmd) util.cbab("rep5", _self=self.cmd) util.cbaw("rep6", _self=self.cmd) util.cbay("rep8", _self=self.cmd) self.cmd.set("suspend_updates", 0, quiet=1) scale = 0.5 for b in range(1, 20): self.cmd.set("suspend_updates", 0, quiet=1) self.cmd.refresh() self.cmd.set("suspend_updates", 1, quiet=1) xt = -3.2 yt = 1.6 for a in range(1, 5): self.cmd.translate([xt * scale, yt * scale, 0], object="rep%d" % a, camera=0) xt = xt + 2 yt = -yt xt = -3.2 for a in range(5, 9): self.cmd.translate([xt * scale, yt * scale, 0], object="rep%d" % a, camera=0) xt = xt + 2 for a in range(1, 9): self.cmd.origin("rep%d" % a, object="rep%d" % a) self.cmd.mset("1") st = ' '.join("rotate angle=-3,object=rep%d,axis=%s;" % (x, 'yx'[x % 2]) for x in range(1, 9)) self.cmd.mdo(1, st) self.cmd.set("suspend_updates", 0, quiet=1) self.cmd.mplay() cgo = [] axes = [[4.5, 0.0, 0.0], [0.0, 3.0, 0.0], [0.0, 0.0, 3.0]] c = 1 for a in rep_list: ext = self.cmd.get_extent("rep%d" % c) pos = [(ext[0][0] + ext[1][0]) / 2, (ext[0][1] + ext[1][1]) / 2 + 14, (ext[0][2] + ext[1][2]) / 2] c = c + 1 pos[0] = pos[0] - (measure_text(plain, a, axes) / 2) wire_text(cgo, plain, pos, a, axes) self.cmd.set("cgo_line_width", 1.5) self.cmd.set("auto_zoom", 0) self.cmd.load_cgo(cgo, 'reps') self.cmd.set("auto_zoom", 1) else: self.cmd.delete("rep*") self.cmd.mset() self.cmd.mstop() self.cmd.set("movie_panel", 1) except: traceback.print_exc()
print "done" # Align all states cmd.intra_fit('all') cmd.hide('all') #cmd.rewind() cmd.select('receptor', '(not resn MOL) and (not resn WAT) and (not hydrogen)') cmd.select('ligand', 'resn MOL and not hydrogen') cmd.select('ions', 'resn Na\+ or resn Cl\-') cmd.deselect() cmd.hide('all') cmd.show('spheres', 'receptor') util.cbaw('receptor') cmd.show('spheres', 'ligand') cmd.show('spheres', 'ions') util.cbay('ligand') cmd.color('green', 'receptor') #cmd.show('surface', 'receptor') #cmd.set('transparency', 0.65) #cmd.set('surface_mode', 3) #cmd.set('surface_color', 'white') # QuteMol-like cmd.bg_color('white') cmd.set('light_count', 8) cmd.set('spec_count', 1)
# Load PDB file into PyMOL cmd.set('suspend_updates', 'on') cmd.set('retain_order', 1) cmd.load(pdb_temporary_filename, object='system') cmd.hide('all') print('selecting solute...') print(cmd.select('solute', '(not resn WAT) and (not resn HOH) and (not hydrogen)')) cmd.select('water', 'resn WAT') cmd.deselect() #cmd.show('cartoon', 'solute') #cmd.color('white', 'solute') cmd.orient('solute') util.cbaw('solute') if solute == 'dna': cmd.show('sticks', 'solute') # DNA else: cmd.show('cartoon', 'solute') # DNA # speed up builds cmd.set('defer_builds_mode', 3) cmd.set('cache_frames', 0) cmd.cache('disable') cmd.set('async_builds', 1) cmd.set('ray_transparency_contrast', 3.0) cmd.set('ray_transparency_shadows', 0) model = cmd.get_model('system')
# Aim 3 : benzotriazoles (green) fragments = ['x10820', 'x10871', 'x10876'] for fragment in fragments: cmd.load(path + f'Mpro-{fragment}_0A_bound-ligand.mol2', f'benzotriazoles-{fragment}-ligand') cmd.load(path + f'Mpro-{fragment}_0A_bound-protein.pdb', f'benzotriazoles-{fragment}-protein') util.cbag(f'benzotriazoles-*') # N3 ligand (white) cmd.load('6lu7.pdb') cmd.align('(6lu7 and chain A)', 'aminopyridines-x10237-protein') cmd.select('N3-ligand', '6lu7 and chain C') cmd.select('N3-protein', '6lu7 and (chain A or chain B)') util.cbaw('N3-ligand') # All fragments show_fragments = False if show_fragments: files = glob(f'{path}/Mpro-x*.mol2') for filename in files: print(filename) match = re.search('Mpro-(?P<fragment>x\d+)_', filename) fragment = match.group('fragment') cmd.load(filename, f'fragment-{fragment}') cmd.select('fragments', 'fragments-*') # remove waters cmd.remove('resn HOH') cmd.deselect()
print "done" # Align all states cmd.intra_fit('all') cmd.hide('all') #cmd.rewind() cmd.select('receptor', '(not resn MOL) and (not resn WAT) and (not hydrogen)') cmd.select('ligand', 'resn MOL and not hydrogen') cmd.select('ions', 'resn Na\+ or resn Cl\-') cmd.deselect() cmd.hide('all') cmd.show('spheres', 'receptor') util.cbaw('receptor') cmd.show('spheres', 'ligand') cmd.show('spheres', 'ions') util.cbay('ligand') cmd.color('green', 'receptor') #cmd.show('surface', 'receptor') #cmd.set('transparency', 0.65) #cmd.set('surface_mode', 3) #cmd.set('surface_color', 'white') # QuteMol-like cmd.bg_color('white') cmd.set('light_count',8) cmd.set('spec_count',1)
def reps(self,cleanup=0): rep_list = [ "lines","sticks","spheres","surface","mesh","dots","ribbon","cartoon" ] try: if not cleanup: self.cmd.disable() self.cmd.set("suspend_updates",1,quiet=1) self.cmd.mset() self.cmd.unset("movie_panel") self.cmd.load("$PYMOL_DATA/demo/pept.pdb","rep1") self.cmd.alter("rep1///1-5+8-13/","ss='S'") self.cmd.cartoon("auto") self.cmd.hide("everything","rep1") for a in range(2,9): self.cmd.create("rep%d"%a,"rep1") map(lambda x,y,s=self:s.cmd.show(x,"rep%d"%y), rep_list, range(1,9)) self.cmd.reset() self.cmd.zoom("rep1",24) util.cbay("rep2",_self=self.cmd) util.cbac("rep3",_self=self.cmd) util.cbas("rep4",_self=self.cmd) util.cbab("rep5",_self=self.cmd) util.cbaw("rep6",_self=self.cmd) util.cbay("rep8",_self=self.cmd) self.cmd.set("suspend_updates",0,quiet=1) scale=0.5 for b in range(1,20): self.cmd.set("suspend_updates",0,quiet=1) self.cmd.refresh() self.cmd.set("suspend_updates",1,quiet=1) xt=-3.2 yt=1.6 for a in range(1,5): self.cmd.translate([xt*scale,yt*scale,0],object="rep%d"%a,camera=0) xt=xt+2 yt=-yt xt=-3.2 for a in range(5,9): self.cmd.translate([xt*scale,yt*scale,0],object="rep%d"%a,camera=0) xt=xt+2 for a in range(1,9): self.cmd.origin("rep%d"%a,object="rep%d"%a) self.cmd.mset("1") st = string.join(map(lambda x,y:"rotate angle=-3,object=rep%d,axis=%s;"%(x,y),range(1,9), ['x','y','x','y','x','y','x','y'])) self.cmd.mdo(1,st) self.cmd.set("suspend_updates",0,quiet=1) self.cmd.mplay() cgo = [] axes = [[4.5,0.0,0.0],[0.0,3.0,0.0],[0.0,0.0,3.0]] c = 1 for a in rep_list: ext = self.cmd.get_extent("rep%d"%c) pos = [(ext[0][0]+ext[1][0])/2, (ext[0][1]+ext[1][1])/2+14, (ext[0][2]+ext[1][2])/2] c = c + 1 pos[0]=pos[0]-(measure_text(plain,a,axes)/2) wire_text(cgo,plain,pos,a,axes) self.cmd.set("cgo_line_width",1.5) self.cmd.set("auto_zoom",0) self.cmd.load_cgo(cgo,'reps') self.cmd.set("auto_zoom",1) else: self.cmd.delete("rep*") self.cmd.mset() self.cmd.mstop() self.cmd.set("movie_panel",1) except: traceback.print_exc()
def reps(self, cleanup=0): rep_list = [ "lines", "sticks", "spheres", "surface", "mesh", "dots", "ribbon", "cartoon" ] suspend_undo = self.cmd.get("suspend_undo") self.cmd.set("suspend_undo", 1, updates=0) try: if not cleanup: self.cmd.disable() self.cmd.set("suspend_updates", 1, quiet=1) self.cmd.mset() self.cmd.set("movie_panel", 0) self.cmd.load("$PYMOL_DATA/demo/pept.pdb", "rep1") self.cmd.alter("rep1///1-5+8-13/", "ss='S'") self.cmd.cartoon("auto") self.cmd.hide("everything", "rep1") for a in range(2, 9): self.cmd.create("rep%d" % a, "rep1") for y, x in enumerate(rep_list, 1): self.cmd.show(x, "rep%d" % y) self.cmd.reset() self.cmd.zoom("rep1", 24) util.cbay("rep2", _self=self.cmd) util.cbac("rep3", _self=self.cmd) util.cbas("rep4", _self=self.cmd) util.cbab("rep5", _self=self.cmd) util.cbaw("rep6", _self=self.cmd) util.cbay("rep8", _self=self.cmd) self.cmd.set("suspend_updates", 0, quiet=1) scale = 0.5 for b in range(1, 20): self.cmd.set("suspend_updates", 0, quiet=1) self.cmd.refresh() self.cmd.set("suspend_updates", 1, quiet=1) xt = -3.2 yt = 1.4 for a in range(1, 5): self.cmd.translate([xt * scale, yt * scale, 0], object="rep%d" % a, camera=0) xt = xt + 2 yt = -2. xt = -3.2 for a in range(5, 9): self.cmd.translate([xt * scale, yt * scale, 0], object="rep%d" % a, camera=0) xt = xt + 2 for a in range(1, 9): self.cmd.origin("rep%d" % a, object="rep%d" % a) self.cmd.mset("1") st = ' '.join("rotate angle=-3,object=rep%d,axis=%s;" % (x, 'yx'[x % 2]) for x in range(1, 9)) self.cmd.mdo(1, st) self.cmd.set("suspend_updates", 0, quiet=1) self.cmd.mplay() axes = [[4.5, 0.0, 0.0], [0.0, 3.0, 0.0], [0.0, 0.0, 3.0]] c = 1 self.cmd.set("suspend_updates", 1, quiet=1) for a in rep_list: ext = self.cmd.get_extent("rep%d" % c) pos = [(ext[0][0] + ext[1][0]) / 2, (ext[0][1] + ext[1][1]) / 2 + 16, (ext[0][2] + ext[1][2]) / 2] c = c + 1 self.cmd.pseudoatom("reps", label=str(a), pos=pos) self.cmd.set("label_size", 24, "reps") self.cmd.set("suspend_updates", 0, quiet=1) else: self.cmd.delete("rep*") self.cmd.mset() self.cmd.mstop() self.cmd.set("movie_panel", 1) except cmd.QuietException: # in case of hopping to the next demo pass except: traceback.print_exc() finally: self.cmd.set("suspend_updates", 0, quiet=1) self.cmd.set("suspend_undo", suspend_undo, updates=0)