Revision: 18517
          http://sourceforge.net/p/jmol/code/18517
Author:   hansonr
Date:     2013-08-08 03:06:45 +0000 (Thu, 08 Aug 2013)
Log Message:
-----------
partial commit

Modified Paths:
--------------
    trunk/Jmol/src/org/jmol/adapter/readers/cifpdb/CifReader.java
    trunk/Jmol/src/org/jmol/adapter/readers/cifpdb/ModulationReader.java

Modified: trunk/Jmol/src/org/jmol/adapter/readers/cifpdb/CifReader.java
===================================================================
--- trunk/Jmol/src/org/jmol/adapter/readers/cifpdb/CifReader.java       
2013-08-07 19:52:31 UTC (rev 18516)
+++ trunk/Jmol/src/org/jmol/adapter/readers/cifpdb/CifReader.java       
2013-08-08 03:06:45 UTC (rev 18517)
@@ -128,6 +128,11 @@
       molecularType = "filter \"MOLECULAR\"";
     }
     initializeMod();
+    readCifData();
+    continuing = false;
+  }
+
+  private void readCifData() throws Exception {
     
     /*
      * Modified for 10.9.64 9/23/06 by Bob Hanson to remove as much as possible
@@ -141,7 +146,6 @@
      * report if it finds data where a key is supposed to be.
      */
     line = "";
-    skipping = false;
     while ((key = tokenizer.peekToken()) != null)
       if (!readAllData())
         break;
@@ -152,7 +156,6 @@
         if (!readAllData())
           break;
     }
-    continuing = false;
   }
 
   public String readNextLine() throws Exception {
@@ -211,18 +214,7 @@
       } else if (key.startsWith("_chemical_formula_sum") || 
key.equals("_chem_comp_formula")) {
         processChemicalInfo("formula");
       } else if (key.equals("_cell_modulation_dimension") && !modAverage) {
-        modDim = parseIntStr(data);
-        if (modDim > 1) {
-          // not ready for dim=2
-          appendLoadNote("CIF Reader: Too high modulation dimension (" + 
modDim + ") -- reading average structure");
-          modDim = 0;
-          modAverage = true;
-        } else {
-          appendLoadNote("CIF Reader: modulation dimension = " + modDim);   
-          htModulation = new Hashtable<String, P3>();
-          //allowRotations = false;
-        }
-        incommensurate = (modDim > 0);
+        setModDim(data);
       } else if (key.startsWith("_cell_")) {
         processCellParameter();
       } else if (key.startsWith("_symmetry_space_group_name_H-M")
@@ -265,8 +257,7 @@
 
   @Override
   protected void finalizeReader() throws Exception {
-    if (incommensurate)
-      
atomSetCollection.setBaseSymmetryAtomCount(atomSetCollection.getAtomCount());
+    finalizeIncommensurate();
     if (atomSetCollection.getAtomCount() == nAtoms)
       atomSetCollection.removeCurrentAtomSet();
     else
@@ -285,8 +276,7 @@
         atomSetCollection.applySymmetryBio(vBiomts, notionalUnitCell, 
applySymmetryToBonds, filter);
       }
     }
-    if (incommensurate && htModulation != null)
-      setModulation();
+    setModulation();
     finalizeReaderASCR();
     String header = tokenizer.getFileHeader();
     if (header.length() > 0)
@@ -332,8 +322,9 @@
     // This speeds up calculation, because no crosschecking
     // No special-position atoms in mmCIF files, because there will
     // be no center of symmetry, no rotation-inversions, 
-    // no atom-centered rotation axes, and no mirror or glide planes. 
-    atomSetCollection.setCheckSpecial(checkSpecial && !isPDB);
+    // no atom-centered rotation axes, and no mirror or glide planes.
+    if (isPDB)
+      atomSetCollection.setCheckSpecial(false);
     boolean doCheck = doCheckUnitCell && !isPDB;
     applySymTrajASCR();
     if (doCheck && (bondTypes.size() > 0 || isMolecular))
@@ -2026,17 +2017,17 @@
           if (id.equals("D_S")) {
             // saw tooth displacement  center/width/Axyz
             if (pt.x != 0)
-              addModulation(htModulation, "D_Sx;" + atomLabel, P3.new3(c, w, 
pt.x));
+              addModulation(null, "D_Sx;" + atomLabel, P3.new3(c, w, pt.x));
             if (pt.y != 0)
-              addModulation(htModulation, "D_Sy;" + atomLabel, P3.new3(c, w, 
pt.y));
+              addModulation(null, "D_Sy;" + atomLabel, P3.new3(c, w, pt.y));
             if (pt.z != 0)
-              addModulation(htModulation, "D_Sz;" + atomLabel, P3.new3(c, w, 
pt.z));
+              addModulation(null, "D_Sz;" + atomLabel, P3.new3(c, w, pt.z));
             continue;
           }
             id += axis + ";" + atomLabel;
           break;
         }
-        addModulation(htModulation, id, pt);
+        addModulation(null, id, pt);
       }
     }
   }

Modified: trunk/Jmol/src/org/jmol/adapter/readers/cifpdb/ModulationReader.java
===================================================================
--- trunk/Jmol/src/org/jmol/adapter/readers/cifpdb/ModulationReader.java        
2013-08-07 19:52:31 UTC (rev 18516)
+++ trunk/Jmol/src/org/jmol/adapter/readers/cifpdb/ModulationReader.java        
2013-08-08 03:06:45 UTC (rev 18517)
@@ -53,11 +53,11 @@
   protected String modAxes;
   protected boolean modAverage;
   protected boolean checkSpecial = true;
-  protected boolean modCentered;
-  protected boolean modOffset;
   protected int modDim;
+  //protected boolean modCentered;
+  //protected boolean modOffset;
   protected boolean incommensurate;
-  protected Map<String, P3> htModulation;
+  private Map<String, P3> htModulation;
   protected Atom[] atoms;
   
   protected void initializeMod() throws Exception {
@@ -65,18 +65,63 @@
     modVib = checkFilterKey("MODVIB");
     modAverage = checkFilterKey("MODAVE");
     checkSpecial = !checkFilterKey("NOSPECIAL");
-    modOffset = !checkFilterKey("NOMODOFFSET");
-    modCentered = !checkFilterKey("NOMODCENT");
+    atomSetCollection.setCheckSpecial(checkSpecial);
     allowRotations = !checkFilterKey("NOSYM");
-    if (!modCentered) {
-      if (doCentralize && filter.indexOf("CENTER") == 
filter.lastIndexOf("CENTER"))
-        doCentralize = false;
-      appendLoadNote("CIF reader not using delta to recenter modulation.");
+    //modOffset = !checkFilterKey("NOMODOFFSET");
+    //modCentered = !checkFilterKey("NOMODCENT");
+    //if (!modCentered) {
+    //  if (doCentralize && filter.indexOf("CENTER") == 
filter.lastIndexOf("CENTER"))
+    //    doCentralize = false;
+    //  appendLoadNote("CIF reader not using delta to recenter modulation.");
+    // }
+  }
+
+  private JmolList<float[]> lattvecs;
+
+  protected void addLatticeVector(String data) {
+    if (lattvecs == null)
+      lattvecs = new JmolList<float[]>();
+    float[] a = getTokensFloat(data, null, modDim + 3);
+    boolean isOK = false;
+    for (int i = a.length; --i >= 0 && !isOK;) {
+      if (Float.isNaN(a[i]))
+        return;
+      isOK |= (a[i] != 0);
     }
+    if (isOK)
+      lattvecs.addLast(a);
   }
 
+  protected void finalizeIncommensurate() {
+    if (incommensurate)
+      
atomSetCollection.setBaseSymmetryAtomCount(atomSetCollection.getAtomCount());
+    if (lattvecs != null)
+      atomSetCollection.getSymmetry().addLatticeVectors(lattvecs);
+  }
+
+  protected void setModDim(String token) {
+    modDim = parseIntStr(token);
+    if (modAverage)
+      return;
+    if (modDim > 1) {
+      // not ready for dim=2
+      appendLoadNote("Too high modulation dimension (" + modDim + ") -- 
reading average structure");
+      modDim = 0;
+      modAverage = true;
+    } else {
+      appendLoadNote("Modulation dimension = " + modDim);   
+      htModulation = new Hashtable<String, P3>();
+    }
+    incommensurate = (modDim > 0);
+  }
   
+  protected P3 getModulationVector(String id) {
+    return htModulation.get(id);
+  }
+  
   protected void addModulation(Map<String, P3> map, String id, P3 pt) {
+    if (map == null)
+      map = htModulation;
     map.put(id, pt);
     Logger.info("Adding " + id + " " + pt);
     if (id.charAt(0) == 'W' || id.charAt(0) == 'F')
@@ -88,6 +133,8 @@
    * 
    */
   protected void setModulation() {
+    if (!incommensurate || htModulation == null)
+      return;
     Map<String, P3> map = new Hashtable<String, P3>();
     for (Entry<String, P3> e : htModulation.entrySet()) {
       String key = e.getKey();
@@ -201,8 +248,8 @@
    * 
    * @param i
    * @param modvib
-   * @param pt0 
-   * @param sb 
+   * @param pt0
+   * @param sb
    */
   public void modulateAtom(int i, boolean modvib, P3 pt0, SB sb) {
     Atom a = atoms[i];
@@ -210,54 +257,37 @@
     JmolList<Modulation> list = htAtomMods.get(a.atomName);
     if (list == null || symmetry == null)
       return;
-//    if (pt0 != null) {
-      int iop = a.bsSymmetry.nextSetBit(0);
-      if (iop < 0)
-        iop = 0;
-      Matrix4f m = symmetry.getSpaceGroupOperation(iop);
-      m.getRotationScale(mtemp3);
-      //mtemp3i.invertM(mtemp3);
-      //opTrans = symmetry.getOriginalTranslation(iop);
-      //m.get(opTrans);
-      float epsilon = (modCentered ? symmetry.getModParam(iop, 0) : 1);
-      float delta = (modCentered ? symmetry.getModParam(iop, 1) : 0);
-      if (modOffset) {
-        ptemp.setT(a);
-        symmetry.unitize(ptemp);
-        offset.sub2(a, ptemp);
-        //getOffset(pt0, atoms[i]);
-      }
-      //System.out.println("=========CIF i=" + i + " " + a.atomName + " " + a);
-      //System.out.println("op=" + (iop+1) + " " + 
symmetry.getSpaceGroupXyz(iop, false) + " ep=" + epsilon + " de=" + delta + 
"\nopTrans=" + opTrans + " a=" + a);
-      qNorm = V3.newV(list.get(0).getWaveVector());
-      qNorm.normalize();
-      Modulation.modulateAtom(ptemp, offset, list, epsilon, delta, a.vib);
-      System.out.println("a.vib(abc)=" + a.vib);
-      //System.out.println("CIF R=" + mtemp3);
-      //System.out.println("CIF R-1=" + mtemp3i);
-      mtemp3.transform(a.vib);
-      sb.append((int)(qNorm.dot(offset)*1.01f) + "\n");
-//    } else {
-//      Modulation.modulateAtom(a, null, list, 1, 0f, a.vib);
-//      sb.append("0\n");
-//    }
+    //    if (pt0 != null) {
+    int iop = a.bsSymmetry.nextSetBit(0);
+    if (iop < 0)
+      iop = 0;
+    Matrix4f m = symmetry.getSpaceGroupOperation(iop);
+    m.getRotationScale(mtemp3);
+    //mtemp3i.invertM(mtemp3);
+    //opTrans = symmetry.getOriginalTranslation(iop);
+    //m.get(opTrans);
+    float epsilon = symmetry.getModParam(iop, 0);
+    float delta = symmetry.getModParam(iop, 1);
+    ptemp.setT(a);
+    symmetry.unitize(ptemp);
+    offset.sub2(a, ptemp);
+    //System.out.println("=========CIF i=" + i + " " + a.atomName + " " + a);
+    //System.out.println("op=" + (iop + 1) + " "
+      //  + symmetry.getSpaceGroupXyz(iop, false) + " ep=" + epsilon + " de="
+        //+ delta + " a=" + a);
+    qNorm = V3.newV(list.get(0).getWaveVector());
+    qNorm.normalize();
+    Modulation.modulateAtom(ptemp, offset, list, epsilon, delta, a.vib);
+    System.out.println("a.vib(abc)=" + a.vib);
+    mtemp3.transform(a.vib);
+    sb.append((int) (qNorm.dot(offset) * 1.01f) + "\n");
     if (!modvib) {
       a.add(a.vib);
       a.vib.scale(-1);
     }
     symmetry.toCartesian(a.vib, true);
-    System.out.println("a.vib(xyz)=" + a.vib);
+    //System.out.println("a.vib(xyz)=" + a.vib);
     //if (i == 98 || i == 99)
-      //System.out.println("CIFTEST");  
+      //System.out.println("CIFTEST");
   }
-
-  //  private void getOffset(P3 pt0, P3 pt1) {
-  //    ptemp.setT(pt1);
-  //    
-  //    //ptemp.sub(opTrans);
-  //    //mtemp3i.transform(ptemp);
-  //    //offset.sub2(ptemp, pt0);
-  //    System.out.println("pt0=" + pt0 + " ptemp=" + ptemp);
-  //  }
-
 }

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


------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite!
It's a free troubleshooting tool designed for production.
Get down to code-level detail for bottlenecks, with <2% overhead. 
Download for free and get started troubleshooting in minutes. 
http://pubads.g.doubleclick.net/gampad/clk?id=48897031&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