User:Remig/plico/utilities

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

Utils presents a menu of actions potentially useful for manual folding of polypeptides:

Hover text may be enhanced to include atomIndex values.

All collisions may be listed.

Dispersion bonds contributing to secondary structure (displayed as grey arrows between atoms on residues within 4 AAs of eachother) may be toggled on and off.

Dispersion bonds contributing to tertiary structure (displayed as yellow arrows between atoms outside 4 AAs of eachother) may be toggled on and off.

All dispersion bonds may be cleared.

Paired coils may be presented in a format that highlights the forces pairing them: cartoon backbone, ball-and-stick side-chains, hbonds, and halos on CB atoms.

Utils 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 Utilities
Script=script <path to your script directory>/utils.spt;plico_utils

saved as utilities.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 utils.spt.

#   utils - Jmol script by Ron Mignery
#   v1.0 beta    9/11/2015
#
gE = false
gR = false

function is_collision_in_select() {
    is = false
    var cAtoms = ({})
    var iChain = {selected}.chain
    for (var no = {selected}.min.atomno; no <= {selected}.max.atomno; no++) {
        a = {(atomno=no) and (chain=iChain) and thisModel}
        if (a) {
            is = true
            break
        }
    }
    return is
}

# A handy debug routine
function cc {
    print count_collisions(true)
}

function super_coil_prompt() {
    prompt("TBD")
}

function show_interchain_vbonds() {
    var pc = 0
    if (not gBusy) {
        var selsave = {selected}
        select {visible}
        gBusy = true
        background ECHO pink
        refresh
        if (gE) {
            print "Hiding intERchain dispersion bonds"
            gE = false
            draw ID "vdwe*" delete
        }
        else {
            print "Showing intERchain dispersion bonds"
        
            # For all visible atoms
            for (var i = {*}.atomIndex.min; i <= {*}.atomIndex.max; i++) {
                var a = {atomIndex=i}
                if ((a.group != "hoh") and (a.element != "H")) {
                    var iChain = a.chain
                    
                    # If side chain carbon (or sulfur)
                    if ({a and sidechain and not hydrogen} and a.selected) {
                        var nset = {within(104, VDW, a)
                            and ((chain != iChain) or (not within(4,GROUP, a)))
                            and not hoh and not hydrogen and selected}
                        for (var j = 1; j <= nset.size; j++) {
                            var id = format("vdwe%d.%d", i, j)
                            draw ID @id arrow @{a} @{nset[j]}
                            pc++
                        }
                    }
                }
            }
            gE = true
        }
        background ECHO lightgrey
        refresh
        select selsave
        gBusy = false
    }
    return pc
}

function show_intrachain_vbonds() {
    if (not gBusy) {
        var selsave = {selected}
        select {visible}
        gBusy = true
        var pc = 0
        background ECHO pink
        refresh
        
        if (gR) {
            print "Hiding intRAchain dispersion bonds"
            gR = false
            draw ID "vdwr*" delete
        }
        else {
            print "Showing intRAchain dispersion bonds"
    
            # For all visible atoms
            for (var i = {*}.atomIndex.min; i <= {*}.atomIndex.max; i++) {
                var a = {atomIndex=i}
                var iChain = a.chain
                
                if ({a and sidechain and not hydrogen and selected}) {
                    var nset = {within(100, VDW, a) and within(4,GROUP, a)
                        and not connected(a) and not connected(connected(a))
                        and not hydrogen and (chain = iChain) and selected}
                    for (var j = 1; j <= nset.size; j++) {
                        var id = format("vdwr%d.%d", i, j)
                        draw ID @id arrow @{a} @{nset[j]}
                        pc++
                    }
                }
            }
            color $vdwr* lightblue
            gR = true
        }
        background ECHO lightgrey
        refresh
        select selsave
        gBusy = false
    }
    return pc
    
}
   
function calculate_cb(resmin, resmax, ichain, d) {

    # For all atoms in range
    for (var i = {(resno=resmin) and (chain=ichain)}.atomno.min;
        i <= {(resno=resmax) and (chain=ichain)}.atomno.max; i++) {
        var a = {(atomno=i) and (chain=ichain)}
        
        # If CB
        if (a.atomName == "CB") {
        
            # If within(d, a) and cb
            var nset = {within(@d, a) and (atomName = "CB") and not a}
            for (var j = 1; j <= nset.size; j++) {
                measure @{nset[j]} @a
            }
        }
    }
}

function show_alpha_pairs() {
    if (not gBusy) {
        gBusy = true
        background echo pink
        refresh
        print "Backbone cartoon, sidechain ball-and-stick, hbonds on, halo on CBs"
        select all
        calculate STRUCTURE DSSP
        cartoons only
        color structure
        select {sidechain}
        wireframe -0.1
        spacefill 23%
        color jmol
        select {atomName="CB"}
        halo on
        set hbondsRasmol off
        select all
        calculate hbonds
        background echo lightgrey
        refresh
        gBusy = false
    }
}

function utils_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:
            print "hover++"
            hi()
            break
        case 2:
            print "Counting collisions"
            cc()
            break
        case 3:
            print "showing interchain D bonds"
            print show_interchain_vbonds()
            break
        case 4:
            print "showing intrachain D bonds"
            print show_intrachain_vbonds()
            break
        case 5:
            print "Hiding all D bonds"
            draw ID "vdw*" delete
            gE = false
            gR = false
            break
        case 6:
            print "Show alpha chain pairs"
            show_alpha_pairs()
            break
        case 7:
            utils_exit()
            break
        }
    }
}

# Top level of utils
function plico_utils() {

    # 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 = "UTILS"
    plico_prelim(false, false)
    gE = false
    gR = false

    gEcho="______Menu_______|Hover++|List collisions|Show intERchain D bonds|"  +
     "Show intRAchain D bonds|Hide all D bonds|Show alpha pairs| BACK"
    set echo top left
    color echo black
    background echo lightgrey
    echo @gEcho

    bind "SHIFT-DOUBLE" "utils_exit";
    bind "LEFT-CLICK" "+:plico_menu_toggle";
    bind "LEFT-CLICK" "+:utils_click_mb";

}

function utils_exit() {
    if (plico_exit(false)) {
        display all
    }
}

# End of UTILS.SPT

Contributors

Remig