Revision: 20679 http://sourceforge.net/p/jmol/code/20679 Author: hansonr Date: 2015-08-07 18:04:07 +0000 (Fri, 07 Aug 2015) Log Message: ----------- Jmol.___JmolVersion="14.3.15_2015.08.07"
bug fix: write property atomno temperature "test.pdb" preserves long residue names from CIF files bug fix: load "test.pdb" from write property atomno temperature restores values for atomno and temperature Modified Paths: -------------- trunk/Jmol/src/org/jmol/adapter/readers/pdb/PdbReader.java trunk/Jmol/src/org/jmol/adapter/readers/pdb/PqrReader.java trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollectionReader.java trunk/Jmol/src/org/jmol/adapter/smarter/Resolver.java trunk/Jmol/src/org/jmol/api/JmolDataManager.java trunk/Jmol/src/org/jmol/modelset/LabelToken.java trunk/Jmol/src/org/jmol/modelset/ModelLoader.java trunk/Jmol/src/org/jmol/script/ScriptEval.java trunk/Jmol/src/org/jmol/script/ScriptExpr.java trunk/Jmol/src/org/jmol/scriptext/CmdExt.java trunk/Jmol/src/org/jmol/scriptext/IsoExt.java trunk/Jmol/src/org/jmol/scriptext/MathExt.java trunk/Jmol/src/org/jmol/viewer/DataManager.java trunk/Jmol/src/org/jmol/viewer/Jmol.properties trunk/Jmol/src/org/jmol/viewer/PropertyManager.java trunk/Jmol/src/org/jmol/viewer/Viewer.java Added Paths: ----------- trunk/Jmol/src/org/jmol/adapter/readers/pdb/JmolDataReader.java Added: trunk/Jmol/src/org/jmol/adapter/readers/pdb/JmolDataReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/readers/pdb/JmolDataReader.java (rev 0) +++ trunk/Jmol/src/org/jmol/adapter/readers/pdb/JmolDataReader.java 2015-08-07 18:04:07 UTC (rev 20679) @@ -0,0 +1,169 @@ +/* $RCSfile$ + * $Author: hansonr $ + * $Date: 2006-10-15 17:34:01 -0500 (Sun, 15 Oct 2006) $ + * $Revision: 5957 $ + * + * Copyright (C) 2003-2005 Miguel, Jmol Development, www.jmol.org + * + * Contact: jmol-develop...@lists.sf.net + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.jmol.adapter.readers.pdb; + +import java.util.Hashtable; +import java.util.Map; + +import javajs.util.P3; + +import org.jmol.adapter.smarter.Atom; +import org.jmol.util.Logger; +import org.jmol.util.Parser; + +/** + * JmolData file reader, for a modified PDB format + * + */ + +public class JmolDataReader extends PdbReader { + + + private Map<String, float[]> props; + private String[] residueNames; + private String[] atomNames; + + // REMARK 6 Jmol PDB-encoded data: property atomno temperature; + // REMARK 6 Jmol atom names ... ... ...; + // REMARK 6 Jmol residue names ... ... ...; + // REMARK 6 Jmol data min = {1.0 -41.87 0.0} max = {26.0 66.53 0.0} unScaledXyz = xyz * {1.0 1.0 0.0} + {0.0 12.33 0.0} plotscale = {100 100 100}; + // REMARK 6 Jmol property atomno [1.0, 2.0, ...]; + // REMARK 6 Jmol property temperature [0.0, 23.0, 21.0, ...]; + + @Override + protected void checkRemark() { + // REMARK 6 Jmol + while (true) { + if (line.length() < 30 || line.indexOf("Jmol") != 11) + break; + switch ("Ppard".indexOf(line.substring(16, 17))) { + case 0: //Jmol PDB-encoded data + props = new Hashtable<String, float[]>(); + asc.setInfo("jmolData", line); + if (!line.endsWith("#noautobond")) + line += "#noautobond"; + break; + case 1: // Jmol property + int pt1 = line.indexOf("["); + int pt2 = line.indexOf("]"); + if (pt1 < 25 || pt2 <= pt1) + return; + String name = line.substring(25, pt1).trim(); + line = line.substring(pt1 + 1, pt2).replace(',', ' '); + String[] tokens = getTokens(); + Logger.info("reading " + name + " " + tokens.length); + float[] prop = new float[tokens.length]; + for (int i = prop.length; --i >= 0;) + prop[i] = parseFloatStr(tokens[i]); + props.put(name, prop); + break; + case 2: // Jmol atom names + // REMARK 6 Jmol atom names ... ... ...; + line = line.substring(27); + atomNames = getTokens(); + Logger.info("reading atom names " + atomNames.length); + break; + case 3: // Jmol residue names + // REMARK 6 Jmol residue names ... ... ...; + line = line.substring(30); + residueNames = getTokens(); + Logger.info("reading residue names " + residueNames.length); + break; + case 4: //Jmol data min + Logger.info(line); + // The idea here is to use a line such as the following: + // + // REMARK 6 Jmol data min = {-1 -1 -1} max = {1 1 1} + // unScaledXyz = xyz / {10 10 10} + {0 0 0} + // plotScale = {100 100 100} + // + // to pass on to Jmol how to graph non-molecular data. + // The format allows for the actual data to be linearly transformed + // so that it fits into the PDB format for x, y, and z coordinates. + // This adapter will then unscale the data and also pass on to + // Jmol the unit cell equivalent that takes the actual data (which + // will be considered the fractional coordinates) to Jmol coordinates, + // which will be a cube centered at {0 0 0} and ranging from {-100 -100 -100} + // to {100 100 100}. + // + // Jmol 12.0.RC23 uses this to pass through the adapter a quaternion, + // ramachandran, or other sort of plot. + + float[] data = new float[15]; + Parser.parseStringInfestedFloatArray( + line.substring(10).replace('=', ' ').replace('{', ' ') + .replace('}', ' '), null, data); + P3 minXYZ = P3.new3(data[0], data[1], data[2]); + P3 maxXYZ = P3.new3(data[3], data[4], data[5]); + fileScaling = P3.new3(data[6], data[7], data[8]); + fileOffset = P3.new3(data[9], data[10], data[11]); + P3 plotScale = P3.new3(data[12], data[13], data[14]); + if (plotScale.x <= 0) + plotScale.x = 100; + if (plotScale.y <= 0) + plotScale.y = 100; + if (plotScale.z <= 0) + plotScale.z = 100; + if (fileScaling.y == 0) + fileScaling.y = 1; + if (fileScaling.z == 0) + fileScaling.z = 1; + setFractionalCoordinates(true); + latticeCells = new int[3]; + asc.xtalSymmetry = null; + setUnitCell(plotScale.x * 2 / (maxXYZ.x - minXYZ.x), plotScale.y * 2 + / (maxXYZ.y - minXYZ.y), plotScale.z * 2 + / (maxXYZ.z == minXYZ.z ? 1 : maxXYZ.z - minXYZ.z), 90, 90, 90); + unitCellOffset = P3.newP(plotScale); + unitCellOffset.scale(-1); + getSymmetry(); + symmetry.toFractional(unitCellOffset, false); + unitCellOffset.scaleAdd2(-1f, minXYZ, unitCellOffset); + symmetry.setOffsetPt(unitCellOffset); + asc.setInfo("jmolDataScaling", new P3[] { minXYZ, maxXYZ, plotScale }); + doApplySymmetry = true; + break; + } + break; + } + checkCurrentLineForScript(); + } + + @Override + protected void setAdditionalAtomParameters(Atom atom) { + if (residueNames != null && atom.index < residueNames.length) + atom.group3 = residueNames[atom.index]; + if (atomNames != null && atom.index < atomNames.length) + atom.atomName = atomNames[atom.index]; + } + + @Override + protected void finalizeSubclassReader() throws Exception { + asc.setCurrentModelInfo("jmolDataProperties", props); + finalizeReaderPDB(); + } + +} + Property changes on: trunk/Jmol/src/org/jmol/adapter/readers/pdb/JmolDataReader.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Modified: trunk/Jmol/src/org/jmol/adapter/readers/pdb/PdbReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/readers/pdb/PdbReader.java 2015-08-06 18:37:56 UTC (rev 20678) +++ trunk/Jmol/src/org/jmol/adapter/readers/pdb/PdbReader.java 2015-08-07 18:04:07 UTC (rev 20679) @@ -116,8 +116,7 @@ private boolean isConnectStateBug; private boolean isLegacyModelType; - private boolean gromacsWideFormat; - protected boolean isPQR; + protected boolean gromacsWideFormat; private final Map<String, Map<String, Boolean>> htFormul = new Hashtable<String, Map<String, Boolean>>(); private Map<String, String> htHetero; @@ -327,14 +326,6 @@ formul(); return true; case 17: - if (line.contains("The B-factors in this file hold atomic radii")) { - isPQR = true; - return true; - } - if (line.contains("This file does not adhere to the PDB standard")) { - gromacsWideFormat = true; - return true; - } if (line.startsWith("REMARK 350")) { remark350(); return false; @@ -343,11 +334,14 @@ remark290(); return false; } + if (line.contains("This file does not adhere to the PDB standard")) { + gromacsWideFormat = true; + } if (getTlsGroups) { if (line.indexOf("TLS DETAILS") > 0) return remarkTls(); } - checkCurrentLineForScript(); + checkRemark(); return true; case 18: header(); @@ -368,6 +362,10 @@ return true; } + protected void checkRemark() { + checkCurrentLineForScript(); + } + private void checkDSSR() throws Exception { if (line.trim().startsWith("DSSR:") && asc.ac > 0) processDSSR(this, htGroup1); @@ -1020,21 +1018,7 @@ * @param atom */ protected void setAdditionalAtomParameters(Atom atom) { - if (isPQR) { - if (gromacsWideFormat) { - atom.partialCharge = parseFloatRange(line, 60, 68); - atom.radius = fixRadius(parseFloatRange(line, 68, 76)); - } else { - String[] tokens = getTokens(); - int pt = tokens.length - 2 - (line.length() > 75 ? 1 : 0); - atom.partialCharge = parseFloatStr(tokens[pt++]); - atom.radius = fixRadius(parseFloatStr(tokens[pt])); - } - return; - } - - float floatOccupancy; - + float floatOccupancy; if (gromacsWideFormat) { floatOccupancy = parseFloatRange(line, 60, 68); atom.bfactor = fixRadius(parseFloatRange(line, 68, 76)); Modified: trunk/Jmol/src/org/jmol/adapter/readers/pdb/PqrReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/readers/pdb/PqrReader.java 2015-08-06 18:37:56 UTC (rev 20678) +++ trunk/Jmol/src/org/jmol/adapter/readers/pdb/PqrReader.java 2015-08-07 18:04:07 UTC (rev 20679) @@ -25,6 +25,7 @@ package org.jmol.adapter.readers.pdb; import org.jmol.adapter.readers.pdb.PdbReader; +import org.jmol.adapter.smarter.Atom; /** * PQR file reader. @@ -60,13 +61,17 @@ public class PqrReader extends PdbReader { - protected boolean gromacsWideFormat; - @Override - protected void initializeReader() throws Exception { - isPQR = true; - super.initializeReader(); + protected void setAdditionalAtomParameters(Atom atom) { + if (gromacsWideFormat) { + atom.partialCharge = parseFloatRange(line, 60, 68); + atom.radius = fixRadius(parseFloatRange(line, 68, 76)); + } else { + String[] tokens = getTokens(); + int pt = tokens.length - 2 - (line.length() > 75 ? 1 : 0); + atom.partialCharge = parseFloatStr(tokens[pt++]); + atom.radius = fixRadius(parseFloatStr(tokens[pt])); + } } - } Modified: trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollectionReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollectionReader.java 2015-08-06 18:37:56 UTC (rev 20678) +++ trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollectionReader.java 2015-08-07 18:04:07 UTC (rev 20679) @@ -28,29 +28,26 @@ import java.io.BufferedReader; import java.util.Map; -import org.jmol.api.Interface; -import org.jmol.api.JmolAdapter; -import org.jmol.api.SymmetryInterface; -import org.jmol.java.BS; -import org.jmol.script.SV; -import org.jmol.symmetry.Symmetry; -import org.jmol.util.BSUtil; -import org.jmol.util.Logger; -import org.jmol.util.Parser; - import javajs.api.GenericBinaryDocument; import javajs.api.GenericLineReader; +import javajs.util.Lst; import javajs.util.M3; +import javajs.util.OC; import javajs.util.P3; - -import javajs.util.OC; import javajs.util.PT; import javajs.util.Quat; +import javajs.util.SB; import javajs.util.T3; import javajs.util.V3; -import javajs.util.Lst; -import javajs.util.SB; +import org.jmol.api.Interface; +import org.jmol.api.JmolAdapter; +import org.jmol.api.SymmetryInterface; +import org.jmol.java.BS; +import org.jmol.script.SV; +import org.jmol.symmetry.Symmetry; +import org.jmol.util.BSUtil; +import org.jmol.util.Logger; import org.jmol.viewer.Viewer; @@ -211,7 +208,7 @@ protected float latticeScaling = Float.NaN; protected P3 fileOffset; private P3 fileOffsetFractional; - P3 unitCellOffset; + protected P3 unitCellOffset; private boolean unitCellOffsetFractional; private Lst<String> moreUnitCellInfo; @@ -1449,67 +1446,6 @@ } public void checkCurrentLineForScript() { - if (line.indexOf("Jmol") >= 0) { - if (line.indexOf("Jmol PDB-encoded data") >= 0) { - asc.setInfo("jmolData", line); - if (!line.endsWith("#noautobond")) - line += "#noautobond"; - } - if (line.indexOf("Jmol data min") >= 0) { - Logger.info(line); - // The idea here is to use a line such as the following: - // - // REMARK 6 Jmol data min = {-1 -1 -1} max = {1 1 1} - // unScaledXyz = xyz / {10 10 10} + {0 0 0} - // plotScale = {100 100 100} - // - // to pass on to Jmol how to graph non-molecular data. - // The format allows for the actual data to be linearly transformed - // so that it fits into the PDB format for x, y, and z coordinates. - // This adapter will then unscale the data and also pass on to - // Jmol the unit cell equivalent that takes the actual data (which - // will be considered the fractional coordinates) to Jmol coordinates, - // which will be a cube centered at {0 0 0} and ranging from {-100 -100 -100} - // to {100 100 100}. - // - // Jmol 12.0.RC23 uses this to pass through the adapter a quaternion, - // ramachandran, or other sort of plot. - - float[] data = new float[15]; - Parser.parseStringInfestedFloatArray(line.substring(10).replace('=', ' ') - .replace('{', ' ').replace('}', ' '), null, data); - P3 minXYZ = P3.new3(data[0], data[1], data[2]); - P3 maxXYZ = P3.new3(data[3], data[4], data[5]); - fileScaling = P3.new3(data[6], data[7], data[8]); - fileOffset = P3.new3(data[9], data[10], data[11]); - P3 plotScale = P3.new3(data[12], data[13], data[14]); - if (plotScale.x <= 0) - plotScale.x = 100; - if (plotScale.y <= 0) - plotScale.y = 100; - if (plotScale.z <= 0) - plotScale.z = 100; - if (fileScaling.y == 0) - fileScaling.y = 1; - if (fileScaling.z == 0) - fileScaling.z = 1; - setFractionalCoordinates(true); - latticeCells = new int[3]; - asc.xtalSymmetry = null; - setUnitCell(plotScale.x * 2 / (maxXYZ.x - minXYZ.x), plotScale.y * 2 - / (maxXYZ.y - minXYZ.y), plotScale.z * 2 - / (maxXYZ.z == minXYZ.z ? 1 : maxXYZ.z - minXYZ.z), 90, 90, 90); - unitCellOffset = P3.newP(plotScale); - unitCellOffset.scale(-1); - getSymmetry(); - symmetry.toFractional(unitCellOffset, false); - unitCellOffset.scaleAdd2(-1f, minXYZ, unitCellOffset); - symmetry.setOffsetPt(unitCellOffset); - asc.setInfo("jmolDataScaling", - new P3[] { minXYZ, maxXYZ, plotScale }); - doApplySymmetry = true; - } - } if (line.endsWith("#noautobond")) { line = line.substring(0, line.lastIndexOf('#')).trim(); asc.setNoAutoBond(); Modified: trunk/Jmol/src/org/jmol/adapter/smarter/Resolver.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/smarter/Resolver.java 2015-08-06 18:37:56 UTC (rev 20678) +++ trunk/Jmol/src/org/jmol/adapter/smarter/Resolver.java 2015-08-07 18:04:07 UTC (rev 20679) @@ -50,7 +50,7 @@ "quantum.", ";Adf;Csf;Dgrid;GamessUK;GamessUS;Gaussian;GaussianFchk;GaussianWfn;Jaguar;" + "Molden;MopacGraphf;GenNBO;NWChem;Odyssey;Psi;Qchem;Spartan;SpartanSmol;" + "WebMO;", - "pdb.", ";Pdb;Pqr;P2n;", + "pdb.", ";Pdb;Pqr;P2n;JmolData;", "pymol.", ";PyMOL;", "simple.", ";Alchemy;Ampac;Cube;FoldingXyz;GhemicalMM;HyperChem;Jme;JSON;Mopac;MopacArchive;Tinker;Input;", "xtal.", ";Abinit;Aims;Bilbao;Castep;Cgd;Crystal;Dmol;Espresso;Gulp;Jana;Magres;Shelx;Siesta;VaspOutcar;" + @@ -347,12 +347,22 @@ private final static String[] jcampdxStartRecords = { "Jcampdx", "##TITLE" }; + private final static String[] jmoldataStartRecords = + { "JmolData", "REMARK 6 Jmol" }; + + private final static String[] pqrStartRecords = + { "Pqr", "REMARK 1 PQR", "REMARK The B-factors" }; + + private final static String[] p2nStartRecords = + { "P2n", "REMARK 1 P2N" }; + private final static String[][] fileStartsWithRecords = { sptRecords, m3dStartRecords, cubeFileStartRecords, mol2Records, webmoFileStartRecords, moldenFileStartRecords, dcdFileStartRecords, tlsDataOnlyFileStartRecords, inputFileStartRecords, magresFileStartRecords, pymolStartRecords, - janaStartRecords, jsonStartRecords, jcampdxStartRecords }; + janaStartRecords, jsonStartRecords, jcampdxStartRecords, + jmoldataStartRecords, pqrStartRecords, p2nStartRecords }; //////////////////////////////////////////////////////////////// // Test 3. check first time for special file types @@ -595,12 +605,6 @@ private final static String[] cifLineStartRecords = { "Cif", "data_", "_publ" }; - private final static String[] pqrLineStartRecords = - { "Pqr", "REMARK 1 PQR" }; - - private final static String[] p2nLineStartRecords = - { "P2n", "REMARK 1 P2N" }; - private final static String[] pdbLineStartRecords = { "Pdb", "HEADER", "OBSLTE", "TITLE ", "CAVEAT", "COMPND", "SOURCE", "KEYWDS", "EXPDTA", "AUTHOR", "REVDAT", "SPRSDE", "JRNL ", "REMARK ", @@ -641,7 +645,7 @@ { "VaspOutcar", " vasp.", " INCAR:" }; private final static String[][] lineStartsWithRecords = - { mmcifLineStartRecords, cifLineStartRecords, pqrLineStartRecords, p2nLineStartRecords, + { mmcifLineStartRecords, cifLineStartRecords, pdbLineStartRecords, cgdLineStartRecords, shelxLineStartRecords, ghemicalMMLineStartRecords, jaguarLineStartRecords, mdlLineStartRecords, spartanSmolLineStartRecords, csfLineStartRecords, Modified: trunk/Jmol/src/org/jmol/api/JmolDataManager.java =================================================================== --- trunk/Jmol/src/org/jmol/api/JmolDataManager.java 2015-08-06 18:37:56 UTC (rev 20678) +++ trunk/Jmol/src/org/jmol/api/JmolDataManager.java 2015-08-07 18:04:07 UTC (rev 20679) @@ -29,7 +29,7 @@ float getDataFloat(String label, int atomIndex); - float[] getDataFloatA(String label); + float[] getDataFloatA(String label, BS bsSelected); String getDefaultVdwNameOrData(VDW type, BS bs); Modified: trunk/Jmol/src/org/jmol/modelset/LabelToken.java =================================================================== --- trunk/Jmol/src/org/jmol/modelset/LabelToken.java 2015-08-06 18:37:56 UTC (rev 20678) +++ trunk/Jmol/src/org/jmol/modelset/LabelToken.java 2015-08-07 18:04:07 UTC (rev 20679) @@ -405,10 +405,10 @@ String propertyName = strFormat.substring(ich, ichClose).toLowerCase(); if (propertyName.startsWith("property_")) { lt.tok = T.data; - lt.data = vwr.getDataFloat(propertyName); + lt.data = vwr.getDataFloat(propertyName, null); } else if (propertyName.startsWith("validation.")) { lt.tok = T.validation; - lt.data = vwr.getDataFloat("property_" + propertyName.substring(11)); + lt.data = vwr.getDataFloat("property_" + propertyName.substring(11), null); } else { T token = T.getTokenFromName(propertyName); if (token != null && isLabelPropertyTok(token.tok)) @@ -427,7 +427,7 @@ break; } String s = strFormat.substring(ich, ichCloseBracket); - lt.data = vwr.getDataFloat(s); + lt.data = vwr.getDataFloat(s, null); // TODO untested j2s issue fix if (lt.data == null) { lt.data = vwr.getData(s); Modified: trunk/Jmol/src/org/jmol/modelset/ModelLoader.java =================================================================== --- trunk/Jmol/src/org/jmol/modelset/ModelLoader.java 2015-08-06 18:37:56 UTC (rev 20678) +++ trunk/Jmol/src/org/jmol/modelset/ModelLoader.java 2015-08-07 18:04:07 UTC (rev 20679) @@ -60,6 +60,7 @@ import java.util.Hashtable; import java.util.Map; +import java.util.Map.Entry; import java.util.Properties; /* @@ -170,7 +171,7 @@ isMutate = ms.getMSInfoB("isMutate"); if (ms.haveBioModels) jbr = vwr.getJBR().setLoader(this); - jmolData = (String) ms.getInfoM("jmolData"); + jmolData = (adapterModelCount == 0 ? (String) ms.getInfoM("jmolData") : null); fileHeader = (String) ms.getInfoM("fileHeader"); Lst<P3[]> steps = (Lst<P3[]>) ms.getInfoM("trajectorySteps"); isTrajectory = (steps != null); @@ -440,6 +441,8 @@ Map<String, Object> atomProperties = (Map<String, Object>) ms.getInfo(i, "atomProperties"); // list of properties that are to be transfered to H atoms as well. + if (jmolData != null) + addJmolDataProperties(ms.am[i], (Map<String, float[]>) ms.getInfo(i, "jmolDataProperties")); String groupList = (String) ms.getInfo(i, "groupPropertyList"); if (atomProperties == null) @@ -615,10 +618,10 @@ if (atomInfo != null) ms.setInfo(modelIndex, "PDB_CONECT_firstAtom_count_max", atomInfo); } + Model[] models = ms.am; + Atom[] atoms = ms.at; // this next sets the bitset length to avoid // unnecessary calls to System.arrayCopy - Model[] models = ms.am; - Atom[] atoms = ms.at; models[modelIndex].bsAtoms.set(atoms.length + 1); models[modelIndex].bsAtoms.clear(atoms.length + 1); String codes = (String) ms.getInfo(modelIndex, "altLocs"); @@ -836,6 +839,26 @@ Logger.info(nRead + " atoms created"); } + private void addJmolDataProperties(Model m, Map<String, float[]> jmolDataProperties) { + if (jmolDataProperties == null) + return; + BS bs = m.bsAtoms; + for (Entry<String, float[]> e : jmolDataProperties.entrySet()) { + String key = e.getKey(); + float[] data = e.getValue(); + if (key.startsWith("property_")) { + vwr.setData( + key, + new Object[] { key, data, bs, + Integer.valueOf(JmolDataManager.DATA_TYPE_AF) }, 0, 0, 0, 0, 0); + } else { + int tok = T.getTokFromName(key); + if (T.tokAttr(tok, T.settable)) + vwr.setAtomProperty(bs, tok, 0, 0, null, data, null); + } + } + } + /** * Adjust known N and O atom formal charges. * Note that this does not take care of ligands. Modified: trunk/Jmol/src/org/jmol/script/ScriptEval.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptEval.java 2015-08-06 18:37:56 UTC (rev 20678) +++ trunk/Jmol/src/org/jmol/script/ScriptEval.java 2015-08-07 18:04:07 UTC (rev 20679) @@ -8102,8 +8102,8 @@ if (pal == PAL.PROPERTY) { if (isColorIndex) { if (!chk) { - data = getBitsetPropertyFloat(bsSelected, (isByElement ? T.elemno - : T.groupid) | T.allfloat, Float.NaN, Float.NaN); + data = getCmdExt().getBitsetPropertyFloat(bsSelected, (isByElement ? T.elemno + : T.groupid) | T.allfloat, null, Float.NaN, Float.NaN); } } else { boolean isPropertyExplicit = name.equals("property"); @@ -8112,8 +8112,8 @@ && T.tokAttr((tok = getToken(++index).tok), T.atomproperty) && !T.tokAttr(tok, T.strproperty)) { if (!chk) { - data = getBitsetPropertyFloat(bsSelected, getToken(index).tok - | T.allfloat, Float.NaN, Float.NaN); + data = getCmdExt().getBitsetPropertyFloat(bsSelected, getToken(index).tok + | T.allfloat, null, Float.NaN, Float.NaN); } index++; } else if (!isPropertyExplicit && !isIsosurface) { Modified: trunk/Jmol/src/org/jmol/script/ScriptExpr.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptExpr.java 2015-08-06 18:37:56 UTC (rev 20678) +++ trunk/Jmol/src/org/jmol/script/ScriptExpr.java 2015-08-07 18:04:07 UTC (rev 20679) @@ -28,7 +28,6 @@ import org.jmol.scriptext.MathExt; import org.jmol.scriptext.ScriptExt; import org.jmol.scriptext.SmilesExt; -import org.jmol.shape.Shape; import org.jmol.util.BSUtil; import org.jmol.util.Elements; import org.jmol.util.Escape; @@ -967,7 +966,7 @@ if (pc + 2 == code.length) invArg(); if (!chk) - data = vwr.getDataFloat((String) code[++pc].value); + data = vwr.getDataFloat((String) code[++pc].value, null); } if (++pc == code.length) invArg(); // compiler would not let this happen, actually @@ -1522,21 +1521,6 @@ return SV.newSV(T.propselector, tok, paramAsStr(i)); } - public float[] getBitsetPropertyFloat(BS bs, int tok, float min, float max) - throws ScriptException { - float[] data = (float[]) getBitsetProperty(bs, tok, null, null, null, null, - false, Integer.MAX_VALUE, false); - if (!Float.isNaN(min)) - for (int i = 0; i < data.length; i++) - if (data[i] < min) - data[i] = Float.NaN; - if (!Float.isNaN(max)) - for (int i = 0; i < data.length; i++) - if (data[i] > max) - data[i] = Float.NaN; - return data; - } - @SuppressWarnings("unchecked") public Object getBitsetProperty(BS bs, int tok, P3 ptRef, P4 planeRef, Object tokenValue, Object opValue, @@ -1663,7 +1647,7 @@ ptT = new P3(); break; case T.property: - data = vwr.getDataFloat((String) opValue); + data = vwr.getDataFloat((String) opValue, null); break; } Modified: trunk/Jmol/src/org/jmol/scriptext/CmdExt.java =================================================================== --- trunk/Jmol/src/org/jmol/scriptext/CmdExt.java 2015-08-06 18:37:56 UTC (rev 20678) +++ trunk/Jmol/src/org/jmol/scriptext/CmdExt.java 2015-08-07 18:04:07 UTC (rev 20679) @@ -2279,12 +2279,12 @@ if (T.tokAttrOr(tokProp1, T.intproperty, T.floatproperty) && T.tokAttrOr(tokProp2, T.intproperty, T.floatproperty) && T.tokAttrOr(tokKey, T.intproperty, T.floatproperty)) { - float[] data1 = eval.getBitsetPropertyFloat(bsFrom, tokProp1 - | T.selectedfloat, Float.NaN, Float.NaN); - float[] data2 = eval.getBitsetPropertyFloat(bsFrom, tokKey - | T.selectedfloat, Float.NaN, Float.NaN); - float[] data3 = eval.getBitsetPropertyFloat(bsTo, tokKey - | T.selectedfloat, Float.NaN, Float.NaN); + float[] data1 = getBitsetPropertyFloat(bsFrom, tokProp1 + | T.selectedfloat, null, Float.NaN, Float.NaN); + float[] data2 = getBitsetPropertyFloat(bsFrom, tokKey + | T.selectedfloat, null, Float.NaN, Float.NaN); + float[] data3 = getBitsetPropertyFloat(bsTo, tokKey + | T.selectedfloat, null, Float.NaN, Float.NaN); boolean isProperty = (tokProp2 == T.property); float[] dataOut = new float[isProperty ? vwr.ms.ac : data3.length]; @@ -2856,6 +2856,7 @@ eval.iToken = st.length; error(ScriptError.ERROR_endOfStatementUnexpected); } + eval.slen = slen = pt + 1; break; } String qFrame = ""; @@ -2865,7 +2866,9 @@ boolean isDerivative = false; boolean isSecondDerivative = false; boolean isRamachandranRelative = false; - int propertyX = 0, propertyY = 0, propertyZ = 0; + String[] props = new String[3]; + int[] propToks = new int[3]; + BS bs = BSUtil.copy(vwr.bsA()); String preSelected = "; select " + Escape.eBS(bs) + ";\n "; String type = eval.optParameterAsString(pt).toLowerCase(); @@ -2887,11 +2890,19 @@ break; case T.property: eval.iToken = pt0 + 1; - propertyX = plotProp(); - if (propertyX == 0) - invArg(); - propertyY = plotProp(); - propertyZ = plotProp(); + for (int i = 0; i < 3; i++) { + switch (tokAt(eval.iToken)) { + case T.format: + case T.min: + case T.max: + i = 2; + continue; + } + if (!T.tokAttr(propToks[i] = tokAt(eval.iToken), T.atomproperty)) + invArg(); + props[i] = getToken(eval.iToken).value.toString(); + eval.iToken++; + } if (tokAt(eval.iToken) == T.format) { format = stringParameter(++eval.iToken); pdbFormat = false; @@ -2905,9 +2916,9 @@ maxXYZ = getPoint3f(++eval.iToken, false); eval.iToken++; } - type = "property " + T.nameOf(propertyX) - + (propertyY == 0 ? "" : " " + T.nameOf(propertyY)) - + (propertyZ == 0 ? "" : " " + T.nameOf(propertyZ)); + type = "property " + props[0] + + (props[1] == null ? "" : " " + props[1]) + + (props[2] == null ? "" : " " + props[2]); if (bs.nextSetBit(0) < 0) bs = vwr.getModelUndeletedAtomsBitSet(modelIndex); stateScript = "select " + Escape.eBS(bs) + ";\n "; @@ -2975,25 +2986,30 @@ float[] dataX = null, dataY = null, dataZ = null; if (tok == T.property) { - dataX = eval.getBitsetPropertyFloat(bs, propertyX | T.selectedfloat, - (minXYZ == null ? Float.NaN : minXYZ.x), (maxXYZ == null ? Float.NaN + dataX = getBitsetPropertyFloat(bs, propToks[0] | T.selectedfloat, + propToks[0] == T.property? props[0] : null, (minXYZ == null ? Float.NaN : minXYZ.x), (maxXYZ == null ? Float.NaN : maxXYZ.x)); - if (propertyY != 0) - dataY = eval.getBitsetPropertyFloat(bs, propertyY | T.selectedfloat, - (minXYZ == null ? Float.NaN : minXYZ.y), + props[0] = props[0] + " " + Escape.eAF(dataX); + if (props[1] != null) { + dataY = getBitsetPropertyFloat(bs, propToks[1] | T.selectedfloat, + propToks[1] == T.property? props[1] : null, (minXYZ == null ? Float.NaN : minXYZ.y), (maxXYZ == null ? Float.NaN : maxXYZ.y)); - if (propertyZ != 0) - dataZ = eval.getBitsetPropertyFloat(bs, propertyZ | T.selectedfloat, - (minXYZ == null ? Float.NaN : minXYZ.z), + props[1] = props[1] + " " + Escape.eAF(dataY); + } + if (props[2] != null) { + dataZ = getBitsetPropertyFloat(bs, propToks[2] | T.selectedfloat, + propToks[2] == T.property? props[2] : null, (minXYZ == null ? Float.NaN : minXYZ.z), (maxXYZ == null ? Float.NaN : maxXYZ.z)); + props[2] = props[2] + " " + Escape.eAF(dataZ); + } if (minXYZ == null) - minXYZ = P3.new3(getPlotMinMax(dataX, false, propertyX), - getPlotMinMax(dataY, false, propertyY), - getPlotMinMax(dataZ, false, propertyZ)); + minXYZ = P3.new3(getPlotMinMax(dataX, false, propToks[0]), + getPlotMinMax(dataY, false, propToks[1]), + getPlotMinMax(dataZ, false, propToks[2])); if (maxXYZ == null) - maxXYZ = P3.new3(getPlotMinMax(dataX, true, propertyX), - getPlotMinMax(dataY, true, propertyY), - getPlotMinMax(dataZ, true, propertyZ)); + maxXYZ = P3.new3(getPlotMinMax(dataX, true, propToks[0]), + getPlotMinMax(dataY, true, propToks[1]), + getPlotMinMax(dataZ, true, propToks[2])); Logger.info("plot min/max: " + minXYZ + " " + maxXYZ); P3 center = null; P3 factors = null; @@ -3004,37 +3020,37 @@ center.ave(maxXYZ, minXYZ); factors.sub2(maxXYZ, minXYZ); factors.set(factors.x / 200, factors.y / 200, factors.z / 200); - if (T.tokAttr(propertyX, T.intproperty)) { + if (T.tokAttr(propToks[0], T.intproperty)) { factors.x = 1; center.x = 0; } else if (factors.x > 0.1 && factors.x <= 10) { factors.x = 1; } - if (T.tokAttr(propertyY, T.intproperty)) { + if (T.tokAttr(propToks[1], T.intproperty)) { factors.y = 1; center.y = 0; } else if (factors.y > 0.1 && factors.y <= 10) { factors.y = 1; } - if (T.tokAttr(propertyZ, T.intproperty)) { + if (T.tokAttr(propToks[2], T.intproperty)) { factors.z = 1; center.z = 0; } else if (factors.z > 0.1 && factors.z <= 10) { factors.z = 1; } - if (propertyZ == 0 || propertyY == 0) + if (props[2] == null || props[1] == null) center.z = minXYZ.z = maxXYZ.z = factors.z = 0; for (int i = 0; i < dataX.length; i++) dataX[i] = (dataX[i] - center.x) / factors.x; - if (propertyY != 0) + if (props[1] != null) for (int i = 0; i < dataY.length; i++) dataY[i] = (dataY[i] - center.y) / factors.y; - if (propertyZ != 0) + if (props[2] != null) for (int i = 0; i < dataZ.length; i++) dataZ[i] = (dataZ[i] - center.z) / factors.z; } parameters = new Object[] { bs, dataX, dataY, dataZ, minXYZ, maxXYZ, - factors, center, format}; + factors, center, format, props}; } // all set... @@ -3090,13 +3106,13 @@ float f = 3; script = "frame 0.0; frame last; reset;" + "select visible; spacefill " + f + "; wireframe 0;" + "draw plotAxisX" + modelCount - + " {100 -100 -100} {-100 -100 -100} \"" + T.nameOf(propertyX) + + " {100 -100 -100} {-100 -100 -100} \"" + props[0] + "\";" + "draw plotAxisY" + modelCount - + " {-100 100 -100} {-100 -100 -100} \"" + T.nameOf(propertyY) + + " {-100 100 -100} {-100 -100 -100} \"" + props[1] + "\";"; - if (propertyZ != 0) + if (props[2] != null) script += "draw plotAxisZ" + modelCount - + " {-100 -100 100} {-100 -100 -100} \"" + T.nameOf(propertyZ) + + " {-100 -100 100} {-100 -100 -100} \"" + props[2] + "\";"; break; case T.ramachandran: @@ -3137,21 +3153,6 @@ return ""; } - private int plotProp() { - int p = 0; - switch (tokAt(e.iToken)) { - case T.format: - case T.min: - case T.max: - break; - default: - if (T.tokAttr(p = tokAt(e.iToken), T.atomproperty)) - e.iToken++; - break; - } - return p; - } - private boolean polyhedra() throws ScriptException { ScriptEval eval = e; /* @@ -4987,4 +4988,24 @@ return data; } + public float[] getBitsetPropertyFloat(BS bs, int tok, String property, + float min, float max) + throws ScriptException { + + float[] data = (property == null ? + (float[]) e.getBitsetProperty(bs, tok, null, null, null, null, + false, Integer.MAX_VALUE, false) + : vwr.getDataFloat(property, bs)); + if (!Float.isNaN(min)) + for (int i = 0; i < data.length; i++) + if (data[i] < min) + data[i] = Float.NaN; + if (!Float.isNaN(max)) + for (int i = 0; i < data.length; i++) + if (data[i] > max) + data[i] = Float.NaN; + return data; + } + + } Modified: trunk/Jmol/src/org/jmol/scriptext/IsoExt.java =================================================================== --- trunk/Jmol/src/org/jmol/scriptext/IsoExt.java 2015-08-06 18:37:56 UTC (rev 20678) +++ trunk/Jmol/src/org/jmol/scriptext/IsoExt.java 2015-08-07 18:04:07 UTC (rev 20679) @@ -1440,7 +1440,7 @@ data = new float[vwr.ms.ac]; if (chk) continue; - data = vwr.getDataFloat(str); + data = vwr.getDataFloat(str, null); if (data == null) invArg(); addShapeProperty(propertyList, propertyName, data); Modified: trunk/Jmol/src/org/jmol/scriptext/MathExt.java =================================================================== --- trunk/Jmol/src/org/jmol/scriptext/MathExt.java 2015-08-06 18:37:56 UTC (rev 20678) +++ trunk/Jmol/src/org/jmol/scriptext/MathExt.java 2015-08-07 18:04:07 UTC (rev 20679) @@ -790,10 +790,10 @@ // parallel mp.addition of float property data sets if (selected.indexOf("property_") == 0) { - float[] f1 = vwr.getDataFloat(selected); + float[] f1 = vwr.getDataFloat(selected, null); if (f1 == null) return mp.addXStr(""); - float[] f2 = (type.indexOf("property_") == 0 ? vwr.getDataFloat(type) + float[] f2 = (type.indexOf("property_") == 0 ? vwr.getDataFloat(type, null) : null); if (f2 != null) { f1 = AU.arrayCopyF(f1, -1); Modified: trunk/Jmol/src/org/jmol/viewer/DataManager.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/DataManager.java 2015-08-06 18:37:56 UTC (rev 20678) +++ trunk/Jmol/src/org/jmol/viewer/DataManager.java 2015-08-07 18:04:07 UTC (rev 20679) @@ -239,14 +239,25 @@ return info; } + /** + * When bsSelected is not null, this returns a truncated array + * + */ @Override - public float[] getDataFloatA(String label) { + public float[] getDataFloatA(String label, BS bsSelected) { if (dataValues.size() == 0) return null; Object[] data = getData(label); if (data == null || ((Integer)data[DATA_TYPE]).intValue() != JmolDataManager.DATA_TYPE_AF) return null; - return (float[]) data[DATA_VALUE]; + float[] f = (float[]) data[DATA_VALUE]; + if (bsSelected == null) + return f; + float[] fnew = new float[bsSelected.cardinality()]; + // load array + for (int i = 0, n = f.length, p = bsSelected.nextSetBit(0); p >= 0 && i < n; p = bsSelected.nextSetBit(p + 1)) + fnew[i++] = f[p]; + return fnew; } @Override Modified: trunk/Jmol/src/org/jmol/viewer/Jmol.properties =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2015-08-06 18:37:56 UTC (rev 20678) +++ trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2015-08-07 18:04:07 UTC (rev 20679) @@ -51,15 +51,20 @@ TODO: curved arrows overextend and with width settings do not truncate shaft properly -Jmol.___JmolVersion="14.3.15_2015.08.06" +Jmol.___JmolVersion="14.3.15_2015.08.07" +bug fix: write property atomno temperature "test.pdb" preserves long residue names from CIF files +bug fix: load "test.pdb" from write property atomno temperature restores values for atomno and temperature + +JmolVersion="14.3.15_2015.08.06" + bug fix: stereo setting should not be saved in state. -- though saved, it was not by default set to normal, -- thus influencing later loads. -bug fix: stereo not implemented in JavaScript +bug fix: STEREO not implemented in JavaScript -new feature: stereo DTI +new feature: STEREO DTI -- left/right dual panel, as just STEREO -- compresses width by 50% for DTI mode (Dimension Technologies, Inc.) Modified: trunk/Jmol/src/org/jmol/viewer/PropertyManager.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/PropertyManager.java 2015-08-06 18:37:56 UTC (rev 20678) +++ trunk/Jmol/src/org/jmol/viewer/PropertyManager.java 2015-08-07 18:04:07 UTC (rev 20679) @@ -1999,7 +1999,7 @@ BS bsWritten = new BS(); char ctype = '\0'; LabelToken[] tokens = vwr.ms.getLabeler().compile(vwr, - "ATOM %-6i%4a%1A%3n %1c%4R%1E ", '\0', null); + "ATOM %-6i%4a%1A%3.-3n %1c%4R%1E ", '\0', null); if (parameters == null) { ctype = (type.length() > 11 && type.indexOf("quaternion ") >= 0 ? type .charAt(11) : 'R'); @@ -2019,7 +2019,9 @@ P3 factors = (P3) parameters[6]; P3 center = (P3) parameters[7]; String format = (String) parameters[8]; + String[] properties = (String[]) parameters[9]; boolean isPDBFormat = (factors != null && format == null); + Atom[] atoms = vwr.ms.at; if (isPDBFormat) { out.append("REMARK 6 Jmol PDB-encoded data: ").append(type) .append(";\n"); @@ -2028,10 +2030,42 @@ .append(Escape.eP(maxXYZ)).append(" unScaledXyz = xyz * ") .append(Escape.eP(factors)).append(" + ").append(Escape.eP(center)) .append(";\n"); + String atomNames = null; + for (int i = bsAtoms.nextSetBit(0); i >= 0; i = bsAtoms + .nextSetBit(i + 1)) { + String name = "" + atoms[i].getAtomName(); + if (atomNames != null || name.length() > 4) { + if (atomNames == null) { + atomNames = ""; + i = -1; + continue; + } + atomNames += " " + name; + } + } + if (atomNames != null) + out.append("REMARK 6 Jmol atom names").append(atomNames).append("\n"); + String resNames = null; + for (int i = bsAtoms.nextSetBit(0); i >= 0; i = bsAtoms + .nextSetBit(i + 1)) { + String name = "" + atoms[i].getGroup3(true); + if (resNames != null || name.length() > 3) { + if (resNames == null) { + resNames = ""; + i = -1; + continue; + } + resNames += " " + name; + } + } + if (resNames != null) + out.append("REMARK 6 Jmol residue names").append(resNames).append("\n"); + for (int i = 0; i < properties.length; i++) + if (properties[i] != null) + out.append("REMARK 6 Jmol property ").append(properties[i]).append(";\n"); } String strExtra = ""; Atom atomLast = null; - Atom[] atoms = vwr.ms.at; P3 ptTemp = new P3(); if (!isPDBFormat) { if (format == null) Modified: trunk/Jmol/src/org/jmol/viewer/Viewer.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Viewer.java 2015-08-06 18:37:56 UTC (rev 20678) +++ trunk/Jmol/src/org/jmol/viewer/Viewer.java 2015-08-07 18:04:07 UTC (rev 20679) @@ -2859,7 +2859,7 @@ } public void setCurrentColorRange(String label) { - float[] data = getDataFloat(label); + float[] data = getDataFloat(label, null); BS bs = (data == null ? null : (BS) (getDataManager().getData(label))[2]); if (bs != null && g.rangeSelected) bs.and(bsA()); @@ -2879,8 +2879,8 @@ return (type == null ? lastData : getDataManager().getData(type)); } - public float[] getDataFloat(String label) { - return getDataManager().getDataFloatA(label); + public float[] getDataFloat(String label, BS bsSelected) { + return getDataManager().getDataFloatA(label, bsSelected); } public float[][] getDataFloat2D(String label) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ _______________________________________________ Jmol-commits mailing list Jmol-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jmol-commits