Talk:Rasmolify

From PyMOLWiki
Revision as of 23:10, 28 February 2008 by Gilleain (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Thanks to scripts found here; http://www.ebi.ac.uk/~gareth/pymol/ --Dan 07:44, 20 February 2008 (CST)

I altered this slightly, but I didn't want to just replace the code (it uses a nested function, which isn't great, but makes some things clearer, I think):

selectionMap = {
                "water" : "r. hoh",
                "protein" : "all and not hetatm",
                "ligand" : "organic"
}

def processSelection(selection):
    if selection in selectionMap:
        print "selecting '%s' = '%s'" % (selection, selectionMap[selection])
        return selectionMap[selection]
    else:
        return selection
 
def rselect(selection):
    cmd.select("_selection", processSelection(selection))
cmd.extend("rselect", rselect)

def displayFunctionGenerator(representation, rasmolName=None):
    if rasmolName is not None:
        representation = rasmolName
    def innerFunction(arg=None):
        if arg == 'off':
            cmd.hide(representation, "_selection")
        elif arg is None:
            cmd.show(representation, "_selection")
    return innerFunction

def makeDisplayFunction(representation, rasmolName=None):
    cmd.extend(representation, displayFunctionGenerator(representation, rasmolName))

makeDisplayFunction("spacefill", "spheres")
makeDisplayFunction("cartoon")
makeDisplayFunction("wireframe", "lines")
makeDisplayFunction("sticks")
makeDisplayFunction("dots")

cmd.alias("quit", "exit")
cmd.alias("zap", "delete all")

--Gilleain 22:10, 28 February 2008 (CST)