Revision: 20625 http://sourceforge.net/p/jmol/code/20625 Author: hansonr Date: 2015-07-04 13:47:56 +0000 (Sat, 04 Jul 2015) Log Message: ----------- Jmol.___JmolVersion="14.3.15_2015.07.03"
bug fix: mmCIF reader does not recognize load MODEL ... bug fix: PDB reader should be reading load "" [1 3 4] as MODEL record numbers, not sequential numbers bug fix: load MODELS "" [1 3 4] does not work (although load "" [1 3 4], without with MODELS keyword, works) clarification: load "" 1 # loads the first model in a file when not PDB or mmCIF. load "" 1 # loads the model with MODEL 1 record for a PDB file. load "" 1 # loads the model with _atom_site.pdbx_PDB_model_num = 1 for an mmCIF file load "" [1] # same as load "" 1; brackets allow for more than one model, for instance [1 3 5] load MODELS ({1}) "" # always loads the SECOND model in a file Modified Paths: -------------- trunk/Jmol/src/org/jmol/adapter/readers/cif/CifReader.java trunk/Jmol/src/org/jmol/adapter/readers/cif/MMCifReader.java trunk/Jmol/src/org/jmol/adapter/readers/pdb/PdbReader.java trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollectionReader.java trunk/Jmol/src/org/jmol/script/ScriptEval.java trunk/Jmol/src/org/jmol/viewer/Jmol.properties Modified: trunk/Jmol/src/org/jmol/adapter/readers/cif/CifReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/readers/cif/CifReader.java 2015-07-03 17:54:59 UTC (rev 20624) +++ trunk/Jmol/src/org/jmol/adapter/readers/cif/CifReader.java 2015-07-04 13:47:56 UTC (rev 20625) @@ -50,8 +50,10 @@ /** * A true line-free CIF file reader for CIF files. * - * Subclasses of CIF -- mmCIF/PDBx and msCIF -- are initialized from here. + * Subclasses of CIF -- mmCIF/PDBx (pre-initialized) and msCIF (initialized here). * + * Note that a file can be a PDB file without being + * * Added nonstandard mCIF (magnetic_ tags) 5/2/2014 note that PRELIM keys can be * removed at some later time * @@ -92,7 +94,7 @@ private String chemicalName = ""; private String thisStructuralFormula = ""; private String thisFormula = ""; - private boolean iHaveDesiredModel; + protected boolean iHaveDesiredModel; protected boolean isMMCIF; boolean isMagCIF; private String molecularType = "GEOM_BOND default"; @@ -101,7 +103,7 @@ private int conformationIndex; private int nMolecular = 0; private String appendedData; - private boolean skipping; + protected boolean skipping; protected int nAtoms; protected int ac; @@ -470,7 +472,7 @@ Logger.debug(key); } - private void nextAtomSet() { + protected void nextAtomSet() { asc.setCurrentModelInfo("isCIF", Boolean.TRUE); if (asc.iSet >= 0) { // note that there can be problems with multi-data mmCIF sets each with @@ -993,7 +995,7 @@ * @throws Exception */ boolean processAtomSiteLoopBlock(boolean isLigand) throws Exception { - int currentModelNo = -1; // PDBX + int pdbModelNo = -1; // PDBX boolean haveCoord = true; parseLoopParametersFor(FAMILY_ATOM, atomFields); if (fieldOf[CC_ATOM_X_IDEAL] != NONE) { @@ -1003,13 +1005,17 @@ disableField(FRACT_X); disableField(FRACT_Y); disableField(FRACT_Z); + if (fieldOf[GROUP_PDB] != NONE && !isMMCIF) { + // this should not happen + setIsPDB(); + isMMCIF = true; + } } else if (fieldOf[FRACT_X] != NONE) { setFractionalCoordinates(true); disableField(CARTN_X); disableField(CARTN_Y); disableField(CARTN_Z); - } else if (fieldOf[ANISO_LABEL] != NONE - || fieldOf[ANISO_MMCIF_ID] != NONE + } else if (fieldOf[ANISO_LABEL] != NONE || fieldOf[ANISO_MMCIF_ID] != NONE || fieldOf[MOMENT_LABEL] != NONE) { haveCoord = false; // no coordinates, but valuable information @@ -1021,39 +1027,21 @@ int modelField = fieldOf[MODEL_NO]; int siteMult = 0; while (parser.getData()) { - if (modelField >= 0) { - fieldProperty(modelField); - int modelNo = parseIntStr(field); - if (modelNo != currentModelNo) { - if (iHaveDesiredModel && asc.atomSetCount > 0) { - parser.skipLoop(false); - // but only this atom loop - skipping = false; - continuing = true; - break; - } - currentModelNo = modelNo; - newModel(modelNo); - if (!skipping) { - nextAtomSet(); - if (modelMap == null || asc.ac == 0) - modelMap = new Hashtable<String, Integer>(); - modelMap.put("" + modelNo, Integer.valueOf(Math.max(0, asc.iSet))); - modelMap - .put("_" + Math.max(0, asc.iSet), Integer.valueOf(modelNo)); - } - } - if (skipping) - continue; - } + if (modelField >= 0) { + // mmCIF only + pdbModelNo = checkPDBModelField(modelField, pdbModelNo); + if (pdbModelNo < 0) + break; + if (skipping) + continue; + } Atom atom = null; if (haveCoord) { atom = new Atom(); } else { if (fieldProperty(fieldOf[ANISO_LABEL]) != NONE || fieldProperty(fieldOf[ANISO_MMCIF_ID]) != NONE - || fieldProperty(fieldOf[MOMENT_LABEL]) != NONE - ) { + || fieldProperty(fieldOf[MOMENT_LABEL]) != NONE) { if ((atom = asc.getAtomFromName(field)) == null) continue; // atom has been filtered out } else { @@ -1153,15 +1141,15 @@ case ASYM_ID: assemblyId = field; if (!useAuthorChainID) - setChainID(atom, strChain = field); + setChainID(atom, strChain = field); break; case AUTH_ASYM_ID: if (useAuthorChainID) - setChainID(atom, strChain = field); + setChainID(atom, strChain = field); break; case AUTH_SEQ_ID: maxSerial = Math.max(maxSerial, - atom.sequenceNumber = parseIntStr(field)); + atom.sequenceNumber = parseIntStr(field)); break; case INS_CODE: atom.insertionCode = firstChar; @@ -1182,10 +1170,6 @@ } break; case GROUP_PDB: - if (!isMMCIF) { - setIsPDB(); - isMMCIF = true; - } if ("HETATM".equals(field)) atom.isHetero = true; break; @@ -1317,6 +1301,17 @@ return true; } + /** + * @param modelField + * @param currentModelNo + * @return new currentModelNo + * @throws Exception + */ + protected int checkPDBModelField(int modelField, int currentModelNo) throws Exception { + // overridden in MMCIF reader + return 0; + } + protected Map<String, String> htHetero; /** Modified: trunk/Jmol/src/org/jmol/adapter/readers/cif/MMCifReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/readers/cif/MMCifReader.java 2015-07-03 17:54:59 UTC (rev 20624) +++ trunk/Jmol/src/org/jmol/adapter/readers/cif/MMCifReader.java 2015-07-04 13:47:56 UTC (rev 20625) @@ -41,6 +41,18 @@ import org.jmol.util.SimpleUnitCell; /** + * + * mmCIF files are recognized prior to class creation. + * Required fields include one of: + * + * _entry.id + * _database_PDB_ + * _pdbx_ + * _chem_comp.pdbx_type + * _audit_author.name + * _atom_site. + * + * * @author Bob Hanson (hans...@stolaf.edu) * */ @@ -1060,4 +1072,36 @@ return false; } + private int modelIndex = 0; + + @Override + protected int checkPDBModelField(int modelField, int currentModelNo) throws Exception { + // the model field value is only used if + // it is indicated AFTER the file name in the load command, + // not if we have a MODEL keyword before the file name. + // + fieldProperty(modelField); + int modelNo = parseIntStr(field); + if (modelNo != currentModelNo) { + if (iHaveDesiredModel && asc.atomSetCount > 0) { + parser.skipLoop(false); + // but only this atom loop + skipping = false; + continuing = true; + return Integer.MIN_VALUE; + } + int modelNumberToUse = (useFileModelNumbers ? modelNo : ++modelIndex); + newModel(modelNumberToUse); + if (!skipping) { + nextAtomSet(); + if (modelMap == null || asc.ac == 0) + modelMap = new Hashtable<String, Integer>(); + modelMap.put("" + modelNo, Integer.valueOf(Math.max(0, asc.iSet))); + modelMap + .put("_" + Math.max(0, asc.iSet), Integer.valueOf(modelNo)); + } + } + return modelNo; + } + } Modified: trunk/Jmol/src/org/jmol/adapter/readers/pdb/PdbReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/readers/pdb/PdbReader.java 2015-07-03 17:54:59 UTC (rev 20624) +++ trunk/Jmol/src/org/jmol/adapter/readers/pdb/PdbReader.java 2015-07-04 13:47:56 UTC (rev 20625) @@ -239,7 +239,7 @@ boolean isAtom = (ptOption == 0 || ptOption == 1); boolean isModel = (ptOption == 2); serial = (isAtom ? getSerial(6, 11) : 0); - boolean isNewModel = ((isTrajectory || isSequential) && !isMultiModel + boolean forceNewModel = ((isTrajectory || isSequential) && !isMultiModel && isAtom && serial == 1); if (getHeader) { if (isAtom || isModel) @@ -247,12 +247,12 @@ else readHeader(false); } - if (isModel || isNewModel) { + if (isModel || forceNewModel) { isMultiModel = isModel; getHeader = false; // PDB is different -- targets actual model number - int modelNo = (isNewModel ? modelNumber + 1 : getModelNumber()); - modelNumber = (bsModels == null ? modelNo : modelNumber + 1); + int modelNo = (forceNewModel ? modelNumber + 1 : getModelNumber()); + modelNumber = (useFileModelNumbers ? modelNo : modelNumber + 1); if (!doGetModel(modelNumber, null)) { handleTlsMissingModels(); boolean isOK = checkLastModel(); Modified: trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollectionReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollectionReader.java 2015-07-03 17:54:59 UTC (rev 20624) +++ trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollectionReader.java 2015-07-04 13:47:56 UTC (rev 20625) @@ -180,6 +180,7 @@ protected int vibrationNumber; public int desiredVibrationNumber = Integer.MIN_VALUE; protected BS bsModels; + protected boolean useFileModelNumbers; // PDB, MMCIF only protected boolean havePartialChargeFilter; public String calculationType = "?"; protected String sgName; @@ -566,6 +567,7 @@ } else if (htParams.containsKey("bsModels")) { bsModels = (BS) htParams.get("bsModels"); } + useFileModelNumbers = htParams.containsKey("useFileModelNumbers"); if (htParams.containsKey("templateAtomCount")) templateAtomCount = ((Integer) htParams.get("templateAtomCount")) .intValue(); Modified: trunk/Jmol/src/org/jmol/script/ScriptEval.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptEval.java 2015-07-03 17:54:59 UTC (rev 20624) +++ trunk/Jmol/src/org/jmol/script/ScriptEval.java 2015-07-04 13:47:56 UTC (rev 20625) @@ -4429,8 +4429,7 @@ case T.varray: case T.leftsquare: case T.spacebeforesquare: - getLoadModelIndex(i, sOptions, htParams); - tok = tokAt(i = ++iToken); + tok = tokAt(getLoadModelIndex(i, sOptions, htParams)); break; } i = getCmdExt().getLoadSymmetryParams(i, sOptions, htParams); @@ -4673,8 +4672,7 @@ case T.varray: case T.leftsquare: case T.spacebeforesquare: - getLoadModelIndex(i, sOptions, htParams); - i = iToken + 1; + i = getLoadModelIndex(i, sOptions, htParams); continue; case T.filter: filter = stringParameter(++i); @@ -4757,12 +4755,16 @@ return false; } - private void getLoadModelIndex(int i, SB sOptions, + private int getLoadModelIndex(int i, SB sOptions, Map<String, Object> htParams) throws ScriptException { + int n; switch (tokAt(i)) { case T.integer: - int n = intParameter(i); + htParams.remove("firstLastStep"); + htParams.remove("bsModel"); + htParams.put("useFileModelNumbers", Boolean.TRUE); + n = intParameter(i); sOptions.append(" ").appendI(n); if (n < 0) htParams.put("vibrationNumber", Integer.valueOf(-n)); @@ -4772,21 +4774,25 @@ case T.varray: case T.leftsquare: case T.spacebeforesquare: - System.out.println(sOptions); + htParams.remove("firstLastStep"); float[] data = floatParameterSet(i, 1, Integer.MAX_VALUE); i = iToken; BS bs = new BS(); - for (int j = 0; j < data.length; j++) - if (data[j] >= 1 && data[j] == (int) data[j]) - bs.set((int) data[j] - 1); - htParams.remove("firstLastStep"); + int[] iArray = new int[data.length]; + for (int j = 0; j < data.length; j++) { + n = (int) data[j]; + if (data[j] >= 1 && data[j] == n) + bs.set(n - 1); + else + invArg(); + iArray[j] = n; + } + sOptions.append(" " + Escape.eAI(iArray)); htParams.put("bsModels", bs); - int[] iArray = new int[bs.cardinality()]; - for (int pt = 0, j = bs.nextSetBit(0); j >= 0; j = bs.nextSetBit(j + 1)) - iArray[pt++] = j + 1; - sOptions.append(" " + Escape.eAI(iArray)); + htParams.put("useFileModelNumbers", Boolean.TRUE); break; } + return iToken + 1; } private void finalizeLoad(boolean isAppend, boolean appendNew, Modified: trunk/Jmol/src/org/jmol/viewer/Jmol.properties =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2015-07-03 17:54:59 UTC (rev 20624) +++ trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2015-07-04 13:47:56 UTC (rev 20625) @@ -50,8 +50,20 @@ Jmol.___JmolVersion="14.3.15_2015.07.03" -bug fix: mmCIF reader does not recognize load model +bug fix: mmCIF reader does not recognize load MODEL ... +bug fix: PDB reader should be reading load "" [1 3 4] as MODEL record numbers, not sequential numbers +bug fix: load MODELS "" [1 3 4] does not work (although load "" [1 3 4], without with MODELS keyword, works) +clarification: + + load "" 1 # loads the first model in a file when not PDB or mmCIF. + load "" 1 # loads the model with MODEL 1 record for a PDB file. + load "" 1 # loads the model with _atom_site.pdbx_PDB_model_num = 1 for an mmCIF file + load "" [1] # same as load "" 1; brackets allow for more than one model, for instance [1 3 5] + load MODELS ({1}) "" # always loads the SECOND model in a file + + + JmolVersion="14.3.15_2015.06.30" bug fix: POVRay and VRML exporters mishandle label backgrounds This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Don't Limit Your Business. Reach for the Cloud. GigeNET's Cloud Solutions provide you with the tools and support that you need to offload your IT needs and focus on growing your business. Configured For All Businesses. Start Your Cloud Today. https://www.gigenetcloud.com/ _______________________________________________ Jmol-commits mailing list Jmol-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jmol-commits