This is a read-only mirror of

Difference between revisions of "Resicolor plugin"

From PyMOL Wiki
Jump to navigation Jump to search
Line 3: Line 3:
<source lang="python">
<source lang="python">
#plugin contributed by Philippe Garteiser
#plugin contributed by Philippe Garteiser
from Tkinter import *
from Tkinter import *
from pymol import cmd
from pymol import cmd

Revision as of 01:53, 30 July 2008


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',