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

From Jmol
Jump to navigation Jump to search
m
(Add multi-frame support)
Line 1: Line 1:
'''ToABnt''' allows the user to convert a polynucleotide chain or chain pair from A-form to B-form and ''vice versa''.
+
'''ToABnt''' allows the user to convert a polynucleotide chain or chain pair from A-form to B-form and ''vice versa''.  Both chains are converted in double helixes.
 
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.
  
Line 11: Line 11:
 
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.7 beta    6/11/2014 -bug fix
+
#  v1.8 beta    7/11/2014 -add multi-frame support
 
#
 
#
 
#  Convert a polynucleotide chain from A-form to B-form or vice versa
 
#  Convert a polynucleotide chain from A-form to B-form or vice versa
Line 33: Line 33:
 
     if (not gBusy) {
 
     if (not gBusy) {
 
         gBusy = TRUE
 
         gBusy = TRUE
          
+
         var f = (_frameID/1000000)
         select all
+
         var m = (_frameID%1000000)
         g5cargoIdx = {(atomno=@{{chain=gChain1}.atomno.min})
+
         var toab = (gToA ? "A" : "B")
            and (chain=gChain1)}.atomIndex
+
        var a = (gToA ? 20.8 : 19.3)
         g3cargoIdx = {(atomno=@{{chain=gChain1}.atomno.max})
+
        var s = (gToA ? 4.44 : 4.73)
            and (chain=gChain1)}.atomIndex
+
 
   
+
        var minres = {(chain=gChain1) and (file=f)and (model=m)}.resno.min
         # If new drag
+
         var maxres = {(chain=gChain1) and (file=f)and (model=m)}.resno.max
         if (gNewDrag) {
+
        var maxP = atom_rcn(maxres, gChain1, "P")
             gNewDrag = FALSE
+
        var cp = maxP.xyz
            save state gState
+
         var w = array()
 +
         for (var i = maxres-1; i <= minres; i--) {
 +
             w += who_pairs(i, gChain1)
 
         }
 
         }
   
+
         if (auto == FALSE) {
        # Move the cargo
+
            var isForm = (is_form_a( maxres, gChain1) ? "A" : "B")
        select {gCargoSet}
+
            var p = prompt(format("Convert chain %s from %s-form to:",
        gChain1 = {atomIndex=g3cargoIdx}.chain
+
                gChain1, isForm), "A-form|B-form", TRUE)
        gChain2 = ""
+
            if (p == "A-form") {
   
+
                 toab = "A"
        # Move between A-form and B-form
+
                 a = 20.8
        var res5 = {atomIndex=g5cargoIdx}.resno
+
                 s = 4.44
        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 = (is_form_a( 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 w = who_pairs(i, gChain1)
 
                k = w[1]
 
                isP = (k > 0)
 
                gChain2 = (isP ? w[2] : "")
 
                 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
 
                    (atomno >= @{{atomIndex=g5cargoIdx}.atomno}) and (chain=gChain1)}
 
                 set_dihedral_atoms(aP, aO3p, aC3p, aC4p, (gToA ? kPO3C3C4A : kPO3C3C4B))
 
   
 
                set_dihedral_atoms(aO5, aP, aO3p, aC3p, (gToA ? kO5PO3C3A : kO5PO3C3B))
 
   
 
                select bSet or {(atomno < @{aO5.atomno}) and
 
                    (atomno >= @{{atomIndex=g5cargoIdx}.atomno}) and (chain=gChain1)}
 
                set_dihedral_atoms(aC5, aO5, aP, aO3p, (gToA ? kC5O5PO3A : kC5O5PO3B))
 
 
             }
 
             }
             select bSet or {(atomno < @{aO5.atomno}) and
+
             else if (p == "B-form") {
                (atomno >= @{{atomIndex=g5cargoIdx}.atomno}) and (chain=gChain1)}
+
                 toab = "B"
            set_dihedral_atoms(aC4, aC5, aO5, aP, (gToA ? kC4C5O5PA : kC4C5O5PB))
+
                 a = 19.3
            select (bP or (connected(bP) and {resno=k}))
+
                 s = 4.73
            set_dihedral_atoms(bC4, bC5, bO5, bP, (gToA ? kC4C5O5PA : kC4C5O5PB))
 
   
 
            select bSet or {(atomno < @{aC5.atomno}) and
 
                (atomno >= @{{atomIndex=g5cargoIdx}.atomno}) and (chain=gChain1)}
 
            set_dihedral_atoms(aC3, aC4, aC5, aO5, (gToA ? kC3C4C5O5A : kC3C4C5O5B))
 
            select (bP or (connected(bP) and {resno=k}))
 
            set_dihedral_atoms(bC3, bC4, bC5, bO5, (gToA ? kC3C4C5O5A : kC3C4C5O5B))
 
   
 
            select (({(resno >= k) and (chain=gChain2)}
 
                or {(resno <= i) and (chain=gChain1)}) and not aO3)
 
            set_dihedral_atoms(aO3, aC3, aC4, aC5, (gToA ? kO3C3C4C5A : kO3C3C4C5B))
 
            select bO3
 
            set_dihedral_atoms(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}
+
             background ECHO pink
             set_dihedral_atoms(aO4, aC1, aNx, aCx, ang)
+
             refresh
             select {pSet and not base}
+
             print format("Converting to %s", p)
            set_dihedral_atoms(bCx, bNx, bC1, bO4, pang)
+
        }
   
+
        adjust_nts(minres, maxres, gChain1, toab, a, s)
            # Set pucker 3' endo or 2' endo
+
        select {(file=f)and (model=m)}
            select pSet or {(resno=i) and (chain=gChain1) and base}
+
        var v = cp - maxP.xyz
            set_dihedral_atoms(aC4, aO4, aC1, aNx, (gToA ? kC4O4C1NxA : kC4O4C1NxB))
+
         translateSelected @v
            select {pSet and not base}
 
            set_dihedral_atoms(bNx, bC1, bO4, bC4, (gToA ? kC4O4C1NxA : kC4O4C1NxB))
 
   
 
            select (pSet or
 
                {((resno=i) and (chain=gChain1) and base) or aC1})
 
            set_dihedral_atoms(aC5, aC4, aO4, aC1, (gToA ? kC5C4O4C1A : kC5C4O4C1B))
 
            select {pSet and not base and not bC1}
 
            set_dihedral_atoms(bC1, bO4, bC4, bC5, (gToA ? kC5C4O4C1A : kC5C4O4C1B))
 
   
 
            select aC2 or aO2
 
            set_dihedral_atoms(aC4, aO4, aC1, aC2, (gToA ? kC4O4C1C2A : kC4O4C1C2B))
 
            if (aO2.size > 0) {
 
                ang = (gToA ? kC3C1C2O2A : kC3C1C2O2B)
 
                set_dihedral_atoms(aC3, aC1, aC2, aO2, (gToA ? kC3C1C2O2A : kC3C1C2O2B))
 
            }
 
            set_distance_atoms(aC3, aC2, 1.52)
 
            set_distance_atoms(aC1, aC2, 1.52)
 
            select bC2 or bO2
 
            set_dihedral_atoms(bC4, bO4, bC1, bC2, (gToA ? kC4O4C1C2A : kC4O4C1C2B))
 
            if (bO2.size > 0) {
 
                ang = (gToA ? kC3C1C2O2A : kC3C1C2O2B)
 
                set_dihedral_atoms(bC3, bC1, bC2, bO2, (gToA ? kC3C1C2O2A : kC3C1C2O2B))
 
            }
 
            set_distance_atoms(bC3, bC2, 1.52)
 
            set_distance_atoms(bC1, bC2, 1.52)
 
   
 
            refresh               
 
   
 
            bSet = bset or pSet
 
            if (k > 0) {
 
                k--
 
            }
 
   
 
        } # endfor i
 
       
 
        gBusy = FALSE
 
         background ECHO yellow
 
        refresh
 
 
     }
 
     }
 
}
 
}
Line 235: Line 78:
 
# Bound to ALT-LEFT-CLICK by plicoto_ab_nt
 
# Bound to ALT-LEFT-CLICK by plicoto_ab_nt
 
function to_ab_chain_mb() {
 
function to_ab_chain_mb() {
     color {all} @gScheme
+
     color {(file=f)and (model=m)} @gScheme
 
     gChain1 = {atomIndex=_atomPicked}.chain
 
     gChain1 = {atomIndex=_atomPicked}.chain
     color {chain=gChain1} @gAltScheme
+
     color {(chain=gChain1) and (file=f)and (model=m)} @gAltScheme
 
     refresh
 
     refresh
 
     to_ab_nt(FALSE)
 
     to_ab_nt(FALSE)

Revision as of 14:09, 16 July 2014

ToABnt allows the user to convert a polynucleotide chain or chain pair from A-form to B-form and vice versa. Both chains are converted in double helixes. 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.

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.8 beta    7/11/2014 -add multi-frame support
#
#   Convert a 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_nt(auto) {
    if (not gBusy) {
        gBusy = TRUE
        var f = (_frameID/1000000)
        var m = (_frameID%1000000)
        var toab = (gToA ? "A" : "B")
        var a = (gToA ? 20.8 : 19.3)
        var s = (gToA ? 4.44 : 4.73)

        var minres = {(chain=gChain1) and (file=f)and (model=m)}.resno.min
        var maxres = {(chain=gChain1) and (file=f)and (model=m)}.resno.max
        var maxP = atom_rcn(maxres, gChain1, "P")
        var cp = maxP.xyz
        var w = array()
        for (var i = maxres-1; i <= minres; i--) {
            w += who_pairs(i, gChain1)
        }
        if (auto == FALSE) {
            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", TRUE)
            if (p == "A-form") {
                toab = "A"
                a = 20.8
                s = 4.44
            }
            else if (p == "B-form") {
                toab = "B"
                a = 19.3
                s = 4.73
            }
            else {
                color {all} @gScheme
                return # early exit
            }
            background ECHO pink
            refresh
            print format("Converting to %s", p)
        }
        adjust_nts(minres, maxres, gChain1, toab, a, s)
        select {(file=f)and (model=m)}
        var v = cp - maxP.xyz
        translateSelected @v
    }
}

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

# Load common functions if not already
function load_common() {
    if (kCommon < 2) {
        script $SCRIPT_PATH$plicoCommon.spt
        if (kCommon < 2) {
            prompt ("A newer version of plicoCommon.SPT is required")
            quit
        }
    }
    if (kNTcommon < 3) {
        script $SCRIPT_PATH$plicoNTcommon.spt
        if (kNTcommon < 3) {
            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
    load_common()

    gPlico = "TO A-FORM/B-FORM"
    plico_prelim(FALSE)

    gEcho = ("________A <==> B_______|ALT-CLICK=mark chain|DOUBLE-CLICK=exit")
    echo @gEcho
    gChain = ""
    unbind

    bind "ALT-LEFT-CLICK" "_pickAtom";
    bind "ALT-LEFT-CLICK" "+:to_ab_chain_mb";
    bind "DOUBLE" "plico_exit";
}
# End of to_ab_nt.SPT

Contributors

Remig