Revision: 21563
          http://sourceforge.net/p/jmol/code/21563
Author:   hansonr
Date:     2017-04-27 19:00:54 +0000 (Thu, 27 Apr 2017)
Log Message:
-----------
Jmol.___JmolVersion="14.15.1" // 4/28/17

new feature: x.split(true)
 -- does a white-space token split of the string value of x

new feature: MOL/SDF reader reads M  ISO  lines for isotopes
new feature: CIP chirality adds P, S, As, Se, Sb, Te, Bi, Po trigonal pyramidal 
and tetrahedral
new feature: CIP chirality adds imine and diazine E/Z chirality

bug fix: CIP chirality broken for carbonyl groups
bug fix: CIP chirality E/Z should not be indicated for rings of size < 8

code: CIPChirality.java 779 lines Rules 1-5 validated on 145 compounds 
  - see https://sourceforge.net/p/jmol/code/HEAD/tree/trunk/Jmol-datafiles/cip/
code: CIP optimizations

Modified Paths:
--------------
    trunk/Jmol/src/org/jmol/adapter/readers/molxyz/MolReader.java
    trunk/Jmol/src/org/jmol/modelset/Atom.java
    trunk/Jmol/src/org/jmol/symmetry/CIPChirality.java
    trunk/Jmol/src/org/jmol/util/Elements.java
    trunk/Jmol/src/org/jmol/viewer/Jmol.properties

Modified: trunk/Jmol/src/org/jmol/adapter/readers/molxyz/MolReader.java
===================================================================
--- trunk/Jmol/src/org/jmol/adapter/readers/molxyz/MolReader.java       
2017-04-27 17:06:47 UTC (rev 21562)
+++ trunk/Jmol/src/org/jmol/adapter/readers/molxyz/MolReader.java       
2017-04-27 19:00:54 UTC (rev 21563)
@@ -32,6 +32,7 @@
 import org.jmol.adapter.smarter.AtomSetCollectionReader;
 import org.jmol.adapter.smarter.Atom;
 import org.jmol.api.JmolAdapter;
+import org.jmol.util.Elements;
 import org.jmol.util.Logger;
 
 /**
@@ -278,46 +279,69 @@
 
     Atom[] atoms = asc.atoms;
     Map<String, String> molData = new Hashtable<String, String>();
-    boolean haveData = false;
-    
     rd();
     while (line != null && line.indexOf("$$$$") != 0) {
-      if (line.indexOf(">") != 0) {
-        rd();
+      if (line.indexOf(">") == 0) {
+        readMolData(molData);
         continue;
       }
-      String dataName = PT.trim(line, "> <").toLowerCase();
-      String data = "";
-      float[] fdata = null;
-      while (rd() != null && line.indexOf("$$$$") != 0
-          && line.indexOf(">") != 0) {
-        data += line + "\n";
+      if (line.startsWith("M  ISO")) {
+        readIsotopes();
         continue;
       }
-      data = PT.trim(data, "\n");
-      Logger.info(dataName + ":" + data.replace('\n', '|'));
-      haveData = true;
-      molData.put(dataName, data);
-      if (dataName.toUpperCase().contains("_PARTIAL_CHARGES")) {
-        try {
-          fdata = PT.parseFloatArray(data);
-          for (int i = asc.getLastAtomSetAtomIndex(), n = asc.ac; i < n; i++)
-            atoms[i].partialCharge = 0;
-          int pt = 0;
-          for (int i = (int) fdata[pt++]; --i >= 0;) {
-            int atomIndex = (int) fdata[pt++] + iatom0 - 1;
-            float partialCharge = fdata[pt++];
-            atoms[atomIndex].partialCharge = partialCharge;
-          }
-        } catch (Exception e) {
-          for (int i = asc.getLastAtomSetAtomIndex(), n = asc.ac; i < n; i++)
-            atoms[i].partialCharge = 0;
-          return;
+      rd();
+    }
+    if (!molData.isEmpty())
+      asc.setModelInfoForSet("molData", molData, asc.iSet);
+  }
+
+  private void readIsotopes() throws Exception {
+    int n = parseIntAt(line, 6);
+    try {
+    for (int i = 0, pt = 9; i < n; i++) {
+      int ipt = parseIntAt(line, pt) - 1;
+      Atom atom = asc.atoms[ipt];
+      String ss = atom.getElementSymbol();
+      int iso = parseIntAt(line, pt + 4) + 
Elements.getNaturalIsotope(JmolAdapter.getElementNumber(ss));
+      pt += 8;
+      String s = atom.elementSymbol = "" + iso + atom.elementSymbol;
+      System.out.println(s);
+      atom.elementSymbol = s;
+    }
+    } catch (Throwable e) {}
+    rd();
+  }
+
+  private void readMolData(Map<String, String> molData) throws Exception {
+    Atom[] atoms = asc.atoms;
+    String dataName = PT.trim(line, "> <").toLowerCase();
+    String data = "";
+    float[] fdata = null;
+    while (rd() != null && line.indexOf("$$$$") != 0
+        && line.indexOf(">") != 0) {
+      data += line + "\n";
+      continue;
+    }
+    data = PT.trim(data, "\n");
+    Logger.info(dataName + ":" + data.replace('\n', '|'));
+    molData.put(dataName, data);
+    if (dataName.toUpperCase().contains("_PARTIAL_CHARGES")) {
+      try {
+        fdata = PT.parseFloatArray(data);
+        for (int i = asc.getLastAtomSetAtomIndex(), n = asc.ac; i < n; i++)
+          atoms[i].partialCharge = 0;
+        int pt = 0;
+        for (int i = (int) fdata[pt++]; --i >= 0;) {
+          int atomIndex = (int) fdata[pt++] + iatom0 - 1;
+          float partialCharge = fdata[pt++];
+          atoms[atomIndex].partialCharge = partialCharge;
         }
+      } catch (Exception e) {
+        for (int i = asc.getLastAtomSetAtomIndex(), n = asc.ac; i < n; i++)
+          atoms[i].partialCharge = 0;
+        return;
       }
     }
-    if (haveData)
-      asc.setModelInfoForSet("molData", molData, asc.iSet);
   }
 
   public void addMolAtom(int iAtom, int isotope, String elementSymbol,

Modified: trunk/Jmol/src/org/jmol/modelset/Atom.java
===================================================================
--- trunk/Jmol/src/org/jmol/modelset/Atom.java  2017-04-27 17:06:47 UTC (rev 
21562)
+++ trunk/Jmol/src/org/jmol/modelset/Atom.java  2017-04-27 19:00:54 UTC (rev 
21563)
@@ -1334,7 +1334,8 @@
   @Override
   
   public int getNominalMass() {
-    return Math.round(getMass());
+    int mass = getIsotopeNumber();
+    return (mass > 0 ? mass : Elements.getNaturalIsotope(getElementNumber()));
   }
   
   private float getMass() {

Modified: trunk/Jmol/src/org/jmol/symmetry/CIPChirality.java
===================================================================
--- trunk/Jmol/src/org/jmol/symmetry/CIPChirality.java  2017-04-27 17:06:47 UTC 
(rev 21562)
+++ trunk/Jmol/src/org/jmol/symmetry/CIPChirality.java  2017-04-27 19:00:54 UTC 
(rev 21563)
@@ -67,7 +67,8 @@
  * 4/6/17 Introduced in Jmol 14.12.0; 
  * validated for Rules 1 and 2 in Jmol 14.13.2; 
  * E/Z added 14.14.1; 
- * 4/27/17 Ruled 3-5 completed 14.15.1   
+ * 4/27/17 Ruled 3-5 completed 14.15.1
+ * 4/28/17 Validated for 146 compounds, including imines and diazines   
  * 
  * 
  * validation suite: see 
https://sourceforge.net/p/jmol/code/HEAD/tree/trunk/Jmol-datafiles/cip/
@@ -401,8 +402,10 @@
   private boolean couldBeChiralAtom(Node a) {
     boolean mustBePlanar = false;
     switch (a.getCovalentBondCount()) {
-    case 4:
-      break;
+    default:
+      return  false;
+    case 2:
+      return a.getElementNumber() == 7; // could be diazine or imine
     case 3:
       switch (a.getElementNumber()) {
       case 6: // C
@@ -417,13 +420,14 @@
       case 83: // Bi
       case 84: // Po
         break;
+      case 4:
+        break;
       default:
         return false;
       }
       break;
-    // could add case 2 for imines here
-    default:
-      return false;
+    case 4:
+      break;
     }
     // check that the atom has at most one 1H atom
     Edge[] edges = a.getEdges();
@@ -453,7 +457,7 @@
       return false;
     case 2:
       // imines and diazines
-      if (a.getElementNumber() != 7) // nitrogen
+      if (a.getElementNumber  () != 7) // nitrogen
         return false;
       break;
     case 3:
@@ -1228,6 +1232,7 @@
             priorities[i]++;
             if (Logger.debuggingHigh)
               Logger.info(this + "." + b + " B-beats " + a);
+            
             break;
           case A_WINS:
             indices[j]++;

Modified: trunk/Jmol/src/org/jmol/util/Elements.java
===================================================================
--- trunk/Jmol/src/org/jmol/util/Elements.java  2017-04-27 17:06:47 UTC (rev 
21562)
+++ trunk/Jmol/src/org/jmol/util/Elements.java  2017-04-27 19:00:54 UTC (rev 
21563)
@@ -176,6 +176,27 @@
     /* 7 Rf - Mt */ 261f, 262f, 263f, 262f, 265f, 268f
     };
   
+   public final static int[] isotopeMass = {
+     0, 
+     /* 1 H */   1, 4, 
+     /* 2 Li */  7, 9,                              11, 12, 14, 16, 19, 20,
+     /* 3 Na */ 23,24,                              27, 28, 31, 32, 35, 40,
+     /* 4 K */      39, 40,  45,   48,  51,   52,  55,  56,  59,  59,  64,  
65,  70,  73,  75,  79,  80,  84,
+
+  /* 5 Rb */   85,  88,  89,  91,  93,  96,  98,  101,  103,  106,  108,  112, 
 115,  119,  122,  128,  127,  131,
+   
+  /* 6 Cs, Ba, actinides */   133,  137,  139,  140,  141,  144,  145,  150,  
152,  157,  159,  163,  165,  167,  169,  173,  175,
+  179,  181,  184,  186,  190,  192,  195,  197,  201,  204,  207,  209,   
209,  210,  222,
+  
+  /* 7 Fr, Ra, lanthanides */   
+  223,  226,  227,  232,  231,  238,  237,  244,   243,  247, 247,  251,  252, 
 257,  258,  259,   260,
+   /* 7 Rf - Mt */   261,  262,  263,  262,  265,  268
+   };
+
+   public static int getNaturalIsotope(int elementNumber) {
+     return isotopeMass[elementNumber];
+   }
+
    public static float getAtomicMass(int i) {
      return (i < 1 || i >= atomicMass.length ? 0 : atomicMass[i]);
    }
@@ -459,21 +480,7 @@
     return 0;
   }
   
-  private static int[] naturalIsotopeMasses = {
-    1, 1, // H
-    6, 12,// C
-    7, 14,// N
-    8, 16,// O   -- can add any number more if desired
-  };
 
-  public static int getNaturalIsotope(int elementNumber) {
-    for (int i = 0; i < naturalIsotopeMasses.length; i += 2)
-      if (naturalIsotopeMasses[i] == elementNumber)
-        return naturalIsotopeMasses[++i];
-    return 0;
-  }
-
-
   // add as we go
   private final static String naturalIsotopes = "1H,12C,14N";
   

Modified: trunk/Jmol/src/org/jmol/viewer/Jmol.properties
===================================================================
--- trunk/Jmol/src/org/jmol/viewer/Jmol.properties      2017-04-27 17:06:47 UTC 
(rev 21562)
+++ trunk/Jmol/src/org/jmol/viewer/Jmol.properties      2017-04-27 19:00:54 UTC 
(rev 21563)
@@ -49,17 +49,19 @@
 # 10. Run jmol/tools build-release.xml
 #
 
-Jmol.___JmolVersion="14.15.1" // 4/26/17
+Jmol.___JmolVersion="14.15.1" // 4/28/17
 
 new feature: x.split(true)
  -- does a white-space token split of the string value of x
 
+new feature: MOL/SDF reader reads M  ISO  lines for isotopes
 new feature: CIP chirality adds P, S, As, Se, Sb, Te, Bi, Po trigonal 
pyramidal and tetrahedral
+new feature: CIP chirality adds imine and diazine E/Z chirality
 
 bug fix: CIP chirality broken for carbonyl groups
 bug fix: CIP chirality E/Z should not be indicated for rings of size < 8
 
-code: CIPChirality.java 763 lines Rules 1-5 validated on 86 compounds 
+code: CIPChirality.java 779 lines Rules 1-5 validated on 145 compounds 
   - see https://sourceforge.net/p/jmol/code/HEAD/tree/trunk/Jmol-datafiles/cip/
 code: CIP optimizations
 

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


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Jmol-commits mailing list
Jmol-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-commits

Reply via email to