User:Remig/plico/utilities

From Jmol

Jump to: navigation, 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.1 beta    4/12/2016 -require latest common includes
#
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
}

function eval_chain(iChain) {
    gChain = iChain
    select gChain
    calculate structure
    calculate hydrogens true
    set hbondsRasmol false
    calculate hbonds
    set showHydrogens true
    
    gSeq = ""
    for (var i = get_resno_min(iChain); i <= get_resno_max(iChain); i++) {
        var aCA = get_atom_rcn(i , iChain, "CA")
        gSeq += aCA.group1
        gPsi += [aCA.psi]
        gPhi += [aCA.phi]
    } 
    gMin = get_resno_min(gChain)
    gMax = get_resno_max(gChain)
    gOff = 1-gMin
    set multipleBondBananas true
    #calc_masks()
}

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

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

function show_3d_ldbonds (){

    var pc = 0
    if (not gBusy) {
        var selsave = {selected}
        select {visible and thisModel}
        gBusy = true
        background ECHO pink
        refresh
        if (gE) {
            print "Hiding 3D dispersion bonds"
            gE = false
            draw ID "vdwe*" delete
        }
        else {
            print "Showing 3D 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.0, VDW, a)
                            and ((chain != iChain) or (not within(4,GROUP, a)))
                            and not hoh and not hydrogen and selected}
                        var ps = ""    
                        for (var j = 1; j <= nset.size; j++) {
                            var id = format("vdwe%d.%d", i, j)
                            draw ID @id arrow @{a} @{nset[j]}
                            ps += format("%s%d-%s%d(%s-%s) ", a.group, a.resno,
                                nset[j].group, nset[j].resno, a.atomName, nset[j].atomName)
                            pc++
                        }
                        if ((ps.size > 0) and (a.atomIndex < nset[j].atomIndex)) {
                            print ps
                        }
                    }
                }
            }
            gE = true
        }
        background ECHO lightgrey
        refresh
        select selsave
        gBusy = false
    }
    return pc
}

function show_2d_ldbonds() {
    if (not gBusy) {
        var selsave = {selected}
        select {visible and thisModel}
        gBusy = true
        var pc = 0
        background ECHO pink
        refresh
        
        if (gR) {
            print "Hiding 2D dispersion bonds"
            gR = false
            draw ID "vdwr*" delete
        }
        else {
            print "Showing 2D 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 connected(connected(connected(a)))
                        and not hydrogen and (chain = iChain) and selected}
                        var ps = ""    
                        for (var j = 1; j <= nset.size; j++) {
                            var id = format("vdwe%d.%d", i, j)
                            draw ID @id arrow @{a} @{nset[j]}
                            ps += format("%s%d-%s%d(%s-%s) ", a.group, a.resno,
                                nset[j].group, nset[j].resno, a.atomName, nset[j].atomName)
                            pc++
                        }
                        if ((ps.size > 0) and (a.atomIndex < nset[j].atomIndex)) {
                            print ps
                        }
                }
            }
            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 {thisModel}
        calculate STRUCTURE DSSP
        cartoons only
        color structure
        select {sidechain and thisModel}
        wireframe -0.1
        spacefill 23%
        color jmol
        select {atomName="CB" and thisModel}
        halo on
        set hbondsRasmol off
        select {thisModel}
        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 show_3d_ldbonds()/2
            break
        case 4:
            print show_2d_ldbonds()/2
            break
        case 5:
            print "Hiding all LD bonds"
            draw ID "vdw*" delete
            gE = false
            gR = false
            break
        case 6:
            print "Show alpha chain pairs"
            show_alpha_pairs()
            break
        case 7:
            eval_chain(gChain)
            break
        case 8:
            utils_exit()
            break
        }
    }
}

# Top level of utils
function plico_utils() {

    # Load common functions if not already
    if (kCommon < 7) {
        script $SCRIPT_PATH$plicoCommon.spt
        if (kCommon < 7) {
            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 3D LD bonds|"  +
     "Show 2D LD bonds|Hide all LD bonds|Show helix pairing|Evaluate| 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
Personal tools