Revision: 18611
          http://sourceforge.net/p/jmol/code/18611
Author:   hansonr
Date:     2013-08-21 14:46:32 +0000 (Wed, 21 Aug 2013)
Log Message:
-----------
___JmolVersion="13.3.4_dev_2013.08.21"

bug fix: JANA2006 reader not processing occupancies 
   -- read now forced to "PACKED" in order to calculate site multiplicity 

Modified Paths:
--------------
    trunk/Jmol/src/org/jmol/adapter/readers/cif/CifReader.java
    trunk/Jmol/src/org/jmol/adapter/readers/cif/ModulationReader.java
    trunk/Jmol/src/org/jmol/adapter/readers/pdb/PdbReader.java
    trunk/Jmol/src/org/jmol/adapter/readers/pymol/PyMOLReader.java
    trunk/Jmol/src/org/jmol/adapter/readers/xtal/JanaReader.java
    trunk/Jmol/src/org/jmol/adapter/smarter/Atom.java
    trunk/Jmol/src/org/jmol/adapter/smarter/AtomIterator.java
    trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollection.java
    trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollectionReader.java
    trunk/Jmol/src/org/jmol/util/Modulation.java
    trunk/Jmol/src/org/jmol/util/ModulationSet.java
    trunk/Jmol/src/org/jmol/viewer/Jmol.properties

Modified: trunk/Jmol/src/org/jmol/adapter/readers/cif/CifReader.java
===================================================================
--- trunk/Jmol/src/org/jmol/adapter/readers/cif/CifReader.java  2013-08-21 
09:56:53 UTC (rev 18610)
+++ trunk/Jmol/src/org/jmol/adapter/readers/cif/CifReader.java  2013-08-21 
14:46:32 UTC (rev 18611)
@@ -349,7 +349,6 @@
     // no atom-centered rotation axes, and no mirror or glide planes.
     if (isPDB)
       atomSetCollection.setCheckSpecial(false);
-
     boolean doCheck = doCheckUnitCell && !isPDB;
     SymmetryInterface sym = applySymTrajASCR();
     if (auditBlockCode != null && auditBlockCode.contains("REFRNCE") && sym != 
null) {
@@ -1037,8 +1036,8 @@
           break;
         case OCCUPANCY:
           float floatOccupancy = parseFloatStr(field);
-          if (!Float.isNaN(floatOccupancy))
-            atom.occupancy = (int) (floatOccupancy * 100);
+          if (Float.isNaN(floatOccupancy))
+            atom.foccupancy = floatOccupancy;
           break;
         case B_ISO:
           atom.bfactor = parseFloatStr(field) * (isPDB ? 1 : 100f);

Modified: trunk/Jmol/src/org/jmol/adapter/readers/cif/ModulationReader.java
===================================================================
--- trunk/Jmol/src/org/jmol/adapter/readers/cif/ModulationReader.java   
2013-08-21 09:56:53 UTC (rev 18610)
+++ trunk/Jmol/src/org/jmol/adapter/readers/cif/ModulationReader.java   
2013-08-21 14:46:32 UTC (rev 18611)
@@ -117,12 +117,12 @@
   }
 
   protected void addModulation(Map<String, P3> map, String id, P3 pt, int 
iModel) {
-    if (modType != null)
-      switch (id.charAt(0)) {
+    char ch  = id.charAt(0);
+      switch (ch) {
       case 'O':
       case 'D':
       case 'U':
-        if (modType.indexOf(id.charAt(0)) < 0 || modSelected > 0
+        if (modType != null && modType.indexOf(ch) < 0 || modSelected > 0
             && modSelected != 1)
           return;
         break;
@@ -344,7 +344,7 @@
 
     if (Logger.debuggingHigh)
       Logger.debug("\nsetModulation: i=" + a.index + " " + a.atomName + " xyz="
-          + a + " occ=" + a.occupancy);
+          + a + " occ=" + a.foccupancy);
     if (iop != iopLast) {
       //System.out.println("mdim=" + mdim + " op=" + (iop + 1) + " " + 
symmetry.getSpaceGroupOperation(iop) + " " + symmetry.getSpaceGroupXyz(iop, 
false));
       iopLast = iop;
@@ -356,21 +356,24 @@
       Logger.debug("setModulation iop = " + iop + " "
           + symmetry.getSpaceGroupXyz(iop, false) + " " + a.bsSymmetry);
     }
-    
-    float vocc0 = a.occupancy / 100f;
+
     ModulationSet ms = new ModulationSet(a.index + " " + a.atomName, 
-        P3.newP(a), vocc0, modDim, list, gammaE, gammaIS, q123, qlen);
+        P3.newP(a), a.foccupancy / 10000f, modDim, list, gammaE, gammaIS, 
q123, qlen);
     a.vib = ms;
     ms.calculate();
-    if (!Float.isNaN(ms.vocc)) {
-      if (modVib && !Float.isNaN(vocc0)) {
-        a.occupancy = (int) ((vocc0 + ms.vocc) * 100);
-      } else if (ms.vocc < 0.5f) {
-        a.occupancy = 0;
+    float occ = ms.vOcc;
+    if (!Float.isNaN(occ)) {
+      if (modVib && !Float.isNaN(ms.vOcc0)) {
+        a.foccupancy = Math.min(1, Math.max(0, ms.vOcc0 + occ));
+        if (a.foccupancy  < 0)
+          a.foccupancy = 0;
+        
+      } else if (occ < 0.5f) {
+        a.foccupancy = 0;
         if (bsAtoms != null)
           bsAtoms.clear(a.index);
-      } else if (ms.vocc >= 0.5f) {
-        a.occupancy = 100;
+      } else if (occ >= 0.5f) {
+        a.foccupancy = 1;
       }
     }
     if (ms.htUij != null) {
@@ -398,7 +401,7 @@
 
     // set property_modT to be Math.floor (q.r/|q|) -- really only for d=1
 
-    if (modVib || a.occupancy != 0) {
+    if (modVib || a.foccupancy != 0) {
       float t = q1Norm.dot(a);
       if (Math.abs(t - (int) t) > 0.001f)
         t = (int) Math.floor(t);

Modified: trunk/Jmol/src/org/jmol/adapter/readers/pdb/PdbReader.java
===================================================================
--- trunk/Jmol/src/org/jmol/adapter/readers/pdb/PdbReader.java  2013-08-21 
09:56:53 UTC (rev 18610)
+++ trunk/Jmol/src/org/jmol/adapter/readers/pdb/PdbReader.java  2013-08-21 
14:46:32 UTC (rev 18611)
@@ -955,8 +955,7 @@
         
     }
     
-    atom.occupancy = (Float.isNaN(floatOccupancy) ? 100
-        : (int) (floatOccupancy * 100));
+    atom.foccupancy = (Float.isNaN(floatOccupancy) ? 1 : floatOccupancy);
     
   }
 

Modified: trunk/Jmol/src/org/jmol/adapter/readers/pymol/PyMOLReader.java
===================================================================
--- trunk/Jmol/src/org/jmol/adapter/readers/pymol/PyMOLReader.java      
2013-08-21 09:56:53 UTC (rev 18610)
+++ trunk/Jmol/src/org/jmol/adapter/readers/pymol/PyMOLReader.java      
2013-08-21 14:46:32 UTC (rev 18611)
@@ -1051,7 +1051,7 @@
       bs.set(seqNo - MIN_RESNO);
     }
     atom.bfactor = floatAt(a, 14);
-    atom.occupancy = (int) (floatAt(a, 15) * 100);
+    atom.foccupancy = floatAt(a, 15);
     atom.radius = floatAt(a, 16);
     if (atom.radius == 0)
       atom.radius = 1;

Modified: trunk/Jmol/src/org/jmol/adapter/readers/xtal/JanaReader.java
===================================================================
--- trunk/Jmol/src/org/jmol/adapter/readers/xtal/JanaReader.java        
2013-08-21 09:56:53 UTC (rev 18610)
+++ trunk/Jmol/src/org/jmol/adapter/readers/xtal/JanaReader.java        
2013-08-21 14:46:32 UTC (rev 18611)
@@ -29,6 +29,7 @@
 import org.jmol.adapter.readers.cif.ModulationReader;
 import org.jmol.adapter.smarter.Atom;
 import org.jmol.io.JmolBinary;
+import org.jmol.util.BS;
 import org.jmol.util.JmolList;
 import org.jmol.util.Logger;
 import org.jmol.util.P3;
@@ -48,6 +49,7 @@
       setFractionalCoordinates(true);
       initializeModulation();
       atomSetCollection.newAtomSet();
+      forcePacked = true; // need site occupancies anyway
   }
   
   final static String records = "tit  cell ndim qi   lat  sym  spg  end";
@@ -122,6 +124,7 @@
     if (lattvecs != null)
       atomSetCollection.getSymmetry().addLatticeVectors(lattvecs);
     applySymmetryAndSetTrajectory();
+    adjustM40Occupancies();
     setModulation();
     finalizeModulation();
     finalizeReaderASCR();
@@ -236,6 +239,7 @@
       atom.atomName = line.substring(0, 9).trim();
       if (!filterAtom(atom, 0))
         continue;
+      atom.foccupancy = floats[2];
       setAtomCoordXYZ(atom, floats[3], floats[4], floats[5]);
       atomSetCollection.addAtom(atom);
       if (!incommensurate)
@@ -247,7 +251,6 @@
       int nOcc = getInt(65, 68);
       int nDisp = getInt(68, 71);
       int nUij = getInt(71, 74);
-
       // read anisotropies
       readM40Floats(r);
       boolean isIso = true;
@@ -398,4 +401,19 @@
     return data;
   }
 
+  /**
+   * M40 occupancies are divided by the site multiplicity
+   */
+  private void adjustM40Occupancies() {
+    int nOps = atomSetCollection.getSymmetry().getSpaceGroupOperationCount();
+    BS bsSite = new BS();
+    Atom[] atoms = atomSetCollection.getAtoms();
+    for (int i = atomSetCollection.getAtomCount(); --i >= 0;) {
+      Atom a = atoms[i];
+      bsSite.clearAll();
+      bsSite.setBits(0, nOps);
+      bsSite.and(a.bsSymmetry);
+      a.foccupancy *= bsSite.cardinality();
+    }
+  }
 }

Modified: trunk/Jmol/src/org/jmol/adapter/smarter/Atom.java
===================================================================
--- trunk/Jmol/src/org/jmol/adapter/smarter/Atom.java   2013-08-21 09:56:53 UTC 
(rev 18610)
+++ trunk/Jmol/src/org/jmol/adapter/smarter/Atom.java   2013-08-21 14:46:32 UTC 
(rev 18611)
@@ -43,7 +43,7 @@
   public float partialCharge = Float.NaN;
   public V3 vib;
   public float bfactor = Float.NaN;
-  public int occupancy = 100;
+  public float foccupancy = 1;
   public float radius = Float.NaN;
   public boolean isHetero;
   public int atomSerial = Integer.MIN_VALUE;

Modified: trunk/Jmol/src/org/jmol/adapter/smarter/AtomIterator.java
===================================================================
--- trunk/Jmol/src/org/jmol/adapter/smarter/AtomIterator.java   2013-08-21 
09:56:53 UTC (rev 18610)
+++ trunk/Jmol/src/org/jmol/adapter/smarter/AtomIterator.java   2013-08-21 
14:46:32 UTC (rev 18611)
@@ -123,7 +123,7 @@
 
        
        public int getOccupancy() {
-               return atom.occupancy;
+               return (int) (atom.foccupancy * 100);
        }
 
        

Modified: trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollection.java
===================================================================
--- trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollection.java      
2013-08-21 09:56:53 UTC (rev 18610)
+++ trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollection.java      
2013-08-21 14:46:32 UTC (rev 18611)
@@ -55,6 +55,8 @@
 @SuppressWarnings("unchecked")
 public class AtomSetCollection {
 
+  public BS bsAtoms; // required for CIF reader
+    
   private String fileTypeName;
   
   public String getFileTypeName() {
@@ -80,8 +82,6 @@
     return atomSetCollectionAuxiliaryInfo;
   }
   
-  public BS bsAtoms; // required for CIF reader
-  
   private final static String[] globalBooleans = 
{"someModelsHaveFractionalCoordinates",
     "someModelsHaveSymmetry", "someModelsHaveUnitcells", 
"someModelsHaveCONECT", "isPDB"};
 
@@ -1509,7 +1509,7 @@
     haveMappedSerials = false;
   }
 
-  boolean haveMappedSerials;
+  private boolean haveMappedSerials;
 
   private void mapMostRecentAtomSerialNumber() {
     if (atomCount == 0)

Modified: trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollectionReader.java
===================================================================
--- trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollectionReader.java        
2013-08-21 09:56:53 UTC (rev 18610)
+++ trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollectionReader.java        
2013-08-21 14:46:32 UTC (rev 18611)
@@ -183,6 +183,7 @@
   protected String strSupercell;
   protected P3 ptSupercell;
   protected boolean mustFinalizeModelSet;
+  protected boolean forcePacked;
 
   // private state variables
 
@@ -514,27 +515,7 @@
 
     symmetryRange = (htParams.containsKey("symmetryRange") ? ((Float) htParams
         .get("symmetryRange")).floatValue() : 0);
-    latticeCells = new int[3];
-    if (htParams.containsKey("lattice")) {
-      P3 pt = ((P3) htParams.get("lattice"));
-      latticeCells[0] = (int) pt.x;
-      latticeCells[1] = (int) pt.y;
-      latticeCells[2] = (int) pt.z;
-      doCentroidUnitCell = (htParams.containsKey("centroid"));
-      if (doCentroidUnitCell && (latticeCells[2] == -1 || latticeCells[2] == 
0))
-        latticeCells[2] = 1;
-      centroidPacked = doCentroidUnitCell && htParams.containsKey("packed");
-      doPackUnitCell = !doCentroidUnitCell && (htParams.containsKey("packed") 
|| latticeCells[2] < 0);
-      
-    }
-    doApplySymmetry = (latticeCells[0] > 0 && latticeCells[1] > 0);
-    //allows for {1 1 1} or {1 1 -1} or {555 555 0|1|-1} (-1  being "packed")
-    if (!doApplySymmetry) {
-      latticeCells[0] = 0;
-      latticeCells[1] = 0;
-      latticeCells[2] = 0;
-    }
-
+    initializeSymmetryOptions();
     //this flag FORCES symmetry -- generally if coordinates are not fractional,
     //we may note the unit cell, but we do not apply symmetry
     //with this flag, we convert any nonfractional coordinates to fractional
@@ -581,6 +562,31 @@
     }
   }
 
+  protected void initializeSymmetryOptions() {
+    latticeCells = new int[3];
+    P3 pt = ((P3) htParams.get("lattice"));
+    if (forcePacked && pt == null)
+      pt = P3.new3(1, 1, 1);
+    if (pt != null) {
+      latticeCells[0] = (int) pt.x;
+      latticeCells[1] = (int) pt.y;
+      latticeCells[2] = (int) pt.z;
+      doCentroidUnitCell = (htParams.containsKey("centroid"));
+      if (doCentroidUnitCell && (latticeCells[2] == -1 || latticeCells[2] == 
0))
+        latticeCells[2] = 1;
+      boolean isPacked = forcePacked || htParams.containsKey("packed");
+      centroidPacked = doCentroidUnitCell && isPacked;
+      doPackUnitCell = !doCentroidUnitCell && (isPacked || latticeCells[2] < 
0);      
+    }
+    doApplySymmetry = (latticeCells[0] > 0 && latticeCells[1] > 0);
+    //allows for {1 1 1} or {1 1 -1} or {555 555 0|1|-1} (-1  being "packed")
+    if (!doApplySymmetry) {
+      latticeCells[0] = 0;
+      latticeCells[1] = 0;
+      latticeCells[2] = 0;
+    }
+  }
+
   public boolean haveModel;
 
   public boolean doGetModel(int modelNumber, String title) {
@@ -1051,6 +1057,8 @@
   }
   
   public SymmetryInterface applySymTrajASCR() throws Exception {
+    if (forcePacked)
+      initializeSymmetryOptions();
     SymmetryInterface sym = null;
     if (iHaveUnitCell && doCheckUnitCell) {
       
atomSetCollection.setCoordinatesAreFractional(iHaveFractionalCoordinates);

Modified: trunk/Jmol/src/org/jmol/util/Modulation.java
===================================================================
--- trunk/Jmol/src/org/jmol/util/Modulation.java        2013-08-21 09:56:53 UTC 
(rev 18610)
+++ trunk/Jmol/src/org/jmol/util/Modulation.java        2013-08-21 14:46:32 UTC 
(rev 18611)
@@ -153,8 +153,8 @@
       //           p(x4)=0   if x4 is outside the interval [c-w/2,c+w/2],
 
       x -= Math.floor(x);
-      ms.vocc = (range(x) ? 1 : 0);
-      ms.vocc0 = Float.NaN; // don't add this in
+      ms.vOcc = (range(x) ? 1 : 0);
+      ms.vOcc0 = Float.NaN; // don't add this in
       //System.out.println("MOD " + ms.r + " " +  ms.delta + " " + ms.epsilon 
+ " " + ms.id + " " + ms.v + " l=" + left + " x=" + x4 + " r=" + right);
       return;
     case TYPE_DISP_SAWTOOTH:
@@ -249,9 +249,9 @@
       ms.addUTens(utens, (float) v);
       break;
     default:
-      if (Float.isNaN(ms.vocc))
-        ms.vocc = 0;
-      ms.vocc += (float) v;
+      if (Float.isNaN(ms.vOcc))
+        ms.vOcc = 0;
+      ms.vOcc += (float) v;
     }
   }
 

Modified: trunk/Jmol/src/org/jmol/util/ModulationSet.java
===================================================================
--- trunk/Jmol/src/org/jmol/util/ModulationSet.java     2013-08-21 09:56:53 UTC 
(rev 18610)
+++ trunk/Jmol/src/org/jmol/util/ModulationSet.java     2013-08-21 14:46:32 UTC 
(rev 18611)
@@ -13,13 +13,13 @@
 
 public class ModulationSet extends Vibration {
 
-  public float vocc = Float.NaN;
+  public float vOcc = Float.NaN;
   public Map<String, Float> htUij;
   public boolean enabled = false;
   public String id;
   public V3 prevSetting;
 
-  float vocc0 = Float.NaN;
+  public float vOcc0;
 
   private JmolList<Modulation> mods;
   private Matrix3f gammaE;
@@ -48,7 +48,7 @@
   public ModulationSet(String id, P3 r, float vocc0, int modDim, 
                        JmolList<Modulation> mods, Matrix3f gammaE, Matrix4f 
gammaIS, P3[] q123, double[] qlen) {
     this.id = id;
-    this.vocc0 = vocc0;
+    this.vOcc0 = vocc0;
     this.modDim = modDim;
     this.mods = mods;
     
@@ -76,7 +76,7 @@
   public void calculate() {
     x = y = z = 0;
     htUij = null;
-    vocc = Float.NaN;
+    vOcc = Float.NaN;
     double offset = (t == Integer.MAX_VALUE ? 0 : qlen[0] * t);
     for (int i = mods.size(); --i >= 0;)
       mods.get(i).apply(this, offset);

Modified: trunk/Jmol/src/org/jmol/viewer/Jmol.properties
===================================================================
--- trunk/Jmol/src/org/jmol/viewer/Jmol.properties      2013-08-21 09:56:53 UTC 
(rev 18610)
+++ trunk/Jmol/src/org/jmol/viewer/Jmol.properties      2013-08-21 14:46:32 UTC 
(rev 18611)
@@ -11,8 +11,10 @@
 #  The quotes above look odd for a parameter file, but they are 
 #  important for the JavaScript version of Jmol.
 
-___JmolVersion="13.3.4_dev_2013.08.20c"
+___JmolVersion="13.3.4_dev_2013.08.21"
 
+bug fix: JANA2006 reader not processing occupancies 
+   -- read now forced to "PACKED" in order to calculate site multiplicity 
 bug fix: CIF reader not reading _CCDC_GEOM_BOND_TYPE record
 bug fix: File dialog problems with paths having space
 bug fix: GAMESS reader not reading energies

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


------------------------------------------------------------------------------
Introducing Performance Central, a new site from SourceForge and 
AppDynamics. Performance Central is your source for news, insights, 
analysis and resources for efficient Application Performance Management. 
Visit us today!
http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk
_______________________________________________
Jmol-commits mailing list
Jmol-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-commits

Reply via email to