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

From Jmol
Jump to navigation Jump to search
(Undo revision 8464 by Remig (talk))
m
 
(7 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 directory>/toab.spt;plicoToab
+
Script=script <path to your scripts directory>/toab.spt;plico_to_ab
 
</pre>saved as plicotoab.macro in your .jmol/macros directory 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 directory as toabNT.spt.
+
 
<pre>#  toABnt - 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.
#  v1.1 beta    4/3/2014 for Jmol 14 -do not var globals for Jmol 14.0.13+
+
 
 +
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
 
#
 
#
Convert a polynucleotide chain from A-form to B-form 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
 
#
 
#
kC5O5PO3B = -71.0
+
gToab = false
kO5PO3C3B = -106.50
+
gToabAlt = false
kPO3C3C4B = -160.67
+
gBusy = false
kO3C3C4C5B = 125.44
 
kC3C4C5O5B = 55.65
 
kC4C5O5PB = 169.10
 
  
kO4C4C3C2B = 15.92
+
# Bound to LEFT-UP by to_ab_enable_drag
kC4O4C1C2B = -41.7
+
function to_ab_drag_done_mb() {
kC4O4C1NxB = -159.03
+
    if (not gToabAlt) {
kC5C4O4C1B = 146.31
+
        if (gNanchorIdx >= 0) {
kC3C1C2O2B = -167.9
+
            tug_drag_done_mb()
 +
        }
 +
    }
 +
    else {
 +
        if (gCanchorIdx >= 0) {
 +
            tug_drag_done_mb()
 +
        }
 +
    }
 +
}
  
kPuB = 59.0
+
# Bound to ALT-SHIFT-LEFT-DRAG by to_ab_enable_drag
kPyB = 61.0
+
function to_ab_drag_2_mb() {
 +
    gToabAlt = true
 +
    to_ab_drag()
 +
}
  
kC5O5PO3A = -59.3
+
# Bound to ALT-LEFT-DRAG by to_ab_enable_drag
kO5PO3C3A = -56.9
+
function to_ab_drag_mb() {
kPO3C3C4A = -157.4
+
    gToabAlt = false
kO3C3C4C5A = 75.5
+
    to_ab_drag()
kC3C4C5O5A = 49.55
+
}
kC4C5O5PA = 170.8
 
  
kO4C4C3C2A = -35.55
+
# Bound to ALT-LEFT-DOWN by tug_enable_drag
kC4O4C1C2A = 3.8
+
function tug_mark_mb() {
kC4O4C1NxA = -117.4
+
    gMouseX = _mouseX
kC5C4O4C1A = 144.85
+
    gMouseY = _mouseY
kC3C1C2O2A = 116.3
+
    gNewDrag = true
 +
}
  
kPuA = 15
+
function to_ab_drag() {
kPyA = 15
+
    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) {
  
gToab = FALSE
+
            # If sidechain mode
gToabAlt = FALSE
+
            if (gSCidx >= 0) {
gToA = FALSE
+
                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)
 +
                }
 +
            }
  
function getInterbaseRotors(stator, mover) {
+
            # Else
    var rotors = array()
+
            else {
    var sRes = stator.resno
 
    var mRes = mover.resno
 
    var iChain = mover.chain
 
    var mC4 = {(resno=mRes) and (chain=iChain) and (atomName="C4\'")}
 
    var mC3 = {(resno=mRes) and (chain=iChain) and (atomName="C3\'")}
 
    var mO3 = {(resno=mRes) and (chain=iChain) and (atomName="O3\'")}
 
    var sP = {(resno=sRes) and (chain=iChain) and (atomName="P")}
 
    var sO5 = {(resno=sRes) and (chain=iChain) and (atomName="O5\'")}
 
    var sC5 = {(resno=sRes) and (chain=iChain) and (atomName="C5\'")}
 
    var sC4 = {(resno=sRes) and (chain=iChain) and (atomName="C4\'")}
 
    var sC3 = {(resno=sRes) and (chain=iChain) and (atomName="C3\'")}
 
  
    rotors += [mC4.atomIndex, mC3.atomIndex, mO3.atomIndex, sP.atomIndex]
+
                # If new drag
    rotors += [mC3.atomIndex, mO3.atomIndex, sP.atomIndex, sO5.atomIndex]
+
                if (gNewDrag) {
    rotors += [mO3.atomIndex, sP.atomIndex, sO5.atomIndex, sC5.atomIndex]
+
                    gNewDrag = false
    rotors += [sP.atomIndex, sO5.atomIndex, sC5.atomIndex, sC4.atomIndex]
+
                    save state gState
    rotors = [sO5.atomIndex, sC5.atomIndex, sC4.atomIndex, sC3.atomIndex]
+
                }
    return rotors
 
}
 
  
function setResidueDistance(stator, mover, dist) {
+
                # Move the cargo
    var selsave = {selected}
+
                select {gCargoSet}
    var cp = mover.xyz
 
    select mover
 
    setDistanceAtoms(stator, mover, dist)
 
    var pt = mover.xyz
 
    mover.xyz = cp
 
    select selsave
 
    var rotors = getInterbaseRotors(stator, mover)
 
    toabTrackIdx(mover.atomIndex, pt, rotors)
 
    toabTrackIdx(mover.atomIndex, pt, rotors)
 
    toabTrackIdx(mover.atomIndex, pt, rotors)
 
}
 
  
# Rotate rotor set to move target atom to its proper place
+
                var phi = ((dx < 0) ? -57 : -90)
function toabTrackIdx(targetIdx, targetPt, iRotors) {
+
                var psi = ((dx < 0) ? -47 : 120)
    gOK = FALSE
 
    var pt = targetPt
 
    var dist = distance(pt, {atomIndex=targetIdx}.xyz)
 
    var baseSet = {selected}
 
    var rotors = iRotors
 
  
    # For a number of passes
+
                # Move between alpha and beta
    for (var pass1 = 0; pass1 < 20; pass1++) {
+
                f = {atomIndex=_atomPicked}.file
        var blocked = ({})
+
                m = {atomIndex=_atomPicked}.model
        for (var pass2 = 0; pass2 < (rotors.size/4); pass2++) {
+
                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) {
  
            var v1 = {atomIndex=targetIdx}.xyz - pt
+
                    # Adjust phi
 
+
                    var ncIdx = get_nward_bb_idx(nIdx, gChain)
            # Find the most orthgonal unused rotor
+
                    var caIdx = get_cward_bb_idx(nIdx, gChain)
            var imax = 0
+
                    var cIdx = get_cward_bb_idx(caIdx, gChain)
            var smax = 0.5
+
                     if (ncIdx >= 0) {
            for (var ri = 1; ri < rotors.size; ri += 4) {
+
                         var dh= angle({atomIndex=ncIdx}, {atomIndex=nIdx},
                var i2 = rotors[ri+1]
+
                            {atomIndex=caIdx}, {atomIndex=cIdx})
                var i3 = rotors[ri+2]
+
                         var dir = ((phi > dh) ? abs(8*dx) : -(abs(8*dx)))
                var i4 = rotors[ri+3]
+
                        if (not gToabAlt) {
                if ((i2 != targetIdx) and (i3 != targetIdx) and (i4 != targetIdx)) {
+
                            select_nward_idx(nIdx, ((gNanchorIdx >= 0) ? gNcargoIdx : minIdx))
                     if ({blocked and {atomIndex=i2}}.count == 0) {
+
                        }
                         var v2 = {atomIndex=i3}.xyz - {atomIndex=i2}.xyz
+
                        else {
 
+
                            select_cward_idx(caIdx, ((gCanchorIdx >= 0) ? gCcargoIdx : maxIdx))
                         var s = sin(abs(angle(v1, {0 0 0}, v2)))
+
                        }
                         if (s > smax) {
+
                         if (abs(phi-dh) > 0.5) {
                             smax = s
+
                             rotate_selected_record(caIdx, {atomIndex=nIdx}, dir)
                            imax = ri
 
 
                         }
 
                         }
 
                     }
 
                     }
                }
 
            }
 
  
            # If no more rotors, break to next full try
+
                    # Adjust psi
            if (imax == 0) {
+
                    var cnIdx = get_cward_bb_idx (cIdx, gChain)
              break
+
                    dh= angle({atomIndex=nIdx}, {atomIndex=caIdx},
            }
+
                        {atomIndex=cIdx}, {atomIndex=cnIdx})
            var i1 = rotors[imax+0]
+
                    dir = ((psi > dh) ? abs(8*dx) : -(abs(8*dx)))
            var i2 = rotors[imax+1]
+
                    if (not gToabAlt) {
            var i3 = rotors[imax+2]
+
                        select_nward_idx(caIdx, ((gNanchorIdx >= 0) ? gNcargoIdx : minIdx))
            var i4 = rotors[imax+3]
+
                    }
 +
                    else {
 +
                        select_cward_idx(cIdx, ((gCanchorIdx >= 0) ? gCcargoIdx : maxIdx))
 +
                    }
 +
                    if (abs(psi-dh) > 0.5) {
 +
                        rotate_selected_record(cIdx, {atomIndex=caIdx}, dir)
 +
                    }
  
            # Get dihedral of rotor with target point
+
                    if (gCcargoIdx== cIdx) {
            var dt = angle({atomIndex=targetIdx}, {atomIndex=i2}, {atomIndex=i3}, pt)
+
                        break
 +
                    }
 +
                    nIdx = cnIdx
 +
                } # endwhile
  
            # Add rotor stators to select
 
            select baseSet
 
            for (var ri = 1; ri <= imax; ri += 4) {
 
                {atomIndex=@{rotors[ri]}}.selected = TRUE
 
                {atomIndex=@{rotors[ri+1]}}.selected = TRUE
 
 
             }
 
             }
  
             # Rotate to minimize vector ====================
+
             gMouseX = _mouseX
             rotateSelected {atomIndex=i2} {atomIndex=i3} @dt
+
             gMouseY = _mouseY
 +
        }
  
            # If close enough, stop
+
        select {gCargoSet}
            if (distance(pt, {atomIndex=targetIdx}) < (kDtolerance/4)) {
+
        var lcset = (within(kCtolerance, false, {selected})
                gOK = TRUE
+
            and not {selected} and not connected({selected}))
                gTargetPt = pt
+
        gOk2 = true
                 break
+
        if (lcset) {
 +
            for (var i = 1; i <= lcset.size; i++) {
 +
                 to_handle_collisions(lcset[i].atomIndex)
 
             }
 
             }
 +
        }
 +
        var bkc = (gOk2 ? "yellow" : "pink")
 +
        background ECHO @bkc
  
            # Block rotor
 
            blocked |= {atomIndex=i2}
 
  
         }   # endfor num rotors passes
+
         gBusy = false
 +
    }
 +
}
  
        if (gOK) {
+
# Called by to_ab_cargo_mb when gToab is true
            break
+
function to_ab_enable_drag() {
         }
+
    gEcho = "____Alpha <==> Beta____|ALT-CLICK=mark block|SHIFT-CLICK=anchors" +
     }  # endfor 20 passes
+
         "|ALT-DRAG=move|SHIFT-ALT-DRAG=alt move|DOUBLE-CLICK=exit"
}
+
     echo @gEcho
  
function toabNtAuto(iChain, toA) {
+
    # 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";
  
     # Load common functions if not already
+
     unbind "SHIFT-LEFT-CLICK"
     if (kCommon < 1) {
+
     bind "SHIFT-LEFT-CLICK" "_pickAtom";
        script $SCRIPT_PATH$plicoCommon.spt
+
     bind "SHIFT-LEFT-CLICK" "+:tug_anchor_mb";
        if (kCommon < 1) {
 
            prompt ("A newer version of plicoCommon.SPT is required")
 
            quit
 
        }
 
     }
 
  
    gChain1 = iChain
 
    gToA = toA
 
    toabNt(TRUE)
 
 
}
 
}
  
function toabNt(auto) {
+
# Bound to ALT-LEFT-CLICK by plico_to_ab
     select all
+
function to_ab_cargo_mb() {
    g5cargoIdx = {(atomno=@{{chain=gChain1}.atomno.min})
+
     gToab = true
        and (chain=gChain1)}.atomIndex
+
     tug_cargo_mb()
     g3cargoIdx = {(atomno=@{{chain=gChain1}.atomno.max})
+
}
        and (chain=gChain1)}.atomIndex
 
  
     # If new drag
+
function set_phi_psi( r, iChain, phi, psi) {
     if (gNewDrag) {
+
    var aCp = get_atom_rcn( r-1, iChain, "C")
         gNewDrag = FALSE
+
    var aN = get_atom_rcn( r, iChain, "N")
         save state gState
+
     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
 +
}
  
    # Move the cargo
+
# Bound to ALT-SHIFT-LEFT-CLICK by plico_to_ab
     select {gCargoSet}
+
function to_alpha_mb() {
     gChain1 = {atomIndex=g3cargoIdx}.chain
+
     var r = {atomIndex=_atomPicked}.resno
     gChain2 = ""
+
     var iChain = {atomIndex=_atomPicked}.chain
 +
     print r+" to alpha"
 +
    set_phi_psi( r, iChain, -50, -45)
 +
}
  
    # Move between A-form and B-form
+
# Bound to CTRL-SHIFT-LEFT-CLICK by plico_to_ab
     var res5 = {atomIndex=g5cargoIdx}.resno
+
function to_beta_mb() {
     var res3 = {atomIndex=g3cargoIdx}.resno
+
     var r = {atomIndex=_atomPicked}.resno
     var pSet = ({})
+
     var iChain = {atomIndex=_atomPicked}.chain
    var bSet = ({})
+
     print r+" to beta"
    var k = -1
+
    set_phi_psi( r, iChain, -100, 135)
    var ang = 0
+
}
    var pang = 0
 
    var isP = FALSE
 
    for (var i = res5; i <= res3; i++) {
 
        var j = i-1
 
        var aO3 = {(resno=i) and (chain=gChain1) and (atomName="O3\'")}
 
        var aC3 = {(resno=i) and (chain=gChain1) and (atomName="C3\'")}
 
        var aC4 = {(resno=i) and (chain=gChain1) and (atomName="C4\'")}
 
        var aC5 = {(resno=i) and (chain=gChain1) and (atomName="C5\'")}
 
        var aO5 = {(resno=i) and (chain=gChain1) and (atomName="O5\'")}
 
        var aP =  {(resno=i) and (chain=gChain1) and (atomName="P")}
 
        if (i == res5) {
 
            if (auto == FALSE) {
 
                isForm = "A"
 
                if (angle(aO3, aC3, aC4, aC5) > ((kO3C3C4C5A + kO3C3C4C5B)/2)) {
 
                    isForm = "B"
 
                }
 
                p = prompt(format("Convert chain %s from %s-form to:", gChain1, isForm),
 
                    "A-form|B-form", TRUE)
 
                if (p == "A-form") {
 
                    gToA = TRUE
 
                }
 
                else if (p == "B-form") {
 
                    gToA = FALSE
 
                }
 
                else {
 
                    color {all} @gScheme
 
                    break
 
                }
 
                print format("Converting to %s", p)
 
            }
 
  
            # If paired
+
# Bound to ALT-CTRL-LEFT-CLICK by plico_to_ab
            lcAtoms = (within(3.0, FALSE,
+
function to_L_mb() {
                {(resno=i) and (chain=gChain1) and base})
+
print "L"
                and not {chain=gChain1})
+
    var r = {atomIndex=_atomPicked}.resno
            isP = (lcAtoms.size > 0)
+
    var iChain = {atomIndex=_atomPicked}.chain
            gChain2 = (isP ? lcAtoms[1].chain : "")
+
    set_phi_psi( r, iChain, 50, 45)
            k = (isP ? lcAtoms[1].resno : -1)
+
}
        }
 
        pSet = {(resno=k) and (chain=gChain2)}
 
        var bO3 = {(resno=k) and (chain=gChain2) and (atomName="O3\'")}
 
        var bC3 = {(resno=k) and (chain=gChain2) and (atomName="C3\'")}
 
        var bC4 = {(resno=k) and (chain=gChain2) and (atomName="C4\'")}
 
        var bC5 = {(resno=k) and (chain=gChain2) and (atomName="C5\'")}
 
        var bO5 = {(resno=k) and (chain=gChain2) and (atomName="O5\'")}
 
        var bP =  {(resno=k) and (chain=gChain2) and (atomName="P")}
 
  
        # If not 5' terminus
+
function to_ab_menu_mb() {
        var aC4p = ({})
+
    gEcho="______Menu_______|Twist|Bend|SuperCoil| BACK"
        var aC3p = ({})
+
    set echo top left
        var aO3p = ({})
+
    color echo black
        var bO5p = ({})
+
    background echo lightgrey
        var bC4p = ({})
+
    echo @gEcho
        var bC3p = ({})
 
        var bO3p = ({})
 
        var bPp = ({})
 
        if (i > res5) {
 
            aC4p = {(resno=j) and (chain=gChain1) and (atomName="C4\'")}
 
            aC3p = {(resno=j) and (chain=gChain1) and (atomName="C3\'")}
 
            aO3p = {(resno=j) and (chain=gChain1) and (atomName="O3\'")}
 
  
            bO5p = {(resno=@{k+1}) and (chain=gChain2) and (atomName="O5\'")}
+
    bind "LEFT-CLICK" "+:to_ab_routines_mb";
            bC4p = {(resno=@{k+1}) and (chain=gChain2) and (atomName="C4\'")}
+
}
            bC3p = {(resno=@{k+1}) and (chain=gChain2) and (atomName="C3\'")}
 
            bO3p = {(resno=@{k+1}) and (chain=gChain2) and (atomName="O3\'")}
 
            bPp = {(resno=@{k+1}) and (chain=gChain2) and (atomName="P")}
 
  
            select bSet or {(atomno < @{aP.atomno}) and
+
function to_ab_routines_mb() {
                (atomno >= @{{atomIndex=g5cargoIdx}.atomno}) and (chain=gChain1)}
+
    # If in menu zone
            setDihedralAtoms(aP, aO3p, aC3p, aC4p, (gToA ? kPO3C3C4A : kPO3C3C4B))
+
    if ((_mouseX < 100) and ((_height-_mouseY) < 343)) {
 
+
        var line = ((_mouseX < 125) ? ((_height-_mouseY)\26) : 0)
             setDihedralAtoms(aO5, aP, aO3p, aC3p, (gToA ? kO5PO3C3A : kO5PO3C3B))
+
        switch (line) {
 
+
        case 1:
             select bSet or {(atomno < @{aO5.atomno}) and
+
            print "twistTBD"
                (atomno >= @{{atomIndex=g5cargoIdx}.atomno}) and (chain=gChain1)}
+
             break
             setDihedralAtoms(aC5, aO5, aP, aO3p, (gToA ? kC5O5PO3A : kC5O5PO3B))
+
        case 2:
 +
            print "bendTBD"
 +
            break
 +
        case 3:
 +
            print "supercoilTBD"
 +
             break
 +
        case 4:
 +
            plico_to_ab()
 +
             break
 
         }
 
         }
        select bSet or {(atomno < @{aO5.atomno}) and
+
    }
            (atomno >= @{{atomIndex=g5cargoIdx}.atomno}) and (chain=gChain1)}
+
}
        setDihedralAtoms(aC4, aC5, aO5, aP, (gToA ? kC4C5O5PA : kC4C5O5PB))
 
        select (bP or (connected(bP) and {resno=k}))
 
        setDihedralAtoms(bC4, bC5, bO5, bP, (gToA ? kC4C5O5PA : kC4C5O5PB))
 
  
        select bSet or {(atomno < @{aC5.atomno}) and
+
# Top level of ToAlphaBeta
            (atomno >= @{{atomIndex=g5cargoIdx}.atomno}) and (chain=gChain1)}
+
function plico_to_ab() {
        setDihedralAtoms(aC3, aC4, aC5, aO5, (gToA ? kC3C4C5O5A : kC3C4C5O5B))
 
        select (bP or (connected(bP) and {resno=k}))
 
        setDihedralAtoms(bC3, bC4, bC5, bO5, (gToA ? kC3C4C5O5A : kC3C4C5O5B))
 
  
        select (({(resno >= k) and (chain=gChain2)}
+
    # Load common functions if not already
            or {(resno <= i) and (chain=gChain1)}) and not aO3)
+
    if (kCommon < 7) {
        setDihedralAtoms(aO3, aC3, aC4, aC5, (gToA ? kO3C3C4C5A : kO3C3C4C5B))
+
         script $SCRIPT_PATH$plicoCommon.spt
        select bO3
+
         if (kCommon < 7) {
        setDihedralAtoms(bC5, bC4, bC3, bO3, (gToA ? kO3C3C4C5A : kO3C3C4C5B))
+
             prompt ("A newer version of plicoCommon.SPT is required")
 
+
             quit
 
 
        var aC1 =  {(resno=i) and (chain=gChain1) and (atomName="C1\'")}
 
         var aC2 =  {(resno=i) and (chain=gChain1) and (atomName="C2\'")}
 
        var aO2 =  {(resno=i) and (chain=gChain1) and (atomName="O2\'")}
 
        var aO4 =  {(resno=i) and (chain=gChain1) and (atomName="O4\'")}
 
 
 
        var bC1 =  {(resno=k) and (chain=gChain2) and (atomName="C1\'")}
 
        var bC2 =  {(resno=k) and (chain=gChain2) and (atomName="C2\'")}
 
        var bO2 =  {(resno=k) and (chain=gChain2) and (atomName="O2\'")}
 
        var bO4 =  {(resno=k) and (chain=gChain2) and (atomName="O4\'")}
 
 
 
        # Set chi
 
        var aNx = -1
 
        var aCx = -1
 
        var bNx = -1
 
        var bCx = -1
 
         if ((aC1 and {purine}).size > 0) {
 
             aNx =  {(resno=i) and (chain=gChain1) and (atomName="N9")}
 
            aCx =  {(resno=i) and (chain=gChain1) and (atomName="C8")}
 
            bNx =  {(resno=k) and (chain=gChain2) and (atomName="N1")}
 
             bCx =  {(resno=k) and (chain=gChain2) and (atomName="C6")}
 
            ang = (gToA ? kPuA : kPuB)
 
            pang = (gToA ? kPyA : kPyB)
 
 
         }
 
         }
        else {
+
    }
            aNx =  {(resno=i) and (chain=gChain1) and (atomName="N1")}
+
   
            aCx =  {(resno=i) and (chain=gChain1) and (atomName="C6")}
+
    # Load tug functions if not already
            bNx =  {(resno=k) and (chain=gChain2) and (atomName="N9")}
+
    if (kTug < 3) {
             bCx =  {(resno=k) and (chain=gChain2) and (atomName="C8")}
+
        script $SCRIPT_PATH$tug.spt
            ang = (gToA ? kPyA : kPyB)
+
        if (kTug < 3) {
             pang = (gToA ? kPuA : kPuB)
+
             prompt ("A newer version of tug.SPT is required")
 +
             quit
 
         }
 
         }
        select pSet or {(resno=i) and (chain=gChain1) and base}
+
    }
        setDihedralAtoms(aO4, aC1, aNx, aCx, ang)
 
        select {pSet and not base}
 
        setDihedralAtoms(bCx, bNx, bC1, bO4, pang)
 
  
        # Set pucker 3' endo or 2' endo
+
    gPlico = "TO ALPHA/BETA"
        select pSet or {(resno=i) and (chain=gChain1) and base}
+
    plico_prelim(true, true)
        setDihedralAtoms(aC4, aO4, aC1, aNx, (gToA ? kC4O4C1NxA : kC4O4C1NxB))
 
        select {pSet and not base}
 
        setDihedralAtoms(bNx, bC1, bO4, bC4, (gToA ? kC4O4C1NxA : kC4O4C1NxB))
 
  
        select (pSet or
+
    gEcho = ("______Alpha <==> Beta______|ALT-CLICK=mark block" +
            {((resno=i) and (chain=gChain1) and base) or aC1})
+
    "|CTRL-SHIFT-CLICK=to beta|ALT-SHIFT-CLICK=to alpha" +
        setDihedralAtoms(aC5, aC4, aO4, aC1, (gToA ? kC5C4O4C1A : kC5C4O4C1B))
+
    "|ALT-CTRL-CLICK=to L|CTRL-CLICK=menu|SHIFT-DOUBLE-CLICK=exit")
        select {pSet and not base and not bC1}
+
    echo @gEcho
        setDihedralAtoms(bC1, bO4, bC4, bC5, (gToA ? kC5C4O4C1A : kC5C4O4C1B))
 
  
        select aC2 or aO2
+
    bind "ALT-LEFT-CLICK" "_pickAtom";
        setDihedralAtoms(aC4, aO4, aC1, aC2, (gToA ? kC4O4C1C2A : kC4O4C1C2B))
+
    bind "ALT-LEFT-CLICK" "+:to_ab_cargo_mb";
        if (aO2.size > 0) {
+
    bind "ALT-SHIFT-LEFT-CLICK" "_pickAtom";
            ang = (gToA ? kC3C1C2O2A : kC3C1C2O2B)
+
    bind "ALT-SHIFT-LEFT-CLICK" "+:to_alpha_mb";
            setDihedralAtoms(aC3, aC1, aC2, aO2, (gToA ? kC3C1C2O2A : kC3C1C2O2B))
+
    bind "CTRL-SHIFT-LEFT-CLICK" "_pickAtom";
        }
+
    bind "CTRL-SHIFT-LEFT-CLICK" "+:to_beta_mb";
        setDistanceAtoms(aC3, aC2, 1.52)
+
    bind "ALT-CTRL-LEFT-CLICK" "_pickAtom";
        setDistanceAtoms(aC1, aC2, 1.52)
+
    bind "ALT-CTRL-LEFT-CLICK" "+:to_L_mb";
        select bC2 or bO2
+
    bind "CTRL-LEFT-CLICK" "to_ab_menu_mb";
        setDihedralAtoms(bC4, bO4, bC1, bC2, (gToA ? kC4O4C1C2A : kC4O4C1C2B))
+
    unbind "CTRL-LEFT-DOWN"
        if (bO2.size > 0) {
+
    bind "SHIFT-DOUBLE" "plico_exit(true)";
            ang = (gToA ? kC3C1C2O2A : kC3C1C2O2B)
+
    bind "LEFT-CLICK" "+:plico_menu_toggle";
            setDihedralAtoms(bC3, bC1, bC2, bO2, (gToA ? kC3C1C2O2A : kC3C1C2O2B))
+
}
        }
 
        setDistanceAtoms(bC3, bC2, 1.52)
 
        setDistanceAtoms(bC1, bC2, 1.52)
 
  
         # compress
+
# MENU functions
         if (i > res5) {
+
function toab_twist(iChain, rmin, rmax, phi, psi, omega) {
             select ({resno<i} or {resno>k}) and not aP
+
    if (rmin < 0) {
             #setResidueDistance(aC4, aC4p, 4.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) {
        # If paired, make minor adjustments
+
             select {(resno >= r)}
         if (isP and (i > res5)) {
+
print "phi=t"
 
+
if (x1) throw context t           
            var cp = bPp.xyz
+
             set_dihedral_atoms(aCAp, aCp, aN, aCA, omega)
             select bPp
+
             set_dihedral_atoms(aCp, aN, aCA, aC, phi)
            setDistanceAtoms(bO3, bPp, 1.59)
 
            setAngleAtoms(bC3, bO3, bPp, 118.2)
 
            setDihedralAtoms(bC4, bC3, bO3, bPp, (gToA ? kPO3C3C4A : kPO3C3C4B))
 
            var pt = bPp.xyz
 
            bPp.xyz = cp
 
            rotors = [aC4p.atomIndex, aC3p.atomIndex, aO3p.atomIndex, aP.atomIndex]
 
            rotors += [aC3p.atomIndex, aO3p.atomIndex, aP.atomIndex, aO5.atomIndex]
 
            rotors += [aO3p.atomIndex, aP.atomIndex, aO5.atomIndex, aC5.atomIndex]
 
            rotors += [aP.atomIndex, aO5.atomIndex, aC5.atomIndex, aC4.atomIndex]
 
            rotors += [aO5.atomIndex, aC5.atomIndex, aC4.atomIndex, aC3.atomIndex]
 
            select ({((resno < i) and (chain=gChain1))} or
 
                {(resno > k) and (chain=gChain2)})
 
            toabTrackIdx(bPp.atomIndex, pt, rotors)
 
            var bOP1 =  {(resno=@{bPp.resno}) and (chain=gChain2) and (atomName="OP1")}
 
            var bOP2 =  {(resno=@{bPp.resno}) and (chain=gChain2) and (atomName="OP2")}
 
             bOP1.xyz = getTetIdx(bO3.atomIndex, bPp.atomIndex, bO5p.atomIndex, 1.5)
 
            bOP2.xyz = getTetIdx(bO5p.atomIndex, bPp.atomIndex, bO3.atomIndex, 1.5)
 
             var aOP1 =  {(resno=@{aP.resno}) and (chain=gChain1) and (atomName="OP1")}
 
            var aOP2 =  {(resno=@{aP.resno}) and (chain=gChain1) and (atomName="OP2")}
 
            aOP1.xyz = getTetIdx(aO3p.atomIndex, aP.atomIndex, aO5.atomIndex, 1.5)
 
            aOP2.xyz = getTetIdx(aO5.atomIndex, aP.atomIndex, aO3p.atomIndex, 1.5)
 
 
         }
 
         }
 +
    }
 +
}
  
         bSet = bset or pSet
+
function toab_bend(iChain, rmin, rmax, cacn, cnca, ncac) {
        if (k > 0) {
+
    if (rmin < 0) {
            k--
+
         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}
     } # endfor
+
print "psi=t"
 
+
if (x1) throw context t           
 +
        set_angle_atoms(aN, aCA, aC, ncac)
 +
     }
 
}
 
}
  
# Bound to ALT-LEFT-CLICK by plicoToabNt
+
function toab_supercoil(iChain, rmin, rmax, n, f) {
function toabChainMB() {
+
     var delta = [-1, 0, 1, 2, 1, 0, -1]
     color {all} @gScheme
+
     if (rmin < 0) {
     gChain1 = {atomIndex=_atomPicked}.chain
+
        rmin = get_resno_min(iChain)
     color {chain=gChain1} @gAltScheme
+
    }
     refresh
+
     if (rmax < 0) {
     toabNt(FALSE)
+
        rmax = get_resno_max(iChain)
}
+
     }
 
+
     for (var r = rmin; r <= rmax; r++) {
# Top level of ToABnt
+
   
function plicoToabNT() {
+
        var aN = get_atom_rcn(r, iChain, "N")
 
+
        var aCA = get_atom_rcn(r, iChain, "CA")
    # Load common functions if not already
+
        var aC = get_atom_rcn(r, iChain, "C")
    if (kCommon < 1) {
+
        var aO = get_atom_rcn(r, iChain, "O")
        script $SCRIPT_PATH$plicoCommon.spt
+
        var aNn = get_atom_rcn(r+1, iChain, "N")
         if (kCommon < 1) {
+
         if (aNn) {
             prompt ("A newer version of plicoCommon.SPT is required")
+
             select {(resno > r) or aO}
             quit
+
            var ca = angle(aN, aCA, aC, aNn)
 +
print ca           
 +
             set_dihedral_atoms(aN, aCA, aC, aNn, ca+(f*delta[n]))
 
         }
 
         }
 +
        n = 1+((++n)%7)
 
     }
 
     }
 
    gPlico = "TO A-FORM/B-FORM"
 
    plicoPrelim()
 
 
    gEcho = ("________A <==> B_______|ALT-CLICK=mark chain|DOUBLE-CLICK=exit")
 
    echo @gEcho
 
    gChain = ""
 
    unbind
 
 
    bind "ALT-LEFT-CLICK" "_pickAtom";
 
    bind "ALT-LEFT-CLICK" "+:toabChainMB";
 
    bind "DOUBLE" "plicoExit";
 
 
}
 
}
  
# 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