예제 #1
0
파일: creating.py 프로젝트: evonove/pymol
    def pseudoatom(object='', selection='', name='PS1', resn='PSD', resi='1', chain='P',
                   segi='PSDO', elem='PS', vdw=-1.0, hetatm=1, b=0.0, q=0.0, color='',
                   label='', pos=None, state=0, mode='rms', quiet=1,_self=cmd):
        '''
        
DESCRIPTION

    "pseudoatom" adds a pseudoatom to a molecular object, and will
    creating the molecular object if it does not yet exist.
    
USAGE

    pseudoatom object [, selection [, name [, resn [, resi [, chain
        [, segi [, elem [, vdw [, hetatm [, b [, q [, color [, label
        [, pos [, state [, mode [, quiet ]]]]]]]]]]]]]]]]]

NOTES

    "pseudoatom" can be used for a wide variety of random tasks where
    on must place an atom or a label in 3D space.
    
    '''
        
        r = DEFAULT_ERROR      
        # preprocess selection
        if len(color):
            color = _self.get_color_index(str(color))
        else:
            color = -1 # default
        object = str(object)
        if not len(object):
            object = _self.get_unused_name(prefix="pseudo")
        selection = selector.process(selection)
        mode = pseudoatom_mode_dict[pseudoatom_mode_sc.auto_err(str(mode),'pseudoatom mode')]
        
        (name,resn,resi,chain,segi,elem,label) = map(unquote,(name,resn,resi,chain,segi,elem,label))
        #      
        try:
            _self.lock(_self)
            if pos!=None:
                if not (is_list(pos) or is_tuple(pos)):
                    pos = safe_list_eval(pos)
                pos = (float(pos[0]), # tuple-ize
                       float(pos[1]),
                       float(pos[2]))
            if len(selection.split())>1:
                selection = "("+str(selection)+")"
            r = _cmd.pseudoatom(_self._COb,str(object), str(selection),
                                str(name), str(resn), str(resi), str(chain),
                                str(segi), str(elem), float(vdw), int(hetatm),
                                float(b), float(q), str(label), pos, int(color),
                                int(state)-1, int(mode), int(quiet))
        finally:
            _self.unlock(r,_self)
        if _self._raising(r,_self): raise pymol.CmdException                                    
        return r
예제 #2
0
 def _get_dump_str(obj):
     if is_list(obj):
         list = map(_get_dump_str,obj)
         result = "[ "+string.join(list,",\n")+" ] "
     elif is_dict(obj):
         list = []
         for key in obj.keys():
             list.append( _get_dump_str(key)+" : "+_get_dump_str(obj[key]) )
         result = "{ "+string.join(list,",\n")+" } "
     elif is_tuple(obj):
         list = map(_get_dump_str,obj)
         result = "( "+string.join(list,",\n")+" ) "
     else:
         result = str(obj)
     return result
예제 #3
0
파일: exporting.py 프로젝트: jchodera/pymol
 def _get_dump_str(obj):
     if is_list(obj):
         list = map(_get_dump_str,obj)
         result = "[ "+string.join(list,",\n")+" ] "
     elif is_dict(obj):
         list = []
         for key in obj.keys():
             list.append( _get_dump_str(key)+" : "+_get_dump_str(obj[key]) )
         result = "{ "+string.join(list,",\n")+" } "
     elif is_tuple(obj):
         list = map(_get_dump_str,obj)
         result = "( "+string.join(list,",\n")+" ) "
     else:
         result = str(obj)
     return result
예제 #4
0
파일: creating.py 프로젝트: aghozlane/pymol
    def volume_color(name, colors, _self=cmd):
        """
DESCRIPTION -- untested do not use
ALSO -- this belongs in a different module
        """
        if not (is_list(colors) or is_tuple(colors)):
            colors = safe_list_eval(colors)
        # tuple of tuples to list of float
        cList = []
        map(lambda x: cList.extend(x), colors)
        cList = map(lambda x: float(x), cList)

        try:
            _self.lock(_self)
            r = _cmd.volume_color(_self._COb, str(name), cList)
        finally:
            _self.unlock(r,_self)
        
        if _self._raising(r,_self): raise pymol.CmdException

        # unlock and then use this to differentiate our viz
        return r        
예제 #5
0
파일: creating.py 프로젝트: jchodera/pymol
    def volume_color(name, colors, _self=cmd):
        """
DESCRIPTION -- untested do not use
ALSO -- this belongs in a different module
        """
        if not (is_list(colors) or is_tuple(colors)):
            colors = safe_list_eval(colors)
        # tuple of tuples to list of float
        cList = []
        map(lambda x: cList.extend(x), colors)
        cList = map(lambda x: float(x), cList)

        try:
            _self.lock(_self)
            r = _cmd.volume_color(_self._COb, str(name), cList)
        finally:
            _self.unlock(r, _self)

        if _self._raising(r, _self): raise pymol.CmdException

        # unlock and then use this to differentiate our viz
        return r
예제 #6
0
파일: creating.py 프로젝트: jchodera/pymol
    def pseudoatom(object='',
                   selection='',
                   name='PS1',
                   resn='PSD',
                   resi='1',
                   chain='P',
                   segi='PSDO',
                   elem='PS',
                   vdw=-1.0,
                   hetatm=1,
                   b=0.0,
                   q=0.0,
                   color='',
                   label='',
                   pos=None,
                   state=0,
                   mode='rms',
                   quiet=1,
                   _self=cmd):
        '''
        
DESCRIPTION

    "pseudoatom" adds a pseudoatom to a molecular object, and will
    creating the molecular object if it does not yet exist.
    
USAGE

    pseudoatom object [, selection [, name [, resn [, resi [, chain
        [, segi [, elem [, vdw [, hetatm [, b [, q [, color [, label
        [, pos [, state [, mode [, quiet ]]]]]]]]]]]]]]]]]

NOTES

    "pseudoatom" can be used for a wide variety of random tasks where
    on must place an atom or a label in 3D space.
    
    '''

        r = DEFAULT_ERROR
        # preprocess selection
        if len(color):
            color = _self.get_color_index(str(color))
        else:
            color = -1  # default
        object = str(object)
        if not len(object):
            object = _self.get_unused_name(prefix="pseudo")
        selection = selector.process(selection)
        mode = pseudoatom_mode_dict[pseudoatom_mode_sc.auto_err(
            str(mode), 'pseudoatom mode')]

        (name, resn, resi, chain, segi, elem,
         label) = map(unquote, (name, resn, resi, chain, segi, elem, label))
        #
        try:
            _self.lock(_self)
            if pos != None:
                if not (is_list(pos) or is_tuple(pos)):
                    pos = safe_list_eval(pos)
                pos = (
                    float(pos[0]),  # tuple-ize
                    float(pos[1]),
                    float(pos[2]))
            if len(selection.split()) > 1:
                selection = "(" + str(selection) + ")"
            r = _cmd.pseudoatom(_self._COb, str(object), str(selection),
                                str(name), str(resn), str(resi), str(chain),
                                str(segi), str(elem), float(vdw), int(hetatm),
                                float(b), float(q), str(label), pos,
                                int(color),
                                int(state) - 1, int(mode), int(quiet))
        finally:
            _self.unlock(r, _self)
        if _self._raising(r, _self): raise pymol.CmdException
        return r
예제 #7
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")
예제 #8
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")