Difference between revisions of "User:Remig/plico/toab"

From Jmol
Jump to navigation Jump to search
(Plico Jmol script to move between alpha and beta configurations)
 
m
 
(11 intermediate revisions by the same user not shown)
Line 3: Line 3:
 
'''ToAlphaBeta''' is a member of the Plico suite of protein folding tools described [[User:Remig/plico|here]]. It may be installed and accessed as a macro with the file:
 
'''ToAlphaBeta''' is a member of the Plico suite of protein folding tools described [[User:Remig/plico|here]]. It may be installed and accessed as a macro with the file:
 
<pre>Title=PLICO To Alpha/Beta
 
<pre>Title=PLICO To Alpha/Beta
Script=script <path to your scripts folder>/toab.spt;plicoToab
+
Script=script <path to your scripts directory>/toab.spt;plico_to_ab
</pre>saved as plicotoab.macro in your .jmol/macros folder as described in [[Macro]].
+
</pre>saved as plicotoab.macro in your .jmol/macros directory as described in [[Macro]].
Copy and paste the following into a text editor and save in your scripts folder as toab.spt, replacing the text "<SCRIPT_PATH>" with the path to your scripts.
+
 
<pre>#  toAlphBeta - Jmol script by Ron Mignery
+
A copy of the Plico scripts [[User:Remig/plico/tug|tug.spt]] and [[User:Remig/plico/plicoCommon|plicoCommon.spt]] must be in the same directory as this script.
#*****Replace <SCRIPT_PATH> with path to your scripts folder before use***
+
 
#  v1.0 beta    2/14/2014 for Jmol 14
+
Copy and paste the following into a text editor and save in your scripts directory as toab.spt.
 +
<pre>#  toAlphaBeta - Jmol script by Ron Mignery
 +
#  v1.7 beta    4/12/2016 -require latest common includes
 
#
 
#
 
#  Move a stretch of polypeptide from alpha to beta or vice versa
 
#  Move a stretch of polypeptide from alpha to beta or vice versa
 +
#  or change an amino acid to alpha, beta or L
 
#
 
#
var gToab = FALSE
+
gToab = false
var gToabAlt = FALSE
+
gToabAlt = false
 +
gBusy = false
  
# Bound to LEFT-UP by toabEnableDrag
+
# Bound to LEFT-UP by to_ab_enable_drag
function toabDragDoneMB() {
+
function to_ab_drag_done_mb() {
 
     if (not gToabAlt) {
 
     if (not gToabAlt) {
 
         if (gNanchorIdx >= 0) {
 
         if (gNanchorIdx >= 0) {
             tugDragDoneMB()
+
             tug_drag_done_mb()
 
         }
 
         }
 
     }
 
     }
 
     else {
 
     else {
 
         if (gCanchorIdx >= 0) {
 
         if (gCanchorIdx >= 0) {
             tugDragDoneMB()
+
             tug_drag_done_mb()
 
         }
 
         }
 
     }
 
     }
 
}
 
}
  
# Bound to ALT-SHIFT-LEFT-DRAG by toabEnableDrag
+
# Bound to ALT-SHIFT-LEFT-DRAG by to_ab_enable_drag
function toabDrag2MB() {
+
function to_ab_drag_2_mb() {
     gToabAlt = TRUE
+
     gToabAlt = true
     toabDrag()
+
     to_ab_drag()
 +
}
 +
 
 +
# Bound to ALT-LEFT-DRAG by to_ab_enable_drag
 +
function to_ab_drag_mb() {
 +
    gToabAlt = false
 +
    to_ab_drag()
 
}
 
}
  
# Bound to ALT-LEFT-DRAG by toabEnableDrag
+
# Bound to ALT-LEFT-DOWN by tug_enable_drag
function toabDragMB() {
+
function tug_mark_mb() {
     gToabAlt = FALSE
+
     gMouseX = _mouseX
     toabDrag()
+
     gMouseY = _mouseY
 +
    gNewDrag = true
 
}
 
}
  
function toabDrag() {
+
function to_ab_drag() {
 
     if (not gBusy) {
 
     if (not gBusy) {
         gBusy = TRUE
+
         gBusy = true
 
         var dx = (40.0 * (_mouseX - gMouseX))/_width
 
         var dx = (40.0 * (_mouseX - gMouseX))/_width
 
         var dy = (40.0 * (_mouseY - gMouseY))/_height
 
         var dy = (40.0 * (_mouseY - gMouseY))/_height
Line 50: Line 61:
 
         var pt = (!q)%ptd
 
         var pt = (!q)%ptd
 
         if (distance(pt,  {0 0 0}) > 0.004) {
 
         if (distance(pt,  {0 0 0}) > 0.004) {
       
+
 
 
             # If sidechain mode
 
             # If sidechain mode
 
             if (gSCidx >= 0) {
 
             if (gSCidx >= 0) {
 
                 if ({atomIndex=gSCidx}.atomName == "O") {
 
                 if ({atomIndex=gSCidx}.atomName == "O") {
                     dir = ((abs(dx) > abs(dy))
+
                     var dir = ((abs(dx) > abs(dy))
 
                         ? ((dx < 0) ? 2 : -2)
 
                         ? ((dx < 0) ? 2 : -2)
 
                         : ((dy < 0) ? 2 : -2))
 
                         : ((dy < 0) ? 2 : -2))
Line 70: Line 81:
 
                 # If new drag
 
                 # If new drag
 
                 if (gNewDrag) {
 
                 if (gNewDrag) {
                     gNewDrag = FALSE
+
                     gNewDrag = false
 
                     save state gState
 
                     save state gState
 
                 }
 
                 }
Line 79: Line 90:
 
                 var phi = ((dx < 0) ? -57 : -90)
 
                 var phi = ((dx < 0) ? -57 : -90)
 
                 var psi = ((dx < 0) ? -47 : 120)
 
                 var psi = ((dx < 0) ? -47 : 120)
               
+
 
 
                 # Move between alpha and beta
 
                 # Move between alpha and beta
 +
                f = {atomIndex=_atomPicked}.file
 +
                m = {atomIndex=_atomPicked}.model
 
                 var nIdx = gNcargoIdx
 
                 var nIdx = gNcargoIdx
                 var iNidx = {(atomno=@{{chain=gChain}.atomno.min})
+
                 var cmin = {(chain=gChain) and thisModel}.atomno.min
                    and (chain=gChain)}.atomIndex
+
                var cmax = {(chain=gChain) and thisModel}.atomno.max
                 var maxIdx = {(atomno=@{{chain=gchain}.atomno.max})
+
                 var maxIdx = {(atomno=cmax) and (chain=gchain) and thisModel}.atomIndex
                    and (chain=gchain)}.atomIndex
+
                 var minIdx = {(atomno=cmin) and (chain=gchain) and thisModel}.atomIndex
                 var minIdx = {(atomno=@{{chain=gchain}.atomno.min})
+
                 while (true) {
                    and (chain=gchain)}.atomIndex
+
 
                 while (TRUE) {
 
               
 
 
                     # Adjust phi
 
                     # Adjust phi
                     var ncIdx = getNwardBBidx(nIdx, gChain)
+
                     var ncIdx = get_nward_bb_idx(nIdx, gChain)
                     var caIdx = getCwardBBidx(nIdx, gChain)
+
                     var caIdx = get_cward_bb_idx(nIdx, gChain)
                     var cIdx = getCwardBBidx(caIdx, gChain)
+
                     var cIdx = get_cward_bb_idx(caIdx, gChain)
                     var dh= angle({atomIndex=ncIdx}, {atomIndex=nIdx},
+
                     if (ncIdx >= 0) {
                        {atomIndex=caIdx}, {atomIndex=cIdx})  
+
                        var dh= angle({atomIndex=ncIdx}, {atomIndex=nIdx},
                    var dir = ((phi > dh) ? abs(8*dx) : -(abs(8*dx)))
+
                            {atomIndex=caIdx}, {atomIndex=cIdx})
                    if (not gToabAlt) {
+
                        var dir = ((phi > dh) ? abs(8*dx) : -(abs(8*dx)))
                        selectNwardIdx(nIdx, ((gNanchorIdx >= 0) ? gNcargoIdx : minIdx))  
+
                        if (not gToabAlt) {
 +
                            select_nward_idx(nIdx, ((gNanchorIdx >= 0) ? gNcargoIdx : minIdx))
 +
                        }
 +
                        else {
 +
                            select_cward_idx(caIdx, ((gCanchorIdx >= 0) ? gCcargoIdx : maxIdx))
 +
                        }
 +
                        if (abs(phi-dh) > 0.5) {
 +
                            rotate_selected_record(caIdx, {atomIndex=nIdx}, dir)
 +
                        }
 
                     }
 
                     }
                    else {
+
 
                        selectCwardIdx(caIdx, ((gCanchorIdx >= 0) ? gCcargoIdx : maxIdx))
 
                    }
 
                    if (abs(phi-dh) > 0.5) {
 
                        rotateSelectedRecord(caIdx, {atomIndex=nIdx}, dir)
 
                    }
 
               
 
 
                     # Adjust psi
 
                     # Adjust psi
                     var cnIdx = getCwardBBidx (cIdx, gChain)
+
                     var cnIdx = get_cward_bb_idx (cIdx, gChain)
 
                     dh= angle({atomIndex=nIdx}, {atomIndex=caIdx},
 
                     dh= angle({atomIndex=nIdx}, {atomIndex=caIdx},
                         {atomIndex=cIdx}, {atomIndex=cnIdx})  
+
                         {atomIndex=cIdx}, {atomIndex=cnIdx})
 
                     dir = ((psi > dh) ? abs(8*dx) : -(abs(8*dx)))
 
                     dir = ((psi > dh) ? abs(8*dx) : -(abs(8*dx)))
 
                     if (not gToabAlt) {
 
                     if (not gToabAlt) {
                         selectNwardIdx(caIdx, ((gNanchorIdx >= 0) ? gNcargoIdx : minIdx))  
+
                         select_nward_idx(caIdx, ((gNanchorIdx >= 0) ? gNcargoIdx : minIdx))
 
                     }
 
                     }
 
                     else {
 
                     else {
                         selectCwardIdx(cIdx, ((gCanchorIdx >= 0) ? gCcargoIdx : maxIdx))  
+
                         select_cward_idx(cIdx, ((gCanchorIdx >= 0) ? gCcargoIdx : maxIdx))
 
                     }
 
                     }
 
                     if (abs(psi-dh) > 0.5) {
 
                     if (abs(psi-dh) > 0.5) {
                         rotateSelectedRecord(cIdx, {atomIndex=caIdx}, dir)
+
                         rotate_selected_record(cIdx, {atomIndex=caIdx}, dir)
 
                     }
 
                     }
                   
+
 
 
                     if (gCcargoIdx== cIdx) {
 
                     if (gCcargoIdx== cIdx) {
 
                         break
 
                         break
Line 127: Line 140:
 
                     nIdx = cnIdx
 
                     nIdx = cnIdx
 
                 } # endwhile
 
                 } # endwhile
               
+
 
 
             }
 
             }
           
+
 
 
             gMouseX = _mouseX
 
             gMouseX = _mouseX
 
             gMouseY = _mouseY
 
             gMouseY = _mouseY
 
         }
 
         }
       
+
 
 
         select {gCargoSet}
 
         select {gCargoSet}
         var lcset = (within(kCtolerance, FALSE, {selected})
+
         var lcset = (within(kCtolerance, false, {selected})
 
             and not {selected} and not connected({selected}))
 
             and not {selected} and not connected({selected}))
         gOk2 = TRUE
+
         gOk2 = true
         if (lcset.size > 0) {
+
         if (lcset) {
 
             for (var i = 1; i <= lcset.size; i++) {
 
             for (var i = 1; i <= lcset.size; i++) {
                 handleCollisions2(lcset[i].atomIndex)
+
                 to_handle_collisions(lcset[i].atomIndex)
 
             }
 
             }
 
         }
 
         }
 
         var bkc = (gOk2 ? "yellow" : "pink")
 
         var bkc = (gOk2 ? "yellow" : "pink")
 
         background ECHO @bkc
 
         background ECHO @bkc
       
+
 
       
+
 
         gBusy = FALSE
+
         gBusy = false
 
     }
 
     }
 
}
 
}
  
# Called by tugCargoMB when gToab is true
+
# Called by to_ab_cargo_mb when gToab is true
function toabEnableDrag() {
+
function to_ab_enable_drag() {
 
     gEcho = "____Alpha <==> Beta____|ALT-CLICK=mark block|SHIFT-CLICK=anchors" +
 
     gEcho = "____Alpha <==> Beta____|ALT-CLICK=mark block|SHIFT-CLICK=anchors" +
 
         "|ALT-DRAG=move|SHIFT-ALT-DRAG=alt move|DOUBLE-CLICK=exit"
 
         "|ALT-DRAG=move|SHIFT-ALT-DRAG=alt move|DOUBLE-CLICK=exit"
Line 158: Line 171:
  
 
     # Allow atoms to be dragged
 
     # Allow atoms to be dragged
     bind "ALT-LEFT-DOWN" "tugMarkMB";
+
     bind "ALT-LEFT-DOWN" "tug_mark_mb";
     bind "ALT-LEFT-UP" "tugDragDoneMB";
+
     bind "ALT-LEFT-UP" "tug_drag_done_mb";
     bind "ALT-LEFT-DRAG" "toabDragMB";
+
     bind "ALT-LEFT-DRAG" "to_ab_drag_mb";
     bind "ALT-SHIFT-LEFT-UP" "toabDragDoneMB";
+
     bind "ALT-SHIFT-LEFT-UP" "to_ab_drag_done_mb";
     bind "ALT-SHIFT-LEFT-DRAG" "toabDrag2MB";
+
     bind "ALT-SHIFT-LEFT-DRAG" "to_ab_drag_2_mb";
  
 
     unbind "SHIFT-LEFT-CLICK"
 
     unbind "SHIFT-LEFT-CLICK"
 
     bind "SHIFT-LEFT-CLICK" "_pickAtom";
 
     bind "SHIFT-LEFT-CLICK" "_pickAtom";
     bind "SHIFT-LEFT-CLICK" "+:tugAnchorMB";
+
     bind "SHIFT-LEFT-CLICK" "+:tug_anchor_mb";
 +
 
 +
}
 +
 
 +
# Bound to ALT-LEFT-CLICK by plico_to_ab
 +
function to_ab_cargo_mb() {
 +
    gToab = true
 +
    tug_cargo_mb()
 +
}
 +
 
 +
function set_phi_psi( r, iChain, phi, psi) {
 +
    var aCp = get_atom_rcn( r-1, iChain, "C")
 +
    var aN = get_atom_rcn( r, iChain, "N")
 +
    var aCA = get_atom_rcn( r, iChain, "CA")
 +
    var aC = get_atom_rcn( r, iChain, "C")
 +
    var aO = get_atom_rcn( r, iChain, "O")
 +
    var aNn = get_atom_rcn( r+1, iChain, "N")
 +
    if (aNn) {
 +
        select {(resno <= r) and not aC and not aO and chain=iChain
 +
            and thisModel}
 +
        set_dihedral_atoms(aNn, aC, aCA, aN, psi)
 +
    }
 +
    if (aCp) {
 +
        select {(resno < r) and chain=iChain and thisModel}
 +
        set_dihedral_atoms(aC, aCA, aN, aCp, phi)
 +
    }
 +
    color {resno=r} @gAltScheme
 +
    color {(resno=r) and oxygen} pink
 +
}
 +
 
 +
# Bound to ALT-SHIFT-LEFT-CLICK by plico_to_ab
 +
function to_alpha_mb() {
 +
    var r = {atomIndex=_atomPicked}.resno
 +
    var iChain = {atomIndex=_atomPicked}.chain
 +
    print r+" to alpha"
 +
    set_phi_psi( r, iChain, -50, -45)
 +
}
 +
 
 +
# Bound to CTRL-SHIFT-LEFT-CLICK by plico_to_ab
 +
function to_beta_mb() {
 +
    var r = {atomIndex=_atomPicked}.resno
 +
    var iChain = {atomIndex=_atomPicked}.chain
 +
    print r+" to beta"
 +
    set_phi_psi( r, iChain, -100, 135)
 +
}
 +
 
 +
# Bound to ALT-CTRL-LEFT-CLICK by plico_to_ab
 +
function to_L_mb() {
 +
print "L"
 +
    var r = {atomIndex=_atomPicked}.resno
 +
    var iChain = {atomIndex=_atomPicked}.chain
 +
    set_phi_psi( r, iChain, 50, 45)
 +
}
 +
 
 +
function to_ab_menu_mb() {
 +
    gEcho="______Menu_______|Twist|Bend|SuperCoil| BACK"
 +
    set echo top left
 +
    color echo black
 +
    background echo lightgrey
 +
    echo @gEcho
  
 +
    bind "LEFT-CLICK" "+:to_ab_routines_mb";
 
}
 
}
  
# Bound to ALT-LEFT-CLICK by plicoToab
+
function to_ab_routines_mb() {
function toabCargoMB() {
+
    # If in menu zone
print "toabCargoMB()"#TBD
+
    if ((_mouseX < 100) and ((_height-_mouseY) < 343)) {
    gToab = TRUE
+
        var line = ((_mouseX < 125) ? ((_height-_mouseY)\26) : 0)
     tugCargoMB
+
        switch (line) {
 +
        case 1:
 +
            print "twistTBD"
 +
            break
 +
        case 2:
 +
            print "bendTBD"
 +
            break
 +
        case 3:
 +
            print "supercoilTBD"
 +
            break
 +
        case 4:
 +
            plico_to_ab()
 +
            break
 +
        }
 +
     }
 
}
 
}
  
 
# Top level of ToAlphaBeta
 
# Top level of ToAlphaBeta
function plicoToab() {
+
function plico_to_ab() {
  
 +
    # 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
 +
        }
 +
    }
 +
   
 
     # Load tug functions if not already
 
     # Load tug functions if not already
 
     if (kTug < 3) {
 
     if (kTug < 3) {
         script "<SCRIPT_PATH>tug.spt"
+
         script $SCRIPT_PATH$tug.spt
 
         if (kTug < 3) {
 
         if (kTug < 3) {
             prompt ("A newer version of TUG.SPT is required")
+
             prompt ("A newer version of tug.SPT is required")
 
             quit
 
             quit
 
         }
 
         }
 
     }
 
     }
   
+
 
 
     gPlico = "TO ALPHA/BETA"
 
     gPlico = "TO ALPHA/BETA"
     plicoPrelim()
+
     plico_prelim(true, true)
   
+
 
     gEcho = ("____Alpha <==> Beta____|ALT-CLICK=mark block|DOUBLE-CLICK=exit")
+
     gEcho = ("______Alpha <==> Beta______|ALT-CLICK=mark block" +
 +
    "|CTRL-SHIFT-CLICK=to beta|ALT-SHIFT-CLICK=to alpha" +
 +
    "|ALT-CTRL-CLICK=to L|CTRL-CLICK=menu|SHIFT-DOUBLE-CLICK=exit")
 
     echo @gEcho
 
     echo @gEcho
    gChain = ""
 
    unbind
 
  
 
     bind "ALT-LEFT-CLICK" "_pickAtom";
 
     bind "ALT-LEFT-CLICK" "_pickAtom";
     bind "ALT-LEFT-CLICK" "+:toabCargoMB";
+
     bind "ALT-LEFT-CLICK" "+:to_ab_cargo_mb";
     bind "DOUBLE" "plicoExit";
+
     bind "ALT-SHIFT-LEFT-CLICK" "_pickAtom";
 +
    bind "ALT-SHIFT-LEFT-CLICK" "+:to_alpha_mb";
 +
    bind "CTRL-SHIFT-LEFT-CLICK" "_pickAtom";
 +
    bind "CTRL-SHIFT-LEFT-CLICK" "+:to_beta_mb";
 +
    bind "ALT-CTRL-LEFT-CLICK" "_pickAtom";
 +
    bind "ALT-CTRL-LEFT-CLICK" "+:to_L_mb";
 +
    bind "CTRL-LEFT-CLICK" "to_ab_menu_mb";
 +
    unbind "CTRL-LEFT-DOWN"
 +
    bind "SHIFT-DOUBLE" "plico_exit(true)";
 +
    bind "LEFT-CLICK" "+:plico_menu_toggle";
 +
}
 +
 
 +
# MENU functions
 +
function toab_twist(iChain, rmin, rmax, phi, psi, omega) {
 +
    if (rmin < 0) {
 +
        rmin = get_resno_min(iChain)
 +
    }
 +
    if (rmax < 0) {
 +
        rmax = get_resno_max(iChain)
 +
    }
 +
    for (var r = rmin; r <= rmax; r++) {
 +
        var aCAp = get_atom_rcn(r-1, iChain, "CA")
 +
        var aCp = get_atom_rcn(r-1, iChain, "C")
 +
        var aN = get_atom_rcn(r, iChain, "N")
 +
        var aCA = get_atom_rcn(r, iChain, "CA")
 +
        var aC = get_atom_rcn(r, iChain, "C")
 +
        var aO = get_atom_rcn(r, iChain, "O")
 +
        var aNn = get_atom_rcn(r+1, iChain, "N")
 +
        if (aNn) {
 +
            select {(resno > r) or aO}
 +
print "psi=t"
 +
if (x1) throw context t           
 +
            set_dihedral_atoms(aN, aCA, aC, aNn, psi)
 +
        }
 +
        if (aCp) {
 +
            select {(resno >= r)}
 +
print "phi=t"
 +
if (x1) throw context t           
 +
            set_dihedral_atoms(aCAp, aCp, aN, aCA, omega)
 +
            set_dihedral_atoms(aCp, aN, aCA, aC, phi)
 +
        }
 +
    }
 +
}
 +
 
 +
function toab_bend(iChain, rmin, rmax, cacn, cnca, ncac) {
 +
    if (rmin < 0) {
 +
        rmin = get_resno_min(iChain)
 +
    }
 +
    if (rmax < 0) {
 +
        rmax = get_resno_max(iChain)
 +
    }
 +
    for (var r = rmin; r <= rmax; r++) {
 +
        var aCAp = get_atom_rcn(r-1, iChain, "CA")
 +
        var aCp = get_atom_rcn(r-1, iChain, "C")
 +
        var aN = get_atom_rcn(r, iChain, "N")
 +
        var aCA = get_atom_rcn(r, iChain, "CA")
 +
        var aC = get_atom_rcn(r, iChain, "C")
 +
        var aO = get_atom_rcn(r, iChain, "O")
 +
        var aNn = get_atom_rcn(r+1, iChain, "N")
 +
        if (aCp) {
 +
            select {(resno >= r) or aOp}
 +
print "phi=t"
 +
if (x1) throw context t           
 +
            set_angle_atoms(aCAp, aCp, aN, cacn)
 +
            select remove aOp
 +
            set_angle_atoms(aCp, aN, aCA, cnca)
 +
        }
 +
        select {(resno > r) or aO or aC}
 +
print "psi=t"
 +
if (x1) throw context t           
 +
        set_angle_atoms(aN, aCA, aC, ncac)
 +
    }
 +
}
 +
 
 +
function toab_supercoil(iChain, rmin, rmax, n, f) {
 +
    var delta = [-1, 0, 1, 2, 1, 0, -1]
 +
    if (rmin < 0) {
 +
        rmin = get_resno_min(iChain)
 +
    }
 +
    if (rmax < 0) {
 +
        rmax = get_resno_max(iChain)
 +
    }
 +
    for (var r = rmin; r <= rmax; r++) {
 +
   
 +
        var aN = get_atom_rcn(r, iChain, "N")
 +
        var aCA = get_atom_rcn(r, iChain, "CA")
 +
        var aC = get_atom_rcn(r, iChain, "C")
 +
        var aO = get_atom_rcn(r, iChain, "O")
 +
        var aNn = get_atom_rcn(r+1, iChain, "N")
 +
        if (aNn) {
 +
            select {(resno > r) or aO}
 +
            var ca = angle(aN, aCA, aC, aNn)
 +
print ca           
 +
            set_dihedral_atoms(aN, aCA, aC, aNn, ca+(f*delta[n]))
 +
        }
 +
        n = 1+((++n)%7)
 +
    }
 
}
 
}
  
# End of TURN.SPT
+
# End of TOAB.SPT</pre>
</pre>
 

Latest revision as of 17:07, 12 April 2016

ToAlphaBeta allows the user to mark a section of a polypeptide chain to fold towards an alpha helix configuration or towards a beta strand configuration as described here.

ToAlphaBeta 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 To Alpha/Beta
Script=script <path to your scripts directory>/toab.spt;plico_to_ab

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

A copy of the Plico scripts tug.spt and plicoCommon.spt must be in the same directory as this script.

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

#   toAlphaBeta - Jmol script by Ron Mignery
#   v1.7 beta    4/12/2016 -require latest common includes
#
#   Move a stretch of polypeptide from alpha to beta or vice versa
#   or change an amino acid to alpha, beta or L
#
gToab = false
gToabAlt = false
gBusy = false

# Bound to LEFT-UP by to_ab_enable_drag
function to_ab_drag_done_mb() {
    if (not gToabAlt) {
        if (gNanchorIdx >= 0) {
            tug_drag_done_mb()
        }
    }
    else {
        if (gCanchorIdx >= 0) {
            tug_drag_done_mb()
        }
    }
}

# Bound to ALT-SHIFT-LEFT-DRAG by to_ab_enable_drag
function to_ab_drag_2_mb() {
    gToabAlt = true
    to_ab_drag()
}

# Bound to ALT-LEFT-DRAG by to_ab_enable_drag
function to_ab_drag_mb() {
    gToabAlt = false
    to_ab_drag()
}

# Bound to ALT-LEFT-DOWN by tug_enable_drag
function tug_mark_mb() {
    gMouseX = _mouseX
    gMouseY = _mouseY
    gNewDrag = true
}

function to_ab_drag() {
    if (not gBusy) {
        gBusy = true
        var dx = (40.0 * (_mouseX - gMouseX))/_width
        var dy = (40.0 * (_mouseY - gMouseY))/_height
        var q = quaternion()
        var ptd = {@dx @dy 0}
        var pt = (!q)%ptd
        if (distance(pt,  {0 0 0}) > 0.004) {

            # If sidechain mode
            if (gSCidx >= 0) {
                if ({atomIndex=gSCidx}.atomName == "O") {
                    var dir = ((abs(dx) > abs(dy))
                        ? ((dx < 0) ? 2 : -2)
                        : ((dy < 0) ? 2 : -2))
                    counterRotate(gSCidx, dir, not gToabAlt)
                }
                else {
                    gSCcheck = not gToabAlt
                    tugSideChain(pt)
                }
            }

            # Else
            else {

                # If new drag
                if (gNewDrag) {
                    gNewDrag = false
                    save state gState
                }

                # Move the cargo
                select {gCargoSet}

                var phi = ((dx < 0) ? -57 : -90)
                var psi = ((dx < 0) ? -47 : 120)

                # Move between alpha and beta
                f = {atomIndex=_atomPicked}.file
                m = {atomIndex=_atomPicked}.model
                var nIdx = gNcargoIdx
                var cmin = {(chain=gChain) and thisModel}.atomno.min
                var cmax = {(chain=gChain) and thisModel}.atomno.max
                var maxIdx = {(atomno=cmax) and (chain=gchain) and thisModel}.atomIndex
                var minIdx = {(atomno=cmin) and (chain=gchain) and thisModel}.atomIndex
                while (true) {

                    # Adjust phi
                    var ncIdx = get_nward_bb_idx(nIdx, gChain)
                    var caIdx = get_cward_bb_idx(nIdx, gChain)
                    var cIdx = get_cward_bb_idx(caIdx, gChain)
                    if (ncIdx >= 0) {
                        var dh= angle({atomIndex=ncIdx}, {atomIndex=nIdx},
                            {atomIndex=caIdx}, {atomIndex=cIdx})
                        var dir = ((phi > dh) ? abs(8*dx) : -(abs(8*dx)))
                        if (not gToabAlt) {
                            select_nward_idx(nIdx, ((gNanchorIdx >= 0) ? gNcargoIdx : minIdx))
                        }
                        else {
                            select_cward_idx(caIdx, ((gCanchorIdx >= 0) ? gCcargoIdx : maxIdx))
                        }
                        if (abs(phi-dh) > 0.5) {
                            rotate_selected_record(caIdx, {atomIndex=nIdx}, dir)
                        }
                    }

                    # Adjust psi
                    var cnIdx = get_cward_bb_idx (cIdx, gChain)
                    dh= angle({atomIndex=nIdx}, {atomIndex=caIdx},
                        {atomIndex=cIdx}, {atomIndex=cnIdx})
                    dir = ((psi > dh) ? abs(8*dx) : -(abs(8*dx)))
                    if (not gToabAlt) {
                        select_nward_idx(caIdx, ((gNanchorIdx >= 0) ? gNcargoIdx : minIdx))
                    }
                    else {
                        select_cward_idx(cIdx, ((gCanchorIdx >= 0) ? gCcargoIdx : maxIdx))
                    }
                    if (abs(psi-dh) > 0.5) {
                        rotate_selected_record(cIdx, {atomIndex=caIdx}, dir)
                    }

                    if (gCcargoIdx== cIdx) {
                        break
                    }
                    nIdx = cnIdx
                } # endwhile

            }

            gMouseX = _mouseX
            gMouseY = _mouseY
        }

        select {gCargoSet}
        var lcset = (within(kCtolerance, false, {selected})
            and not {selected} and not connected({selected}))
        gOk2 = true
        if (lcset) {
            for (var i = 1; i <= lcset.size; i++) {
                to_handle_collisions(lcset[i].atomIndex)
            }
        }
        var bkc = (gOk2 ? "yellow" : "pink")
        background ECHO @bkc


        gBusy = false
    }
}

# Called by to_ab_cargo_mb when gToab is true
function to_ab_enable_drag() {
    gEcho = "____Alpha <==> Beta____|ALT-CLICK=mark block|SHIFT-CLICK=anchors" +
        "|ALT-DRAG=move|SHIFT-ALT-DRAG=alt move|DOUBLE-CLICK=exit"
    echo @gEcho

    # Allow atoms to be dragged
    bind "ALT-LEFT-DOWN" "tug_mark_mb";
    bind "ALT-LEFT-UP" "tug_drag_done_mb";
    bind "ALT-LEFT-DRAG" "to_ab_drag_mb";
    bind "ALT-SHIFT-LEFT-UP" "to_ab_drag_done_mb";
    bind "ALT-SHIFT-LEFT-DRAG" "to_ab_drag_2_mb";

    unbind "SHIFT-LEFT-CLICK"
    bind "SHIFT-LEFT-CLICK" "_pickAtom";
    bind "SHIFT-LEFT-CLICK" "+:tug_anchor_mb";

}

# Bound to ALT-LEFT-CLICK by plico_to_ab
function to_ab_cargo_mb() {
    gToab = true
    tug_cargo_mb()
}

function set_phi_psi( r, iChain, phi, psi) {
    var aCp = get_atom_rcn( r-1, iChain, "C")
    var aN = get_atom_rcn( r, iChain, "N")
    var aCA = get_atom_rcn( r, iChain, "CA")
    var aC = get_atom_rcn( r, iChain, "C")
    var aO = get_atom_rcn( r, iChain, "O")
    var aNn = get_atom_rcn( r+1, iChain, "N")
    if (aNn) {
        select {(resno <= r) and not aC and not aO and chain=iChain
            and thisModel}
        set_dihedral_atoms(aNn, aC, aCA, aN, psi)
    }
    if (aCp) {
        select {(resno < r) and chain=iChain and thisModel}
        set_dihedral_atoms(aC, aCA, aN, aCp, phi)
    }
    color {resno=r} @gAltScheme
    color {(resno=r) and oxygen} pink
}

# Bound to ALT-SHIFT-LEFT-CLICK by plico_to_ab
function to_alpha_mb() {
    var r = {atomIndex=_atomPicked}.resno
    var iChain = {atomIndex=_atomPicked}.chain
    print r+" to alpha"
    set_phi_psi( r, iChain, -50, -45)
}

# Bound to CTRL-SHIFT-LEFT-CLICK by plico_to_ab
function to_beta_mb() {
    var r = {atomIndex=_atomPicked}.resno
    var iChain = {atomIndex=_atomPicked}.chain
    print r+" to beta"
    set_phi_psi( r, iChain, -100, 135)
}

# Bound to ALT-CTRL-LEFT-CLICK by plico_to_ab
function to_L_mb() {
print "L"
    var r = {atomIndex=_atomPicked}.resno
    var iChain = {atomIndex=_atomPicked}.chain
    set_phi_psi( r, iChain, 50, 45)
}

function to_ab_menu_mb() {
    gEcho="______Menu_______|Twist|Bend|SuperCoil| BACK"
    set echo top left
    color echo black
    background echo lightgrey
    echo @gEcho

    bind "LEFT-CLICK" "+:to_ab_routines_mb";
}

function to_ab_routines_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 "twistTBD"
            break
        case 2:
            print "bendTBD"
            break
        case 3:
            print "supercoilTBD"
            break
        case 4:
            plico_to_ab()
            break
        }
    }
}

# Top level of ToAlphaBeta
function plico_to_ab() {

    # 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
        }
    }
    
    # Load tug functions if not already
    if (kTug < 3) {
        script $SCRIPT_PATH$tug.spt
        if (kTug < 3) {
            prompt ("A newer version of tug.SPT is required")
            quit
        }
    }

    gPlico = "TO ALPHA/BETA"
    plico_prelim(true, true)

    gEcho = ("______Alpha <==> Beta______|ALT-CLICK=mark block" +
    "|CTRL-SHIFT-CLICK=to beta|ALT-SHIFT-CLICK=to alpha" +
    "|ALT-CTRL-CLICK=to L|CTRL-CLICK=menu|SHIFT-DOUBLE-CLICK=exit")
    echo @gEcho

    bind "ALT-LEFT-CLICK" "_pickAtom";
    bind "ALT-LEFT-CLICK" "+:to_ab_cargo_mb";
    bind "ALT-SHIFT-LEFT-CLICK" "_pickAtom";
    bind "ALT-SHIFT-LEFT-CLICK" "+:to_alpha_mb";
    bind "CTRL-SHIFT-LEFT-CLICK" "_pickAtom";
    bind "CTRL-SHIFT-LEFT-CLICK" "+:to_beta_mb";
    bind "ALT-CTRL-LEFT-CLICK" "_pickAtom";
    bind "ALT-CTRL-LEFT-CLICK" "+:to_L_mb";
    bind "CTRL-LEFT-CLICK" "to_ab_menu_mb";
    unbind "CTRL-LEFT-DOWN"
    bind "SHIFT-DOUBLE" "plico_exit(true)";
    bind "LEFT-CLICK" "+:plico_menu_toggle";
}

# MENU functions
function toab_twist(iChain, rmin, rmax, phi, psi, omega) {
    if (rmin < 0) {
        rmin = get_resno_min(iChain)
    }
    if (rmax < 0) {
        rmax = get_resno_max(iChain)
    }
    for (var r = rmin; r <= rmax; r++) {
        var aCAp = get_atom_rcn(r-1, iChain, "CA")
        var aCp = get_atom_rcn(r-1, iChain, "C")
        var aN = get_atom_rcn(r, iChain, "N")
        var aCA = get_atom_rcn(r, iChain, "CA")
        var aC = get_atom_rcn(r, iChain, "C")
        var aO = get_atom_rcn(r, iChain, "O")
        var aNn = get_atom_rcn(r+1, iChain, "N")
        if (aNn) {
            select {(resno > r) or aO}
print "psi=t"
if (x1) throw context t            
            set_dihedral_atoms(aN, aCA, aC, aNn, psi)
        }
        if (aCp) {
            select {(resno >= r)}
print "phi=t"
if (x1) throw context t            
            set_dihedral_atoms(aCAp, aCp, aN, aCA, omega)
            set_dihedral_atoms(aCp, aN, aCA, aC, phi)
        }
    }
}

function toab_bend(iChain, rmin, rmax, cacn, cnca, ncac) {
    if (rmin < 0) {
        rmin = get_resno_min(iChain)
    }
    if (rmax < 0) {
        rmax = get_resno_max(iChain)
    }
    for (var r = rmin; r <= rmax; r++) {
        var aCAp = get_atom_rcn(r-1, iChain, "CA")
        var aCp = get_atom_rcn(r-1, iChain, "C")
        var aN = get_atom_rcn(r, iChain, "N")
        var aCA = get_atom_rcn(r, iChain, "CA")
        var aC = get_atom_rcn(r, iChain, "C")
        var aO = get_atom_rcn(r, iChain, "O")
        var aNn = get_atom_rcn(r+1, iChain, "N")
        if (aCp) {
            select {(resno >= r) or aOp}
print "phi=t"
if (x1) throw context t            
            set_angle_atoms(aCAp, aCp, aN, cacn)
            select remove aOp
            set_angle_atoms(aCp, aN, aCA, cnca)
        }
        select {(resno > r) or aO or aC}
print "psi=t"
if (x1) throw context t            
        set_angle_atoms(aN, aCA, aC, ncac)
    }
}

function toab_supercoil(iChain, rmin, rmax, n, f) {
    var delta = [-1, 0, 1, 2, 1, 0, -1]
    if (rmin < 0) {
        rmin = get_resno_min(iChain)
    }
    if (rmax < 0) {
        rmax = get_resno_max(iChain)
    }
    for (var r = rmin; r <= rmax; r++) {
    
        var aN = get_atom_rcn(r, iChain, "N")
        var aCA = get_atom_rcn(r, iChain, "CA")
        var aC = get_atom_rcn(r, iChain, "C")
        var aO = get_atom_rcn(r, iChain, "O")
        var aNn = get_atom_rcn(r+1, iChain, "N")
        if (aNn) {
            select {(resno > r) or aO}
            var ca = angle(aN, aCA, aC, aNn)
print ca            
            set_dihedral_atoms(aN, aCA, aC, aNn, ca+(f*delta[n]))
        }
        n = 1+((++n)%7)
    }
}

# End of TOAB.SPT

Contributors

Remig