From: <ha...@us...> - 2011-10-29 17:17:47
|
Revision: 16426 http://jmol.svn.sourceforge.net/jmol/?rev=16426&view=rev Author: hansonr Date: 2011-10-29 17:17:39 +0000 (Sat, 29 Oct 2011) Log Message: ----------- version=12.3.3 # new feature: ellipsoid SET 1; ellipsoid SET 2; # -- TLS ellipsoids are dual # -- TLS-S is SET 1; TLS-T is SET 2 # -- after issuing this command, further size or color commands affect only that set # -- needs verification by Ethan Merrit Modified Paths: -------------- trunk/Jmol/src/org/jmol/adapter/readers/cifpdb/PdbReader.java trunk/Jmol/src/org/jmol/adapter/readers/xtal/CastepReader.java trunk/Jmol/src/org/jmol/adapter/readers/xtal/CrystalReader.java trunk/Jmol/src/org/jmol/adapter/smarter/Atom.java trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollection.java trunk/Jmol/src/org/jmol/adapter/smarter/SmarterJmolAdapter.java trunk/Jmol/src/org/jmol/api/JmolAdapter.java trunk/Jmol/src/org/jmol/modelset/Atom.java trunk/Jmol/src/org/jmol/modelset/AtomCollection.java trunk/Jmol/src/org/jmol/modelset/ModelCollection.java trunk/Jmol/src/org/jmol/modelset/ModelLoader.java trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java trunk/Jmol/src/org/jmol/shape/AtomShape.java trunk/Jmol/src/org/jmol/shapespecial/Ellipsoids.java trunk/Jmol/src/org/jmol/shapespecial/EllipsoidsRenderer.java trunk/Jmol/src/org/jmol/viewer/Jmol.properties Modified: trunk/Jmol/src/org/jmol/adapter/readers/cifpdb/PdbReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/readers/cifpdb/PdbReader.java 2011-10-29 08:22:10 UTC (rev 16425) +++ trunk/Jmol/src/org/jmol/adapter/readers/cifpdb/PdbReader.java 2011-10-29 17:17:39 UTC (rev 16426) @@ -24,13 +24,13 @@ package org.jmol.adapter.readers.cifpdb; -import org.jmol.adapter.smarter.*; - - - +import org.jmol.adapter.smarter.Atom; +import org.jmol.adapter.smarter.AtomSetCollectionReader; +import org.jmol.adapter.smarter.Structure; import org.jmol.api.JmolAdapter; import org.jmol.constant.EnumStructure; import org.jmol.util.Logger; +import org.jmol.util.Quadric; import org.jmol.util.TextFormat; import java.util.ArrayList; @@ -64,21 +64,54 @@ */ public class PdbReader extends AtomSetCollectionReader { + private int lineLength; - // index into atoms array + 1 - // so that 0 can be used for the null value + + private StringBuffer pdbHeader; + + private boolean applySymmetry; + private boolean getTlsGroups; + + private boolean isMultiModel; // MODEL ... + private boolean haveMappedSerials; + private final Map<String, Map<String, Boolean>> htFormul = new Hashtable<String, Map<String, Boolean>>(); private Map<String, String> htHetero = null; private Map<String, Map<String, Object>> htSites = null; - private String currentGroup3; - private int currentResno = Integer.MIN_VALUE; private Map<String, Boolean> htElementsInCurrentGroup; + private Map<String, Map<String, String>> htMolIds; + + private List<Map<String, String>> vCompnds; + private List<Matrix4f> vBiomts; + private List<Map<String, Object>> vBiomolecules; + private List<Map<String, Object>> vTlsModels = null; + + private int[] chainAtomCounts; + + private StringBuffer sbIgnored, sbSelected, sbConect; + + private int atomCount; private int maxSerial; - private int[] chainAtomCounts; private int nUNK; private int nRes; - private boolean isMultiModel; // MODEL ... + private Map<String, String> currentCompnd; + private String currentGroup3; + private String currentKey; + private int currentResno = Integer.MIN_VALUE; + private int configurationPtr = Integer.MIN_VALUE; + private boolean resetKey = true; + private String compnd = null; + private int conformationIndex; + private int fileAtomIndex; + private char lastAltLoc; + private String lastAtomData; + private int lastAtomIndex; + private int lastGroup = Integer.MIN_VALUE; + private char lastInsertion; + private int lastSourceSerial = Integer.MIN_VALUE; + private int lasttargetSerial = Integer.MIN_VALUE; + final private static String lineOptions = "ATOM " + //0 "HETATM " + //1 @@ -103,11 +136,6 @@ "SOURCE " + //20 "TITLE "; //21 - private int serial = 0; - private StringBuffer pdbHeader; - private int configurationPtr = Integer.MIN_VALUE; - private boolean applySymmetry; -private boolean getTlsGroups; @Override protected void initializeReader() throws Exception { @@ -115,7 +143,6 @@ pdbHeader = (getHeader ? new StringBuffer() : null); applySymmetry = !checkFilter("NOSYMMETRY"); getTlsGroups = checkFilter("TLS"); - if (checkFilter("CONF ")) { configurationPtr = parseInt(filter, filter.indexOf("CONF ") + 5); @@ -130,8 +157,7 @@ .indexOf(line.substring(0, 6))) >> 3; boolean isAtom = (ptOption == 0 || ptOption == 1); boolean isModel = (ptOption == 2); - if (isAtom) - serial = parseInt(line, 6, 11); + int serial = (isAtom ? parseInt(line, 6, 11) : 0); boolean isNewModel = ((isTrajectory || isSequential) && !isMultiModel && isAtom && serial == 1); if (getHeader) { @@ -230,11 +256,8 @@ header(); return true; case 19: - compndOld(); - compndSource(false); - return true; case 20: - compndSource(true); + compnd(ptOption == 20); return true; case 21: title(); @@ -247,23 +270,25 @@ protected void finalizeReader() throws Exception { checkNotPDB(); atomSetCollection.connectAll(maxSerial); - if (biomolecules != null && biomolecules.size() > 0 + if (vBiomolecules != null && vBiomolecules.size() > 0 && atomSetCollection.getAtomCount() > 0) { - atomSetCollection.setAtomSetAuxiliaryInfo("biomolecules", biomolecules); + atomSetCollection.setAtomSetAuxiliaryInfo("biomolecules", vBiomolecules); setBiomoleculeAtomCounts(); - if (biomts != null && applySymmetry) { - atomSetCollection.applySymmetry(biomts, notionalUnitCell, applySymmetryToBonds, filter); - tlsModels = null; // for now, no TLS groups for biomolecules + if (vBiomts != null && applySymmetry) { + atomSetCollection.applySymmetry(vBiomts, notionalUnitCell, applySymmetryToBonds, filter); + vTlsModels = null; // for now, no TLS groups for biomolecules } } - if (tlsModels != null) { + if (vTlsModels != null) { + symmetry = atomSetCollection.getSymmetry(); + symmetry.setUnitCell(new float[] { 1, 1, 1, 90, 90, 90 }); int n = atomSetCollection.getAtomSetCount(); - if (n == tlsModels.size()) { + if (n == vTlsModels.size()) { for (int i = n; --i >= 0;) setTlsGroups(i, i); } else { - Logger.info(n + " models but " + tlsModels.size() + " TLS descriptions"); - if (tlsModels.size() == 1) { + Logger.info(n + " models but " + vTlsModels.size() + " TLS descriptions"); + if (vTlsModels.size() == 1) { Logger.info(" -- assuming all models have the same TLS description -- check REMARK 3 for details."); for (int i = n; --i >= 0;) setTlsGroups(0, i); @@ -311,14 +336,19 @@ return; appendLoadNote(line.substring(10).trim()); } - - private List<Map<String, String>> vCompnds; - private Map<String, String> currentCompnd; - private String currentKey; - private Map<String, Map<String, String>> htMolIds; - private boolean resetKey = true; - private void compndSource(boolean isSource) { + private void compnd(boolean isSource) { + if (!isSource) { + if (compnd == null) + compnd = ""; + else + compnd += " "; + String s = line; + if (lineLength > 62) + s = s.substring(0, 62); + compnd += s.substring(10).trim(); + atomSetCollection.setAtomSetCollectionAuxiliaryInfo("COMPND", compnd); + } if (vCompnds == null) { if (isSource) return; @@ -372,24 +402,10 @@ .simpleReplace(value, ", ", ",:"), " ", "") + ")"); } - private String compnd = null; - private void compndOld() { - if (compnd == null) - compnd = ""; - else - compnd += " "; - String s = line; - if (lineLength > 62) - s = s.substring(0, 62); - compnd += s.substring(10).trim(); - atomSetCollection.setAtomSetCollectionAuxiliaryInfo("COMPND", compnd); - } - - @SuppressWarnings("unchecked") private void setBiomoleculeAtomCounts() { - for (int i = biomolecules.size(); --i >= 0;) { - Map<String, Object> biomolecule = biomolecules.get(i); + for (int i = vBiomolecules.size(); --i >= 0;) { + Map<String, Object> biomolecule = vBiomolecules.get(i); String chain = (String) biomolecule.get("chains"); int nTransforms = ((List<Matrix4f>) biomolecule.get("biomts")).size(); int nAtoms = 0; @@ -433,12 +449,10 @@ */ - private List<Map<String, Object>> biomolecules; - private List<Matrix4f> biomts; private void remark350() throws Exception { List<Matrix4f> biomts = null; - biomolecules = new ArrayList<Map<String,Object>>(); + vBiomolecules = new ArrayList<Map<String,Object>>(); chainAtomCounts = new int[255]; String title = ""; String chainlist = ""; @@ -468,7 +482,7 @@ info.put("title", title); info.put("chains", ""); info.put("biomts", biomts); - biomolecules.add(info); + vBiomolecules.add(info); nBiomt = 0; //continue; need to allow for next IF, in case this is a reconstruction } @@ -487,7 +501,7 @@ if (checkFilter("BIOMOLECULE " + iMolecule + ";")) { setFilter(filter.replace(':', '_') + chainlist); Logger.info("filter set to \"" + filter + "\""); - this.biomts = biomts; + this.vBiomts = biomts; } info.put("chains", chainlist); continue; @@ -520,8 +534,8 @@ } } catch (Exception e) { // probably just - this.biomts = null; - this.biomolecules = null; + this.vBiomts = null; + this.vBiomolecules = null; return; } } @@ -570,10 +584,6 @@ } } - private int atomCount; - private String lastAtomData; - private int lastAtomIndex; - private int iAtom; private void atom(int serial) { Atom atom = new Atom(); @@ -590,7 +600,7 @@ atom.insertionCode = JmolAdapter.canonizeInsertionCode(line.charAt(26)); atom.isHetero = line.startsWith("HETATM"); atom.elementSymbol = deduceElementSymbol(atom.isHetero); - if (!filterAtom(atom, iAtom++)) + if (!filterAtom(atom, fileAtomIndex++)) return; atom.atomSerial = serial; if (serial > maxSerial) @@ -650,12 +660,6 @@ } } - private int lastGroup = Integer.MIN_VALUE; - private char lastInsertion; - private char lastAltLoc; - private int conformationIndex; - private StringBuffer sbIgnored, sbSelected; - @Override protected boolean filterAtom(Atom atom, int iAtom) { if (!super.filterAtom(atom, iAtom)) @@ -773,10 +777,6 @@ return "" + ch13 + ch14; return "Xx"; } - - private StringBuffer sbConect; - private int sourceSerialLast = Integer.MIN_VALUE; - private int targetSerialLast = Integer.MIN_VALUE; private void conect() { // adapted for improper non-crossreferenced files such as 1W7R @@ -793,9 +793,9 @@ offsetEnd) : -1); if (targetSerial < 0) continue; - boolean isDoubleBond = (sourceSerial == sourceSerialLast && targetSerial == targetSerialLast); - sourceSerialLast = sourceSerial; - targetSerialLast = targetSerial; + boolean isDoubleBond = (sourceSerial == lastSourceSerial && targetSerial == lasttargetSerial); + lastSourceSerial = sourceSerial; + lasttargetSerial = targetSerial; boolean isSwapped = (targetSerial < sourceSerial); int i1; if (isSwapped) { @@ -1085,7 +1085,6 @@ * The anisotropic temperature factors are stored in the same coordinate frame as the atomic coordinate records. */ - private boolean haveMappedSerials; private void anisou() { float[] data = new float[8]; @@ -1180,8 +1179,6 @@ } } - private List<Map<String, Object>> tlsModels = null; - /* REMARK 3 TLS DETAILS REMARK 3 NUMBER OF TLS GROUPS : NULL @@ -1239,8 +1236,8 @@ nGroups = parseInt(tokens[tokens.length - 1]); if (nGroups < 1) break; - if (tlsModels == null) - tlsModels = new ArrayList<Map<String, Object>>(); + if (vTlsModels == null) + vTlsModels = new ArrayList<Map<String, Object>>(); tlsGroups = new ArrayList<Map<String, Object>>(); appendLoadNote(line.substring(11).trim()); } @@ -1340,7 +1337,7 @@ Hashtable<String, Object> groups = new Hashtable<String, Object>(); groups.put("groupCount", Integer.valueOf(nGroups)); groups.put("groups", tlsGroups); - tlsModels.add(groups); + vTlsModels.add(groups); } return (nGroups < 1); } @@ -1349,7 +1346,7 @@ * for now, we just ignore TLS details if user has selected a specific model */ private void handleTlsMissingModels() { - tlsModels = null; + vTlsModels = null; } /** @@ -1361,11 +1358,12 @@ @SuppressWarnings("unchecked") private void setTlsGroups(int iGroup, int iModel) { Logger.info("TLS model " + iModel + " group " + iGroup); - Map<String, Object> tlsGroupInfo = tlsModels.get(iGroup); + Map<String, Object> tlsGroupInfo = vTlsModels.get(iGroup); List<Map<String, Object>> groups = (List<Map<String, Object>>) tlsGroupInfo.get("groups"); int firstModelAtom = atomSetCollection.getAtomSetAtomIndex(iModel); int[] data = new int[atomSetCollection.getAtomSetAtomCount(iModel)]; int atomMax = firstModelAtom + data.length; + Atom[] atoms = atomSetCollection.getAtoms(); for (int i = groups.size(); --i >= 0;) { Map<String, Object> group = groups.get(i); List<Map<String, Object>> ranges = (List<Map<String, Object>>) group.get("ranges"); @@ -1380,8 +1378,10 @@ Logger.info("TLS ID="+id + " model atom index range " + atom1 + "-" + atom2); atom1 -= firstModelAtom; atom2 -= firstModelAtom; - for (int iAtom = atom1; iAtom < atom2; iAtom++) + for (int iAtom = atom1; iAtom < atom2; iAtom++) { data[iAtom] = id; + setTlsEllipsoid(atoms[iAtom], group); + } } } StringBuffer sdata = new StringBuffer(); @@ -1409,6 +1409,63 @@ return (isTrue ? -1 : atom2); } + private final float[] dataS = new float[8]; + private final float[] dataT = new float[8]; + private static final float RAD_PER_DEG = (float) (Math.PI / 180); + + private void setTlsEllipsoid(Atom atom, Map<String, Object> group) { + Point3f origin = (Point3f) group.get("origin"); + if (Float.isNaN(origin.x)) + return; + + float[][] T = (float[][]) group.get("tT"); + float[][] L = (float[][]) group.get("tL"); + float[][] S = (float[][]) group.get("tS"); + + if (T == null || L == null || S == null) + return; + + // just factor degrees-to-radians into x, y, and z rather + // than create all new matrices + + float x = (atom.x - origin.x) * RAD_PER_DEG; + float y = (atom.y - origin.y) * RAD_PER_DEG; + float z = (atom.z - origin.z) * RAD_PER_DEG; + + float xx = x * x; + float yy = y * y; + float zz = z * z; + float xy = x * y; + float xz = x * z; + float yz = y * z; + + /* + * + * from pymmlib-1.2.0.tar|mmLib/TLS.py + * + */ + + dataT[0] = T[0][0]; + dataT[1] = T[1][1]; + dataT[2] = T[2][2]; + dataT[3] = T[0][1]; + dataT[4] = T[0][2]; + dataT[5] = T[1][2]; + dataT[6] = 8; // ORTEP type 8 + + dataS[0] /*u11*/ = dataT[0] + L[1][1]*zz + L[2][2]*yy - 2*L[1][2]*yz + 2*S[1][0]*z - 2*S[2][0]*y; + dataS[1] /*u22*/ = dataT[1] + L[0][0]*zz + L[2][2]*xx - 2*L[2][0]*xz - 2*S[0][1]*z + 2*S[2][1]*x; + dataS[2] /*u33*/ = dataT[2] + L[0][0]*yy + L[1][1]*xx - 2*L[0][1]*xy - 2*S[1][2]*x + 2*S[0][2]*y; + dataS[3] /*u12*/ = dataT[3] - L[2][2]*xy + L[1][2]*xz + L[2][0]*yz - L[0][1]*zz - S[0][0]*z + S[1][1]*z + S[2][0]*x - S[2][1]*y; + dataS[4] /*u13*/ = dataT[4] - L[1][1]*xz + L[1][2]*xy - L[2][0]*yy + L[0][1]*yz + S[0][0]*y - S[2][2]*y + S[1][2]*z - S[1][0]*x; + dataS[5] /*u23*/ = dataT[5] - L[0][0]*yz - L[1][2]*xx + L[2][0]*xy + L[0][1]*xz - S[1][1]*x + S[2][2]*x + S[0][1]*y - S[0][2]*z; + dataS[6] = 8; + + // symmetry is set to [1 1 1 90 90 90] -- Cartesians, not actual unit cell + + atom.ellipsoid = new Quadric[] { symmetry.getEllipsoid(dataS), symmetry.getEllipsoid(dataT) }; + } + } Modified: trunk/Jmol/src/org/jmol/adapter/readers/xtal/CastepReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/readers/xtal/CastepReader.java 2011-10-29 08:22:10 UTC (rev 16425) +++ trunk/Jmol/src/org/jmol/adapter/readers/xtal/CastepReader.java 2011-10-29 17:17:39 UTC (rev 16426) @@ -537,7 +537,7 @@ y = -(a[0][2] - a[2][0])/2; a[0][2] = a[2][0] = (a[0][2] + a[2][0])/2; } - atom.ellipsoid = Eigen.getEllipsoid(a); + atom.setEllipsoid(Eigen.getEllipsoid(a)); atomSetCollection.addVibrationVector(atom.atomIndex, (float) x, (float) y, (float) z); } Modified: trunk/Jmol/src/org/jmol/adapter/readers/xtal/CrystalReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/readers/xtal/CrystalReader.java 2011-10-29 08:22:10 UTC (rev 16425) +++ trunk/Jmol/src/org/jmol/adapter/readers/xtal/CrystalReader.java 2011-10-29 17:17:39 UTC (rev 16426) @@ -1010,10 +1010,10 @@ String[] tokens = getTokens(); int index = parseInt(tokens[3]) - 1; tokens = getTokens(readLines(3)); - atoms[index].ellipsoid = Eigen.getEllipsoid(directLatticeVectors, + atoms[index].setEllipsoid(Eigen.getEllipsoid(directLatticeVectors, new float[] {parseFloat(tokens[1]), parseFloat(tokens[3]), - parseFloat(tokens[5]) }, false); + parseFloat(tokens[5]) }, false)); readLine(); } return true; Modified: trunk/Jmol/src/org/jmol/adapter/smarter/Atom.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/smarter/Atom.java 2011-10-29 08:22:10 UTC (rev 16425) +++ trunk/Jmol/src/org/jmol/adapter/smarter/Atom.java 2011-10-29 17:17:39 UTC (rev 16426) @@ -53,7 +53,12 @@ public int sequenceNumber = Integer.MIN_VALUE; public char insertionCode = '\0'; float[] anisoBorU; //[6] = 1 for U, 0 for B; [7] = bFactor - public Quadric ellipsoid; + public Quadric[] ellipsoid; + public void setEllipsoid(Quadric e) { + ellipsoid = new Quadric[] { e }; + } + + public boolean ignoreSymmetry; // CIF _atom_site_disorder_group -1 public Atom() { @@ -282,4 +287,5 @@ char chSecond = str.charAt(1); return isValidElementSymbolNoCaseSecondChar(chFirst, chSecond); } + } Modified: trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollection.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollection.java 2011-10-29 08:22:10 UTC (rev 16425) +++ trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollection.java 2011-10-29 17:17:39 UTC (rev 16426) @@ -856,7 +856,7 @@ int iAtomFirst = getLastAtomSetAtomIndex(); if (needEllipsoids) for (int i = iAtomFirst; i < atomCount; i++) - atoms[i].ellipsoid = symmetry.getEllipsoid(atoms[i].anisoBorU); + atoms[i].ellipsoid = new Quadric[] { symmetry.getEllipsoid(atoms[i].anisoBorU) }; bondCount0 = bondCount; @@ -1072,7 +1072,8 @@ for (int i = iAtomFirst; i < atomMax; i++) { if (atoms[i].ignoreSymmetry) continue; - symmetry.newSpaceGroupPoint(iSym, atoms[i], ptAtom, transX, transY, transZ); + symmetry.newSpaceGroupPoint(iSym, atoms[i], ptAtom, transX, transY, + transZ); Atom special = null; Point3f cartesian = new Point3f(ptAtom); symmetry.toCartesian(cartesian, false); @@ -1080,8 +1081,8 @@ symmetry.toUnitCell(cartesian, ptOffset); ptAtom.set(cartesian); symmetry.toFractional(ptAtom, false); - if (!isWithinCell(dtype, ptAtom, minXYZ0.x, maxXYZ0.x, - minXYZ0.y, maxXYZ0.y, minXYZ0.z, maxXYZ0.z)) + if (!isWithinCell(dtype, ptAtom, minXYZ0.x, maxXYZ0.x, minXYZ0.y, + maxXYZ0.y, minXYZ0.z, maxXYZ0.z)) continue; } if (checkSymmetryMinMax) @@ -1123,19 +1124,23 @@ if (addCartesian) cartesians[pt++] = cartesian; if (atoms[i].ellipsoid != null) { - Vector3f[] axes = atoms[i].ellipsoid.vectors; - float[] lengths = atoms[i].ellipsoid.lengths; - if (axes != null) { - // note -- PDB reader specifically turns off cartesians - if (addCartesian) { - ptTemp.set(cartesians[i - iAtomFirst]); - } else { - ptTemp.set(atoms[i]); - symmetry.toCartesian(ptTemp, false); + for (int j = 0; j < atoms[i].ellipsoid.length; j++) { + Quadric e = atoms[i].ellipsoid[j]; + Vector3f[] axes = e.vectors; + float[] lengths = e.lengths; + if (axes != null) { + // note -- PDB reader specifically turns off cartesians + if (addCartesian) { + ptTemp.set(cartesians[i - iAtomFirst]); + } else { + ptTemp.set(atoms[i]); + symmetry.toCartesian(ptTemp, false); + } + axes = symmetry.rotateEllipsoid(iSym, ptTemp, axes, ptTemp1, + ptTemp2); } - axes = symmetry.rotateEllipsoid(iSym, ptTemp, axes, ptTemp1, ptTemp2); + atom1.ellipsoid[j] = new Quadric(axes, lengths, e.isThermalEllipsoid); } - atom1.ellipsoid = new Quadric(axes, lengths, atoms[i].ellipsoid.isThermalEllipsoid); } } } Modified: trunk/Jmol/src/org/jmol/adapter/smarter/SmarterJmolAdapter.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/smarter/SmarterJmolAdapter.java 2011-10-29 08:22:10 UTC (rev 16425) +++ trunk/Jmol/src/org/jmol/adapter/smarter/SmarterJmolAdapter.java 2011-10-29 17:17:39 UTC (rev 16426) @@ -681,7 +681,7 @@ @Override public float getPartialCharge() { return atom.partialCharge; } @Override - public Quadric getEllipsoid() { return atom.ellipsoid; } + public Quadric[] getEllipsoid() { return atom.ellipsoid; } @Override public float getRadius() { return atom.radius; } @Override Modified: trunk/Jmol/src/org/jmol/api/JmolAdapter.java =================================================================== --- trunk/Jmol/src/org/jmol/api/JmolAdapter.java 2011-10-29 08:22:10 UTC (rev 16425) +++ trunk/Jmol/src/org/jmol/api/JmolAdapter.java 2011-10-29 17:17:39 UTC (rev 16426) @@ -425,7 +425,7 @@ public String getAtomName() { return null; } public int getFormalCharge() { return 0; } public float getPartialCharge() { return Float.NaN; } - public Quadric getEllipsoid() { return null; } + public Quadric[] getEllipsoid() { return null; } public float getRadius() { return Float.NaN; } abstract public float getX(); abstract public float getY(); Modified: trunk/Jmol/src/org/jmol/modelset/Atom.java =================================================================== --- trunk/Jmol/src/org/jmol/modelset/Atom.java 2011-10-29 08:22:10 UTC (rev 16425) +++ trunk/Jmol/src/org/jmol/modelset/Atom.java 2011-10-29 17:17:39 UTC (rev 16426) @@ -267,8 +267,8 @@ } public float getADPMinMax(boolean isMax) { - Quadric ellipsoid = getEllipsoid(); - return (ellipsoid == null ? 0 : ellipsoid.lengths[isMax ? 2 : 0] * ellipsoid.scale); + Quadric[] ellipsoid = getEllipsoid(); + return (ellipsoid == null ? 0 : ellipsoid[0].lengths[isMax ? 2 : 0] * ellipsoid[0].scale); } public int getRasMolRadius() { @@ -617,15 +617,15 @@ return partialCharges == null ? 0 : partialCharges[index]; } - public Quadric getEllipsoid() { + public Quadric[] getEllipsoid() { return group.chain.modelSet.getEllipsoid(index); } - public void scaleEllipsoid(int size) { - Quadric ellipsoid = getEllipsoid(); - if (ellipsoid == null) + public void scaleEllipsoid(int size, int iSelect) { + Quadric[] ellipsoid = getEllipsoid(); + if (ellipsoid == null || iSelect >= ellipsoid.length) return; - ellipsoid.setSize(size); + ellipsoid[iSelect].setSize(size); } /** Modified: trunk/Jmol/src/org/jmol/modelset/AtomCollection.java =================================================================== --- trunk/Jmol/src/org/jmol/modelset/AtomCollection.java 2011-10-29 08:22:10 UTC (rev 16425) +++ trunk/Jmol/src/org/jmol/modelset/AtomCollection.java 2011-10-29 17:17:39 UTC (rev 16426) @@ -145,7 +145,7 @@ float[] ionicRadii; float[] hydrophobicities; - protected Quadric[] ellipsoids; + protected Quadric[][] ellipsoids; protected int[] surfaceDistance100s; protected boolean haveStraightness; @@ -245,9 +245,7 @@ return atoms[i].getModelIndex(); } - public Quadric getEllipsoid(int i) { - // [0]: set of three vectors - // [1]: set of six values + public Quadric[] getEllipsoid(int i) { return (i < 0 || ellipsoids == null || i >= ellipsoids.length ? null : ellipsoids[i]); } @@ -781,11 +779,11 @@ return true; } - protected void setEllipsoid(int atomIndex, Quadric ellipsoid) { + protected void setEllipsoid(int atomIndex, Quadric[] ellipsoid) { if (ellipsoid == null) return; if (ellipsoids == null) - ellipsoids = new Quadric[atoms.length]; + ellipsoids = new Quadric[atoms.length][]; ellipsoids[atomIndex] = ellipsoid; } @@ -2662,7 +2660,7 @@ firstAtomIndex, nAtoms); partialCharges = (float[]) ArrayUtil.deleteElements(partialCharges, firstAtomIndex, nAtoms); - ellipsoids = (Quadric[]) ArrayUtil.deleteElements(ellipsoids, + ellipsoids = (Quadric[][]) ArrayUtil.deleteElements(ellipsoids, firstAtomIndex, nAtoms); vibrationVectors = (Vector3f[]) ArrayUtil.deleteElements(vibrationVectors, firstAtomIndex, nAtoms); Modified: trunk/Jmol/src/org/jmol/modelset/ModelCollection.java =================================================================== --- trunk/Jmol/src/org/jmol/modelset/ModelCollection.java 2011-10-29 08:22:10 UTC (rev 16425) +++ trunk/Jmol/src/org/jmol/modelset/ModelCollection.java 2011-10-29 17:17:39 UTC (rev 16426) @@ -4272,7 +4272,7 @@ if (partialCharges != null) partialCharges = ArrayUtil.setLength(partialCharges, newLength); if (ellipsoids != null) - ellipsoids = (Quadric[]) ArrayUtil.setLength(ellipsoids, newLength); + ellipsoids = (Quadric[][]) ArrayUtil.setLength(ellipsoids, newLength); if (atomNames != null) atomNames = ArrayUtil.setLength(atomNames, newLength); if (atomTypes != null) @@ -4293,7 +4293,7 @@ int atomSite, float x, float y, float z, float radius, float vectorX, float vectorY, float vectorZ, int formalCharge, float partialCharge, - int occupancy, float bfactor, Quadric ellipsoid, + int occupancy, float bfactor, Quadric[] ellipsoid, boolean isHetero, char alternateLocationID, byte specialAtomID, BitSet atomSymmetry) { Atom atom = new Atom(modelIndex, atomCount, x, y, z, radius, atomSymmetry, Modified: trunk/Jmol/src/org/jmol/modelset/ModelLoader.java =================================================================== --- trunk/Jmol/src/org/jmol/modelset/ModelLoader.java 2011-10-29 08:22:10 UTC (rev 16425) +++ trunk/Jmol/src/org/jmol/modelset/ModelLoader.java 2011-10-29 17:17:39 UTC (rev 16426) @@ -791,7 +791,7 @@ private void addAtom(boolean isPDB, BitSet atomSymmetry, int atomSite, Object atomUid, short atomicAndIsotopeNumber, String atomName, int formalCharge, float partialCharge, - Quadric ellipsoid, int occupancy, float bfactor, + Quadric[] ellipsoid, int occupancy, float bfactor, float x, float y, float z, boolean isHetero, int atomSerial, String group3, float vectorX, float vectorY, float vectorZ, Modified: trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java 2011-10-29 08:22:10 UTC (rev 16425) +++ trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java 2011-10-29 17:17:39 UTC (rev 16426) @@ -10962,6 +10962,10 @@ case Token.integer: mad = intParameter(1); break; + case Token.set: + checkLength(3); + setShapeProperty(JmolConstants.SHAPE_ELLIPSOIDS, "select", Integer.valueOf(intParameter(2, 1, 2))); + return; case Token.id: case Token.times: case Token.identifier: @@ -10989,7 +10993,8 @@ break; case Token.color: float translucentLevel = Float.NaN; - i++; + if (tokAt(i) == Token.color) + i++; if ((theTok = tokAt(i)) == Token.translucent) { value = "translucent"; if (isFloatParameter(++i)) Modified: trunk/Jmol/src/org/jmol/shape/AtomShape.java =================================================================== --- trunk/Jmol/src/org/jmol/shape/AtomShape.java 2011-10-29 08:22:10 UTC (rev 16425) +++ trunk/Jmol/src/org/jmol/shape/AtomShape.java 2011-10-29 17:17:39 UTC (rev 16426) @@ -78,7 +78,7 @@ @Override protected void setSize(RadiusData rd, BitSet bsSelected) { - // Halos Stars Vectors only + // Halos Stars Vectors Ellipsoids if (atoms == null) // vector values are ignored if there are none for a model return; isActive = true; Modified: trunk/Jmol/src/org/jmol/shapespecial/Ellipsoids.java =================================================================== --- trunk/Jmol/src/org/jmol/shapespecial/Ellipsoids.java 2011-10-29 08:22:10 UTC (rev 16425) +++ trunk/Jmol/src/org/jmol/shapespecial/Ellipsoids.java 2011-10-29 17:17:39 UTC (rev 16426) @@ -29,30 +29,31 @@ import java.util.Hashtable; import java.util.Iterator; import java.util.Map; -//import java.util.Map.Entry; import javax.vecmath.Matrix3f; import javax.vecmath.Point3f; import javax.vecmath.Vector3f; import org.jmol.g3d.Graphics3D; -//import org.jmol.script.Token; import org.jmol.shape.AtomShape; import org.jmol.util.Escape; import org.jmol.util.Quadric; +import org.jmol.viewer.StateManager; public class Ellipsoids extends AtomShape { - // most differences are in renderer - + Map<String, Ellipsoid> htEllipsoids = new Hashtable<String, Ellipsoid>(); boolean haveEllipsoids; - + short[][] colixset; + byte[][] paletteIDset; + short[][] madset; + static class Ellipsoid { - + String id; Vector3f[] axes; float[] lengths; - Point3f center = new Point3f(0,0,0); + Point3f center = new Point3f(0, 0, 0); double[] coef; short colix = Graphics3D.GOLD; int modelIndex; @@ -60,44 +61,41 @@ boolean visible; boolean isValid; boolean isOn = true; - + Ellipsoid(String id, int modelIndex) { this.id = id; this.modelIndex = modelIndex; } } - -// @SuppressWarnings("unchecked") + @Override public boolean getProperty(String property, Object[] data) { -/* just implemented for MeshCollection - if (property == "getNames") { - Map<String, Token> map = (Map<String, Token>) data[0]; - boolean withDollar = ((Boolean) data[1]).booleanValue(); - for (Entry<String, Ellipsoid>entry : htEllipsoids.entrySet()) - map.put((withDollar ? "$" : "") + entry.getKey(), Token.tokenExpressionBegin); // just a placeholder - return true; - } -*/ return super.getProperty(property, data); } - + @Override public int getIndexFromName(String thisID) { - return ((ellipsoid = htEllipsoids.get(thisID)) - == null ? -1 : 1); + return ((ellipsoid = htEllipsoids.get(thisID)) == null ? -1 : 1); } Ellipsoid ellipsoid; - + private int iSelect; + @Override protected void setSize(int size, BitSet bsSelected) { super.setSize(size, bsSelected); - if (size == 0) - return; - for (int i = bsSelected.nextSetBit(0); i >= 0; i = bsSelected.nextSetBit(i + 1)) - atoms[i].scaleEllipsoid(size); + checkSets(); + madset[iSelect] = mads; + for (int i = bsSelected.nextSetBit(0); i >= 0; i = bsSelected + .nextSetBit(i + 1)) { + if (size != 0) + atoms[i].scaleEllipsoid(size, iSelect); + boolean isVisible = madset[0][i] > 0 + || (madset[1] != null && madset[1].length > i && madset[1][i] > 0); + bsSizeSet.set(i, isVisible); + atoms[i].setShapeVisibility(myVisibilityFlag, isVisible); + } } @Override @@ -135,11 +133,11 @@ if ("modelindex" == propertyName) { ellipsoid.modelIndex = ((Integer) value).intValue(); return; - } + } if ("on" == propertyName) { ellipsoid.isOn = ((Boolean) value).booleanValue(); return; - } + } if ("axes" == propertyName) { ellipsoid.isValid = false; ellipsoid.axes = (Vector3f[]) value; @@ -207,9 +205,36 @@ return; } } + + if ("select" == propertyName) { + iSelect = ((Integer) value).intValue() - 1; + checkSets(); + colixes = colixset[iSelect]; + paletteIDs = paletteIDset[iSelect]; + mads = madset[iSelect]; + return; + } + super.setProperty(propertyName, value, bs); + + if (colixset != null) { + if ("color" == propertyName || "translucency" == propertyName + || "deleteModelAtoms" == propertyName) { + colixset[iSelect] = colixes; + paletteIDset[iSelect] = paletteIDs; + madset[iSelect] = mads; + } + } } + private void checkSets() { + if (colixset == null) { + colixset = new short[2][]; + paletteIDset = new byte[2][]; + madset = new short[2][]; + } + } + private void updateEquation(Ellipsoid ellipsoid) { if (ellipsoid.axes == null || ellipsoid.lengths == null) return; @@ -217,16 +242,24 @@ Matrix3f mTemp = new Matrix3f(); Vector3f v1 = new Vector3f(); ellipsoid.coef = new double[10]; - Quadric.getEquationForQuadricWithCenter(ellipsoid.center.x, - ellipsoid.center.y, ellipsoid.center.z, mat, v1, mTemp, - ellipsoid.coef, null); + Quadric.getEquationForQuadricWithCenter(ellipsoid.center.x, + ellipsoid.center.y, ellipsoid.center.z, mat, v1, mTemp, ellipsoid.coef, + null); ellipsoid.isValid = true; } - + @Override public String getShapeState() { + StringBuffer sb = new StringBuffer(); + getStateID(sb); + getStateAtoms(sb); + return sb.toString(); + } + + private void getStateID(StringBuffer sb) { + if (!isActive || madset == null) + return; Iterator<Ellipsoid> e = htEllipsoids.values().iterator(); - StringBuffer sb = new StringBuffer(); Vector3f v1 = new Vector3f(); while (e.hasNext()) { Ellipsoid ellipsoid = e.next(); @@ -245,23 +278,28 @@ sb.append(" off"); sb.append(";\n"); } - if (isActive) { + } + + private void getStateAtoms(StringBuffer sb) { + for (int ii = 0; ii < 2; ii++) { + if (madset[ii] == null) + continue; + StateManager.appendCmd(sb, "Ellipsoids set " + (ii + 1) + "\n"); Map<String, BitSet> temp = new Hashtable<String, BitSet>(); Map<String, BitSet> temp2 = new Hashtable<String, BitSet>(); if (bsSizeSet != null) for (int i = bsSizeSet.nextSetBit(0); i >= 0; i = bsSizeSet .nextSetBit(i + 1)) - setStateInfo(temp, i, "Ellipsoids " + mads[i]); - if (bsColixSet != null) + setStateInfo(temp, i, "Ellipsoids " + madset[ii][i]); + if (bsColixSet != null && colixset[ii] != null) for (int i = bsColixSet.nextSetBit(0); i >= 0; i = bsColixSet .nextSetBit(i + 1)) - setStateInfo(temp2, i, getColorCommand("Ellipsoids", paletteIDs[i], - colixes[i])); + setStateInfo(temp2, i, getColorCommand("Ellipsoids", + paletteIDset[ii][i], colixset[ii][i])); sb.append(getShapeCommands(temp, temp2)); } - return sb.toString(); } - + @Override public void setVisibilityFlags(BitSet bs) { /* @@ -271,9 +309,9 @@ Iterator<Ellipsoid> e = htEllipsoids.values().iterator(); while (e.hasNext()) { Ellipsoid ellipsoid = e.next(); - ellipsoid.visible = ellipsoid.isOn && (ellipsoid.modelIndex < 0 || bs.get(ellipsoid.modelIndex)); + ellipsoid.visible = ellipsoid.isOn + && (ellipsoid.modelIndex < 0 || bs.get(ellipsoid.modelIndex)); } } - + } - Modified: trunk/Jmol/src/org/jmol/shapespecial/EllipsoidsRenderer.java =================================================================== --- trunk/Jmol/src/org/jmol/shapespecial/EllipsoidsRenderer.java 2011-10-29 08:22:10 UTC (rev 16425) +++ trunk/Jmol/src/org/jmol/shapespecial/EllipsoidsRenderer.java 2011-10-29 17:17:39 UTC (rev 16426) @@ -88,7 +88,7 @@ @Override protected void render() { ellipsoids = (Ellipsoids) shape; - if (ellipsoids.mads == null && !ellipsoids.haveEllipsoids) + if (ellipsoids.madset == null && !ellipsoids.haveEllipsoids) return; wireframeOnly = (viewer.getWireframeRotation() && viewer.getInMotion()); drawAxes = viewer.getBooleanProperty("ellipsoidAxes"); @@ -141,21 +141,26 @@ continue; if (atom.screenZ <= 1) continue; - Quadric ellipsoid = atom.getEllipsoid(); - if (ellipsoid == null) + Quadric[] ellipsoid2 = atom.getEllipsoid(); + if (ellipsoid2 == null) continue; - colix = Shape.getColix(ellipsoids.colixes, i, atom); - if (!g3d.setColix(colix)) - continue; - render1(atom, ellipsoid); + + for (int j = 0; j < ellipsoid2.length; j++) { + if (ellipsoids.madset[j] == null || ellipsoids.madset[j][i] == 0) + continue; + colix = Shape.getColix(ellipsoids.colixset[j], i, atom); + if (!g3d.setColix(colix)) + continue; + render1(atom, ellipsoid2[j]); + } } - + if (ellipsoids.haveEllipsoids) { Iterator<Ellipsoid> e = ellipsoids.htEllipsoids.values().iterator(); while (e.hasNext()) { Ellipsoid ellipsoid = e.next(); if (ellipsoid.visible && ellipsoid.isValid) - renderEllipsoid(ellipsoid); + renderEllipsoid(ellipsoid); } } coords = null; Modified: trunk/Jmol/src/org/jmol/viewer/Jmol.properties =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2011-10-29 08:22:10 UTC (rev 16425) +++ trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2011-10-29 17:17:39 UTC (rev 16426) @@ -3,6 +3,11 @@ version=12.3.3 +# new feature: ellipsoid SET 1; ellipsoid SET 2; +# -- TLS ellipsoids are dual +# -- TLS-S is SET 1; TLS-T is SET 2 +# -- after issuing this command, further size or color commands affect only that set +# -- needs verification by Ethan Merrit # new feature: load xxx.pdb filter "TLS" -- loads TLS data # new feature: atom property property_tlsGroup # new feature: MolecularPlayground now accepts messages to the banner: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |