User:Remig/plico/plots

From Jmol
< User:Remig‎ | plico
Revision as of 16:23, 11 September 2015 by Remig (talk | contribs) (Some useful plots for manually folding polyopeptides)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Plots allows the user to generate explorable 3D plots of various interesting aspects of protein folding such as O rotations, chi values, and phi psi values. A menu is presented of available actions:

Plot O rotations - plot the phi and psi angle on either side of all peptide bonds. This is useful to view where O atoms have been pushed aside.

Plot CHIs 1&2 - plot chi values 1 & 2 (0 if n/a).

Plot CHIs 2&3 - plot chi values 2 & 3 (0 if n/a).

Plot PHIs and PSIs - a Ramachandran plot.

Back - exit plots.

All plots have 'resno' as the third dimension. The plots are of the vx and vx values of a single atom from each residue (N or CA). The vx and vy values are overloaded with the values of interest before the plot is generated.

Note that display, select, color, halo on/off, etc. commands may be applied to the plot to highlight and identify areas and aspects of interest.

Plots is a member of the Plico suite of protein folding tools described here. It may be installed and accessed as a macro with the file:

Title=PLICO Plots
Script=script <path to your script directory>/plots.spt;plico_plots

saved as Plots.macro in your .jmol/macros directory as described in Macro.

Copy and paste the following into a text editor and save in your scripts directory as plots.spt.

#   plots - Jmol script by Ron Mignery
#   v1.0 beta    9/11/2015
#

function plot_chis12() {
    print "Plotting CHIs 1&2"
    
    select none
    var iChain = ""
    var chains = {not hoh and not ligands and thisModel}.chain
    for (var c = 1; c <= chains.size; c++) {
        if (iChain != chains[c]) {
            iChain = chains[c]
            for (var i = get_resno_min(iChain); i <= get_resno_max(iChain); i++) {
                var aN = get_atom_rcn(i, iChain, "N")
                var aCA = get_atom_rcn(i, iChain, "CA")
                var aCB = get_atom_rcn(i, iChain, "CB")
                var aCG = get_atom_rcn(i, iChain, "?G")
                if (aCG.size == 0) {
                    aCG = get_atom_rcn(i, iChain, "?G1")
                }
                var aCD = get_atom_rcn(i, iChain, "?D")
                if (aCD.size == 0) {
                    aCD = get_atom_rcn(i, iChain, "?D1")
                }
                if (aCG) {
                    aCA.vx = angle(aN, aCA, aCB, aCG)
                    if (aCD) {
                        aCA.vy = angle(aCA, aCB, aCG, aCD)
                    }
                    else {
                        aCA.vy = 0
                    }
                }
                else {
                    aCA.vx = 0
                }
                
                select ADD aCA
            }
        }
    }
    gPlotEcho[1 + _lastFrame[1]] = "vx = chi 1 (0 if none)        vy = chi 2 (0 if none)"
    plot properties vx vy resno
}

function plot_chis34( ) {
    print "Plotting CHIs 3&4"
    select none
    var iChain = ""
    var chains = {not hoh and not ligands and thisModel}.chain
    for (var c = 1; c <= chains.size; c++) {
        if (iChain != chains[c]) {
            iChain = chains[c]
            for (var i = get_resno_min(iChain); i <= get_resno_max(iChain); i++) {
                var aCA = get_atom_rcn(i, iChain, "CA")
                var aCB = get_atom_rcn(i, iChain, "CB")
                var aCG = get_atom_rcn(i, iChain, "?G")
                if (aCG.size == 0) {
                    aCG = get_atom_rcn(i, iChain, "?G1")
                }
                var aCD = get_atom_rcn(i, iChain, "?D")
                if (aCD.size == 0) {
                    aCD = get_atom_rcn(i, iChain, "?D1")
                }
                var aCE = get_atom_rcn(i, iChain, "?E")
                if (aCE.size == 0) {
                    aCE = get_atom_rcn(i, iChain, "?E1")
                }
                var aCZ = get_atom_rcn(i, iChain, "?Z")
                if (aCZ.size == 0) {
                    aCZ = get_atom_rcn(i, iChain, "?Z1")
                }
                if (aCE) {
                    aCA.vx = angle(aCB, aCG, aCD, aCE)
                    if (aCZ) {
                        aCA.vy = angle(aCG, aCD, aCE, aCZ)
                    }
                    else {
                        aCA.vy = 0
                    }
                }
                else {
                    aCA.vx = 0
                }
                
                select ADD aCA
            }
        }
    }
    gPlotEcho[1 + _lastFrame[1]] = "vx = chi 3 (0 if none)        vy = chi 4 (0 if none)"
    plot properties resno vx vy
}

function plot_o_rot() {
    print "Plotting O rotations"
    select none
    var first = true
    var aNp = ({})
    var aCAp = ({})
    var aCp = ({})
    var iChain = ""
    var chains = {not hoh and not ligands and thisModel}.chain
    for (var c = 1; c <= chains.size; c++) {
        if (iChain != chains[c]) {
            iChain = chains[c]
            for (var i = get_resno_min(iChain); i <= get_resno_max(iChain); i++) {
                var aN = get_atom_rcn(i, iChain, "N")
                var aCA = get_atom_rcn(i, iChain, "CA")
                var aC = get_atom_rcn(i, iChain, "C")
                
                if (first) {
                    first = false
                }
                else  {
                    aN.vx = angle(aCp, aN, aCA, aC)
                    aN.vy = angle(aNp, aCAp, aCp, aN)
                    select ADD aN
                }
                aNp = aN
                aCAp = aCA
                aCp = aC
            }
        }
    }
    gPlotEcho[1 + _lastFrame[1]] = "vx = phi        vy = n-ward psi"
    plot properties vx resno vy 
}

function plot_phis_and_psis() {
    print "Plotting PHIs and PSIs"
    select none
    var first = true
    var aCp = ({})
    var iChain = ""
    var chains = {not hoh and not ligands and thisModel}.chain
    for (var c = 1; c <= chains.size; c++) {
        if (iChain != chains[c]) {
            iChain = chains[c]
            for (var i = get_resno_min(iChain); i <= get_resno_max(iChain); i++) {
                var aN = get_atom_rcn(i, iChain, "N")
                var aCA = get_atom_rcn(i, iChain, "CA")
                var aC = get_atom_rcn(i, iChain, "C")
                var aNn = get_atom_rcn(i+1, iChain, "N")
                
                if (first) {
                    first = false
                }
                else if (aNn)  {
                    aCA.vx = angle(aCp, aN, aCA, aC) #phi
                    aCA.vy = angle(aN, aCA, aC, aNn) #psi
                    select ADD aCA
                }
                aCp = aC
            }
        }
    }
    gPlotEcho[1 + _lastFrame[1]] = "vx = phi        vy = psi"
    plot properties vy resno vx 
}

# Callback and plot frames persist if plots closed with just yes 
function plot_frame_callback() {
    if (_currentFrame > 0) {
        unbind "LEFT-CLICK" "+:plico_menu_toggle";
        unbind "LEFT-CLICK" "+:plots_click_mb";
        set echo top left
        color echo red
        background echo yellow
        echo @{gPlotEcho[1+_currentFrame]}
    }
    else {
        if (gPlico == "PLOTS") {
            bind "LEFT-CLICK" "+:plico_menu_toggle";
            bind "LEFT-CLICK" "+:plots_click_mb";
        }
        set echo top left
        color echo black
        background echo lightgrey
        echo @gEcho
    }
}

function plots_click_mb() {

    # If in menu zone
    if ((_mouseX < 100) and ((_height-_mouseY) < 343)) {
        var line = ((_mouseX < 125) ? ((_height-_mouseY)\26) : 0)
        switch (line) {
        case 1:
            plot_o_rot()
            break
        case 2:
            plot_chis12()
            break
        case 3:
            plot_chis34()
            break
        case 4:
            plot_phis_and_psis()
            break
        case 5:
            plots_exit()
            break
        }
    }
}

# Top level of plots
function plico_plots() {

    # Load common functions if not already
    if (kCommon < 6) {
        script $SCRIPT_PATH$plicoCommon.spt
        if (kCommon < 6) {
            prompt ("A newer version of plicoCommon.SPT is required")
            quit
        }
    }

    gPlico = "PLOTS"
    gPlotEcho = []
    plico_prelim(false, true)

    gEcho="______Menu_______|Plot O rotations|Plot CHIs 1&2|Plot CHIs 3&4|" +
        "Plot PHIs and PSIs| BACK"
    set echo top left
    color echo black
    background echo lightgrey
    echo @gEcho

    bind "SHIFT-DOUBLE" "plots_exit";
    bind "LEFT-CLICK" "+:plico_menu_toggle";
    bind "LEFT-CLICK" "+:plots_click_mb";
    set AnimFrameCallback "jmolscript:plot_frame_callback"

}

function plots_exit() {
    if (plico_exit(true)) {
        reset gEcho
        display all
        gPlico = ""
    }
}

# End of PLOTS.SPT

Contributors

Remig