Revision: 18331
          http://sourceforge.net/p/jmol/code/18331
Author:   hansonr
Date:     2013-06-14 13:25:46 +0000 (Fri, 14 Jun 2013)
Log Message:
-----------
___JmolVersion="13.1.17_dev_2013.06.14"

bug fix: COMPARE could rotate to less-good fit with SMARTS search

Modified Paths:
--------------
    branches/v13_0/Jmol/src/org/jmol/script/ScriptEvaluator.java
    branches/v13_0/Jmol/src/org/jmol/script/ScriptMathProcessor.java

Modified: branches/v13_0/Jmol/src/org/jmol/script/ScriptEvaluator.java
===================================================================
--- branches/v13_0/Jmol/src/org/jmol/script/ScriptEvaluator.java        
2013-06-14 12:44:40 UTC (rev 18330)
+++ branches/v13_0/Jmol/src/org/jmol/script/ScriptEvaluator.java        
2013-06-14 13:25:46 UTC (rev 18331)
@@ -6814,9 +6814,12 @@
     List<BitSet[]> vAtomSets = null;
     List<Object[]> vQuatSets = null;
     iToken = 0;
-    float nSeconds = (isFloatParameter(1) ? floatParameter(++iToken) : 
Float.NaN);
-    BitSet bsFrom = (tokAt(++iToken) == Token.subset ? null : 
atomExpression(iToken));
-    BitSet bsTo = (tokAt(++iToken) == Token.subset ? null : 
atomExpression(iToken));
+    float nSeconds = (isFloatParameter(1) ? floatParameter(++iToken)
+        : Float.NaN);
+    BitSet bsFrom = (tokAt(++iToken) == Token.subset ? null
+        : atomExpression(iToken));
+    BitSet bsTo = (tokAt(++iToken) == Token.subset ? null
+        : atomExpression(iToken));
     if (bsFrom == null || bsTo == null)
       error(ERROR_invalidArgument);
     BitSet bsSubset = null;
@@ -6936,8 +6939,9 @@
     if (isFrames) {
       BitSet bsModels = viewer.getModelBitSet(bsFrom, false);
       bsFrames = new BitSet[bsModels.cardinality()];
-      for (int i = 0, iModel = bsModels.nextSetBit(0); iModel >= 0; iModel = 
bsModels.nextSetBit(iModel + 1), i++)
-        bsFrames[i] = viewer.getModelUndeletedAtomsBitSet(iModel);       
+      for (int i = 0, iModel = bsModels.nextSetBit(0); iModel >= 0; iModel = 
bsModels
+          .nextSetBit(iModel + 1), i++)
+        bsFrames[i] = viewer.getModelUndeletedAtomsBitSet(iModel);
     } else {
       bsFrames = new BitSet[] { bsFrom };
     }
@@ -6956,6 +6960,8 @@
               .add(bss = new BitSet[] { BitSetUtil.copy(bss[0]), bss[1] });
         bss[0].and(bsFrom);
       }
+      Point3f center = null;
+      Vector3f translation = null;
       if (isAtoms) {
         centerAndPoints = viewer.getCenterAndPoints(vAtomSets2, true);
         q = Measure.calculateQuaternionRotation(centerAndPoints, retStddev,
@@ -6996,30 +7002,36 @@
         */
 
         Matrix4f m4 = new Matrix4f();
+        center = new Point3f();
         float stddev = getSmilesCorrelation(bsFrom, bsTo, strSmiles, null,
-            null, m4, null, !isSmiles, false);
+            null, m4, null, !isSmiles, false, center);
         if (Float.isNaN(stddev))
           error(ERROR_invalidArgument);
-        Vector3f translation = new Vector3f();
+        translation = new Vector3f();
         m4.get(translation);
         Matrix3f m3 = new Matrix3f();
         m4.get(m3);
         q = new Quaternion(m3);
       }
-      if (centerAndPoints == null)
+      if (centerAndPoints != null)
+        center = centerAndPoints[0][0];
+      if (center == null) {
         centerAndPoints = viewer.getCenterAndPoints(vAtomSets2, true);
+        center = centerAndPoints[0][0];
+      }
       Point3f pt1 = new Point3f();
       float endDegrees = Float.NaN;
-      Vector3f translation = null;
       if (doTranslate) {
-        translation = new Vector3f(centerAndPoints[1][0]);
-        translation.sub(centerAndPoints[0][0]);
+        if (translation == null) {
+          translation = new Vector3f(centerAndPoints[1][0]);
+          translation.sub(centerAndPoints[0][0]);
+        }
         endDegrees = 0;
       }
       if (doRotate) {
         if (q == null)
           evalError("option not implemented", null);
-        pt1.set(centerAndPoints[0][0]);
+        pt1.set(center);
         pt1.add(q.getNormal());
         endDegrees = q.getTheta();
       }
@@ -7030,9 +7042,9 @@
         List<Point3f> ptsA = viewer.getAtomPointVector(bsFrom);
         Matrix4f m4 = ScriptMathProcessor.getMatrix4f(q.getMatrix(),
             translation);
-        ptsB = Measure.transformPoints(ptsA, m4, centerAndPoints[0][0]);
+        ptsB = Measure.transformPoints(ptsA, m4, center);
       }
-      viewer.rotateAboutPointsInternal(centerAndPoints[0][0], pt1, endDegrees
+      viewer.rotateAboutPointsInternal(center, pt1, endDegrees
           / nSeconds, endDegrees, doAnimate, bsFrom, translation, ptsB);
     }
   }
@@ -7040,7 +7052,7 @@
   float getSmilesCorrelation(BitSet bsA, BitSet bsB, String smiles,
                              List<Point3f> ptsA, List<Point3f> ptsB,
                              Matrix4f m4, List<BitSet> vReturn, 
-                             boolean isSmarts, boolean asMap)
+                             boolean isSmarts, boolean asMap, Point3f center)
       throws ScriptException {
     float tolerance = 0.1f; // TODO
     try {
@@ -7049,6 +7061,7 @@
         ptsB = new ArrayList<Point3f>();
       }
       Matrix4f m = new Matrix4f();
+      Point3f c = new Point3f();
 
       Atom[] atoms = viewer.getModelSet().atoms;
       int atomCount = viewer.getAtomCount();
@@ -7078,7 +7091,7 @@
         ptsB.clear();
         for (int j = 0; j < maps[i].length; j++)
           ptsB.add(atoms[maps[i][j]]);
-        float stddev = Measure.getTransformMatrix4(ptsA, ptsB, m, null);
+        float stddev = Measure.getTransformMatrix4(ptsA, ptsB, m, center);
         Logger.info("getSmilesCorrelation stddev=" + stddev);
         if (vReturn != null) {
           if (stddev < tolerance) {
@@ -7090,7 +7103,10 @@
         }
         if (stddev < lowestStdDev) {
           mapB = maps[i];
-          m4.set(m);
+          if (m4 != null)
+            m4.set(m);
+          if (center != null)
+            center.set(c);
           lowestStdDev = stddev;
         }
       }
@@ -7150,7 +7166,7 @@
 
       List<BitSet> vReturn = new ArrayList<BitSet>();
       float stddev = getSmilesCorrelation(bsMatch3D, bsSelected, pattern, null,
-          null, null, vReturn, isSmarts, false);
+          null, null, vReturn, isSmarts, false, null);
       if (Float.isNaN(stddev)) {
         if (asOneBitset)
           return new BitSet();

Modified: branches/v13_0/Jmol/src/org/jmol/script/ScriptMathProcessor.java
===================================================================
--- branches/v13_0/Jmol/src/org/jmol/script/ScriptMathProcessor.java    
2013-06-14 12:44:40 UTC (rev 18330)
+++ branches/v13_0/Jmol/src/org/jmol/script/ScriptMathProcessor.java    
2013-06-14 13:25:46 UTC (rev 18331)
@@ -842,7 +842,7 @@
       if (bs1 == null || bs2 == null)
         return addX("IDENTICAL");
       stddev = eval.getSmilesCorrelation(bs1, bs2, smiles1, null, null, null,
-          null, false, false);
+          null, false, false, null);
       return addX(stddev < 0.2f ? "IDENTICAL"
           : "IDENTICAL or CONFORMATIONAL ISOMERS (RMSD=" + stddev + ")");
     } else if (isSmiles) {
@@ -857,7 +857,7 @@
       if (sOpt == null)
         return false;
       stddev = eval.getSmilesCorrelation(bs1, bs2, sOpt, ptsA, ptsB, m, null,
-          !isSmiles, isMap);
+          !isSmiles, isMap, null);
       if (isMap) {
         int nAtoms = ptsA.size();
         if (nAtoms == 0)

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
Jmol-commits mailing list
Jmol-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-commits

Reply via email to