示例#1
0
文件: m4x.py 项目: Almad/pymol
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")
示例#2
0
文件: m4x.py 项目: jchodera/pymol
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")
示例#3
0
文件: m4x.py 项目: 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)
示例#4
0
文件: m4x.py 项目: jchodera/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)