Revision: 18515 http://sourceforge.net/p/jmol/code/18515 Author: hansonr Date: 2013-07-31 12:28:48 +0000 (Wed, 31 Jul 2013) Log Message: ----------- ___JmolVersion="13.3.4_dev_2013.07.31"
TODO: CIF reader is not handling modulation for symmetry-related atoms correctly yet. new feature: msCIF file reading of incommensurate modulation data as vibration new feature: msCIF file filter "MODAXES=xxx" where xxx = X,XY,XYZ,YZ,etc. new feature: msCIF file filter "MODAVE" gives average structure with vibration vectors. Modified Paths: -------------- trunk/Jmol/src/org/jmol/adapter/readers/cifpdb/CifReader.java trunk/Jmol/src/org/jmol/adapter/readers/cifpdb/PdbReader.java trunk/Jmol/src/org/jmol/adapter/readers/quantum/MoldenReader.java trunk/Jmol/src/org/jmol/adapter/readers/xtal/CastepReader.java trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollection.java trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollectionReader.java trunk/Jmol/src/org/jmol/viewer/Jmol.properties Modified: trunk/Jmol/src/org/jmol/adapter/readers/cifpdb/CifReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/readers/cifpdb/CifReader.java 2013-07-31 01:52:42 UTC (rev 18514) +++ trunk/Jmol/src/org/jmol/adapter/readers/cifpdb/CifReader.java 2013-07-31 12:28:48 UTC (rev 18515) @@ -45,9 +45,11 @@ import org.jmol.util.BS; import org.jmol.util.Logger; import org.jmol.util.Matrix4f; +import org.jmol.util.Modulation; import org.jmol.util.P3; import org.jmol.util.SimpleUnitCell; import org.jmol.util.TextFormat; +import org.jmol.util.V3; /** @@ -94,7 +96,8 @@ private int conformationIndex; private boolean filterAssembly; private boolean allowRotations = true; - private String modulationAxes; + private boolean modVib; + private String modAxes; @@ -116,13 +119,14 @@ } protected void initializeReaderCif() throws Exception { - if (checkFilterKey("CONF ")) - configurationPtr = parseIntAt(filter, filter.indexOf("CONF ") + 5); appendedData = (String) htParams.get("appendedData"); - isMolecular = (filter != null && filter.indexOf("MOLECUL") >= 0); - filterAssembly = (filter != null && filter.indexOf("$") >= 0); - int pt = (filter == null ? -1 : filter.indexOf("MODULATIONAXES=")); - modulationAxes = (pt >= 0 ? filter.substring(pt + 15) : null); + String conf = getFilter("CONF "); + if (conf != null) + configurationPtr = parseIntStr(conf); + isMolecular = checkFilterKey("MOLECUL"); + filterAssembly = checkFilterKey("$"); + modAxes = getFilter("MODAXES="); + modVib = checkFilterKey("MODVIB"); if (isMolecular) { if (!doApplySymmetry) { doApplySymmetry = true; @@ -151,13 +155,14 @@ if (!readAllData()) break; if (appendedData != null) { - tokenizer = new CifDataReader(new BufferedReader(new StringReader(appendedData))); + tokenizer = new CifDataReader(new BufferedReader(new StringReader( + appendedData))); while ((key = tokenizer.peekToken()) != null) if (!readAllData()) break; - } + } continuing = false; - } + } public String readNextLine() throws Exception { // from CifDataReader @@ -220,9 +225,9 @@ appendLoadNote("CIF Reader: Too high modulation dimension (" + modDim + ") -- ignored"); modDim = 0; } else { - appendLoadNote("CIF Reader: modulation dimension = " + modDim + " symmetry operations are disabled."); + appendLoadNote("CIF Reader: modulation dimension = " + modDim); htModulation = new Hashtable<String, P3>(); - allowRotations = false; + //allowRotations = false; } } else if (key.startsWith("_cell_")) { processCellParameter(); @@ -1902,7 +1907,12 @@ }; /** - * creates entries in htModulation + * creates entries in htModulation with a key of + * the form: type_id_axis;atomLabel where + * type = W|F|D|O (wave vector, Fourier index, displacement, occupancy); + * id = 1|2|3|S (Fourier index or special -- sawtooth or crenel); + * axis (optional) = o|x|y|z (o indicates irrelevant -- occupancy); + * and ;atomLabel is only for D and O. * * @throws Exception */ @@ -1923,7 +1933,7 @@ case FWV_ID: case FWV_DISP_ID: case FWV_OCC_ID: - switch(tok) { + switch (tok) { case WV_ID: id = "W_" + field; break; @@ -1937,16 +1947,15 @@ id = "O_" + field; break; } - c = w = 99999; break; case DISP_SPEC_LABEL: - if (id == null) - id = "D_S"; + id = "D_S"; atomLabel = field; + axis = "0"; break; case OCC_SPECIAL_LABEL: - id = "O_C"; - c = w = 99999; + id = "O_S"; + axis = "0"; //$FALL-THROUGH$ case FWV_DISP_LABEL: case FWV_OCC_LABEL: @@ -1955,18 +1964,19 @@ break; case FWV_DISP_AXIS: axis = field; - if (modulationAxes != null && modulationAxes.indexOf(axis.toUpperCase()) < 0) + if (modAxes != null + && modAxes.indexOf(axis.toUpperCase()) < 0) ignore = true; break; case WV_X: case FWV_X: case FWV_DISP_COS: case FWV_OCC_COS: - case OCC_CRENEL_C: + case OCC_CRENEL_C: case DISP_SAW_AX: pt.x = parseFloatStr(field); break; - case FWV_Q1_COEF: + case FWV_Q1_COEF: id += "_q_"; pt.x = parseFloatStr(field); switch (modDim) { @@ -2006,16 +2016,30 @@ w = parseFloatStr(field); break; } - if (ignore || Float.isNaN(pt.x + pt.y + pt.z + c + w) || id == null) + if (ignore || Float.isNaN(pt.x + pt.y + pt.z) || id == null) continue; - if (axis != null) - id += axis; - if (c != 99999) - addModulation("D_s;" + atomLabel, P3.new3(c, w, 0)); - if (atomLabel != null) - id += ";" + atomLabel; - addModulation(id, pt); - break; + switch (id.charAt(0)) { + case 'W': + case 'F': + break; + case 'D': + case 'O': + if (atomLabel == null || axis == null) + continue; + if (id.equals("D_S")) { + // saw tooth displacement center/width/Axyz + if (pt.x != 0) + addModulation("D_Sx;" + atomLabel, P3.new3(c, w, pt.x)); + if (pt.y != 0) + addModulation("D_Sy;" + atomLabel, P3.new3(c, w, pt.y)); + if (pt.z != 0) + addModulation("D_Sz;" + atomLabel, P3.new3(c, w, pt.z)); + continue; + } + id += axis + ";" + atomLabel; + break; + } + addModulation(id, pt); } } } @@ -2037,8 +2061,8 @@ switch (key.charAt(0)) { case 'D': case 'O': - // displacement - fix modulus/phase option - if (pt.z > 0) { + // fix modulus/phase option only for non-special modulations; + if (pt.z == 1 && key.charAt(2) != 'S') { // modulus/phase M cos(2pi(q.r) + 2pi(p)) // --> A cos(2pi(p)) cos(2pi(q.r)) + A sin(-2pi(p)) sin(2pi(q.r)) double a = pt.x; @@ -2072,22 +2096,57 @@ for (Entry<String, P3> e : htModulation.entrySet()) { String key = e.getKey(); switch (key.charAt(0)) { + case 'O': + // TODO + break; case 'D': - P3 coefs = e.getValue(); - String label = key.substring(key.indexOf(";") + 1); - P3 q = htModulation.get("F_" + key.substring(2, 3)); char axis = key.charAt(3); - atomSetCollection.addAtomModulation(label, q, axis, coefs); - haveAtomMods = true; + if (key.charAt(2) == 'S') { + // TODO -- sawtooth, so now what? + } else { + P3 coefs = e.getValue(); + String label = key.substring(key.indexOf(";") + 1); + key = "F_" + key.substring(2, 3); + P3 q = htModulation.get(key); + addAtomModulation(label, q, axis, coefs); + haveAtomMods = true; + } break; } } - if (haveAtomMods) - for (int i = atomSetCollection.getAtomCount(); --i >= 0;) - atomSetCollection.modulateAtom(i); + if (!haveAtomMods) + return; + atoms = atomSetCollection.getAtoms(); + symmetry = atomSetCollection.getSymmetry(); + for (int i = atomSetCollection.getAtomCount(); --i >= 0;) + modulateAtom(i, modVib); } + + private Map<String, JmolList<Modulation>> htAtomMods; + + public void addAtomModulation(String label, P3 q, char axis, P3 coefs) { + if (htAtomMods == null) + htAtomMods = new Hashtable<String, JmolList<Modulation>>(); + JmolList<Modulation> list = htAtomMods.get(label); + if (list == null) + htAtomMods.put(label, list = new JmolList<Modulation>()); + list.addLast(new Modulation(q, axis, coefs)); + } + + public void modulateAtom(int i, boolean modvib) { + Atom a = atoms[i]; + a.vib = new V3(); + JmolList<Modulation> list = htAtomMods.get(a.atomName); + if (list == null || symmetry == null) + return; + Modulation.modulateAtom(a, list, a.vib); + if (!modvib) { + a.add(a.vib); + a.vib.scale(-1); + } + symmetry.toCartesian(a.vib, true); + } - //////////////////////////////////////////////////////////////// // symmetry operations //////////////////////////////////////////////////////////////// Modified: trunk/Jmol/src/org/jmol/adapter/readers/cifpdb/PdbReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/readers/cifpdb/PdbReader.java 2013-07-31 01:52:42 UTC (rev 18514) +++ trunk/Jmol/src/org/jmol/adapter/readers/cifpdb/PdbReader.java 2013-07-31 12:28:48 UTC (rev 18515) @@ -194,10 +194,10 @@ // from load files "tls.out" "xxxx.pdb" vTlsModels = ( JmolList<Map<String, Object>>) htParams.remove("vTlsModels"); } - if (checkFilterKey("TYPE ")) { + String s = getFilter("TYPE "); + if (s != null) { // first column, nColumns; - String s = filter.substring(filter.indexOf("TYPE ") + 5).replace(',', ' ').replace(';', ' '); - String[] tokens = Parser.getTokens(s); + String[] tokens = Parser.getTokens(s.replace(',', ' ')); atomTypePt0 = Integer.parseInt(tokens[0]) - 1; int pt = tokens[1].indexOf("="); if (pt >= 0) { @@ -207,8 +207,9 @@ } atomTypeLen = Integer.parseInt(tokens[1].substring(0, pt)); } - if (checkFilterKey("CONF ")) { - configurationPtr = parseIntAt(filter, filter.indexOf("CONF ") + 5); + String conf = getFilter("CONF "); + if (conf != null) { + configurationPtr = parseIntStr(conf); sbIgnored = new SB(); sbSelected = new SB(); } Modified: trunk/Jmol/src/org/jmol/adapter/readers/quantum/MoldenReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/readers/quantum/MoldenReader.java 2013-07-31 01:52:42 UTC (rev 18514) +++ trunk/Jmol/src/org/jmol/adapter/readers/quantum/MoldenReader.java 2013-07-31 12:28:48 UTC (rev 18515) @@ -47,10 +47,8 @@ filter = "alpha"; else if (checkFilterKey("BETA")) filter = "beta"; - else if (checkFilterKey("SYM=")) - filter = filter.substring(filter.indexOf("SYM=") + 4); - else - filter = null; + else + filter = getFilter("SYM="); } @Override Modified: trunk/Jmol/src/org/jmol/adapter/readers/xtal/CastepReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/readers/xtal/CastepReader.java 2013-07-31 01:52:42 UTC (rev 18514) +++ trunk/Jmol/src/org/jmol/adapter/readers/xtal/CastepReader.java 2013-07-31 12:28:48 UTC (rev 18515) @@ -114,14 +114,12 @@ @Override public void initializeReader() throws Exception { if (filter != null) { - if (checkFilterKey("CHARGE=")) { - chargeType = filter.substring(filter.indexOf("CHARGE=") + 7); - if (chargeType.length() > 4) - chargeType = chargeType.substring(0, 4); - } + chargeType = getFilter("CHARGE="); + if (chargeType != null && chargeType.length() > 4) + chargeType = chargeType.substring(0, 4); filter = filter.replace('(', '{').replace(')', '}'); filter = TextFormat.simpleReplace(filter, " ", " "); - isAllQ = (filter.indexOf("Q=ALL") >= 0); + isAllQ = checkFilterKey("Q=ALL"); if (!isAllQ && filter.indexOf("{") >= 0) setDesiredQpt(filter.substring(filter.indexOf("{"))); filter = TextFormat.simpleReplace(filter, "-PT", ""); @@ -713,7 +711,7 @@ lastQPt = tokens[1]; //TODO not quite right: can have more than two options. - if (!isOK && filter != null && checkFilterKey("Q=")) { + if (!isOK && checkFilterKey("Q=")) { // check for an explicit q=n or q={1/4 1/2 1/4} if (desiredQpt != null) { v.sub2(desiredQpt, qvec); Modified: trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollection.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollection.java 2013-07-31 01:52:42 UTC (rev 18514) +++ trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollection.java 2013-07-31 12:28:48 UTC (rev 18515) @@ -41,7 +41,6 @@ import org.jmol.util.Escape; import org.jmol.util.Matrix3f; import org.jmol.util.Matrix4f; -import org.jmol.util.Modulation; import org.jmol.util.P3; import org.jmol.util.P3i; import org.jmol.util.Tensor; @@ -1373,8 +1372,6 @@ atom1.atomSite = atomSite; atom1.bsSymmetry = BSUtil.newAndSetBit(iCellOpPt + iSym); atom1.bsSymmetry.set(iSym); - if (htAtomMods != null) - modulateAtom(atom1.index); if (addCartesian) cartesians[pt++] = cartesian; if (atoms[i].tensors != null) { @@ -2006,26 +2003,4 @@ setAtomSetCollectionAuxiliaryInfo("trajectorySteps", trajectorySteps); } - private Map<String, JmolList<Modulation>> htAtomMods; - - public void addAtomModulation(String label, P3 q, char axis, P3 coefs) { - if (htAtomMods == null) - htAtomMods = new Hashtable<String, JmolList<Modulation>>(); - JmolList<Modulation> list = htAtomMods.get(label); - if (list == null) - htAtomMods.put(label, list = new JmolList<Modulation>()); - list.addLast(new Modulation(q, axis, coefs)); - } - - public void modulateAtom(int i) { - Atom a = atoms[i]; - a.vib = new V3(); - JmolList<Modulation> list = htAtomMods.get(a.atomName); - if (list == null || symmetry == null) - return; - Modulation.modulateAtom(a, list, a.vib); - symmetry.toCartesian(a.vib, true); - - } - } Modified: trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollectionReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollectionReader.java 2013-07-31 01:52:42 UTC (rev 18514) +++ trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollectionReader.java 2013-07-31 12:28:48 UTC (rev 18515) @@ -885,7 +885,12 @@ private String filter1, filter2; - public boolean checkFilterKey(String key) { + protected String getFilter(String key) { + int pt = (filter == null ? -1 : filter.indexOf(key)); + return (pt < 0 ? null : filter.substring(pt + key.length(), filter.indexOf(";", pt))); + } + + protected boolean checkFilterKey(String key) { return (filter != null && filter.indexOf(key) >= 0); } Modified: trunk/Jmol/src/org/jmol/viewer/Jmol.properties =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2013-07-31 01:52:42 UTC (rev 18514) +++ trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2013-07-31 12:28:48 UTC (rev 18515) @@ -11,10 +11,13 @@ # 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.07.30" +___JmolVersion="13.3.4_dev_2013.07.31" +TODO: CIF reader is not handling modulation for symmetry-related atoms correctly yet. + new feature: msCIF file reading of incommensurate modulation data as vibration -new feature: msCIF file filter "MODULATIONAXES=xxx" where xxx = X,XY,XYZ,YZ,etc. +new feature: msCIF file filter "MODAXES=xxx" where xxx = X,XY,XYZ,YZ,etc. +new feature: msCIF file filter "MODAVE" gives average structure with vibration vectors. bug fix: minimization can fail after MMFF switches to UFF. bug fix: CIF reader fix for no element given "phenyl1" in ZjzxlegN.cif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Get your SQL database under version control now! Version control is standard for application code, but databases havent caught up. So what steps can you take to put your SQL databases under version control? Why should you start doing it? Read more to find out. http://pubads.g.doubleclick.net/gampad/clk?id=49501711&iu=/4140/ostg.clktrk _______________________________________________ Jmol-commits mailing list Jmol-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jmol-commits