This is a read-only mirror of pymolwiki.org

Difference between revisions of "Talk:Rasmolify"

From PyMOL Wiki
Jump to navigation Jump to search
(New page: Thanks to scripts found here; http://www.ebi.ac.uk/~gareth/pymol/ --~~~~)
 
Line 1: Line 1:
 
Thanks to scripts found here; http://www.ebi.ac.uk/~gareth/pymol/ --[[User:Dan|Dan]] 07:44, 20 February 2008 (CST)
 
Thanks to scripts found here; http://www.ebi.ac.uk/~gareth/pymol/ --[[User:Dan|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):
 +
 +
<source lang="python">
 +
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")
 +
</source>
 +
--[[User:Gilleain|Gilleain]] 22:10, 28 February 2008 (CST)

Revision as of 04:10, 29 February 2008

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)