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

From Jmol
Jump to navigation Jump to search
(Adjust)
(Avoid "axis," a newly reserved word)
 
(10 intermediate revisions by the same user not shown)
Line 1: Line 1:
'''ToABnt''' allows the user to convert a polynucleotide chain from A-form to B-form and ''vice versa''.
+
'''ToABnt''' allows the user to convert a nucleotide or a polynucleotide chain or chain pair from A-form to B-form and ''vice versa''.
 +
 
 
When you ALT-CLICK on any atom, you are prompted to convert its chain from its current form to either the A-form or the B-form.  The two forms differ primarily in the pucker conformation of their sugar moieties. The A-form has its sugars in the C3'-endo conformation whereas the B-form has it in the C2'-endo conformation.  The A-form is characteristic of RNA while the B-form is characteristic of DNA.
 
When you ALT-CLICK on any atom, you are prompted to convert its chain from its current form to either the A-form or the B-form.  The two forms differ primarily in the pucker conformation of their sugar moieties. The A-form has its sugars in the C3'-endo conformation whereas the B-form has it in the C2'-endo conformation.  The A-form is characteristic of RNA while the B-form is characteristic of DNA.
 +
 +
When you SHIFT-CLICK on any atom, you are prompted to convert just the selected nucleotide.
  
 
This routine is called automatically by the Plico routine [[Recycling_Corner/DNA_Generator|Polymeraze]] when a polynucleotide is generated.
 
This routine is called automatically by the Plico routine [[Recycling_Corner/DNA_Generator|Polymeraze]] when a polynucleotide is generated.
Line 6: Line 9:
 
ToABnt 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:
 
ToABnt 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 toAB NT
 
<pre>Title=PLICO toAB NT
Script=script <path to your script directory>/toABnt.spt;plicotoABnt
+
Script=script <path to your script directory>/toABnt.spt;plico_to_ab_nt
 
</pre> saved as toABnt.macro in your .jmol/macros directory as described in [[Macro]].
 
</pre> saved as toABnt.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.
 
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
 
<pre>#  toABnt - Jmol script by Ron Mignery
#  v1.3 beta    4/29/2014 for Jmol 14 -check kNTcommon for auto
+
#  v1.13 beta    4/12/2016 -require latest common includes
 
#
 
#
#  Convert a polynucleotide chain from A-form to B-form or vice versa
+
#  Convert a nucleotide or polynucleotide chain
 +
from A-form to B-form or vice versa
 
#
 
#
kC5O5PO3B = -71.0
+
gToab = false
kO5PO3C3B = -106.0
+
gToabAlt = false
kPO3C3C4B = -160.67
+
gToA = false
kO3C3C4C5B = 125.44
+
gBusy = false
kC3C4C5O5B = 55.65
 
kC4C5O5PB = 169.0
 
 
 
kO4C4C3C2B = 15.92
 
kC4O4C1C2B = -41.7
 
kC4O4C1NxB = -159.03
 
kC5C4O4C1B = 146.31
 
kC3C1C2O2B = -167.9
 
 
 
kPuB = 59.0
 
kPyB = 61.0
 
 
 
kC5O5PO3A = -59.3
 
kO5PO3C3A = -63.1
 
kPO3C3C4A = -157.4
 
kO3C3C4C5A = 75.5
 
kC3C4C5O5A = 49.55
 
kC4C5O5PA = 169.2
 
 
 
kO4C4C3C2A = -35.55
 
kC4O4C1C2A = 3.8
 
kC4O4C1NxA = -117.4
 
kC5C4O4C1A = 144.85
 
kC3C1C2O2A = 116.3
 
 
 
kPuA = 13.5
 
kPyA = 16.5
 
  
gToab = FALSE
+
function to_ab_nt_auto(iChain, toA) {
gToabAlt = FALSE
 
gToA = FALSE
 
 
 
function toabNtAuto(iChain, toA) {
 
  
 
     # Load common functions if not already
 
     # Load common functions if not already
     loadCommon()
+
     load_common()
  
 
     gChain1 = iChain
 
     gChain1 = iChain
 
     gToA = toA
 
     gToA = toA
     toabNt(TRUE)
+
     to_ab_nt(true)
 
}
 
}
  
function toabNt(auto) {
+
function to_ab_single_nt(res, iChain) {
 +
    var f = {atomIndex=_atomPicked}.file
 +
    var m = {atomIndex=_atomPicked}.model
 +
    var isForm = (is_form_a( res, iChain) ? "A" : "B")
 +
    var p = prompt(format("Convert residue %d from %s-form to:",
 +
        res, isForm), "A-form|B-form|Cancel", true)
 +
    var toab = false
 +
    if (p == "A-form") {
 +
        toab = true
 +
    }
 +
    else if (p != "B-form") {
 +
        color {all} @gScheme
 +
        return # early exit
 +
    }
 +
   
 +
    # Call worker function
 +
    to_ab_nt_res(res, res+1, iChain, toab)
 +
}
 +
 
 +
function to_ab_nt(auto) {
 
     if (not gBusy) {
 
     if (not gBusy) {
         gBusy = TRUE
+
         gBusy = true
 +
        var toab = (gToA ? "A" : "B")
 
          
 
          
         select all
+
         var a = (gToA ? 24.0 : 33.3)
        g5cargoIdx = {(atomno=@{{chain=gChain1}.atomno.min})
+
         var s = (gToA ? 4.6 : 4.46)
            and (chain=gChain1)}.atomIndex
 
        g3cargoIdx = {(atomno=@{{chain=gChain1}.atomno.max})
 
            and (chain=gChain1)}.atomIndex
 
   
 
        # If new drag
 
        if (gNewDrag) {
 
            gNewDrag = FALSE
 
            save state gState
 
        }
 
   
 
        # Move the cargo
 
        select {gCargoSet}
 
        gChain1 = {atomIndex=g3cargoIdx}.chain
 
        gChain2 = ""
 
   
 
        # Move between A-form and B-form
 
         var res5 = {atomIndex=g5cargoIdx}.resno
 
        var res3 = {atomIndex=g3cargoIdx}.resno
 
        var pSet = ({})
 
        var bSet = ({})
 
        var k = -1
 
        var kmax = k
 
        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) {
 
                    var isForm = (isforma( i, gChain1) ? "A" : "B")
 
                    var 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
 
                    }
 
                    background ECHO pink
 
                    refresh
 
                    print format("Converting to %s", p)
 
                }
 
   
 
                # If paired
 
                var lcAtoms = (within(3.0, FALSE,
 
                    {(resno=i) and (chain=gChain1) and base})
 
                    and not {chain=gChain1})
 
                isP = (lcAtoms.size > 0)
 
                gChain2 = (isP ? lcAtoms[1].chain : "")
 
                k = (isP ? lcAtoms[1].resno : -1)
 
                kmax = k
 
            }
 
            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
 
            var aC4p = ({})
 
            var aC3p = ({})
 
            var aO3p = ({})
 
            var bO5p = ({})
 
            var bC4p = ({})
 
            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\'")}
 
                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
+
        var minres = get_resno_min(gChain1)
                    (atomno >= @{{atomIndex=g5cargoIdx}.atomno}) and (chain=gChain1)}
+
        var maxres = get_resno_max(gChain1)
                setDihedralAtoms(aP, aO3p, aC3p, aC4p, (gToA ? kPO3C3C4A : kPO3C3C4B))
+
        var a0 = within(kDtolerance, {0 0 0})
   
+
        if (auto == false) {
                 setDihedralAtoms(aO5, aP, aO3p, aC3p, (gToA ? kO5PO3C3A : kO5PO3C3B))
+
            var f = {atomIndex=_atomPicked}.file
   
+
            var m = {atomIndex=_atomPicked}.model
                select bSet or {(atomno < @{aO5.atomno}) and
+
            var isForm = (is_form_a( maxres, gChain1) ? "A" : "B")
                    (atomno >= @{{atomIndex=g5cargoIdx}.atomno}) and (chain=gChain1)}
+
            var p = prompt(format("Convert chain %s from %s-form to:",
                 setDihedralAtoms(aC5, aO5, aP, aO3p, (gToA ? kC5O5PO3A : kC5O5PO3B))
+
                 gChain1, isForm), "A-form|B-form|Cancel", true)
 +
            if (p == "A-form") {
 +
                toab = "A"
 +
                a = 24.0
 +
                 s = 4.6
 
             }
 
             }
             select bSet or {(atomno < @{aO5.atomno}) and
+
             else if (p == "B-form") {
                (atomno >= @{{atomIndex=g5cargoIdx}.atomno}) and (chain=gChain1)}
+
                 toab = "B"
            setDihedralAtoms(aC4, aC5, aO5, aP, (gToA ? kC4C5O5PA : kC4C5O5PB))
+
                 a = 33.3
            select (bP or (connected(bP) and {resno=k}))
+
                 s = 4.46
            setDihedralAtoms(bC4, bC5, bO5, bP, (gToA ? kC4C5O5PA : kC4C5O5PB))
 
   
 
            select bSet or {(atomno < @{aC5.atomno}) and
 
                (atomno >= @{{atomIndex=g5cargoIdx}.atomno}) and (chain=gChain1)}
 
            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)}
 
                or {(resno <= i) and (chain=gChain1)}) and not aO3)
 
            setDihedralAtoms(aO3, aC3, aC4, aC5, (gToA ? kO3C3C4C5A : kO3C3C4C5B))
 
            select bO3
 
            setDihedralAtoms(bC5, bC4, bC3, bO3, (gToA ? kO3C3C4C5A : kO3C3C4C5B))
 
   
 
   
 
            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 {
 
             else {
                 aNx =  {(resno=i) and (chain=gChain1) and (atomName="N1")}
+
                 color {all} @gScheme
                 aCx =  {(resno=i) and (chain=gChain1) and (atomName="C6")}
+
                 return # early exit
                bNx =  {(resno=k) and (chain=gChain2) and (atomName="N9")}
 
                bCx =  {(resno=k) and (chain=gChain2) and (atomName="C8")}
 
                ang = (gToA ? kPyA : kPyB)
 
                pang = (gToA ? kPuA : kPuB)
 
 
             }
 
             }
            select pSet or {(resno=i) and (chain=gChain1) and base}
+
        }
            setDihedralAtoms(aO4, aC1, aNx, aCx, ang)
+
        else {
            select {pSet and not base}
+
             gEcho = ""
            setDihedralAtoms(bCx, bNx, bC1, bO4, pang)
+
        }
   
+
        set echo TOP LEFT
            # Set pucker 3' endo or 2' endo
+
        background ECHO pink
             select pSet or {(resno=i) and (chain=gChain1) and base}
+
        var ps = "Converting to " + toab + " form..."
            setDihedralAtoms(aC4, aO4, aC1, aNx, (gToA ? kC4O4C1NxA : kC4O4C1NxB))
+
        echo @ps
            select {pSet and not base}
+
        refresh
            setDihedralAtoms(bNx, bC1, bO4, bC4, (gToA ? kC4O4C1NxA : kC4O4C1NxB))
+
       
   
+
        # Call worker function
            select (pSet or
+
        adjust_nts(minres, maxres, gChain1, toab, a, s)
                {((resno=i) and (chain=gChain1) and base) or aC1})
+
 
            setDihedralAtoms(aC5, aC4, aO4, aC1, (gToA ? kC5C4O4C1A : kC5C4O4C1B))
+
        select {thisModel}
            select {pSet and not base and not bC1}
+
        if (a0) {      
            setDihedralAtoms(bC1, bO4, bC4, bC5, (gToA ? kC5C4O4C1A : kC5C4O4C1B))
+
             translateSelected @{-a0.xyz}
   
+
         }
            select aC2 or aO2
 
            setDihedralAtoms(aC4, aO4, aC1, aC2, (gToA ? kC4O4C1C2A : kC4O4C1C2B))
 
            if (aO2.size > 0) {
 
                ang = (gToA ? kC3C1C2O2A : kC3C1C2O2B)
 
                setDihedralAtoms(aC3, aC1, aC2, aO2, (gToA ? kC3C1C2O2A : kC3C1C2O2B))
 
            }
 
            setDistanceAtoms(aC3, aC2, 1.52)
 
            setDistanceAtoms(aC1, aC2, 1.52)
 
            select bC2 or bO2
 
            setDihedralAtoms(bC4, bO4, bC1, bC2, (gToA ? kC4O4C1C2A : kC4O4C1C2B))
 
            if (bO2.size > 0) {
 
                ang = (gToA ? kC3C1C2O2A : kC3C1C2O2B)
 
                setDihedralAtoms(bC3, bC1, bC2, bO2, (gToA ? kC3C1C2O2A : kC3C1C2O2B))
 
            }
 
            setDistanceAtoms(bC3, bC2, 1.52)
 
            setDistanceAtoms(bC1, bC2, 1.52)
 
   
 
            refresh               
 
   
 
            bSet = bset or pSet
 
             if (k > 0) {
 
                k--
 
            }
 
   
 
         } # endfor
 
 
          
 
          
        gBusy = FALSE
 
 
         background ECHO yellow
 
         background ECHO yellow
         refresh
+
         echo @gEcho
 +
        gBusy = false
 
     }
 
     }
 +
   
 
}
 
}
  
# Bound to ALT-LEFT-CLICK by plicoToabNt
+
# Bound to ALT-LEFT-CLICK by plicoto_ab_nt
function toabChainMB() {
+
function to_ab_chain_mb() {
     color {all} @gScheme
+
     color {thisModel} @gScheme
 
     gChain1 = {atomIndex=_atomPicked}.chain
 
     gChain1 = {atomIndex=_atomPicked}.chain
     color {chain=gChain1} @gAltScheme
+
     color {(chain=gChain1) and thisModel} @gAltScheme
 +
    refresh
 +
    to_ab_nt(false)
 +
}
 +
 
 +
# Bound to SHIFT-LEFT-CLICK by plicoto_ab_nt
 +
function to_ab_res_mb() {
 +
    color {thisModel} @gScheme
 +
    iChain = {atomIndex=_atomPicked}.chain
 +
    res = {atomIndex=_atomPicked}.resno
 +
    color {(chain=iChain) and thisModel and (resno=res)} @gAltScheme
 
     refresh
 
     refresh
     toabNt(FALSE)
+
     to_ab_single_nt(res, iChain)
 
}
 
}
  
 
# Load common functions if not already
 
# Load common functions if not already
function loadCommon() {
+
function load_common() {
     if (kCommon < 1) {
+
     if (kCommon < 7) {
 
         script $SCRIPT_PATH$plicoCommon.spt
 
         script $SCRIPT_PATH$plicoCommon.spt
         if (kCommon < 1) {
+
         if (kCommon < 7) {
 
             prompt ("A newer version of plicoCommon.SPT is required")
 
             prompt ("A newer version of plicoCommon.SPT is required")
 
             quit
 
             quit
 
         }
 
         }
 
     }
 
     }
     if (kNTcommon < 1) {
+
     if (kNTcommon < 6) {
 
         script $SCRIPT_PATH$plicoNTcommon.spt
 
         script $SCRIPT_PATH$plicoNTcommon.spt
         if (kNTcommon < 1) {
+
         if (kNTcommon < 6) {
 
             prompt ("A newer version of plicoNTcommon.SPT is required")
 
             prompt ("A newer version of plicoNTcommon.SPT is required")
 
             quit
 
             quit
Line 293: Line 146:
 
}
 
}
  
# Top level of ToABnt
+
# Top level of to_ab_nt
function plicoToabNT() {
+
function plico_to_ab_nt() {
  
 
     # Load common functions if not already
 
     # Load common functions if not already
     loadCommon()
+
     if (kCommon < 7) {
 +
        script $SCRIPT_PATH$plicoCommon.spt
 +
        if (kCommon < 7) {
 +
            prompt ("A newer version of plicoCommon.SPT is required")
 +
            quit
 +
        }
 +
    }
 +
    if (kNTCommon < 6) {
 +
        script $SCRIPT_PATH$plicoCommon.spt
 +
        if (kCommon < 6) {
 +
            prompt ("A newer version of plicoNTcommon.SPT is required")
 +
            quit
 +
        }
 +
    }
  
 
     gPlico = "TO A-FORM/B-FORM"
 
     gPlico = "TO A-FORM/B-FORM"
     plicoPrelim()
+
     plico_prelim(false, true)
  
     gEcho = ("________A <==> B_______|ALT-CLICK=mark chain|DOUBLE-CLICK=exit")
+
     gEcho = ("________A <==> B_______|ALT-CLICK=convert chain" +
 +
        "|SHIFT-CLICK=convert NT|SHIFT-DOUBLE-CLICK=exit")
 
     echo @gEcho
 
     echo @gEcho
    gChain = ""
 
    unbind
 
  
 
     bind "ALT-LEFT-CLICK" "_pickAtom";
 
     bind "ALT-LEFT-CLICK" "_pickAtom";
     bind "ALT-LEFT-CLICK" "+:toabChainMB";
+
     bind "ALT-LEFT-CLICK" "+:to_ab_chain_mb";
     bind "DOUBLE" "plicoExit";
+
     bind "SHIFT-LEFT-CLICK" "_pickAtom";
 +
    bind "SHIFT-LEFT-CLICK" "+:to_ab_res_mb";
 +
    bind "SHIFT-DOUBLE" "plico_exit(true)";
 +
    bind "LEFT-CLICK" "+:plico_menu_toggle";
 
}
 
}
# End of TOABNT.SPT
+
# End of to_ab_nt.SPT
 
</pre>
 
</pre>

Latest revision as of 17:05, 12 April 2016

ToABnt allows the user to convert a nucleotide or a polynucleotide chain or chain pair from A-form to B-form and vice versa.

When you ALT-CLICK on any atom, you are prompted to convert its chain from its current form to either the A-form or the B-form. The two forms differ primarily in the pucker conformation of their sugar moieties. The A-form has its sugars in the C3'-endo conformation whereas the B-form has it in the C2'-endo conformation. The A-form is characteristic of RNA while the B-form is characteristic of DNA.

When you SHIFT-CLICK on any atom, you are prompted to convert just the selected nucleotide.

This routine is called automatically by the Plico routine Polymeraze when a polynucleotide is generated.

ToABnt 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 toAB NT
Script=script <path to your script directory>/toABnt.spt;plico_to_ab_nt

saved as toABnt.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.

#   toABnt - Jmol script by Ron Mignery
#   v1.13 beta    4/12/2016 -require latest common includes
#
#   Convert a nucleotide or polynucleotide chain
#   from A-form to B-form or vice versa
#
gToab = false
gToabAlt = false
gToA = false
gBusy = false

function to_ab_nt_auto(iChain, toA) {

    # Load common functions if not already
    load_common()

    gChain1 = iChain
    gToA = toA
    to_ab_nt(true)
}

function to_ab_single_nt(res, iChain) {
    var f = {atomIndex=_atomPicked}.file
    var m = {atomIndex=_atomPicked}.model
    var isForm = (is_form_a( res, iChain) ? "A" : "B")
    var p = prompt(format("Convert residue %d from %s-form to:",
        res, isForm), "A-form|B-form|Cancel", true)
    var toab = false
    if (p == "A-form") {
        toab = true
    }
    else if (p != "B-form") {
        color {all} @gScheme
        return # early exit
    }
    
    # Call worker function
    to_ab_nt_res(res, res+1, iChain, toab)
}

function to_ab_nt(auto) {
    if (not gBusy) {
        gBusy = true
        var toab = (gToA ? "A" : "B")
        
        var a = (gToA ? 24.0 : 33.3)
        var s = (gToA ? 4.6 : 4.46)

        var minres = get_resno_min(gChain1)
        var maxres = get_resno_max(gChain1)
        var a0 = within(kDtolerance, {0 0 0})
        if (auto == false) {
            var f = {atomIndex=_atomPicked}.file
            var m = {atomIndex=_atomPicked}.model
            var isForm = (is_form_a( maxres, gChain1) ? "A" : "B")
            var p = prompt(format("Convert chain %s from %s-form to:",
                gChain1, isForm), "A-form|B-form|Cancel", true)
            if (p == "A-form") {
                toab = "A"
                a = 24.0
                s = 4.6
            }
            else if (p == "B-form") {
                toab = "B"
                a = 33.3
                s = 4.46
            }
            else {
                color {all} @gScheme
                return # early exit
            }
        }
        else {
            gEcho = ""
        }
        set echo TOP LEFT
        background ECHO pink
        var ps = "Converting to " + toab + " form..."
        echo @ps
        refresh
        
        # Call worker function
        adjust_nts(minres, maxres, gChain1, toab, a, s)

        select {thisModel}
        if (a0) {        
            translateSelected @{-a0.xyz}
        }
        
        background ECHO yellow
        echo @gEcho
        gBusy = false
    }
    
}

# Bound to ALT-LEFT-CLICK by plicoto_ab_nt
function to_ab_chain_mb() {
    color {thisModel} @gScheme
    gChain1 = {atomIndex=_atomPicked}.chain
    color {(chain=gChain1) and thisModel} @gAltScheme
    refresh
    to_ab_nt(false)
}

# Bound to SHIFT-LEFT-CLICK by plicoto_ab_nt
function to_ab_res_mb() {
    color {thisModel} @gScheme
    iChain = {atomIndex=_atomPicked}.chain
    res = {atomIndex=_atomPicked}.resno
    color {(chain=iChain) and thisModel and (resno=res)} @gAltScheme
    refresh
    to_ab_single_nt(res, iChain)
}

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

# Top level of to_ab_nt
function plico_to_ab_nt() {

    # 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
        }
    }
    if (kNTCommon < 6) {
        script $SCRIPT_PATH$plicoCommon.spt
        if (kCommon < 6) {
            prompt ("A newer version of plicoNTcommon.SPT is required")
            quit
        }
    }

    gPlico = "TO A-FORM/B-FORM"
    plico_prelim(false, true)

    gEcho = ("________A <==> B_______|ALT-CLICK=convert chain" +
        "|SHIFT-CLICK=convert NT|SHIFT-DOUBLE-CLICK=exit")
    echo @gEcho

    bind "ALT-LEFT-CLICK" "_pickAtom";
    bind "ALT-LEFT-CLICK" "+:to_ab_chain_mb";
    bind "SHIFT-LEFT-CLICK" "_pickAtom";
    bind "SHIFT-LEFT-CLICK" "+:to_ab_res_mb";
    bind "SHIFT-DOUBLE" "plico_exit(true)";
    bind "LEFT-CLICK" "+:plico_menu_toggle";
}
# End of to_ab_nt.SPT

Contributors

Remig