Beispiel #1
0
def cbc(selection='(all)',first_color=7,quiet=1,legacy=0,_self=cmd):
    pymol=_self._pymol
    cmd=_self 
    '''
    Color all chains a different color
    '''
    if int(legacy):
        c = first_color
        for a in cmd.get_chains(selection):
            if len(string.strip(a)):
                if not quiet: print (" util.cbc: color %d,(chain %s)"%(c,a))
                cmd.color("%d"%c,"(chain %s and (%s))"%(a,selection),quiet=quiet)
                c = c + 1
            elif len(a): # note, PyMOL's selection language can't handle this right now
                if not quiet: print (" util.cbc: color %d,(chain ' ')"%(c))
                cmd.color("%d"%c,"(chain '' and (%s))"%selection,quiet=quiet)
                c = c + 1
            else:
                if not quiet: print (" util.cbc: color %d,(chain '')"%(c))
                cmd.color("%d"%c,"(chain '' and (%s))"%selection,quiet=quiet)
                c = c + 1
    else:
        c = 0
        for a in cmd.get_chains(selection):
            if len(string.strip(a)):
                if not quiet: print (" util.cbc: color %d,(chain %s)"%(_color_cycle[c],a))
                cmd.color(_color_cycle[c],"(chain %s and (%s))"%(a,selection),quiet=quiet)
            elif len(a): # note, PyMOL's selection language can't handle this right now
                if not quiet: print (" util.cbc: color %d,(chain ' ')"%(_color_cycle[c]))
                cmd.color(_color_cycle[c],"(chain '' and (%s))"%selection,quiet=quiet)
            else:
                if not quiet: print (" util.cbc: color %d,(chain '')"%(_color_cycle[c]))
                cmd.color(_color_cycle[c],"(chain '' and (%s))"%selection,quiet=quiet)
            c = (c + 1) % _color_cycle_len
Beispiel #2
0
def chainbow(selection='(all)',first_color=7,_self=cmd):
    pymol=_self._pymol
    cmd=_self # NOT THREAD SAFE
    '''
    Color all chains in rainbow
    '''
    for a in cmd.get_chains(selection):
        if len(a):
            cmd.spectrum('count',selection="(chain %s and (%s))"%(a,selection),byres=1)
        else:
            cmd.spectrum('count',selection="(chain '' and (%s))"%selection,byres=1)
 def __init__(self,complexname,receptor,ligand):
     try:
         cmd.load(complexname)
     except CmdException:
         print complexname
     self.name=complexname.split('.')[0]
     self.chains=dict()
     try:
         chainids=cmd.get_chains(self.name)
     except CmdException:
         print self.name
     for chainid in chainids:
         self.chains[chainid]=cmd.select(self.name+'_'+chainid,self.name+' and chain '+chainid)
         #cmd.delete(self.name+'_'+chainid)
     self.receptor=receptor
     self.ligand=ligand