Difference between revisions of "User:Remig/plico/remap"
(Handle multiple frames) |
m |
||
(4 intermediate revisions by the same user not shown) | |||
Line 13: | Line 13: | ||
Copy and paste the following to a text editor and save to your scripts directory as remap.spt: | Copy and paste the following to a text editor and save to your scripts directory as remap.spt: | ||
<pre># remap - Jmol script by Ron Mignery | <pre># remap - Jmol script by Ron Mignery | ||
− | # v1. | + | # v1.10 beta 4/12/2016 -require latest common includes |
# | # | ||
# Calculate or change polypeptide chain, atom number, residue names and/or residue | # Calculate or change polypeptide chain, atom number, residue names and/or residue | ||
# numbers and print the resultant 1 char string | # numbers and print the resultant 1 char string | ||
# | # | ||
− | gAppendNew = | + | gAppendNew = false |
− | gBusy = | + | gBusy = false |
# Search for N-C-C-0 | # Search for N-C-C-0 | ||
Line 49: | Line 49: | ||
select {atomIndex=aIdx} | select {atomIndex=aIdx} | ||
− | var | + | var sSet = {selected} |
− | while ( | + | while (sSet) { |
− | for (var i = 1; i <= | + | for (var i = 1; i <= sSet.size; i++) { |
− | var idx = | + | var idx = sSet[i].atomIndex |
var caIdx = get_bb_nward_ca_idx(idx) | var caIdx = get_bb_nward_ca_idx(idx) | ||
if (caIdx >= 0) { | if (caIdx >= 0) { | ||
− | + | var cset = connected({atomIndex=idx}) and not {hydrogen} | |
− | return idx | + | var ccset = connected(cset) and not {hydrogen} |
+ | if (cset.size < 2) { | ||
+ | return idx #*** | ||
+ | } | ||
+ | else if (({ccset and {carbon}}.size = 3) and (ccset.size == 4)) { | ||
+ | return idx #*** | ||
} | } | ||
} | } | ||
− | } | + | } # endfor |
− | + | ||
− | select {selected} or | + | sSet = connected({selected}) and not {selected} and not {hydrogen} |
− | } | + | select {selected} or sSet |
+ | } # endwhile | ||
+ | |||
return -1 | return -1 | ||
} | } | ||
Line 68: | Line 75: | ||
# Bound to ALT-LEFT-CLICK by plico_remap | # Bound to ALT-LEFT-CLICK by plico_remap | ||
function remap_cargo_mb() { | function remap_cargo_mb() { | ||
− | |||
− | |||
var idx =_atomPicked | var idx =_atomPicked | ||
Line 78: | Line 83: | ||
# If n-terminal N can be found | # If n-terminal N can be found | ||
var n0idx = find_n0_idx(idx) | var n0idx = find_n0_idx(idx) | ||
− | var isValid = | + | var isValid = false |
var newResno = 1 | var newResno = 1 | ||
var newChain = "A" | var newChain = "A" | ||
Line 85: | Line 90: | ||
# Prompt for new designators | # Prompt for new designators | ||
+ | var f = {atomIndex=n0idx}.file | ||
+ | var m = {atomIndex=n0idx}.model | ||
var iResno = {atomIndex=n0idx}.resno | var iResno = {atomIndex=n0idx}.resno | ||
var iChain = {atomIndex=n0idx}.chain | var iChain = {atomIndex=n0idx}.chain | ||
var iNo = {atomIndex=n0idx}.atomno | var iNo = {atomIndex=n0idx}.atomno | ||
− | select {(chain=iChain) and | + | select {thisModel} |
+ | color {selected} @gScheme | ||
+ | select {(chain=iChain) and thisModel} | ||
color {selected} @gAltScheme | color {selected} @gAltScheme | ||
refresh | refresh | ||
Line 108: | Line 117: | ||
and (newChain.size == 1) | and (newChain.size == 1) | ||
and (newAtomno > 0)) { | and (newAtomno > 0)) { | ||
− | isValid = | + | isValid = true |
} | } | ||
} | } | ||
Line 116: | Line 125: | ||
if (isValid) { | if (isValid) { | ||
− | delete {hydrogen and | + | delete {hydrogen and thisModel} |
− | delete {hoh and | + | delete {hoh and thisModel} |
− | delete %B and | + | delete %B and thisModel |
ssbonds off | ssbonds off | ||
Line 133: | Line 142: | ||
var newGreek = "" | var newGreek = "" | ||
var newCount = "" | var newCount = "" | ||
− | var isCB = | + | var isCB = false |
var nIdx = n0idx | var nIdx = n0idx | ||
var proDidx = -1 | var proDidx = -1 | ||
var oxtIdx = -1 | var oxtIdx = -1 | ||
− | while ((nIdx >= n0idx) or (cSet | + | while ((nIdx >= n0idx) or (cSet)) { |
var s = array(1, 2, 3) | var s = array(1, 2, 3) | ||
var pTrp = 0 | var pTrp = 0 | ||
Line 150: | Line 159: | ||
s1 = "X" | s1 = "X" | ||
newAtomName = "N" | newAtomName = "N" | ||
− | isCB = | + | isCB = false |
} | } | ||
else if (cSet.size == 1) { | else if (cSet.size == 1) { | ||
Line 250: | Line 259: | ||
else { | else { | ||
proDidx = cSet[i].atomIndex | proDidx = cSet[i].atomIndex | ||
− | cSet[i].selected = | + | cSet[i].selected = false |
} | } | ||
} | } | ||
Line 277: | Line 286: | ||
} | } | ||
else { # CB | else { # CB | ||
− | isCB = | + | isCB = true |
− | cSet[i].selected = | + | cSet[i].selected = false |
cSet = (cSet and not cSet[i]) | cSet = (cSet and not cSet[i]) | ||
continue | continue | ||
Line 293: | Line 302: | ||
nIdx = cSet[i].atomIndex | nIdx = cSet[i].atomIndex | ||
} | } | ||
− | cSet[i].selected = | + | cSet[i].selected = false |
} | } | ||
else { | else { | ||
Line 309: | Line 318: | ||
if (cSet[i].element != "C") { | if (cSet[i].element != "C") { | ||
nIdx = cSet[i].atomIndex | nIdx = cSet[i].atomIndex | ||
− | cSet[i].selected = | + | cSet[i].selected = false |
continue | continue | ||
} | } | ||
Line 330: | Line 339: | ||
else if (newAtomName == "XD") { # LEU ASP ASN | else if (newAtomName == "XD") { # LEU ASP ASN | ||
var cTrp = (connected(cSet[2]) and not {selected}) | var cTrp = (connected(cSet[2]) and not {selected}) | ||
− | var sTrp = ((trp | + | var sTrp = ((trp) ? (trp[1].element=="N") : false) |
if ((cSet[2].element != "C") or sTrp | if ((cSet[2].element != "C") or sTrp | ||
or ((connected(cSet[1]) and not {selected}).size == 0)) { | or ((connected(cSet[1]) and not {selected}).size == 0)) { | ||
− | bRev = | + | bRev = true |
} | } | ||
if ((cSet[2].element == "O") or (cSet[1].element == "N") | if ((cSet[2].element == "O") or (cSet[1].element == "N") | ||
or ((cSet[1].element == "C") and (cSet[2].element != "C"))) { | or ((cSet[1].element == "C") and (cSet[2].element != "C"))) { | ||
− | bRev = | + | bRev = true |
} | } | ||
if (hasN) { | if (hasN) { | ||
Line 365: | Line 374: | ||
if ((cSet[2].element == "O") or (cSet[1].element == "N") | if ((cSet[2].element == "O") or (cSet[1].element == "N") | ||
or ((cSet[1].element == "C") and (cSet[2].element != "C"))) { | or ((cSet[1].element == "C") and (cSet[2].element != "C"))) { | ||
− | bRev = | + | bRev = true |
} | } | ||
if (hasO) { | if (hasO) { | ||
Line 410: | Line 419: | ||
nIdx = cSet[i].atomIndex | nIdx = cSet[i].atomIndex | ||
} | } | ||
− | cSet[i].selected = | + | cSet[i].selected = false |
} | } | ||
else { | else { | ||
Line 488: | Line 497: | ||
delete {selected} | delete {selected} | ||
ls += "end \"append remap\"" | ls += "end \"append remap\"" | ||
+ | gAppendNew = appendNew | ||
+ | set appendNew false | ||
script inline @{ls} | script inline @{ls} | ||
+ | set appendNew gAppendNew | ||
var xx = {element="Xx"} | var xx = {element="Xx"} | ||
for (var i = 1; i <= xx.size; i++) { | for (var i = 1; i <= xx.size; i++) { | ||
Line 499: | Line 511: | ||
print ls1 | print ls1 | ||
+ | } | ||
+ | else { | ||
+ | color {selected} @gScheme | ||
} | } | ||
} | } | ||
Line 505: | Line 520: | ||
function plico_remap() { | function plico_remap() { | ||
− | # | + | # 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 | ||
+ | } | ||
+ | } | ||
− | + | gPlico = "Remap" | |
− | + | plico_prelim(false, true) | |
− | + | ||
− | + | gEcho = "_______REMAP_______|ALT-CLICK=select chain|SHIFT-DOUBLE-CLICK=exit" | |
− | |||
− | |||
− | gEcho = "_______REMAP_______|ALT-CLICK=select chain|DOUBLE-CLICK=exit" | ||
echo @gEcho | echo @gEcho | ||
− | |||
− | |||
set picking ON | set picking ON | ||
bind "ALT-LEFT-CLICK" "_pickAtom"; | bind "ALT-LEFT-CLICK" "_pickAtom"; | ||
bind "ALT-LEFT-CLICK" "+:remap_cargo_mb"; | bind "ALT-LEFT-CLICK" "+:remap_cargo_mb"; | ||
− | bind "DOUBLE" " | + | bind "SHIFT-DOUBLE" "plico_exit(true)"; |
+ | bind "LEFT-CLICK" "+:plico_menu_toggle"; | ||
} | } | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
# End of REMAP.SPT</pre> | # End of REMAP.SPT</pre> |
Latest revision as of 17:17, 12 April 2016
Remap allows you to change the chain ID, atom numbers and/or residue numbers of a polypeptide chain by mouse actions. It also calculates group values [amino acid names (GLY, THR, etc.)]. Finally it prints the 1 char resultant string to the console.
When you click on a polypeptide chain, it gives the current chain ID, residue, residue number and atom number of the most nward atom in that chain. You may then edit any value (except residue). Remap then remaps the entire chain based on those values by conventional increments and identifies each amino acid residue.
Note that it will also remove all waters, hydrogens and %B alternates when any chain is updated.
Remap 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 Remap Script=script <path to your scripts directory>/remap.spt;plico_remap
saved as plicoRemap.macro in your .jmol/macros directory as described in Macro.
Copy and paste the following to a text editor and save to your scripts directory as remap.spt:
# remap - Jmol script by Ron Mignery # v1.10 beta 4/12/2016 -require latest common includes # # Calculate or change polypeptide chain, atom number, residue names and/or residue # numbers and print the resultant 1 char string # gAppendNew = false gBusy = false # Search for N-C-C-0 function get_bb_nward_ca_idx(idx) { if ({atomIndex=idx}.element == "N") { var c1 = (connected({atomIndex=idx}) and not {hydrogen}) for (var i1 = 1; i1 <= c1.size; i1++) { if (c1[i1].element == "C") { var c2 = (connected({atomIndex=@{c1[i1].atomIndex}}) and not {hydrogen}) for (var i2 = 1; i2 <= c2.size; i2++) { if (c2[i2].element == "C") { var c3 = (connected({atomIndex=@{c2[i2].atomIndex}}) and not {hydrogen}) for (var i3 = 1; i3 <= c3.size; i3++) { if (c3[i3].element == "O") { return c1[i1].atomIndex } } } } } } } return -1 } # Find N-terminal N function find_n0_idx(aIdx) { select {atomIndex=aIdx} var sSet = {selected} while (sSet) { for (var i = 1; i <= sSet.size; i++) { var idx = sSet[i].atomIndex var caIdx = get_bb_nward_ca_idx(idx) if (caIdx >= 0) { var cset = connected({atomIndex=idx}) and not {hydrogen} var ccset = connected(cset) and not {hydrogen} if (cset.size < 2) { return idx #*** } else if (({ccset and {carbon}}.size = 3) and (ccset.size == 4)) { return idx #*** } } } # endfor sSet = connected({selected}) and not {selected} and not {hydrogen} select {selected} or sSet } # endwhile return -1 } # Bound to ALT-LEFT-CLICK by plico_remap function remap_cargo_mb() { var idx =_atomPicked if ({atomIndex=idx}.element == "H") { idx = connected({atomIndex=idx})[1].atomIndex } # If n-terminal N can be found var n0idx = find_n0_idx(idx) var isValid = false var newResno = 1 var newChain = "A" var newAtomno = 1 if (n0idx >= 0) { # Prompt for new designators var f = {atomIndex=n0idx}.file var m = {atomIndex=n0idx}.model var iResno = {atomIndex=n0idx}.resno var iChain = {atomIndex=n0idx}.chain var iNo = {atomIndex=n0idx}.atomno select {thisModel} color {selected} @gScheme select {(chain=iChain) and thisModel} color {selected} @gAltScheme refresh var p = prompt("Enter n-terminal atom designator as\n" + " <resno>:<chain>.N#<atomno>", format("%d:%s.N#%d", iResno, iChain, iNo)%0) # If valid var iColon = p.find(":") if (iColon > 0) { var iDot = p.find(".") if (iDot > 0) { var iHash = p.find("#") if (iHash > 0) { newResno = 0 + (p[1][iColon-1]) newChain = p[iColon+1][iDot-1] newAtomno = 0 + (p[iHash+1][0]) if ((newResno > 0) and (newChain.size == 1) and (newAtomno > 0)) { isValid = true } } } } } if (isValid) { delete {hydrogen and thisModel} delete {hoh and thisModel} delete %B and thisModel ssbonds off # Build inline pdb file var ls = "data \"append remap\"\n" var rs = "" var ls1 = format("%s:", newChain) select {atomIndex=n0idx} var cSet = {selected} var newAtomName = "N" var newGroup = "UNK" var s1 = "X" var newGreek = "" var newCount = "" var isCB = false var nIdx = n0idx var proDidx = -1 var oxtIdx = -1 while ((nIdx >= n0idx) or (cSet)) { var s = array(1, 2, 3) var pTrp = 0 if (cSet.size == 0) { ls += rs.replace("UNK", newGroup).replace(" SeG" , " SeG ") ls1 += s1 rs = "" newResno++ nIdx = -1 proIdx = -1 newGroup = "UNK" s1 = "X" newAtomName = "N" isCB = false } else if (cSet.size == 1) { if (newAtomName == "N") { newGreek = "" newAtomName = "CA" } else if (newAtomName == "CA") { newGreek = "A" newAtomName = "C" } else if (newAtomName == "C") { newGroup = "GLY" s1 = "G" newGreek = "" newAtomName = "O" } else if (newAtomName == "CB") { if (cSet[1].element == "C") { newGroup = "ALA" # for now s1 = "A" newGreek = "B" } newAtomName = "XG" } else if (newAtomName == "XG") { if (proDidx >= 0) { newGroup = "PRO" s1 = "P" proDidx = -1 } if (cSet[1].element == "O") { # SER CYS SEC newGroup = "SER" s1 = "S" } else if (cSet[1].element == "S") { newGroup = "CYS" s1 = "C" } else if (cSet[1].element == "Se") { newGroup = "SEC" s1 = "U" } newGreek = "G" newAtomName = "XD" } else if (newAtomName == "XD") { if (newGroup == "VAL") { newGroup = "ILE" s1 = "I" newCount = "1" } newGreek = "D" newAtomName = "XE" } else if (newAtomName == "XE") { newGroup = "MET" s1 = "M" newGreek = "E" newAtomName = "XZ" } else if (newAtomName == "XZ") { if (cSet[1].element == "N") { newGroup = "LYS" s1 = "K" } else { newGroup = "PHE" # for now s1 = "F" } newGreek = "Z" newAtomName = "XH" } else if (newAtomName == "XH") { if (cSet[1].element == "O") { newGroup = "TYR" s1 = "Y" } else { newGroup = "TRP" # for now s1 = "W" newCount = "2" } newGreek = "H" newAtomName = "N" } } else if (cSet.size == 2) { var hasN = ((cSet[1].element == "N") or (cSet[2].element == "N")) var hasO = ((cSet[1].element == "O") or (cSet[2].element == "O")) # If CA 2 if (newAtomName == "CA") { var iKeep = -1 for (var i = 1; i <= cSet.size; i++) { if (connected(cSet[i]) > 2) { iKeep = i } else { proDidx = cSet[i].atomIndex cSet[i].selected = false } } cSet = cSet[iKeep] newGroup = "PRO" s1 = "P" newGreek = "A" newAtomName = "C" } # Else if C or CB 2 else if (newAtomName == "C") { for (var i = 1; i <= cSet.size; i++) { # If it connects O and (N or O) var tSet = (connected(cSet[i]) and not {selected}) var oCount = 0 var nCount = 0 for (var j = 1; j <= tSet.size; j++) { oCount += ((tSet[j].element == "O") ? 1 : 0) nCount += ((tSet[j].element == "N") ? 1 : 0) } if ((nCount > 0) or (oCount > 1)) { # C newGreek = "" newAtomName = "O" } else { # CB isCB = true cSet[i].selected = false cSet = (cSet and not cSet[i]) continue } } # endfor } # Else if O or N 2 else if (newAtomName == "O") { var iKeep = -1 for (var i = 1; i <= cSet.size; i++) { if (cSet[i].element != "O") { if (cSet[i].element == "N") { nIdx = cSet[i].atomIndex } cSet[i].selected = false } else { iKeep = i } } cSet = cSet[iKeep] newGreek = "" newAtomName = (isCB ? "CB" : "N") } # Else if N or CB 2 else if (newAtomName == "CB") { for (var i = 1; i <= cSet.size; i++) { if (cSet[i].element != "C") { nIdx = cSet[i].atomIndex cSet[i].selected = false continue } newGreek = "B" newAtomName = "XG" } # endfor } # Else if XG or XGn 2 else if (newAtomName == "XG") { # VAL THR ILE newGroup = (hasO ? "THR" : "VAL") s1 = (hasO ? "T" : "V") newGreek = "G" newAtomName = "XD" } # Else if XD or XDn 2 else if (newAtomName == "XD") { # LEU ASP ASN var cTrp = (connected(cSet[2]) and not {selected}) var sTrp = ((trp) ? (trp[1].element=="N") : false) if ((cSet[2].element != "C") or sTrp or ((connected(cSet[1]) and not {selected}).size == 0)) { bRev = true } if ((cSet[2].element == "O") or (cSet[1].element == "N") or ((cSet[1].element == "C") and (cSet[2].element != "C"))) { bRev = true } if (hasN) { if (hasO) { newGroup = "ASN" s1 = "N" } else { newGroup = "HIS" s1 = "H" } } else if (hasO) { newGroup = "ASP" s1 = "D" } else { newGroup = "LEU" # for now s1 = "L" } newGreek = "D" newAtomName = "XE" } # Else if XE or XEn 2 else if (newAtomName == "XE") { # GLU GLN HIS if ((cSet[2].element == "O") or (cSet[1].element == "N") or ((cSet[1].element == "C") and (cSet[2].element != "C"))) { bRev = true } if (hasO) { if (hasN) { newGroup = "GLN" s1 = "Q" } else { newGroup = "GLU" s1 = "E" } } newGreek = "E" newAtomName = "XZ" } # Else if XZ 2 else if (newAtomName == "XZ") { # ARG if (newGroup == "TRP") { pTrp = 1 } newGreek = "Z" newAtomName = "XH" } # Else if XH 2 else if (newAtomName == "XH") { # ARG newGroup = "ARG" s1 = "R" newGreek = "H" newAtomName = "N" } } # Else cSet.size = 3 else { # If O if (newAtomName == "O") { var oCount = 0 var iKeep = -1 for (var i = 1; i <= cSet.size; i++) { if (cSet[i].element != "O") { if (cSet[i].element == "N") { nIdx = cSet[i].atomIndex } cSet[i].selected = false } else { oCount++ if (iKeep < 0) { iKeep = i } else { oxtIdx = cSet[i].atomIndex } } } cset = cSet[iKeep[1]] newGreek = "" newAtomName = (isCB ? "CB" : "N") } else if (newAtomName == "CA") { # PRO var iKeep = -1 for (var i = 1; i <= cSet.size; i++) { if (connected(cSet[i]) > 2) { iKeep = i } } cSet = cSet[iKeep] newGreek = "A" newAtomName = "C" } else if (newAtomName == "XE") { # TRP for (var i = 1; i <= cSet.size; i++) { if (cSet[i].element == "N") { s[1] = i } else if (connected(cSet[i]) > 2) { s[2] = i } else { s[3] = i } } newGroup = "TRP" s1 = "W" newGreek = "E" newAtomName = "XZ" } else { } } for (var i = 1; i <= cSet.size; i++) { rs += format("ATOM %5d %-4sUNK ", newAtomNo, (cSet[s[i]].element + newGreek + ((cSet.size > 1) ? (i+pTrp) : newCount))) rs += format("%s%4d %8.3f", newChain, newResno, cSet[s[i]].x) rs += format("%8.3f%8.3f\n", cSet[s[i]].y, cSet[s[i]].z) if (newGreek == "XT") { newGreek == "" } newAtomno++ } newCount = "" cSet = (connected({selected}) and not {selected} and not {atomIndex=@nIdx} and not {atomIndex=proDidx}) select ({selected} or cSet and not {atomIndex=nIdx} and not {atomIndex=proDidx}) } # endwhile # Replace chain with new chain if (oxtIdx >= 0) { rs += format("ATOM %5d OXT UNK %s", newAtomNo, newChain) rs += format("%4d %8.3f", newResno, {atomIndex=oxtIdx}.x) rs += format("%8.3f%8.3f\n", {atomIndex=oxtIdx}.y, {atomIndex=oxtIdx}.z) } ls += rs.replace("UNK", newGroup).replace(" SeG" , " SeG ") ls1 += s1 delete {selected} ls += "end \"append remap\"" gAppendNew = appendNew set appendNew false script inline @{ls} set appendNew gAppendNew var xx = {element="Xx"} for (var i = 1; i <= xx.size; i++) { connect 1.8 {atomindex=@{xx[i].atomIndex}} } ssbonds on gEcho += format("|Chain %s has been rebuilt", newChain) set echo TOP LEFT echo @gEcho print ls1 } else { color {selected} @gScheme } } # Top level of Remap function plico_remap() { # 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 } } gPlico = "Remap" plico_prelim(false, true) gEcho = "_______REMAP_______|ALT-CLICK=select chain|SHIFT-DOUBLE-CLICK=exit" echo @gEcho set picking ON bind "ALT-LEFT-CLICK" "_pickAtom"; bind "ALT-LEFT-CLICK" "+:remap_cargo_mb"; bind "SHIFT-DOUBLE" "plico_exit(true)"; bind "LEFT-CLICK" "+:plico_menu_toggle"; } # End of REMAP.SPT