Revision: 9512
http://jmol.svn.sourceforge.net/jmol/?rev=9512&view=rev
Author: hansonr
Date: 2008-06-22 17:06:48 -0700 (Sun, 22 Jun 2008)
Log Message:
-----------
11.5.42 VERSION
# bug fix: color of NaN float values changed from "center of color scheme" to GRAY
# bug fix: connect "_1" was inadvertently dropped in 11.5.26.
# bug fix: state script fails to save data for atoms created using the quaternion command
# bug fix: axes/boundbox/unitcell dotted not working since 11.5.6
# bug fix: spin thread not stopped for applet destroy()
# bug fix: quaternion derivative for i/i+1 assigned to i+1 instead of i; now assigned to i
# bug fix: quaternion calculation using published algorithms was giving inverted quaternions
#
# new feature: set PICKLABEL "xxx" -- allows customized pick reports
#
# for example: set pickLabel "%n x = %x, y = %y, z = %z"
#
# new feature: "quaternion derivative" --> "quaternion difference", which is more
# appropriate, we think, with "absolute" and "relative" qualifiers:
#
# quaternion absolute difference # in the molecular frame
# quaternion relative difference # in the (local) frame of first quaternion:
#
# dq_absolute = q2 * q1_inverse
# dq_relative = q1_inverse * q2
#
# absolute involves un-doing q1's rotation (making it the reference frame), then applying q2.
# relative involves applying q2 (maintaining the original reference frame), then undoing q1.
#
# new feature: quaternion [w|x|y|z|a|r] [difference][2] [draw]
# new feature: write quaternion [w|x|y|z|a|r] [difference][2] [draw]
# and with that: write("quaternion" [,"w"|"x"|"y"|"z"|"a"|"r"][,"difference"|"difference2"][,"draw"])
#
# new feature: set quaternionFrame "N" -- for solid state NMR PISEMA 15N chemical shift frame
# using alpha = 0 and beta = 17 degrees.
#
# new feature: select whatever; quaternion draw
# draws x,y,z and n vectors for a quaternion center
#
# new feature: straightness, defined as:
#
# straightness = 2*|n(dq1).dot(n(dq2))| - 1
#
# where q1 and q2 are quaternions defined generally as:
#
# q = frame{ vA, (vC x vA), vC }
#
# using quaternionFrame "p", which I define as
#
# protein:
#
# vA = C--CA
# vB = C--N[i+1]
#
# purine:
#
# vA = N9--C4
# vB = N9--C8
#
# pyrimidine:
#
# vA = N1--C2
# vB = N1--C6
#
# Differences dq1 and dq2 are absolute quaternion differences
# on the two sides of a residue:
#
# dq1 === q[i] * q[i-1]_inverse
# dq2 === q[i+1] * q[i]_inverse
#
# and n(dq) = the normal vector associated with this quaternion.
# Range is from -1 to 1
#
# applications (note that CALCULATE must be invoked first):
#
# calculate straightness # must be invoked first;
# color straightness;
# select straightness < 0.70; # rounds to nearest hundredth
# selectX {*} x.straightness < 0.995 # does not round
#
# new feature: "%T" label format for straightness
#
# -----------------------------------------------------------------------------
Modified Paths:
--------------
trunk/Jmol/src/org/jmol/modelset/ModelCollection.java
trunk/Jmol/src/org/jmol/modelset/ModelSet.java
trunk/Jmol/src/org/jmol/modelset/Polymer.java
trunk/Jmol/src/org/jmol/modelsetbio/AminoPolymer.java
trunk/Jmol/src/org/jmol/modelsetbio/BioPolymer.java
trunk/Jmol/src/org/jmol/modelsetbio/NucleicPolymer.java
trunk/Jmol/src/org/jmol/util/ColorEncoder.java
trunk/Jmol/src/org/jmol/viewer/ColorManager.java
trunk/Jmol/src/org/jmol/viewer/Eval.java
trunk/Jmol/src/org/jmol/viewer/Jmol.properties
trunk/Jmol/src/org/jmol/viewer/Token.java
trunk/Jmol/src/org/jmol/viewer/Viewer.java
Modified: trunk/Jmol/src/org/jmol/modelset/ModelCollection.java
===================================================================
--- trunk/Jmol/src/org/jmol/modelset/ModelCollection.java 2008-06-21 22:44:17 UTC (rev 9511)
+++ trunk/Jmol/src/org/jmol/modelset/ModelCollection.java 2008-06-23 00:06:48 UTC (rev 9512)
@@ -398,7 +398,7 @@
public void addStateScript(String script1, BitSet bsBonds, BitSet bsAtoms1,
BitSet bsAtoms2, String script2,
- boolean addFrameNumber) {
+ boolean addFrameNumber, boolean postDefinitions) {
if (addFrameNumber) {
int iModel = viewer.getCurrentModelIndex();
if (thisStateModel != iModel)
@@ -410,7 +410,7 @@
thisStateModel = -1;
}
StateScript stateScript = new StateScript(thisStateModel, script1, bsBonds, bsAtoms1,
- bsAtoms2, script2);
+ bsAtoms2, script2, postDefinitions);
if (stateScript.isValid())
stateScripts.addElement(stateScript);
}
@@ -422,15 +422,17 @@
BitSet bsAtoms2;
String script1;
String script2;
+ boolean postDefinitions;
StateScript(int modelIndex, String script1, BitSet bsBonds, BitSet bsAtoms1,
- BitSet bsAtoms2, String script2) {
+ BitSet bsAtoms2, String script2, boolean postDefinitions) {
this.modelIndex = modelIndex;
this.script1 = script1;
this.bsBonds = bsBonds;
this.bsAtoms1 = bsAtoms1;
this.bsAtoms2 = bsAtoms2;
this.script2 = script2;
+ this.postDefinitions = postDefinitions;
}
public boolean isValid() {
@@ -837,7 +839,7 @@
Model model = models[i];
int nPoly = model.getBioPolymerCount();
for (int p = 0; p < nPoly; p++)
- model.bioPolymers[p].getPdbData('w','p', 1, null, null, null, null);
+ model.bioPolymers[p].getPdbData('w','p', 1, false, null, null, null, null);
}
}
@@ -893,24 +895,25 @@
/* ONLY from one model
*
*/
- private String getPdbData(String type, char ctype, int modelIndex,
- int derivType, BitSet bsSelected) {
- StringBuffer pdbCONECT = new StringBuffer();
+ private String getPdbData(int modelIndex, char ctype, int derivType,
+ boolean isDraw, BitSet bsSelected) {
if (isJmolDataFrame(modelIndex))
modelIndex = getJmolDataSourceFrame(modelIndex);
if (modelIndex < 0)
return "";
- StringBuffer pdbATOM = new StringBuffer();
+ char qtype = (ctype == 'R' ? 'R' : viewer.getQuaternionFrame());
Model model = models[modelIndex];
BitSet bsAtoms = getModelAtomBitSet(modelIndex, false);
int nPoly = model.getBioPolymerCount();
+ StringBuffer pdbATOM = new StringBuffer();
+ StringBuffer pdbCONECT = new StringBuffer();
+ if (!isDraw)
+ pdbATOM.append(getProteinStructureState(bsAtoms, ctype == 'R'));
for (int p = 0; p < nPoly; p++)
- model.bioPolymers[p].getPdbData(ctype, (ctype == 'R' ? 'R'
- : viewer.getQuaternionFrame()), derivType, bsAtoms,
- pdbATOM, pdbCONECT, bsSelected);
+ model.bioPolymers[p].getPdbData(ctype, qtype, derivType, isDraw,
+ bsAtoms, pdbATOM, pdbCONECT, bsSelected);
pdbATOM.append(pdbCONECT);
- return (ctype == 's' ? "" : getProteinStructureState(bsAtoms, ctype == 'R'))
- + pdbATOM.toString();
+ return pdbATOM.toString();
}
public String getPdbAtomData(BitSet bs) {
@@ -950,10 +953,10 @@
return null;
char ctype = (type.length() > 11 && type.indexOf("quaternion ") >= 0 ? type
.charAt(11) : 'R');
- int derivType = (type.indexOf(" derivative2") >= 0 ||type.indexOf(" difference2") >= 0 ? 2
- : type.indexOf(" deriv") >= 0 || type.indexOf(" diff") >= 0 ? 1 : 0);
- String s = getPdbData(type, ctype, modelIndex, derivType, bsSelected);
- if (s.length() == 0 || ctype == 's')
+ String s = getPdbData(modelIndex, ctype,
+ (type.indexOf("diff") < 0 ? 0 : type.indexOf("2") < 0 ? 1 : 2),
+ (type.indexOf("draw") >= 0), bsSelected);
+ if (s.length() == 0 || type.indexOf("draw") >= 0)
return s;
String remark = "REMARK 6 Jmol PDB-encoded data: " + type
+ " data(x,y,z,charge)=";
Modified: trunk/Jmol/src/org/jmol/modelset/ModelSet.java
===================================================================
--- trunk/Jmol/src/org/jmol/modelset/ModelSet.java 2008-06-21 22:44:17 UTC (rev 9511)
+++ trunk/Jmol/src/org/jmol/modelset/ModelSet.java 2008-06-23 00:06:48 UTC (rev 9512)
@@ -482,7 +482,7 @@
stateScript += maxDistance + " ";
addStateScript(stateScript, (isBonds? bsA : null),
(isBonds? null : bsA), (isBonds ? null : bsB),
- " delete;", false);
+ " delete;", false, true);
}
return super.makeConnections(minDistance, maxDistance, order,
connectOperation, bsA, bsB, bsBonds, isBonds);
@@ -545,21 +545,29 @@
int len = stateScripts.size();
if (len == 0)
return "";
+
+ boolean haveDefs = false;
StringBuffer commands = new StringBuffer();
+ String cmd;
+ for (int i = 0; i < len; i++) {
+ StateScript ss = (StateScript) stateScripts.get(i);
+ if (!ss.postDefinitions && (cmd = ss.toString()).length() > 0) {
+ commands.append(" ").append(cmd).append("\n");
+ haveDefs = true;
+ }
+ }
+
+ if (!haveDefs)
+ return "";
+ cmd = "";
if (isAll && sfunc != null) {
sfunc.append(" _setDefinedState;\n");
- commands.append("function _setDefinedState();\n");
+ cmd = "function _setDefinedState();\n\n";
}
- String cmd;
- commands.append("\n");
- for (int i = 0; i < len; i++)
- if ((cmd = ((StateScript) stateScripts.get(i)).toString()).length() > 0)
- commands.append(" ").append(cmd).append("\n");
-
if (sfunc != null)
commands.append("\nend function;\n\n");
- return commands.toString();
+ return cmd + commands.toString();
}
public String getState(StringBuffer sfunc, boolean isAll) {
@@ -572,7 +580,16 @@
// connections
+
if (isAll) {
+
+ int len = stateScripts.size();
+ for (int i = 0; i < len; i++) {
+ StateScript ss = (StateScript) stateScripts.get(i);
+ if (ss.postDefinitions && (cmd = ss.toString()).length() > 0)
+ commands.append(" ").append(cmd).append("\n");
+ }
+
for (int i = 0; i < bondCount; i++) {
if ((bonds[i].order & JmolConstants.BOND_NEW) != 0
|| bonds[i].isHydrogen()) {
Modified: trunk/Jmol/src/org/jmol/modelset/Polymer.java
===================================================================
--- trunk/Jmol/src/org/jmol/modelset/Polymer.java 2008-06-21 22:44:17 UTC (rev 9511)
+++ trunk/Jmol/src/org/jmol/modelset/Polymer.java 2008-06-23 00:06:48 UTC (rev 9512)
@@ -106,8 +106,8 @@
}
public void getPdbData(char ctype, char qtype, int derivType,
- BitSet bsAtoms, StringBuffer pdbATOM, StringBuffer pdbCONECT,
- BitSet bsSelected) {
+ boolean isDraw, BitSet bsAtoms, StringBuffer pdbATOM,
+ StringBuffer pdbCONECT, BitSet bsSelected) {
return;
}
Modified: trunk/Jmol/src/org/jmol/modelsetbio/AminoPolymer.java
===================================================================
--- trunk/Jmol/src/org/jmol/modelsetbio/AminoPolymer.java 2008-06-21 22:44:17 UTC (rev 9511)
+++ trunk/Jmol/src/org/jmol/modelsetbio/AminoPolymer.java 2008-06-23 00:06:48 UTC (rev 9512)
@@ -570,10 +570,11 @@
*/
public void getPdbData(char ctype, char qtype, int derivType,
- BitSet bsAtoms, StringBuffer pdbATOM,
- StringBuffer pdbCONECT, BitSet bsSelected) {
- getPdbData(this, ctype, qtype, derivType, bsAtoms, pdbATOM, pdbCONECT,
- bsSelected);
+ boolean isDraw, BitSet bsAtoms,
+ StringBuffer pdbATOM, StringBuffer pdbCONECT,
+ BitSet bsSelected) {
+ getPdbData(this, ctype, qtype, derivType, isDraw, bsAtoms, pdbATOM,
+ pdbCONECT, bsSelected);
}
final private Point3f ptTemp = new Point3f();
Modified: trunk/Jmol/src/org/jmol/modelsetbio/BioPolymer.java
===================================================================
--- trunk/Jmol/src/org/jmol/modelsetbio/BioPolymer.java 2008-06-21 22:44:17 UTC (rev 9511)
+++ trunk/Jmol/src/org/jmol/modelsetbio/BioPolymer.java 2008-06-23 00:06:48 UTC (rev 9512)
@@ -464,9 +464,11 @@
return false;
}
+ final private static String[] qColor = { "yellow", "orange", "purple" };
+
final public static void getPdbData(BioPolymer p, char ctype, char qtype,
- int derivType, BitSet bsAtoms,
- StringBuffer pdbATOM,
+ int derivType, boolean isDraw,
+ BitSet bsAtoms, StringBuffer pdbATOM,
StringBuffer pdbCONECT, BitSet bsSelected) {
int atomno = Integer.MIN_VALUE;
Quaternion qlast = null;
@@ -511,6 +513,7 @@
Atom aprev = null;
String strExtra = "";
boolean isRelativeAlias = (ctype == 'r');
+ String prefix = (derivType > 0 ? "dq" + (derivType == 2 ? "2" : "") : "q");
for (int m = 0; m < p.monomerCount; m++) {
Monomer monomer = p.monomers[m];
if (bsAtoms == null || bsAtoms.get(monomer.getLeadAtomIndex())) {
@@ -620,39 +623,6 @@
y = q.q2;
z = q.q3;
w = q.q0;
- if (ctype == 's') {
- if (bsSelected != null && !bsSelected.get(a.getAtomIndex()))
- continue;
- String strV = " VECTOR " + Escape.escape(ptCenter) + " ";
- int deg = (int) (Math.acos(w) * 360 / Math.PI);
- //this is the angle required to rotate the INITIAL FRAME to this position
- //if (deg < 0)
- //deg += 360;
- if (deg > 180)
- deg = deg - 360;
- if (deg < -180)
- deg = deg + 360;
- int ndeg = -deg;
- if (ndeg > 180)
- ndeg = ndeg - 360;
- if (ndeg < -180)
- ndeg = ndeg + 360;
-
- pdbATOM.append(
- "draw qx" + id + strV + Escape.escape(q.getVector(0)) + " color red\n"
- + "draw qy" + id + strV + Escape.escape(q.getVector(1)) + " color green\n"
- + "draw qz" + id + strV + Escape.escape(q.getVector(2)) + " color blue\n"
- + "draw qa" + id + strV + " {" + (x * 2)
- + "," + (y * 2) + "," + (z * 2) + "}"
- + (deg >= 0 ? " \">" + deg + "\"" : "")
- + " color yellow\n"
- + "draw qb" + id + strV + " {" + (-x * 2)
- + "," + (-y * 2) + "," + (-z * 2) + "}"
- + (ndeg > 0 ? " \">" + ndeg + "\"" : "")
- + " color yellow\n"
- );
- continue;
- }
break;
case 'x':
x = q.q0;
@@ -673,6 +643,39 @@
w = q.q1;
break;
}
+ if (isDraw) {
+ if (bsSelected != null && !bsSelected.get(a.getAtomIndex()))
+ continue;
+ String strV = " VECTOR " + Escape.escape(ptCenter) + " ";
+ int deg = (int) (Math.acos(w) * 360 / Math.PI);
+ //this is the angle required to rotate the INITIAL FRAME to this position
+ //if (deg < 0)
+ //deg += 360;
+ if (deg > 180)
+ deg = deg - 360;
+ if (deg < -180)
+ deg = deg + 360;
+ int ndeg = -deg;
+ if (ndeg > 180)
+ ndeg = ndeg - 360;
+ if (ndeg < -180)
+ ndeg = ndeg + 360;
+ if (derivType == 0)
+ pdbATOM.append("draw " + prefix + "x" + id + strV + Escape.escape(q.getVector(0)))
+ .append(" color red\n")
+ .append("draw " + prefix + "y" + id + strV + Escape.escape(q.getVector(1)))
+ .append(" color green\n")
+ .append("draw " + prefix + "z" + id + strV + Escape.escape(q.getVector(2)))
+ .append(" color blue\n");
+ pdbATOM.append(deg >= 0
+ ? "draw " + prefix + "a" + id + strV + " {" + (x * 2)
+ + "," + (y * 2) + "," + (z * 2) + "}" + " \">" + deg + "\""
+ : "draw " + prefix + "b" + id + strV + " {" + (-x * 2)
+ + "," + (-y * 2) + "," + (-z * 2) + "}" + " \">" + ndeg + "\""
+ )
+ .append(" color ").append(qColor[derivType]).append('\n');
+ continue;
+ }
}
if (pdbATOM == null)
continue;
@@ -696,7 +699,7 @@
private static float getStraightness(String id, Quaternion dqprev, Quaternion dq) {
float f = Math.abs(dqprev.getNormal().dot(dq.getNormal()));
//System.out.println(id + " " + f + " " + dqprev.getNormal() + " " + dq.getNormal());
- return f;
+ return (2 * f - 1);
}
Quaternion getQuaternion(int m, char qtype) {
Modified: trunk/Jmol/src/org/jmol/modelsetbio/NucleicPolymer.java
===================================================================
--- trunk/Jmol/src/org/jmol/modelsetbio/NucleicPolymer.java 2008-06-21 22:44:17 UTC (rev 9511)
+++ trunk/Jmol/src/org/jmol/modelsetbio/NucleicPolymer.java 2008-06-23 00:06:48 UTC (rev 9512)
@@ -95,10 +95,11 @@
}
public void getPdbData(char ctype, char qtype, int derivType,
- BitSet bsAtoms, StringBuffer pdbATOM,
- StringBuffer pdbCONECT, BitSet bsSelected) {
- getPdbData(this, ctype, qtype, derivType, bsAtoms, pdbATOM, pdbCONECT,
- bsSelected);
+ boolean isDraw, BitSet bsAtoms,
+ StringBuffer pdbATOM, StringBuffer pdbCONECT,
+ BitSet bsSelected) {
+ getPdbData(this, ctype, qtype, derivType, isDraw, bsAtoms, pdbATOM,
+ pdbCONECT, bsSelected);
}
static Point3f getQuaternionFrameCenter(NucleicMonomer m, char qType) {
@@ -135,9 +136,13 @@
Point3f ptA, ptB;
Point3f ptN = getQuaternionFrameCenter(m, qType);
if (m.isPurine) {
+ // vA = N9--C4
+ // vB = N9--C8
ptA = m.getAtomFromOffsetIndex(NucleicMonomer.C4);
ptB = m.getAtomFromOffsetIndex(NucleicMonomer.C8);
} else {
+ // vA = N1--C2
+ // vB = N1--C6
ptA = m.getAtomFromOffsetIndex(NucleicMonomer.C2);
ptB = m.getAtomFromOffsetIndex(NucleicMonomer.C6);
}
@@ -149,8 +154,6 @@
Vector3f vB = new Vector3f(ptB);
vB.sub(ptN);
- //vA.set(1f, 0.2f, 0f);
- //vB.set(-0.2f, 1f, 0f);
return Quaternion.getQuaternionFrame(vA, vB, null);
}
Modified: trunk/Jmol/src/org/jmol/util/ColorEncoder.java
===================================================================
--- trunk/Jmol/src/org/jmol/util/ColorEncoder.java 2008-06-21 22:44:17 UTC (rev 9511)
+++ trunk/Jmol/src/org/jmol/util/ColorEncoder.java 2008-06-23 00:06:48 UTC (rev 9512)
@@ -322,7 +322,11 @@
}
+ private final static int GRAY = 0xFF808080;
+
public final static int getArgbFromPalette(float val, float lo, float hi, int palette) {
+ if (Float.isNaN(val))
+ return GRAY;
switch (palette) {
case -1:
if (isColorIndex) {
@@ -355,7 +359,7 @@
case AMINO:
return JmolConstants.argbsAmino[colorIndex((int)val, JmolConstants.argbsAmino.length)];
default:
- return 0xFF808080; // GRAY
+ return GRAY;
}
}
Modified: trunk/Jmol/src/org/jmol/viewer/ColorManager.java
===================================================================
--- trunk/Jmol/src/org/jmol/viewer/ColorManager.java 2008-06-21 22:44:17 UTC (rev 9511)
+++ trunk/Jmol/src/org/jmol/viewer/ColorManager.java 2008-06-23 00:06:48 UTC (rev 9512)
@@ -145,7 +145,7 @@
lo, hi, ColorEncoder.BWR);
case JmolConstants.PALETTE_STRAIGHTNESS:
return ColorEncoder.getColorIndexFromPalette(atom.getStraightness(),
- 0, 1, ColorEncoder.BWR);
+ -1, 1, ColorEncoder.BWR);
case JmolConstants.PALETTE_SURFACE:
hi = viewer.getSurfaceDistanceMax();
return ColorEncoder.getColorIndexFromPalette(atom.getSurfaceDistance100(),
Modified: trunk/Jmol/src/org/jmol/viewer/Eval.java
===================================================================
--- trunk/Jmol/src/org/jmol/viewer/Eval.java 2008-06-21 22:44:17 UTC (rev 9511)
+++ trunk/Jmol/src/org/jmol/viewer/Eval.java 2008-06-23 00:06:48 UTC (rev 9512)
@@ -4143,7 +4143,7 @@
for (int i = statementLength; --i >= 0;)
code[i] = statement[i];
variables.put("!" + variable.substring(8), code);
- viewer.addStateScript(thisCommand, false);
+ viewer.addStateScript(thisCommand, false, true);
} else {
assignBitsetVariable(variable, bs);
}
@@ -4472,24 +4472,25 @@
break;
case JmolConstants.JMOL_DATA_QUATERNION:
isQuaternion = true;
- type = optParameterAsString(statementLength - 1).toLowerCase();
+ // working backward this time:
+ int pt = statementLength - 1;
+ type = optParameterAsString(pt).toLowerCase();
if (type.equalsIgnoreCase("draw")) {
isDraw = true;
- break;
+ type = optParameterAsString(--pt).toLowerCase();
}
- isDerivative = (type.indexOf("deriv") == 0 || type.indexOf("difference") == 0);
- isSecondDerivative = (type.indexOf("derivative2") == 0 || type.indexOf("difference2") == 0);
- type = (statementLength == 1 ? "w" : optParameterAsString(1));
- if (isDerivative && statementLength == 2 || type.length() == 0)
- type = "w";
- type = type.substring(0, 1);
+ isDerivative = (type.startsWith("deriv") || type.startsWith("diff"));
+ isSecondDerivative = (isDerivative && type.indexOf("2") > 0);
+ if (isDerivative)
+ pt--;
+ type = ((pt == 0 ? "" : optParameterAsString(pt))+"w").substring(0, 1);
if (type == "a" || type == "r")
isDerivative = true;
if (!Parser.isOneOf(type, "w;x;y;z;r;a")) // a absolute; r relative
evalError("QUATERNION [w,x,y,z,a,r] [difference][2]");
type = "quaternion " + type + (isDerivative ? " difference" : "")
+ (isSecondDerivative ? "2" : "")
- + " quaternionFrame: " + viewer.getQuaternionFrame();
+ + (isDraw ? " draw" : " (quaternionFrame " + viewer.getQuaternionFrame() + ")");
break;
}
if (isSyntaxCheck) //just in case we later add parameter options to this
@@ -4500,7 +4501,7 @@
error(ERROR_multipleModelsNotOK, type);
modelIndex = viewer.getJmolDataSourceFrame(modelIndex);
if (isQuaternion && isDraw) {
- runScript(viewer.getPdbData(modelIndex, "quaternion s"));
+ runScript(viewer.getPdbData(modelIndex, type));
return;
}
int ptDataFrame = viewer.getJmolDataFrameIndex(modelIndex, type);
@@ -4515,7 +4516,7 @@
// viewer.display(BitSetUtil.setAll(viewer.getAtomCount()), bs2, tQuiet);
return;
}
- viewer.addStateScript(type, true);
+ viewer.addStateScript(type, true, false);
String[] savedFileInfo = viewer.getFileInfo();
boolean oldAppendNew = viewer.getAppendNew();
viewer.setAppendNew(true);
@@ -5951,14 +5952,14 @@
if (statementLength == 1) {
bsConfigurations = viewer.setConformation();
viewer.addStateScript("select", null, viewer.getSelectionSet(), null,
- "configuration", true);
+ "configuration", true, false);
} else {
checkLength2();
if (isSyntaxCheck)
return;
int n = intParameter(1);
bsConfigurations = viewer.setConformation(n - 1);
- viewer.addStateScript("configuration " + n + ";", true);
+ viewer.addStateScript("configuration " + n + ";", true, false);
}
if (isSyntaxCheck)
return;
@@ -6213,8 +6214,10 @@
clearPredefined(JmolConstants.predefinedVariable);
switch (getToken(1).tok) {
case Token.straightness:
- if (!isSyntaxCheck)
+ if (!isSyntaxCheck) {
viewer.calculateStraightness();
+ viewer.addStateScript(thisCommand, false, true);
+ }
return;
case Token.surface:
isSurface = true;
@@ -6266,12 +6269,12 @@
if (bs == null)
bs = viewer.getModelAtomBitSet(-1, false);
viewer.calculateStructures(bs);
- viewer.addStateScript(thisCommand, false);
+ viewer.addStateScript(thisCommand, false, true);
return;
}
}
error(ERROR_what, "CALCULATE",
- "aromatic? hbonds? polymers? structure? surfaceDistance FROM? surfaceDistance WITHIN?");
+ "aromatic? hbonds? polymers? straightness? structure? surfaceDistance FROM? surfaceDistance WITHIN?");
}
private void dots(int ipt, int iShape) throws ScriptException {
@@ -8678,16 +8681,22 @@
case Token.quaternion:
pt++;
type2 = Token.sValue(tokenAt(pt, args)).toLowerCase();
- if (Parser.isOneOf(type2, "w;x;y;z;s;a;r")) // s is draw script; e experimental
+ if (Parser.isOneOf(type2, "w;x;y;z;a;r"))
pt++;
else
type2 = "w";
- type2 = "quaternion " + type2;
- type = Token.sValue(tokenAt(pt, args));
- if (type.indexOf("deriv") == 0 || type.indexOf("difference") == 0) {
- type2 += " difference";
+ type = Token.sValue(tokenAt(pt, args)).toLowerCase();
+ boolean isDerivative = (type.indexOf("deriv") == 0 || type.indexOf("diff") == 0);
+ if (isDerivative || type2.equals("a") || type2.equals("r")) {
+ type2 += " difference" + (type.indexOf("2") >= 0 ? "2" : "");
+ if (isDerivative)
+ type = Token.sValue(tokenAt(++pt, args)).toLowerCase();
+ }
+ if (type.equals("draw")) {
+ type2 += " draw";
pt++;
}
+ type2 = "quaternion " + type2;
type = "QUAT";
break;
case Token.ramachandran:
@@ -11845,6 +11854,7 @@
return evaluateArray(args);
case Token.cos:
case Token.sin:
+ case Token.sqrt:
case Token.quaternion:
return evaluateMath(args, tok);
case Token.cross:
@@ -12300,6 +12310,8 @@
return addX((float) Math.cos(x * Math.PI / 180));
case Token.sin:
return addX((float) Math.sin(x * Math.PI / 180));
+ case Token.sqrt:
+ return addX((float) Math.sqrt(x));
}
return false;
}
Modified: trunk/Jmol/src/org/jmol/viewer/Jmol.properties
===================================================================
--- trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2008-06-21 22:44:17 UTC (rev 9511)
+++ trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2008-06-23 00:06:48 UTC (rev 9512)
@@ -1,37 +1,85 @@
# Developers: to add a description of changes you have made,
# add it on line starting with # below the "version=..." line
-version=11.5.42_dev
+version=11.5.42
-# new feature: set PICKLABEL "xxx" -- allows customized pick reports
-#
+# bug fix: color of NaN float values changed from "center of color scheme" to GRAY
# bug fix: connect "_1" was inadvertently dropped in 11.5.26.
# bug fix: state script fails to save data for atoms created using the quaternion command
# bug fix: axes/boundbox/unitcell dotted not working since 11.5.6
# bug fix: spin thread not stopped for applet destroy()
# bug fix: quaternion derivative for i/i+1 assigned to i+1 instead of i; now assigned to i
# bug fix: quaternion calculation using published algorithms was giving inverted quaternions
+#
+# new feature: set PICKLABEL "xxx" -- allows customized pick reports
+#
+# for example: set pickLabel "%n x = %x, y = %y, z = %z"
+#
# new feature: "quaternion derivative" --> "quaternion difference", which is more
# appropriate, we think, with "absolute" and "relative" qualifiers:
#
# quaternion absolute difference # in the molecular frame
# quaternion relative difference # in the (local) frame of first quaternion:
#
-# absolute, we use q2 * q1_inv
-# relative, we use q1_inv * q2
+# dq_absolute = q2 * q1_inverse
+# dq_relative = q1_inverse * q2
#
# absolute involves un-doing q1's rotation (making it the reference frame), then applying q2.
# relative involves applying q2 (maintaining the original reference frame), then undoing q1.
#
-# new feature: set quaternionFrame "n" -- for solid state NMR PISEMA 15N chemical shift frame
+# new feature: quaternion [w|x|y|z|a|r] [difference][2] [draw]
+# new feature: write quaternion [w|x|y|z|a|r] [difference][2] [draw]
+# and with that: write("quaternion" [,"w"|"x"|"y"|"z"|"a"|"r"][,"difference"|"difference2"][,"draw"])
+#
+# new feature: set quaternionFrame "N" -- for solid state NMR PISEMA 15N chemical shift frame
+# using alpha = 0 and beta = 17 degrees.
+#
# new feature: select whatever; quaternion draw
-# new feature: straightness:
+# draws x,y,z and n vectors for a quaternion center
+#
+# new feature: straightness, defined as:
#
-# calculate straightness;
+# straightness = 2*|n(dq1).dot(n(dq2))| - 1
+#
+# where q1 and q2 are quaternions defined generally as:
+#
+# q = frame{ vA, (vC x vA), vC }
+#
+# using quaternionFrame "p", which I define as
+#
+# protein:
+#
+# vA = C--CA
+# vB = C--N[i+1]
+#
+# purine:
+#
+# vA = N9--C4
+# vB = N9--C8
+#
+# pyrimidine:
+#
+# vA = N1--C2
+# vB = N1--C6
+#
+# Differences dq1 and dq2 are absolute quaternion differences
+# on the two sides of a residue:
+#
+# dq1 === q[i] * q[i-1]_inverse
+# dq2 === q[i+1] * q[i]_inverse
+#
+# and n(dq) = the normal vector associated with this quaternion.
+# Range is from -1 to 1
+#
+# applications (note that CALCULATE must be invoked first):
+#
+# calculate straightness # must be invoked first;
# color straightness;
-# select straightness < 0.7; # rounds to nearest hundredth
+# select straightness < 0.70; # rounds to nearest hundredth
# selectX {*} x.straightness < 0.995 # does not round
#
+# new feature: "%T" label format for straightness
+#
# -----------------------------------------------------------------------------
#version=11.5.41
@@ -173,7 +221,6 @@
# - "c" -- CA-C and CA-N, as per Andy Hanson
# - "q" -- peptide plane CA-C and N'-CA' as per J.R.Quine
# - "p" -- peptide plane CA-C and C-N'
-# new feature: write QUATERNION S -- creates vector script
# new feature: random(a), random(a,b) where a is lower bound and b is upper bound
# new feature: cross(a,b)
# new feature: sin(x), cos(x)
Modified: trunk/Jmol/src/org/jmol/viewer/Token.java
===================================================================
--- trunk/Jmol/src/org/jmol/viewer/Token.java 2008-06-21 22:44:17 UTC (rev 9511)
+++ trunk/Jmol/src/org/jmol/viewer/Token.java 2008-06-23 00:06:48 UTC (rev 9512)
@@ -458,6 +458,7 @@
final static int javascript = 4 | 1 << 3 | mathfunc | command | specialstring;
final static int sin = 5 | 1 << 3 | mathfunc;
final static int cos = 6 | 1 << 3 | mathfunc;
+ final static int sqrt = 7 | 1 << 3 | mathfunc;
// ___.xxx(a)
@@ -1373,6 +1374,7 @@
"solid", new Token(solid),
"solvent", new Token(solvent),
"specialPosition", new Token(specialposition),
+ "sqrt", new Token(sqrt),
"split", new Token(split),
"straightness", new Token(straightness),
"sub", new Token(sub),
Modified: trunk/Jmol/src/org/jmol/viewer/Viewer.java
===================================================================
--- trunk/Jmol/src/org/jmol/viewer/Viewer.java 2008-06-21 22:44:17 UTC (rev 9511)
+++ trunk/Jmol/src/org/jmol/viewer/Viewer.java 2008-06-23 00:06:48 UTC (rev 9512)
@@ -1806,7 +1806,7 @@
if (bsSelected == null) bsSelected = selectionManager.bsSelection;
addStateScript("calculate surfaceDistance "
+ (envelopeRadius == Float.MAX_VALUE ? "FROM" : "WITHIN"), null,
- bsSelected, null, "", false);
+ bsSelected, null, "", false, true);
return modelSet.calculateSurface(bsSelected, envelopeRadius);
}
@@ -1829,14 +1829,15 @@
modelSet.fillAtomData(atomData, mode);
}
- void addStateScript(String script, boolean addFrameNumber) {
- addStateScript(script, null, null, null, null, addFrameNumber);
+ void addStateScript(String script, boolean addFrameNumber, boolean postDefinitions) {
+ addStateScript(script, null, null, null, null, addFrameNumber, postDefinitions);
}
void addStateScript(String script1, BitSet bsBonds, BitSet bsAtoms1,
- BitSet bsAtoms2, String script2, boolean addFrameNumber) {
+ BitSet bsAtoms2, String script2, boolean addFrameNumber,
+ boolean postDefinitions) {
modelSet.addStateScript(script1, bsBonds, bsAtoms1, bsAtoms2, script2,
- addFrameNumber);
+ addFrameNumber, postDefinitions);
}
public boolean getEchoStateActive() {
@@ -5549,7 +5550,7 @@
clearMinimization();
modelSet.deleteAllBonds();
modelSet.autoBond(null, null, null, null);
- addStateScript("connect;", false);
+ addStateScript("connect;", false, true);
refresh(0, "Viewer:rebond()");
}
@@ -5561,10 +5562,10 @@
modelSet.setPdbConectBonding(0, 0, bsExclude);
if (isAuto) {
modelSet.autoBond(null, null, bsExclude, null);
- addStateScript("connect PDB AUTO;", false);
+ addStateScript("connect PDB AUTO;", false, true);
return;
}
- addStateScript("connect PDB;", false);
+ addStateScript("connect PDB;", false, true);
refresh(0, "Viewer:setPdbConnectBonding()");
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|