Difference between revisions of "User:Remig/plico/toab"
< User:Remig | plico
Jump to navigation
Jump to search
m |
(Handle multi-frame environment) |
||
Line 6: | Line 6: | ||
</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]]. | ||
− | A copy of the Plico | + | 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. |
Copy and paste the following into a text editor and save in your scripts directory as toab.spt. | Copy and paste the following into a text editor and save in your scripts directory as toab.spt. | ||
<pre># toAlphBeta - Jmol script by Ron Mignery | <pre># toAlphBeta - Jmol script by Ron Mignery | ||
− | # v1. | + | # v1.3 beta 7/22/2014 -handle multi-frame environment |
# | # | ||
# Move a stretch of polypeptide from alpha to beta or vice versa | # Move a stretch of polypeptide from alpha to beta or vice versa | ||
# | # | ||
− | gToab = | + | gToab = false |
− | gToabAlt = | + | gToabAlt = false |
+ | gBusy = false | ||
# Bound to LEFT-UP by to_ab_enable_drag | # Bound to LEFT-UP by to_ab_enable_drag | ||
Line 21: | Line 22: | ||
if (not gToabAlt) { | if (not gToabAlt) { | ||
if (gNanchorIdx >= 0) { | if (gNanchorIdx >= 0) { | ||
− | + | tug_drag_done_mb() | |
} | } | ||
} | } | ||
else { | else { | ||
if (gCanchorIdx >= 0) { | if (gCanchorIdx >= 0) { | ||
− | + | tug_drag_done_mb() | |
} | } | ||
} | } | ||
Line 33: | Line 34: | ||
# Bound to ALT-SHIFT-LEFT-DRAG by to_ab_enable_drag | # Bound to ALT-SHIFT-LEFT-DRAG by to_ab_enable_drag | ||
function to_ab_drag_2_mb() { | function to_ab_drag_2_mb() { | ||
− | gToabAlt = | + | gToabAlt = true |
to_ab_drag() | to_ab_drag() | ||
} | } | ||
# Bound to ALT-LEFT-DRAG by to_ab_enable_drag | # Bound to ALT-LEFT-DRAG by to_ab_enable_drag | ||
− | function | + | function to_ab_drag_mb() { |
− | gToabAlt = | + | gToabAlt = false |
to_ab_drag() | 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() { | function to_ab_drag() { | ||
+ | var f = (_frameID/1000000) | ||
+ | var m = (_frameID%1000000) | ||
if (not gBusy) { | if (not gBusy) { | ||
− | gBusy = | + | 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 52: | Line 62: | ||
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) { | ||
Line 72: | Line 82: | ||
# If new drag | # If new drag | ||
if (gNewDrag) { | if (gNewDrag) { | ||
− | gNewDrag = | + | gNewDrag = false |
save state gState | save state gState | ||
} | } | ||
Line 81: | Line 91: | ||
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 | + | var cmin = {(chain=gChain) and (file=f) and (model=m)}.atomno.min |
− | + | var cmax = {(chain=gChain) and (file=f) and (model=m)}.atomno.max | |
− | var maxIdx = {(atomno= | + | var maxIdx = {(atomno=cmax) and (chain=gchain) and (file=f) |
− | and ( | + | and (model=m)}.atomIndex |
− | var minIdx = {(atomno= | + | var minIdx = {(atomno=cmin) and (chain=gchain) and (file=f) |
− | and ( | + | and (model=m)}.atomIndex |
− | while ( | + | while (true) { |
− | + | ||
# Adjust phi | # Adjust phi | ||
− | var ncIdx = | + | var ncIdx = get_nward_bb_idx(nIdx, gChain) |
− | var caIdx = | + | var caIdx = get_cward_bb_idx(nIdx, gChain) |
− | var cIdx = | + | var cIdx = get_cward_bb_idx(caIdx, gChain) |
var dh= angle({atomIndex=ncIdx}, {atomIndex=nIdx}, | var dh= angle({atomIndex=ncIdx}, {atomIndex=nIdx}, | ||
− | {atomIndex=caIdx}, {atomIndex=cIdx}) | + | {atomIndex=caIdx}, {atomIndex=cIdx}) |
var dir = ((phi > dh) ? abs(8*dx) : -(abs(8*dx))) | var dir = ((phi > dh) ? abs(8*dx) : -(abs(8*dx))) | ||
if (not gToabAlt) { | if (not gToabAlt) { | ||
− | + | select_nward_idx(nIdx, ((gNanchorIdx >= 0) ? gNcargoIdx : minIdx)) | |
} | } | ||
else { | else { | ||
− | + | select_cward_idx(caIdx, ((gCanchorIdx >= 0) ? gCcargoIdx : maxIdx)) | |
} | } | ||
if (abs(phi-dh) > 0.5) { | if (abs(phi-dh) > 0.5) { | ||
− | + | rotate_selected_record(caIdx, {atomIndex=nIdx}, dir) | |
} | } | ||
− | + | ||
# Adjust psi | # Adjust psi | ||
− | var cnIdx = | + | 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) { | ||
− | + | select_nward_idx(caIdx, ((gNanchorIdx >= 0) ? gNcargoIdx : minIdx)) | |
} | } | ||
else { | else { | ||
− | + | select_cward_idx(cIdx, ((gCanchorIdx >= 0) ? gCcargoIdx : maxIdx)) | |
} | } | ||
if (abs(psi-dh) > 0.5) { | if (abs(psi-dh) > 0.5) { | ||
− | + | rotate_selected_record(cIdx, {atomIndex=caIdx}, dir) | |
} | } | ||
− | + | ||
if (gCcargoIdx== cIdx) { | if (gCcargoIdx== cIdx) { | ||
break | break | ||
Line 129: | Line 141: | ||
nIdx = cnIdx | nIdx = cnIdx | ||
} # endwhile | } # endwhile | ||
− | + | ||
} | } | ||
− | + | ||
gMouseX = _mouseX | gMouseX = _mouseX | ||
gMouseY = _mouseY | gMouseY = _mouseY | ||
} | } | ||
− | + | ||
select {gCargoSet} | select {gCargoSet} | ||
− | var lcset = (within(kCtolerance, | + | var lcset = (within(kCtolerance, false, {selected}) |
and not {selected} and not connected({selected})) | and not {selected} and not connected({selected})) | ||
− | gOk2 = | + | gOk2 = true |
if (lcset.size > 0) { | if (lcset.size > 0) { | ||
for (var i = 1; i <= lcset.size; i++) { | for (var i = 1; i <= lcset.size; i++) { | ||
Line 147: | Line 159: | ||
var bkc = (gOk2 ? "yellow" : "pink") | var bkc = (gOk2 ? "yellow" : "pink") | ||
background ECHO @bkc | background ECHO @bkc | ||
− | + | ||
− | + | ||
− | gBusy = | + | gBusy = false |
} | } | ||
} | } | ||
− | # Called by | + | # Called by to_ab_cargo_mb when gToab is true |
function to_ab_enable_drag() { | 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" + | ||
Line 160: | Line 172: | ||
# Allow atoms to be dragged | # Allow atoms to be dragged | ||
− | bind "ALT-LEFT-DOWN" " | + | bind "ALT-LEFT-DOWN" "tug_mark_mb"; |
− | bind "ALT-LEFT-UP" " | + | bind "ALT-LEFT-UP" "tug_drag_done_mb"; |
− | bind "ALT-LEFT-DRAG" " | + | bind "ALT-LEFT-DRAG" "to_ab_drag_mb"; |
bind "ALT-SHIFT-LEFT-UP" "to_ab_drag_done_mb"; | bind "ALT-SHIFT-LEFT-UP" "to_ab_drag_done_mb"; | ||
bind "ALT-SHIFT-LEFT-DRAG" "to_ab_drag_2_mb"; | bind "ALT-SHIFT-LEFT-DRAG" "to_ab_drag_2_mb"; | ||
Line 168: | Line 180: | ||
unbind "SHIFT-LEFT-CLICK" | unbind "SHIFT-LEFT-CLICK" | ||
bind "SHIFT-LEFT-CLICK" "_pickAtom"; | bind "SHIFT-LEFT-CLICK" "_pickAtom"; | ||
− | bind "SHIFT-LEFT-CLICK" "+: | + | bind "SHIFT-LEFT-CLICK" "+:tug_anchor_mb"; |
} | } | ||
Line 175: | Line 187: | ||
function to_ab_cargo_mb() { | function to_ab_cargo_mb() { | ||
print "to_ab_cargo_mb()"#TBD | print "to_ab_cargo_mb()"#TBD | ||
− | gToab = | + | gToab = true |
− | + | tug_cargo_mb | |
} | } | ||
Line 182: | Line 194: | ||
function plico_to_ab() { | function plico_to_ab() { | ||
− | # Load | + | # Load common functions if not already |
+ | if (kCommon < 3) { | ||
+ | script $SCRIPT_PATH$plicoCommon.spt | ||
+ | if (kCommon < 3) { | ||
+ | prompt ("A newer version of plicoCommon.SPT is required") | ||
+ | quit | ||
+ | } | ||
+ | } | ||
if (kTug < 3) { | if (kTug < 3) { | ||
script $SCRIPT_PATH$tug.spt | script $SCRIPT_PATH$tug.spt | ||
Line 190: | Line 209: | ||
} | } | ||
} | } | ||
− | + | ||
gPlico = "TO ALPHA/BETA" | gPlico = "TO ALPHA/BETA" | ||
− | plico_prelim( | + | plico_prelim(true) |
− | + | ||
gEcho = ("____Alpha <==> Beta____|ALT-CLICK=mark block|DOUBLE-CLICK=exit") | gEcho = ("____Alpha <==> Beta____|ALT-CLICK=mark block|DOUBLE-CLICK=exit") | ||
echo @gEcho | echo @gEcho |
Revision as of 19:32, 22 July 2014
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.
# toAlphBeta - Jmol script by Ron Mignery # v1.3 beta 7/22/2014 -handle multi-frame environment # # Move a stretch of polypeptide from alpha to beta or vice versa # 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() { var f = (_frameID/1000000) var m = (_frameID%1000000) 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") { 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 (file=f) and (model=m)}.atomno.min var cmax = {(chain=gChain) and (file=f) and (model=m)}.atomno.max var maxIdx = {(atomno=cmax) and (chain=gchain) and (file=f) and (model=m)}.atomIndex var minIdx = {(atomno=cmin) and (chain=gchain) and (file=f) and (model=m)}.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) 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.size > 0) { for (var i = 1; i <= lcset.size; i++) { handleCollisions2(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() { print "to_ab_cargo_mb()"#TBD gToab = true tug_cargo_mb } # Top level of ToAlphaBeta function plico_to_ab() { # Load common functions if not already if (kCommon < 3) { script $SCRIPT_PATH$plicoCommon.spt if (kCommon < 3) { prompt ("A newer version of plicoCommon.SPT is required") quit } } 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) gEcho = ("____Alpha <==> Beta____|ALT-CLICK=mark block|DOUBLE-CLICK=exit") echo @gEcho gChain = "" unbind bind "ALT-LEFT-CLICK" "_pickAtom"; bind "ALT-LEFT-CLICK" "+:to_ab_cargo_mb"; bind "DOUBLE" "plico_exit"; } # End of TOAB.SPT