Example #1
0
 def update_selections(self):
     if self.status == HAVE_SELECTIONS:
         if self.mode == 'by_resi':
             self.cmd.select(
                 free_sele, "((byobj %s) and byres ((%s) x; %8.3f))" %
                 (cent_sele, cent_sele, self.radius))
             self.cmd.select(
                 fix_sele,
                 "((byobj %s) and (not %s) and byres ((%s) x; %8.3f))" %
                 (cent_sele, free_sele, cent_sele,
                  self.radius + self.cushion))
             self.cmd.select(
                 excl_sele, "((byobj %s) and (not (%s|%s)))" %
                 (cent_sele, free_sele, fix_sele))
         elif self.mode == 'ligand_rx':
             self.cmd.select(
                 free_sele,
                 "((byobj %s) and byres (%s))" % (cent_sele, cent_sele))
             self.cmd.select(
                 fix_sele,
                 "((byobj %s) and (not %s) and byres ((%s) x; %8.3f))" %
                 (cent_sele, free_sele, free_sele, self.cushion))
             self.cmd.select(
                 excl_sele, "((byobj %s) and (not (%s|%s)))" %
                 (cent_sele, free_sele, fix_sele))
         self.cmd.protect("(byobj %s)" % cent_sele)
         self.cmd.deprotect(free_sele)
         self.cmd.flag('exclude', "(byobj %s)" % cent_sele, "clear")
         self.cmd.flag('exclude', excl_sele, "set")
         self.cmd.color('grey', excl_sele)
         self.cmd.unmask("(byobj %s)" % cent_sele)
         self.cmd.mask(excl_sele)
         self.cmd.mask(fix_sele)
         self.cmd.zoom(free_sele, 3, animate=1)
         util.cbac(fix_sele, _self=self.cmd)
         util.cbag(free_sele, _self=self.cmd)
         self.cmd.disable('indicate')
         self.cmd.disable(cent_sele)
         self.cmd.disable(free_sele)
         self.cmd.disable(fix_sele)
         self.cmd.disable(excl_sele)
         self.cmd.unpick()
         for obj in self.cmd.get_names(selection=cent_sele):
             self.cmd.push_undo(obj)
             self.cmd.sculpt_activate(obj)
Example #2
0
 def update_selections(self):
     if self.status == HAVE_SELECTIONS:
         if self.mode=='by_resi':
             self.cmd.select(free_sele,"((byobj %s) and byres ((%s) x; %8.3f))"%
                           (cent_sele,cent_sele,self.radius))
             self.cmd.select(fix_sele,"((byobj %s) and (not %s) and byres ((%s) x; %8.3f))"%
                           (cent_sele,free_sele,cent_sele,self.radius+self.cushion))
             self.cmd.select(excl_sele,"((byobj %s) and (not (%s|%s)))"%
                           (cent_sele,free_sele,fix_sele))
         elif self.mode=='ligand_rx':
             self.cmd.select(free_sele,"((byobj %s) and byres (%s))"%
                           (cent_sele,cent_sele))
             self.cmd.select(fix_sele,"((byobj %s) and (not %s) and byres ((%s) x; %8.3f))"%
                           (cent_sele,free_sele,free_sele,self.cushion))
             self.cmd.select(excl_sele,"((byobj %s) and (not (%s|%s)))"%
                           (cent_sele,free_sele,fix_sele))
         self.cmd.protect("(byobj %s)"%cent_sele)
         self.cmd.deprotect(free_sele)
         self.cmd.flag('exclude',"(byobj %s)"%cent_sele,"clear")
         self.cmd.flag('exclude',excl_sele,"set")
         self.cmd.color('grey',excl_sele)
         self.cmd.unmask("(byobj %s)"%cent_sele)
         self.cmd.mask(excl_sele)
         self.cmd.mask(fix_sele)
         self.cmd.zoom(free_sele,3,animate=1)
         util.cbac(fix_sele,_self=self.cmd)
         util.cbag(free_sele,_self=self.cmd)
         self.cmd.disable('indicate')
         self.cmd.disable(cent_sele)            
         self.cmd.disable(free_sele)
         self.cmd.disable(fix_sele)
         self.cmd.disable(excl_sele)
         self.cmd.unpick()
         for obj in self.cmd.get_names(selection=cent_sele):
             self.cmd.push_undo(obj)
             self.cmd.sculpt_activate(obj)
    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()
Example #4
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 = ' or '.join(zoom_list)
                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)
cmd.reset()
cmd.delete('all')

path = "/Users/choderaj/github/foldingathome/covid-moonshot/receptors/monomer/"

# Aim 1 : 3-aminopyridines (cyan)
fragments = [
    'x2646', 'x10201', 'x10387', 'x10789', 'x10019', 'x10236', 'x10237',
    'x10959'
]
for fragment in fragments:
    cmd.load(path + f'Mpro-{fragment}_0A_bound-ligand.mol2',
             f'aminopyridines-{fragment}-ligand')
    cmd.load(path + f'Mpro-{fragment}_0A_bound-protein.pdb',
             f'aminopyridines-{fragment}-protein')
util.cbac(f'aminopyridines-*')

# Aim 2 : quinolones (magenta)
fragments = ['x2910', 'x3080', 'x3303']
for fragment in fragments:
    cmd.load(path + f'Mpro-{fragment}_0A_bound-ligand.mol2',
             f'quinolones-{fragment}-ligand')
    cmd.load(path + f'Mpro-{fragment}_0A_bound-protein.pdb',
             f'quinolones-{fragment}-protein')
util.cbam(f'quinolones-*')

# 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')
Example #6
0
File: demo.py Project: Almad/pymol
    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()
Example #7
0
    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)
Example #8
0
File: m4x.py Project: Almad/pymol
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)