From PyMOLWiki
Jump to: navigation, search


Here is a small script to color proteins according to residue type. Call it from your .pymolrc or from within pymol: "run". Then, issuing "resicolor" will apply the scheme. Selections are supported: "resicolor chain A" will apply the scheme only to chain A. This functionality is also available as a plugin (Resicolor_plugin).

#script contributed by Philippe Garteiser;
from pymol import cmd
def resicolor(selection='all'):
    '''USAGE: resicolor <selection>
    colors all or the given selection with arbitrary
    coloring scheme.
    ''' ('calcium','resn ca or resn cal') ('acid','resn asp or resn glu or resn cgu') ('basic','resn arg or resn lys or resn his') ('nonpolar','resn met or resn phe or resn pro or resn trp or resn val or resn leu or resn ile or resn ala') ('polar','resn ser or resn thr or resn asn or resn gln or resn tyr') ('cys','resn cys or resn cyx') ('backbone','name ca or name n or name c or name o') ('none')
    print selection
    code={'acid'    :  'red'    ,
          'basic'   :  'blue'   ,
          'nonpolar':  'orange' ,
          'polar'   :  'green'  ,
          'cys'     :  'yellow'} ('none')
    for elem in code:
        line='color '+code[elem]+','+elem+'&'+selection
        print line (line)
    word='color white,backbone &'+selection
    print word (word)                  #Used to be in code, but looks like
                                   #dictionnaries are accessed at random
    cmd.hide ('everything','resn HOH')
cmd.extend ('resicolor',resicolor)


Personal tools