Revision: 18436 http://sourceforge.net/p/jmol/code/18436 Author: hansonr Date: 2013-07-05 23:08:08 +0000 (Fri, 05 Jul 2013) Log Message: ----------- ___JmolVersion="13.1.19_dev_2013.07.05"
code: org.jmol.quantum.NMRCalculation smoothly handles J-coupling and dipolar coupling constant display. new feature: unitcell center {atomset} new feature: unitcell center {fx fy fz} new feature: {*}.ms, {*}.cs %[ms] %[cs] magnetic shielding and chemical shift new feature: label <color red>xxx</color> new feature: set shift_H xxx (ppm) new feature: getProperty("nmrInfo") Modified Paths: -------------- trunk/Jmol/src/org/jmol/adapter/readers/pymol/PyMOLScene.java trunk/Jmol/src/org/jmol/api/JmolNMRInterface.java trunk/Jmol/src/org/jmol/modelset/Measurement.java trunk/Jmol/src/org/jmol/modelset/MeasurementData.java trunk/Jmol/src/org/jmol/quantum/NMRCalculation.java trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java trunk/Jmol/src/org/jmol/script/ScriptMathProcessor.java trunk/Jmol/src/org/jmol/shape/Measures.java trunk/Jmol/src/org/jmol/viewer/Jmol.properties trunk/Jmol/src/org/jmol/viewer/StateManager.java trunk/Jmol/src/org/jmol/viewer/Viewer.java Modified: trunk/Jmol/src/org/jmol/adapter/readers/pymol/PyMOLScene.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/readers/pymol/PyMOLScene.java 2013-07-05 17:26:35 UTC (rev 18435) +++ trunk/Jmol/src/org/jmol/adapter/readers/pymol/PyMOLScene.java 2013-07-05 23:08:08 UTC (rev 18436) @@ -1049,7 +1049,7 @@ Text text = newTextLabel(strFormat, offset, clabel, (int) floatSetting(PyMOL.label_font_id), floatSetting(PyMOL.label_size)); - md.set(T.define, null, strFormat, "angstroms", null, false, false, null, + md.set(T.define, null, null, strFormat, "angstroms", null, false, false, null, false, (int) (rad * 2000), colix, text); addJmolObject(JC.SHAPE_MEASURES, bs, md); } Modified: trunk/Jmol/src/org/jmol/api/JmolNMRInterface.java =================================================================== --- trunk/Jmol/src/org/jmol/api/JmolNMRInterface.java 2013-07-05 17:26:35 UTC (rev 18435) +++ trunk/Jmol/src/org/jmol/api/JmolNMRInterface.java 2013-07-05 23:08:08 UTC (rev 18436) @@ -1,6 +1,9 @@ package org.jmol.api; +import java.util.Map; + import org.jmol.modelset.Atom; +import org.jmol.modelset.MeasurementData; import org.jmol.modelset.ModelSet; import org.jmol.util.BS; import org.jmol.util.JmolList; @@ -51,16 +54,6 @@ public float getDipolarCouplingHz(Atom a1, Atom a2, V3 vField); /** - * Finds a set of interaction tensors based on a set of atoms -- all within the - * set if bs.cardinality() > 1; all for this atom when bs.cardinality() == 1. - * - * @param type - * @param bs - * @return list of matching tensors - */ - public JmolList<Tensor> getInteractionTensorList(String type, BS bs); - - /** * An attempt to find unique atoms using tensors. * * @param bs @@ -91,5 +84,7 @@ public void setAtomTensors(ModelSet ms, int i, JmolList<Tensor> tensors); public JmolList<Object> getTensorInfo(String tensorType, String infoType, BS bs); + + public Map<String, Float> getMinDistances(MeasurementData md); } Modified: trunk/Jmol/src/org/jmol/modelset/Measurement.java =================================================================== --- trunk/Jmol/src/org/jmol/modelset/Measurement.java 2013-07-05 17:26:35 UTC (rev 18435) +++ trunk/Jmol/src/org/jmol/modelset/Measurement.java 2013-07-05 23:08:08 UTC (rev 18436) @@ -23,6 +23,8 @@ */ package org.jmol.modelset; +import java.util.Map; + import org.jmol.util.AxisAngle4f; import org.jmol.util.Escape; import org.jmol.util.P3; @@ -262,9 +264,8 @@ return ""; if (units == null) { int pt = strFormat.indexOf("//"); - if (pt >= 0) { - units = strFormat.substring(pt + 2); - } else { + units = (pt >= 0 ? strFormat.substring(pt + 2) : null); + if (units == null) { units = viewer.getMeasureDistanceUnits(); strFormat += "//" + units; } @@ -306,8 +307,8 @@ Atom a2 = (Atom) getAtom(2); dist = (isPercent ? dist / a1.getVanderwaalsRadiusFloat(viewer, EnumVdw.AUTO) - + a2.getVanderwaalsRadiusFloat(viewer, EnumVdw.AUTO) : units - .startsWith("dc_") || units.equals("khz") ? viewer.getNMRCalculation() + + a2.getVanderwaalsRadiusFloat(viewer, EnumVdw.AUTO) : + nmrType(units) == NMR_DC ? viewer.getNMRCalculation() .getDipolarConstantHz(a1, a2) : viewer.getNMRCalculation() .getJCouplingHz(a1, a2, units, null)); isValid = !Float.isNaN(dist); @@ -322,12 +323,20 @@ if (units.equals("au")) return (andRound ? Math.round(dist / JC.ANGSTROMS_PER_BOHR * 1000) / 1000f : dist / JC.ANGSTROMS_PER_BOHR); - if (units.equals("khz")) + if (units.endsWith("khz")) return (andRound ? Math.round(dist / 10) / 100f : dist / 1000); } return (andRound ? Math.round(dist * 100) / 100f : dist); } + public final static int NMR_NOT = 0; + public final static int NMR_DC = 1; + public final static int NMR_JC = 2; + + public static int nmrType(String units) { + return (units.indexOf("hz") < 0 ? NMR_NOT : units.startsWith("dc_") || units.equals("khz") ? NMR_DC : NMR_JC); + } + private String formatAngle(float angle) { String label = getLabelString(); if (label.indexOf("%V") >= 0) @@ -521,4 +530,13 @@ return true; } + public boolean isMin(Map<String, Float> htMin) { + Atom a1 = (Atom) getAtom(1); + Atom a2 = (Atom) getAtom(2); + float d = a2.distanceSquared(a1); + String key = (a1.index < a2.index ? a1.getAtomName() + a2.getAtomName() : a2.getAtomName() + a1.getAtomName()); + Float min = htMin.get(key); + return (min != null && d == min.floatValue()); + } + } Modified: trunk/Jmol/src/org/jmol/modelset/MeasurementData.java =================================================================== --- trunk/Jmol/src/org/jmol/modelset/MeasurementData.java 2013-07-05 17:26:35 UTC (rev 18435) +++ trunk/Jmol/src/org/jmol/modelset/MeasurementData.java 2013-07-05 23:08:08 UTC (rev 18436) @@ -23,6 +23,8 @@ */ package org.jmol.modelset; +import java.util.Map; + import org.jmol.util.JmolList; @@ -81,7 +83,8 @@ /* * the general constructor. tokAction is not used here */ - public MeasurementData set(int tokAction, RadiusData radiusData, String strFormat, String units, + public MeasurementData set(int tokAction, Map<String, Float> htMin, + RadiusData radiusData, String strFormat, String units, TickInfo tickInfo, boolean mustBeConnected, boolean mustNotBeConnected, Boolean intramolecular, boolean isAll, @@ -94,6 +97,7 @@ viewer.getModelBitSet((BS) points.get(1), false)); } //this.rangeMinMax = rangeMinMax; + this.htMin = htMin; this.radiusData = radiusData; this.strFormat = strFormat; this.units = units; @@ -118,7 +122,7 @@ public void processNextMeasure(Measurement m) { float value = m.getMeasurement(); // here's where we check vdw - if (radiusData != null && !m.isInRange(radiusData, value)) + if (htMin != null && !m.isMin(htMin) || radiusData != null && !m.isInRange(radiusData, value)) return; if (measurementStrings == null) { float f = minArray[iFirstAtom]; @@ -157,6 +161,7 @@ private Viewer viewer; private int iFirstAtom; private boolean justOneModel = true; + public Map<String, Float> htMin; /** * called by the client to generate a set of measurements Modified: trunk/Jmol/src/org/jmol/quantum/NMRCalculation.java =================================================================== --- trunk/Jmol/src/org/jmol/quantum/NMRCalculation.java 2013-07-05 17:26:35 UTC (rev 18435) +++ trunk/Jmol/src/org/jmol/quantum/NMRCalculation.java 2013-07-05 23:08:08 UTC (rev 18436) @@ -34,6 +34,7 @@ import org.jmol.api.JmolNMRInterface; import org.jmol.io.JmolBinary; import org.jmol.modelset.Atom; +import org.jmol.modelset.MeasurementData; import org.jmol.modelset.ModelSet; import org.jmol.util.BS; import org.jmol.util.Escape; @@ -91,10 +92,11 @@ * * @param type * @param bs + * @param bs2 * @return list of Tensors */ @SuppressWarnings("unchecked") - public JmolList<Tensor> getInteractionTensorList(String type, BS bs) { + private JmolList<Tensor> getInteractionTensorList(String type, BS bs, BS bs2) { type = type.toLowerCase(); BS bsModels = viewer.getModelBitSet(bs, false); int iAtom = (bs.cardinality() == 1 ? bs.nextSetBit(0) : -1); @@ -106,13 +108,19 @@ int n = tensors.size(); for (int j = 0; j < n; j++) { Tensor t = tensors.get(j); - if (t.type.equals(type) && t.isSelected(bs, iAtom)) + if (t.type.equals(type) && t.isSelected(bs, iAtom) + && (bs2 == null || bs2.get(getOtherAtom(t, iAtom)))) + list.addLast(t); } } return list; } + private int getOtherAtom(Tensor t, int iAtom) { + return (t.atomIndex1 == iAtom ? t.atomIndex2 : t.atomIndex1); + } + public BS getUniqueTensorSet(BS bsAtoms) { BS bs = new BS(); Atom[] atoms = viewer.modelSet.atoms; @@ -161,22 +169,16 @@ return bs; } - @SuppressWarnings("unchecked") public float getJCouplingHz(Atom a1, Atom a2, String type, Tensor isc) { if (isc == null) { - JmolList<Tensor> tensors = (JmolList<Tensor>) viewer.getModelAuxiliaryInfoValue(a1.modelIndex, "interactionTensors"); - if (tensors == null) + type = getISCtype(a1, type); + if (type == null) return 0; BS bs = new BS(); + BS bs2 = new BS(); bs.set(a1.index); - bs.set(a2.index); - type = (type == null ? "" : type.toLowerCase()); - int pt = -1; - if ((pt = type.indexOf("_")) >= 0) - type = type.substring(0, pt); - if (type.length() == 0) - type = "isc"; - JmolList<Tensor> list = getInteractionTensorList(type, bs); + bs2.set(a2.index); + JmolList<Tensor> list = getInteractionTensorList(type, bs, bs2); if (list.size() == 0) return Float.NaN; isc = list.get(0); @@ -188,6 +190,21 @@ * getIsotopeData(a2, MAGNETOGYRIC_RATIO) * isc.getIso() * J_FACTOR); } + @SuppressWarnings("unchecked") + private String getISCtype(Atom a1, String type) { + JmolList<Tensor> tensors = (JmolList<Tensor>) viewer.getModelAuxiliaryInfoValue(a1.modelIndex, "interactionTensors"); + if (tensors == null) + return null; + type = (type == null ? "" : type.toLowerCase()); + int pt = -1; + if ((pt = type.indexOf("_hz")) >= 0 || (pt = type.indexOf("_khz")) >= 0 + || (pt = type.indexOf("hz")) >= 0 || (pt = type.indexOf("khz")) >= 0) + type = type.substring(0, pt); + if (type.length() == 0) + type = "isc"; + return type; + } + public float getDipolarConstantHz(Atom a1, Atom a2) { if (Logger.debugging) Logger.debug(a1 + " g=" + getIsotopeData(a1, MAGNETOGYRIC_RATIO) + "; " + a2 + " g=" + getIsotopeData(a2, MAGNETOGYRIC_RATIO)); @@ -382,7 +399,7 @@ boolean isJ = tensorType.equals("isc") && infoType.equals(";jcoupling."); boolean isChi = tensorType.equals("efg") && infoType.equals(";chi."); if (tensorType.equals("isc")) { - JmolList<Tensor> list = getInteractionTensorList("isc", bs); + JmolList<Tensor> list = getInteractionTensorList("isc", bs, null); int n = (list == null ? 0 : list.size()); for (int i = 0; i < n; i++) { Tensor t = list.get(i); @@ -444,4 +461,39 @@ return null; } + public Map<String, Float> getMinDistances(MeasurementData md) { + BS bsPoints1 = (BS) md.points.get(0); + int n1 = bsPoints1.cardinality(); + if (n1 == 0 || !(md.points.get(1) instanceof BS)) + return null; + BS bsPoints2 = (BS) md.points.get(1); + int n2 = bsPoints2.cardinality(); + if (n1 < 2 && n2 < 2) + return null; + Map<String, Float> htMin = new Hashtable<String, Float>(); + Atom[] atoms = viewer.modelSet.atoms; + for (int i = bsPoints1.nextSetBit(0); i >= 0; i = bsPoints1 + .nextSetBit(i + 1)) { + Atom a1 = atoms[i]; + String name = a1.getAtomName(); + for (int j = bsPoints2.nextSetBit(0); j >= 0; j = bsPoints2 + .nextSetBit(j + 1)) { + Atom a2 = atoms[j]; + float d = a2.distanceSquared(a1); + if (d == 0) + continue; + String key = (i < j ? name + a2.getAtomName() : a2.getAtomName() + name); + Float min = htMin.get(key); + if (min == null) { + min = Float.valueOf(d); + htMin.put(key, min); + continue; + } + if (d < min.floatValue()) + htMin.put(key, Float.valueOf(d)); + } + } + return htMin; + } + } Modified: trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java 2013-07-05 17:26:35 UTC (rev 18435) +++ trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java 2013-07-05 23:08:08 UTC (rev 18436) @@ -9850,7 +9850,7 @@ if (text != null) text.pymolOffset = offset; setShapeProperty(JC.SHAPE_MEASURES, "measure", - (new MeasurementData(id, viewer, points)).set(tokAction, rd, strFormat, null, tickInfo, + (new MeasurementData(id, viewer, points)).set(tokAction, null, rd, strFormat, null, tickInfo, isAllConnected, isNotConnected, intramolecular, isAll, mad, colix, text)); return; } @@ -13802,8 +13802,8 @@ } private boolean setUnits(String units, int tok) throws ScriptException { - if (tok == T.measurementunits && Parser.isOneOf(units.toLowerCase(), - ";angstroms;au;bohr;nanometers;nm;picometers;pm;vanderwaals;vdw;")) { + if (tok == T.measurementunits && (units.endsWith("hz") || Parser.isOneOf(units.toLowerCase(), + ";angstroms;au;bohr;nanometers;nm;picometers;pm;vanderwaals;vdw;"))) { if (!chk) viewer.setUnits(units, true); } else if (tok == T.energyunits && Parser.isOneOf(units.toLowerCase(), ";kcal;kj;")) { Modified: trunk/Jmol/src/org/jmol/script/ScriptMathProcessor.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptMathProcessor.java 2013-07-05 17:26:35 UTC (rev 18435) +++ trunk/Jmol/src/org/jmol/script/ScriptMathProcessor.java 2013-07-05 23:08:08 UTC (rev 18436) @@ -1445,7 +1445,7 @@ return addXStr(""); rd = (vdw == Float.MAX_VALUE ? new RadiusData(rangeMinMax, 0, null, null) : new RadiusData(null, vdw, EnumType.FACTOR, EnumVdw.AUTO)); - return addXObj((new MeasurementData(null, viewer, points)).set(0, rd, strFormat, units, null, isAllConnected, + return addXObj((new MeasurementData(null, viewer, points)).set(0, null, rd, strFormat, units, null, isAllConnected, isNotConnected, null, true, 0, (short) 0, null).getMeasurements(asArray)); case T.angle: if ((nPoints = args.length) != 3 && nPoints != 4) Modified: trunk/Jmol/src/org/jmol/shape/Measures.java =================================================================== --- trunk/Jmol/src/org/jmol/shape/Measures.java 2013-07-05 17:26:35 UTC (rev 18435) +++ trunk/Jmol/src/org/jmol/shape/Measures.java 2013-07-05 23:08:08 UTC (rev 18436) @@ -67,6 +67,7 @@ TickInfo tickInfo; TickInfo defaultTickInfo; public JmolFont font3d; + private Map<String, Float> htMin; @Override protected void initModelSet() { @@ -182,7 +183,13 @@ defaultTickInfo = md.tickInfo; return; } + if (md.isAll && md.points.size() == 2 && md.points.get(0) instanceof BS + && Measurement.nmrType(viewer.getDistanceUnits(md.strFormat)) + == Measurement.NMR_JC) + md.htMin = viewer.getNMRCalculation().getMinDistances(md); + tickInfo = md.tickInfo; radiusData = md.radiusData; + htMin = md.htMin; mustBeConnected = md.mustBeConnected; mustNotBeConnected = md.mustNotBeConnected; intramolecular = md.intramolecular; @@ -297,7 +304,7 @@ if (value instanceof String) { doAction(null, (String) value, T.opToggle); } else { - toggle(new Measurement().setPoints(modelSet, (int[]) value, null, null)); + toggle(new Measurement().setPoints(modelSet, (int[]) value, null, null)); } return; } @@ -310,7 +317,6 @@ } return; } - } private Measurement setSingleItem(JmolList<Object> vector) { @@ -397,6 +403,7 @@ private void toggle(Measurement m) { radiusData = null; + htMin = null; //toggling one that is hidden should be interpreted as DEFINE int i = find(m); Measurement mt; @@ -409,6 +416,7 @@ private void toggleOn(int[] indices) { radiusData = null; + htMin = null; //toggling one that is hidden should be interpreted as DEFINE bsSelected = new BS(); defineAll(Integer.MIN_VALUE, new Measurement().setPoints(modelSet, indices, null, defaultTickInfo), false, true, true); @@ -418,6 +426,7 @@ private void deleteM(Measurement m) { radiusData = null; + htMin = null; //toggling one that is hidden should be interpreted as DEFINE int i = find(m); if (i >= 0) @@ -463,7 +472,7 @@ Integer.valueOf(atoms[atomIndex].getAtomNumber())) : (Object) m .getAtom(i)); } - define((new MeasurementData(null, viewer, points)).set(tokAction, radiusData, strFormat, null, tickInfo, + define((new MeasurementData(null, viewer, points)).set(tokAction, htMin, radiusData, strFormat, null, tickInfo, mustBeConnected, mustNotBeConnected, intramolecular, true, 0, (short) 0, null), (isDelete ? T.delete : T.define)); } @@ -505,7 +514,8 @@ private void defineMeasurement(int i, Measurement m, boolean doSelect) { float value = m.getMeasurement(); - if (radiusData != null && !m.isInRange(radiusData, value)) + if (htMin != null && !m.isMin(htMin) + || radiusData != null && !m.isInRange(radiusData, value)) return; if (i == Integer.MIN_VALUE) i = find(m); @@ -517,6 +527,8 @@ } Measurement measureNew = new Measurement().setM(modelSet, m, value, (m.colix == 0 ? colix : m.colix), strFormat, measurementCount); + if (!measureNew.isValid) + return; measurements.addLast(measureNew); viewer.setStatusMeasuring("measureCompleted", measurementCount++, measureNew.toVector(false).toString(), measureNew.getValue()); Modified: trunk/Jmol/src/org/jmol/viewer/Jmol.properties =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2013-07-05 17:26:35 UTC (rev 18435) +++ trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2013-07-05 23:08:08 UTC (rev 18436) @@ -11,11 +11,13 @@ ___JmolVersion="13.1.19_dev_2013.07.05" +code: org.jmol.quantum.NMRCalculation smoothly handles J-coupling and dipolar coupling constant display. + new feature: unitcell center {atomset} new feature: unitcell center {fx fy fz} new feature: {*}.ms, {*}.cs %[ms] %[cs] magnetic shielding and chemical shift new feature: label <color red>xxx</color> -new feature: set shift_H_hz xxx, set shift_H_PPM_400 xxx +new feature: set shift_H xxx (ppm) new feature: getProperty("nmrInfo") Modified: trunk/Jmol/src/org/jmol/viewer/StateManager.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/StateManager.java 2013-07-05 17:26:35 UTC (rev 18435) +++ trunk/Jmol/src/org/jmol/viewer/StateManager.java 2013-07-05 23:08:08 UTC (rev 18436) @@ -1273,6 +1273,8 @@ measureDistanceUnits = "au"; else if (units.equalsIgnoreCase("vanderwaals") || units.equalsIgnoreCase("vdw")) measureDistanceUnits = "vdw"; + else if (units.toLowerCase().endsWith("hz") || units.toLowerCase().endsWith("khz")) + measureDistanceUnits = units.toLowerCase(); else if (units.equalsIgnoreCase("kj")) energyUnits = "kJ"; else if (units.equalsIgnoreCase("kcal")) Modified: trunk/Jmol/src/org/jmol/viewer/Viewer.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Viewer.java 2013-07-05 17:26:35 UTC (rev 18435) +++ trunk/Jmol/src/org/jmol/viewer/Viewer.java 2013-07-05 23:08:08 UTC (rev 18436) @@ -10109,4 +10109,12 @@ return (nmrCalculation == null ? (nmrCalculation = (JmolNMRInterface) Interface .getOptionInterface("quantum.NMRCalculation")).setViewer(this) : nmrCalculation); } + + public String getDistanceUnits(String s) { + if (s == null) + s = getDefaultMeasurementLabel(2); + int pt = s.indexOf("//"); + return (pt < 0 ? getMeasureDistanceUnits() : s.substring(pt + 2)); + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ This SF.net email is sponsored by Windows: Build for Windows Store. http://p.sf.net/sfu/windows-dev2dev _______________________________________________ Jmol-commits mailing list Jmol-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jmol-commits