This is a read-only mirror of pymolwiki.org

Difference between revisions of "Resicolor plugin"

From PyMOL Wiki
Jump to navigation Jump to search
m (9 revisions)
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
{{Infobox script-repo
 +
|type      = plugin
 +
|filename  = plugins/resicolor_plugin.py
 +
|author    = [[User:Philaltist|Philaltist]]
 +
|license  = -
 +
}}
 +
 
==Description==
 
==Description==
Here is a small plugin to color proteins according to residue type. Save the following text as "resicolor.py" 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]]).
+
A small plugin to color proteins according to residue type. This functionality is also available as a script ([[resicolor]]).
 
 
<source lang="python">
 
#plugin contributed by Philippe Garteiser garteiserp@omrf.ouhsc.edu
 
from Tkinter import *
 
from pymol import cmd
 
import tkSimpleDialog
 
 
 
def __init__(self):
 
    # Simply add the menu entry and callback
 
    self.menuBar.addmenuitem('Plugin', 'command',
 
                                    'resicolor',
 
                                    label = 'resicolor2',
 
                                    command = lambda s=self : getselection(s))
 
 
 
def resicolor(selection):
 
    if selection:  # None is returned for user cancel
 
        cmd.select ('calcium','resn ca or resn cal')
 
        cmd.select ('acid','resn asp or resn glu or resn cgu')
 
        cmd.select ('basic','resn arg or resn lys or resn his')
 
        cmd.select ('nonpolar','resn met or resn phe or resn pro or resn trp or resn val or resn leu or resn ile or resn ala')
 
        cmd.select ('polar','resn ser or resn thr or resn asn or resn gln or resn tyr')
 
        cmd.select ('cys','resn cys or resn cyx')
 
        cmd.select ('backbone','name ca or name n or name c or name o')
 
        cmd.select ('none')   
 
        code={'acid'    :  'red'    ,
 
              'basic'  :  'blue'  ,
 
              'nonpolar':  'orange' ,
 
              'polar'  :  'green'  ,
 
              'cys'    :  'yellow'}
 
        cmd.select ('none')
 
        for elem in code:
 
            line='color '+code[elem]+','+elem+'&'+selection
 
            print line
 
            cmd.do (line)
 
        word='color white,backbone &'+selection
 
        print word
 
        cmd.do (word)
 
 
 
def getselection(app):
 
    selection=tkSimpleDialog.askstring('resicolor',
 
                                              'Please enter a selection',
 
                                              parent=app.root)
 
    resicolor(selection)
 
  
</source>
+
== Example of use ==
 +
If you follow the instructions for the [http://www.pymolwiki.org/index.php/Git_intro Pymol-script-repo], it is available from the Plugin menu.
  
 +
[[Category:Script_Library]]
 +
[[Category:Structural_Biology_Scripts]]
 
[[Category:Plugins]]
 
[[Category:Plugins]]
 +
[[Category:Coloring]]
 +
[[Category:Pymol-script-repo]]

Latest revision as of 03:09, 28 March 2014

Type PyMOL Plugin
Download plugins/resicolor_plugin.py
Author(s) Philaltist
License -
This code has been put under version control in the project Pymol-script-repo

Description

A small plugin to color proteins according to residue type. This functionality is also available as a script (resicolor).

Example of use

If you follow the instructions for the Pymol-script-repo, it is available from the Plugin menu.