This is a read-only mirror of

Difference between revisions of "Resicolor plugin"

From PyMOL Wiki
Jump to navigation Jump to search
Line 12: Line 12:
     self.menuBar.addmenuitem('Plugin', 'command',
     self.menuBar.addmenuitem('Plugin', 'command',
                                     label = 'resicolor2',
                                     label = 'resicolor',
                                     command = lambda s=self : getselection(s))
                                     command = lambda s=self : getselection(s))

Revision as of 18:53, 21 April 2007


Here is a small plugin to color proteins according to residue type. Save the following text as "" in your somewhere/PyMOL/modules/pmg_tk/startup directory, and it should add itself to the plugin menu at the next pymol startup. This functionality is also available as a script (resicolor).

#plugin contributed by Philippe Garteiser
from Tkinter import *
from pymol import cmd
import tkSimpleDialog

def __init__(self):
    # Simply add the menu entry and callback
    self.menuBar.addmenuitem('Plugin', 'command',
                                     label = 'resicolor',
                                     command = lambda s=self : getselection(s))

def resicolor(selection):
    if selection:   # None is returned for user cancel ('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')     
        code={'acid'    :  'red'    ,
              'basic'   :  'blue'   ,
              'nonpolar':  'orange' ,
              'polar'   :  'green'  ,
              'cys'     :  'yellow'} ('none')
        for elem in code:
            line='color '+code[elem]+','+elem+'&'+selection
            print line
        word='color white,backbone &'+selection
        print word (word)

def getselection(app):
                                              'Please enter a selection',