Motif: Difference between revisions

From PyMOLWiki
Jump to navigation Jump to search
(New page: Small script to show backbone motifs. Use like "motif 10-12" to show a segment from residues 10 to 12. The (optional) chain argument is the chain letter, but the output lists the chain al...)
 
No edit summary
 
(One intermediate revision by the same user not shown)
Line 59: Line 59:
cmd.extend("my_phi_psi", my_phi_psi)
cmd.extend("my_phi_psi", my_phi_psi)
</source>
</source>
[[Category:Script_Library|Motif]]
[[Category:Structural_Biology_Scripts]]

Latest revision as of 07:43, 30 April 2009

Small script to show backbone motifs. Use like "motif 10-12" to show a segment from residues 10 to 12.

The (optional) chain argument is the chain letter, but the output lists the chain along with the residue, so it's not essential to use this.

When run, the output looks like this (for pdbid 1arb):

PyMOL>motif 10-12
 VAL-10 : (  -62,  -31 ) AR
 VAL-11 : (  -72,   -8 ) AR
 CYS-12 : (  -70,  170 ) BR

The "AR", "BR", "AL", "BL" are conformation symbols, and cover quite large regions of the Ramachandran plot. to change them, change the typemap.

# very rough bounds!
typemap = { (-180,0, 90, 180) : "BR", (-150, -30, -60, 60) : "AR", (0, 180, 90, 180) : "BL", (30, 150, -60, 60) : "AL" }

def determinetype(phipsi):
    phi, psi = phipsi
    for bound in typemap:
        if bound[0] < phi < bound[1] and bound[2] < psi < bound[3]:
            return typemap[bound]
    return "?"

def my_phi_psi(selection):
    r = cmd.get_phipsi(selection)

    if r is not None:
        keys = r.keys()
        keys.sort()

        cmd.feedback('push')
        cmd.feedback('disable','executive','actions')
        for key in keys:
            phipsiType = determinetype(r[key])
            argtuple = r[key] + (phipsiType,)
            cmd.iterate("(%s`%d)" % key, "print ' %-5s " + ("( %4.0f, %4.0f ) %s" % argtuple) + "'%(resn+'-'+resi+' '+chain+':')")
        cmd.feedback('pop')

def motif(residueRange, chain=None):
    """
    Use like "motif 10-12" to show a backbone segment from residues 10 to 12.
    """
    name = residueRange
    if chain is None:
        selection = "name ca+n+c+o+h and not hetatm and resi %s" % residueRange
    else:
        selection = "name ca+n+c+o+h and not hetatm and resi %s and chain %s" % (residueRange, chain)
    cmd.select(name, selection)
    cmd.show("sticks", name)
    cmd.zoom(name)
    cmd.disable(name)
    cmd.label("name ca and %s" % selection, "resi")
    my_phi_psi(name)

cmd.extend("motif", motif)
cmd.extend("my_phi_psi", my_phi_psi)