Пример #1
0
    def minimize(*arg):
        '''
DESCRIPTION

    "fast_minimize" is an unsupported nonfunctional command that may
    eventually have something to do with minimization.
    
'''
        from chempy.tinker import realtime
        grad = 0.01
        iter = 500
        interval = 50
        la = len(arg)
        if not la:
            arg = cmd.get_names("objects")
            arg = arg[0:1]
            la = len(arg)
        if la:
            sele = "(" + arg[0] + ")"
            if la > 1:
                iter = int(arg[1])
            if la > 2:
                grad = float(arg[2])
            if la > 3:
                interval = int(arg[3])
            if realtime.setup(sele):
                t = threading.Thread(target=realtime.mini,
                                     args=(iter, grad, interval, arg[0]))
                t.setDaemon(1)
                t.start()
            else:
                print " minimize: missing parameters, can't continue"
Пример #2
0
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)
Пример #3
0
    def fast_minimize(*arg):
        '''
DESCRIPTION

    "fast_minimize" is an unsupported nonfunctional command that may
    eventually have something to do with doing a quick clean up of the
    molecular structure.
    
'''
        from chempy.tinker import realtime
        grad = 0.01
        iter = 500
        interval = 50
        la = len(arg)
        if not la:
            arg = cmd.get_names("objects")
            arg = arg[0:1]
            la = len(arg)
        if la:
            sele = "(" + arg[0] + ")"
            if la > 1:
                iter = int(arg[1])
            if la > 2:
                grad = float(arg[2])
            if la > 3:
                interval = int(arg[3])
            t = threading.Thread(target=realtime.mini,
                                 args=(iter, grad, interval, arg[0]))
            t.setDaemon(1)
            t.start()
Пример #4
0
    def fast_minimize(*arg):
        '''
DESCRIPTION

    "fast_minimize" is an unsupported nonfunctional command that may
    eventually have something to do with doing a quick clean up of the
    molecular structure.
    
'''        
        from chempy.tinker import realtime  
        grad  = 0.01
        iter = 500
        interval = 50
        la = len(arg)
        if not la:
            arg = cmd.get_names("objects")
            arg = arg[0:1]
            la = len(arg)
        if la:
            sele  = "("+arg[0]+")"
            if la>1:
                iter = int(arg[1])
            if la>2:
                grad = float(arg[2])
            if la>3:
                interval = int(arg[3])
            t = threading.Thread(target=realtime.mini,args=(iter,grad,interval,arg[0]))
            t.setDaemon(1)
            t.start()
Пример #5
0
    def minimize(*arg):
        '''
DESCRIPTION

    "fast_minimize" is an unsupported nonfunctional command that may
    eventually have something to do with minimization.
    
'''        
        from chempy.tinker import realtime  
        grad  = 0.01
        iter = 500
        interval = 50
        la = len(arg)
        if not la:
            arg = cmd.get_names("objects")
            arg = arg[0:1]
            la = len(arg)
        if la:
            sele  = "("+arg[0]+")"
            if la>1:
                iter = int(arg[1])
            if la>2:
                grad = float(arg[2])
            if la>3:
                interval = int(arg[3])
            if realtime.setup(sele):
                t = threading.Thread(target=realtime.mini,args=(iter,grad,interval,arg[0]))
                t.setDaemon(1)
                t.start()
            else:
                print " minimize: missing parameters, can't continue"
Пример #6
0
        def alignto(target='', method="cealign", selection='', quiet=1, _self=cmd, **kwargs):
                """
DESCRIPTION

        "alignto" aligns all other loaded objects to the target
        using the specified alignment algorithm.

USAGE

        alignto target [, method [, quiet ]]

NOTES

        Available alignment methods are "align", "super" and "cealign".

EXAMPLE

        # fetch some calmodulins
        fetch 1cll 1sra 1ggz 1k95, async=0

        # align them to 1cll using cealign
        alignto 1cll, method=cealign
        alignto 1cll, object=all_to_1cll

SEE ALSO

        extra_fit, align, super, cealign, fit, rms, rms_cur, intra_fit
                """
                if not selection:
                    names = cmd.get_names("public_objects", 1)
                    if not names:
                        raise pymol.CmdException('no public objects')
                    selection = '%' + ' %'.join(names)
                return extra_fit(selection, target, method, 0, quiet, _self, **kwargs)
Пример #7
0
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)
Пример #8
0
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)
Пример #9
0
def ligands(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 + ")")

        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("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("nonbonded", 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()
Пример #10
0
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)
Пример #11
0
def color_objs(selection='(all)',quiet=1,_self=cmd):
    pymol=_self._pymol
    cmd=_self 
    '''
    Color all chains a different color
    '''
    c = 0
    for a in cmd.get_names('public_nongroup_objects',selection=selection):
	if (selection!='all') and (selection!='(all)'):
            cmd.color(_color_cycle[c],"(?%s and (%s))"%(a,selection),quiet=quiet)
        else:
            cmd.color(_color_cycle[c],"(?%s)"%(a),quiet=quiet)
        c = (c + 1) % _color_cycle_len
Пример #12
0
def mass_align(target,enabled_only=0,max_gap=50,_self=cmd):
    pymol=_self._pymol
    cmd=_self
    list = cmd.get_names("public_objects",int(enabled_only))
    filter(lambda x:cmd.get_type(x)!="object:molecule",list)
    if enabled_only:
        aln_object = 'aln_enabled_to'+target
    else:
        aln_object = 'aln_all_to_'+target
    cmd.delete(aln_object)
    for name in list:
        if name!=target:
            if cmd.count_atoms("(%s) and (%s)"%(target,name))==0:
                cmd.align('polymer and name ca and (%s)'%name,
                'polymer and name ca and (%s)'%target,max_gap=max_gap,quiet=0,
                          object=aln_object)
Пример #13
0
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)
Пример #14
0
    def alignto(target=None, method="cealign", quiet=1, _self=cmd, **kwargs):
        """
DESCRIPTION

        "alignto" aligns all other loaded objects to the target
        using the specified alignment algorithm.

USAGE

        alignto target [, method [, quiet ]]

NOTES

        Available alignment methods are "align", "super" and "cealign".

EXAMPLE

        # fetch some calmodulins
        fetch 1cll 1sra 1ggz 1k95, async=0

        # align them to 1cll using cealign
        alignto 1cll, method=cealign
        alignto 1cll, object=all_to_1cll

SEE ALSO

        align, super, cealign, fit, rms, rms_cur, intra_fit
                """
        if cmd.is_string(method):
            if method in cmd.keyword:
                method = cmd.keyword[method][0]
            else:
                raise CmdException('Unknown method: ' + method)
        names = cmd.get_names("public_objects", 1)
        if not target:
            target = names[0]
        for x in names:
            if x == target:
                continue
            if not quiet:
                print "Aligning %s to %s" % (x, target)
            method(mobile=x, target=target, **kwargs)
Пример #15
0
        def alignto(target=None,method="cealign",quiet=1,_self=cmd, **kwargs):
                """
DESCRIPTION

        "alignto" aligns all other loaded objects to the target
        using the specified alignment algorithm.

USAGE

        alignto target [, method [, quiet ]]

NOTES

        Available alignment methods are "align", "super" and "cealign".

EXAMPLE

        # fetch some calmodulins
        fetch 1cll 1sra 1ggz 1k95, async=0

        # align them to 1cll using cealign
        alignto 1cll, method=cealign
        alignto 1cll, object=all_to_1cll

SEE ALSO

        align, super, cealign, fit, rms, rms_cur, intra_fit
                """
                if cmd.is_string(method):
                    if method in cmd.keyword:
                        method = cmd.keyword[method][0]
                    else:
                        raise CmdException('Unknown method: ' + method)
                names = cmd.get_names("public_objects", 1)
                if not target:
                    target = names[0]
                for x in names:
                        if x == target:
                            continue
                        if not quiet:
                                print "Aligning %s to %s" % (x, target)
                        method(mobile=x, target=target, **kwargs)
Пример #16
0
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+"))")
Пример #17
0
Файл: m4x.py Проект: Almad/pymol
def get_context_info():  # Author: Warren DeLano
    context_dict= {}
    context_list= []
    for a in cmd.get_names("all"):
       context = None   
       if a[-6:]=='_water': 
          context = a[:-6] 
       if a[-7:]=='_ligand':  
          context = a[:-7] 
       if a[-5:]=='_site':  
          context = a[:-5] 
       if a[-6:]=='_hbond':  
          context = a[:-6]
       if context!=None:
           if not context_dict.has_key(context):
               context_list.append(context)
               context_dict[context] = [a]
           else:
               context_dict[context].append(a)
    return (context_list,context_dict)
Пример #18
0
def get_context_info():  # Author: Warren DeLano
    context_dict = {}
    context_list = []
    for a in cmd.get_names("all"):
        context = None
        if a[-6:] == '_water':
            context = a[:-6]
        if a[-7:] == '_ligand':
            context = a[:-7]
        if a[-5:] == '_site':
            context = a[:-5]
        if a[-6:] == '_hbond':
            context = a[:-6]
        if context != None:
            if not context_dict.has_key(context):
                context_list.append(context)
                context_dict[context] = [a]
            else:
                context_dict[context].append(a)
    return (context_list, context_dict)
Пример #19
0
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 + "))")
Пример #20
0
    def check(selection=None, preserve=0):
        '''
DESCRIPTION

    "check" is unsupported command that may eventually have something
    to do with assigning forcefield parameters to a selection of
    atoms.
    
'''        
        # This function relies on code that is not currently part of PyMOL/ChemPy
        # NOTE: the realtime module relies on code that is not yet part of PyMOL/ChemPy
        from chempy.tinker import realtime
        if selection==None:
            arg = cmd.get_names("objects")
            arg = arg[0:1]
            if arg:
                if len(arg):
                    selection = arg
        if selection!=None:
            selection = selector.process(selection)
            realtime.assign("("+selection+")",int(preserve))
            realtime.setup("("+selection+")")
Пример #21
0
    def check(selection=None, preserve=0):
        '''
DESCRIPTION

    "check" is unsupported command that may eventually have something
    to do with assigning forcefield parameters to a selection of
    atoms.
    
'''
        # This function relies on code that is not currently part of PyMOL/ChemPy
        # NOTE: the realtime module relies on code that is not yet part of PyMOL/ChemPy
        from chempy.tinker import realtime
        if selection == None:
            arg = cmd.get_names("objects")
            arg = arg[0:1]
            if arg:
                if len(arg):
                    selection = arg
        if selection != None:
            selection = selector.process(selection)
            realtime.assign("(" + selection + ")", int(preserve))
            realtime.setup("(" + selection + ")")
Пример #22
0
    def alignto(target, method="cealign", quiet=1, _self=cmd):
        """
DESCRIPTION

        "alignto" aligns all other loaded objects to the target
        using the specified alignment algorithm.

USAGE

        alignto target [, method [, quiet ]]

NOTES

        Available alignment methods are "align", "super" and "cealign".

EXAMPLE

        # fetch some calmodulins
        fetch 1cll 1sra 1ggz 1k95, async=0

        # align them to 1cll using cealign
        alignto 1cll, method=cealign

SEE ALSO

        align, super, cealign, fit, rms, rms_cur, intra_fit
                """
        if method == "align":
            method = lambda x, sel: _self.align(x, sel)
        elif method == "super":
            method = lambda x, sel: _self.super(x, sel)
        else:
            method = lambda x, sel: _self.cealign(sel, x)

        for x in cmd.get_names("public_objects"):
            if not quiet:
                print "Aligning %s to %s" % (x, target)
            method(x, target)
Пример #23
0
        def alignto(target,method="cealign",quiet=1,_self=cmd):
                """
DESCRIPTION

        "alignto" aligns all other loaded objects to the target
        using the specified alignment algorithm.

USAGE

        alignto target [, method [, quiet ]]

NOTES

        Available alignment methods are "align", "super" and "cealign".

EXAMPLE

        # fetch some calmodulins
        fetch 1cll 1sra 1ggz 1k95, async=0

        # align them to 1cll using cealign
        alignto 1cll, method=cealign

SEE ALSO

        align, super, cealign, fit, rms, rms_cur, intra_fit
                """
                if method=="align":
                        method=lambda x, sel : _self.align(x,sel)
                elif method=="super":
                        method=lambda x, sel : _self.super(x,sel)
                else:
                        method=lambda x, sel : _self.cealign(sel,x)
                        
                for x in cmd.get_names("public_objects"):
                        if not quiet:
                                print "Aligning %s to %s" % (x, target)
                        method(x,target)
Пример #24
0
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)
Пример #25
0
    def create(name, selection, source_state=0,
               target_state=0, discrete=0, zoom=-1, quiet=1,
               singletons=0, extract=None, _self=cmd):
        '''
DESCRIPTION

    "create" creates a new molecule object from a selection.  It can
    also be used to create states in an existing object.

USAGE

    create name, selection [,source_state [,target_state ] ]

ARGUMENTS

    name = string: name of object to create or modify

    selection = string: atoms to include in the new object

    source_state = integer: {default: 0 -- copy all states}

    target_state = integer: {default: 0}

PYMOL API

    cmd.create(string name, string selection, int state,
               int target_state, int discrete)

NOTES

    If the source and target states are zero (default), then all
    states will be copied.  Otherwise, only the indicated states will
    be copied.

SEE ALSO

    load, copy, extract
        '''
        r = DEFAULT_ERROR      
        # preprocess selection
        selection = selector.process(selection)
        #      
        try:
            _self.lock(_self)
            if name==None:
                avoid = {}
                for obj in cmd.get_names("all"):
                    avoid[obj] = 1
                sel_cnt = _cmd.get(_self._COb,"sel_counter") 
                while 1:
                    sel_cnt = sel_cnt + 1.0
                    name = "obj%02.0f" % sel_cnt
                    if not avoid.has_key(name):
                        _cmd.legacy_set(_self._COb,"sel_counter","%1.0f" % sel_cnt)
                        break
            r = _cmd.create(_self._COb,str(name),"("+str(selection)+")",
                            int(source_state)-1,int(target_state)-1,
                            int(discrete),int(zoom),int(quiet),int(singletons))
        finally:
            _self.unlock(r,_self)
        if not is_error(r): # temporary inefficient implementation
            if extract not in (None, 0, '0'):
                if extract not in (1, '1'):
                    extract = selector.process(extract)
                else:
                    extract = selection
                _self.remove("(("+extract+") in (%s)) and not (%s)"%(name,name))
        if _self._raising(r,_self): raise pymol.CmdException                                    
        return r
Пример #26
0
def a(fx): return [fx,0,(1.0-fx)]   #fx,fx,1-fx]
def b(fx): return [1,fx,1]   #1,fx,fx]
def c(fx): return [1,1,fx]   #1-fx,1-fx,fx]

color_gradients = [a,b,c]

# Default representations
cmd.hide("everything","all")
cmd.show("ribbon","all")
cmd.show("spheres","resn N06 or resn N15 or resn E40 or resn EST")

# Create a list of unique trajectories loaded by parsing the command line
unique = [arg[:-4] for arg in sys.argv if arg.endswith(".pdb")]

# Go through each trajecotry
models = cmd.get_names("all")
for i, u in enumerate(unique):

    traj = [m for m in models if "_".join(m.split("_")[:-1]) == u]

    # Go through each step in the trajectory
    num_steps = float(len(traj))
    for j, t in enumerate(traj):

        # Determine rgb of new color
        fx = j/num_steps
        color_list = color_gradients[i](fx) 
    
        # Create a new color
        color_name = "col%s%i" % (u,j)
        cmd.set_color(color_name,color_list)
Пример #27
0
def hide_sele(_self=cmd):
    pymol=_self._pymol
    cmd=_self
    arg = cmd.get_names("selections")
    for a in arg:
        cmd.disable(a)
Пример #28
0
def c(fx):
    return [1, 1, fx]  #1-fx,1-fx,fx]


color_gradients = [a, b, c]

# Default representations
cmd.hide("everything", "all")
cmd.show("ribbon", "all")
cmd.show("spheres", "resn N06 or resn N15 or resn E40 or resn EST")

# Create a list of unique trajectories loaded by parsing the command line
unique = [arg[:-4] for arg in sys.argv if arg.endswith(".pdb")]

# Go through each trajecotry
models = cmd.get_names("all")
for i, u in enumerate(unique):

    traj = [m for m in models if "_".join(m.split("_")[:-1]) == u]

    # Go through each step in the trajectory
    num_steps = float(len(traj))
    for j, t in enumerate(traj):

        # Determine rgb of new color
        fx = j / num_steps
        color_list = color_gradients[i](fx)

        # Create a new color
        color_name = "col%s%i" % (u, j)
        cmd.set_color(color_name, color_list)