From: <ha...@us...> - 2014-01-27 21:08:52
|
Revision: 19218 http://sourceforge.net/p/jmol/code/19218 Author: hansonr Date: 2014-01-27 21:08:46 +0000 (Mon, 27 Jan 2014) Log Message: ----------- ___JmolVersion="14.1.8_dev_2014.01.27" code: reader overhaul for setting atom coordinates in a consistent fashion bug fix: abinit reader was nonfunctional Modified Paths: -------------- trunk/Jmol/src/org/jmol/adapter/readers/molxyz/XyzReader.java trunk/Jmol/src/org/jmol/adapter/readers/quantum/AdfReader.java trunk/Jmol/src/org/jmol/adapter/readers/quantum/CsfReader.java trunk/Jmol/src/org/jmol/adapter/readers/quantum/DgridReader.java trunk/Jmol/src/org/jmol/adapter/readers/quantum/GamessUKReader.java trunk/Jmol/src/org/jmol/adapter/readers/quantum/GaussianReader.java trunk/Jmol/src/org/jmol/adapter/readers/quantum/GenNBOReader.java trunk/Jmol/src/org/jmol/adapter/readers/quantum/JaguarReader.java trunk/Jmol/src/org/jmol/adapter/readers/quantum/MoldenReader.java trunk/Jmol/src/org/jmol/adapter/readers/quantum/NWChemReader.java trunk/Jmol/src/org/jmol/adapter/readers/quantum/PsiReader.java trunk/Jmol/src/org/jmol/adapter/readers/quantum/QchemReader.java trunk/Jmol/src/org/jmol/adapter/readers/quantum/SpartanArchive.java trunk/Jmol/src/org/jmol/adapter/readers/quantum/SpartanInputReader.java trunk/Jmol/src/org/jmol/adapter/readers/quantum/WebMOReader.java trunk/Jmol/src/org/jmol/adapter/readers/simple/AlchemyReader.java trunk/Jmol/src/org/jmol/adapter/readers/simple/AmpacReader.java trunk/Jmol/src/org/jmol/adapter/readers/simple/CubeReader.java trunk/Jmol/src/org/jmol/adapter/readers/simple/GhemicalMMReader.java trunk/Jmol/src/org/jmol/adapter/readers/simple/HyperChemReader.java trunk/Jmol/src/org/jmol/adapter/readers/simple/MopacReader.java trunk/Jmol/src/org/jmol/adapter/readers/xml/XmlQEReader.java trunk/Jmol/src/org/jmol/adapter/readers/xtal/AbinitReader.java trunk/Jmol/src/org/jmol/adapter/readers/xtal/AimsReader.java trunk/Jmol/src/org/jmol/adapter/readers/xtal/CastepReader.java trunk/Jmol/src/org/jmol/adapter/readers/xtal/GulpReader.java trunk/Jmol/src/org/jmol/adapter/readers/xtal/ShelxReader.java trunk/Jmol/src/org/jmol/adapter/readers/xtal/SiestaReader.java trunk/Jmol/src/org/jmol/adapter/readers/xtal/VaspOutcarReader.java trunk/Jmol/src/org/jmol/adapter/readers/xtal/VaspPoscarReader.java trunk/Jmol/src/org/jmol/adapter/readers/xtal/XcrysdenReader.java trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollectionReader.java trunk/Jmol/src/org/jmol/adapter/smarter/Resolver.java trunk/Jmol/src/org/jmol/viewer/Jmol.properties Added Paths: ----------- trunk/Jmol/src/org/jmol/adapter/readers/simple/TinkerReader.java Modified: trunk/Jmol/src/org/jmol/adapter/readers/molxyz/XyzReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/readers/molxyz/XyzReader.java 2014-01-27 17:15:44 UTC (rev 19217) +++ trunk/Jmol/src/org/jmol/adapter/readers/molxyz/XyzReader.java 2014-01-27 21:08:46 UTC (rev 19218) @@ -102,17 +102,9 @@ Logger.warn("line cannot be read for XYZ atom data: " + line); continue; } - Atom atom = atomSetCollection.addNewAtom(); + Atom atom = addAtomXYZSymName(tokens, 1, null, null); setElementAndIsotope(atom, tokens[0]); - atom.x = parseFloatStr(tokens[1]); - atom.y = parseFloatStr(tokens[2]); - atom.z = parseFloatStr(tokens[3]); - if (Float.isNaN(atom.x) || Float.isNaN(atom.y) || Float.isNaN(atom.z)) { - Logger.warn("line cannot be read for XYZ atom data: " + line); - atom.set(0, 0, 0); - } int vpt = 4; - setAtomCoord(atom); switch (tokens.length) { case 4: continue; Modified: trunk/Jmol/src/org/jmol/adapter/readers/quantum/AdfReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/readers/quantum/AdfReader.java 2014-01-27 17:15:44 UTC (rev 19217) +++ trunk/Jmol/src/org/jmol/adapter/readers/quantum/AdfReader.java 2014-01-27 21:08:46 UTC (rev 19218) @@ -161,17 +161,14 @@ if (tokens.length < 5) break; String symbol = tokens[1]; - if (JmolAdapter.getElementNumber(symbol) < 1) { + if (JmolAdapter.getElementNumber(symbol) < 1) nXX++; - continue; - } - Atom atom = atomSetCollection.addNewAtom(); - atom.elementSymbol = symbol; - setAtomCoordXYZ(atom, parseFloatStr(tokens[pt0]), parseFloatStr(tokens[pt0 + 1]), - parseFloatStr(tokens[pt0 + 2])); + else + addAtomXYZSymName(tokens, pt0, symbol, null); } } + /* Vibrations and Normal Modes *** (cartesian coordinates, NOT mass-weighted) *** =========================== Modified: trunk/Jmol/src/org/jmol/adapter/readers/quantum/CsfReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/readers/quantum/CsfReader.java 2014-01-27 17:15:44 UTC (rev 19217) +++ trunk/Jmol/src/org/jmol/adapter/readers/quantum/CsfReader.java 2014-01-27 21:08:46 UTC (rev 19218) @@ -293,11 +293,14 @@ break; String tokens[] = getTokens(); Atom atom = new Atom(); + String field; for (int i = 0; i < fieldCount; i++) { - String field = tokens[i]; - if (field == null) + int type = fieldTypes[i]; + if (type == 0) + continue; + if ((field = tokens[i]) == null) Logger.warn("field == null in " + line); - switch (fieldTypes[i]) { + switch (type) { case ID: atom.atomSerial = PT.parseInt(field); break; @@ -315,7 +318,8 @@ atom.partialCharge = parseFloatStr(field); break; case xyz_coordinates: - setAtomCoordXYZ(atom, parseFloatStr(field), parseFloatStr(tokens[i + 1]), parseFloatStr(tokens[i + 2])); + setAtomCoordTokens(atom, tokens, i); + i += 2; break; } } Modified: trunk/Jmol/src/org/jmol/adapter/readers/quantum/DgridReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/readers/quantum/DgridReader.java 2014-01-27 17:15:44 UTC (rev 19217) +++ trunk/Jmol/src/org/jmol/adapter/readers/quantum/DgridReader.java 2014-01-27 21:08:46 UTC (rev 19218) @@ -91,12 +91,7 @@ String[] tokens = getTokens(); if (tokens.length < 5) break; - String symbol = tokens[0]; - Atom atom = atomSetCollection.addNewAtom(); - atom.elementSymbol = symbol; - setAtomCoordXYZ(atom, parseFloatStr(tokens[2]) * ANGSTROMS_PER_BOHR, - parseFloatStr(tokens[3]) * ANGSTROMS_PER_BOHR, - parseFloatStr(tokens[4]) * ANGSTROMS_PER_BOHR); + setAtomCoordScaled(null, tokens, 2, ANGSTROMS_PER_BOHR).elementSymbol = tokens[0]; } } Modified: trunk/Jmol/src/org/jmol/adapter/readers/quantum/GamessUKReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/readers/quantum/GamessUKReader.java 2014-01-27 17:15:44 UTC (rev 19217) +++ trunk/Jmol/src/org/jmol/adapter/readers/quantum/GamessUKReader.java 2014-01-27 21:08:46 UTC (rev 19218) @@ -107,18 +107,10 @@ if (line.charAt(14) == ' ') continue; String[] tokens = getTokens(); - String atomName = tokens[1]; int atomicNumber = (int) parseFloatStr(tokens[2]); - float x = parseFloatStr(tokens[3]); - float y = parseFloatStr(tokens[4]); - float z = parseFloatStr(tokens[5]); - if (Float.isNaN(x) || Float.isNaN(y) || Float.isNaN(z)) - break; - Atom atom = atomSetCollection.addNewAtom(); - atom.atomName = atomName; - setAtomCoordXYZ(atom, x * ANGSTROMS_PER_BOHR, y * ANGSTROMS_PER_BOHR, z * ANGSTROMS_PER_BOHR); + Atom atom = setAtomCoordScaled(null, tokens, 3, ANGSTROMS_PER_BOHR); atom.elementSymbol = AtomSetCollectionReader.getElementSymbol(atomicNumber); - atomNames.addLast(atomName); + atomNames.addLast(atom.atomName = tokens[1]); } } Modified: trunk/Jmol/src/org/jmol/adapter/readers/quantum/GaussianReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/readers/quantum/GaussianReader.java 2014-01-27 17:15:44 UTC (rev 19217) +++ trunk/Jmol/src/org/jmol/adapter/readers/quantum/GaussianReader.java 2014-01-27 21:08:46 UTC (rev 19218) @@ -298,10 +298,7 @@ (short)parseIntStr(tokens[STD_ORIENTATION_ATOMIC_NUMBER_OFFSET]); if (atom.elementNumber < 0) atom.elementNumber = 0; // dummy atoms have -1 -> 0 - int offset = tokens.length-3; - setAtomCoordXYZ(atom, parseFloatStr(tokens[offset]), - parseFloatStr(tokens[++offset]), - parseFloatStr(tokens[++offset])); + setAtomCoordTokens(atom, tokens, tokens.length - 3); } atomSetCollection.setAtomSetModelProperty(SmarterJmolAdapter.PATH_KEY, "Calculation "+calculationNumber+ Modified: trunk/Jmol/src/org/jmol/adapter/readers/quantum/GenNBOReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/readers/quantum/GenNBOReader.java 2014-01-27 17:15:44 UTC (rev 19217) +++ trunk/Jmol/src/org/jmol/adapter/readers/quantum/GenNBOReader.java 2014-01-27 21:08:46 UTC (rev 19218) @@ -248,8 +248,7 @@ continue; Atom atom = atomSetCollection.addNewAtom(); atom.elementNumber = (short) z; - setAtomCoordXYZ(atom, parseFloatStr(tokens[1]), parseFloatStr(tokens[2]), - parseFloatStr(tokens[3])); + setAtomCoordTokens(atom, tokens, 1); } // read basis functions Modified: trunk/Jmol/src/org/jmol/adapter/readers/quantum/JaguarReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/readers/quantum/JaguarReader.java 2014-01-27 17:15:44 UTC (rev 19217) +++ trunk/Jmol/src/org/jmol/adapter/readers/quantum/JaguarReader.java 2014-01-27 21:08:46 UTC (rev 19218) @@ -24,7 +24,6 @@ package org.jmol.adapter.readers.quantum; -import org.jmol.adapter.smarter.Atom; import org.jmol.api.JmolAdapter; import org.jmol.util.Logger; @@ -105,22 +104,11 @@ while (readLine() != null && line.length() >= 60 && line.charAt(2) != ' ') { String[] tokens = getTokens(); String atomName = tokens[0]; - float x = parseFloatStr(tokens[1]); - float y = parseFloatStr(tokens[2]); - float z = parseFloatStr(tokens[3]); - if (Float.isNaN(x) || Float.isNaN(y) || Float.isNaN(z) - || atomName.length() < 2) + if (atomName.length() < 2) return; - String elementSymbol; char ch2 = atomName.charAt(1); - if (ch2 >= 'a' && ch2 <= 'z') - elementSymbol = atomName.substring(0, 2); - else - elementSymbol = atomName.substring(0, 1); - Atom atom = atomSetCollection.addNewAtom(); - atom.elementSymbol = elementSymbol; - atom.atomName = atomName; - setAtomCoordXYZ(atom, x, y, z); + String elementSymbol = (ch2 >= 'a' && ch2 <= 'z' ? atomName.substring(0, 2) : atomName.substring(0, 1)); + addAtomXYZSymName(tokens, 1, elementSymbol, atomName); } } Modified: trunk/Jmol/src/org/jmol/adapter/readers/quantum/MoldenReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/readers/quantum/MoldenReader.java 2014-01-27 17:15:44 UTC (rev 19217) +++ trunk/Jmol/src/org/jmol/adapter/readers/quantum/MoldenReader.java 2014-01-27 21:08:46 UTC (rev 19218) @@ -132,8 +132,6 @@ */ String coordUnit = getTokensStr(line.replace(']', ' '))[1]; - int nPrevAtom = 0, nCurAtom = 0; - boolean isAU = (coordUnit.indexOf("ANGS") < 0); if (isAU && coordUnit.indexOf("AU") < 0) { throw new Exception("invalid coordinate unit " + coordUnit + " in [Atoms]"); @@ -144,20 +142,9 @@ String [] tokens = getTokens(); if (tokens.length < 6) continue; - Atom atom = atomSetCollection.addNewAtom(); + Atom atom = setAtomCoordScaled(null, tokens, 3, f); atom.atomName = tokens[0]; - // tokens[1] is the atom number. Since sane programs shouldn't list - // these out of order, just throw an exception if one is encountered - // out of order (for now) - nCurAtom = parseIntStr(tokens[1]); - if (nPrevAtom > 0 && nCurAtom != nPrevAtom + 1 ) { - throw new Exception("out of order atom in [Atoms]"); - } - nPrevAtom = nCurAtom; atom.elementNumber = (short) parseIntStr(tokens[2]); - setAtomCoordXYZ(atom, parseFloatStr(tokens[3]) * f, - parseFloatStr(tokens[4]) * f, - parseFloatStr(tokens[5]) * f); } } @@ -518,25 +505,15 @@ if (atomSetCollection.atomCount == 0) { while (readLine() != null && line.indexOf('[') < 0) { String [] tokens = getTokens(); - if (tokens.length != 4) - continue; - Atom atom = atomSetCollection.addNewAtom(); - atom.atomName = tokens[0]; - setAtomCoordXYZ(atom, parseFloatStr(tokens[1]) * f, - parseFloatStr(tokens[2]) * f, - parseFloatStr(tokens[3]) * f); + if (tokens.length == 4) + setAtomCoordScaled(null, tokens, 1, f).atomName = tokens[0]; } modelAtomCount = atomSetCollection.getLastAtomSetAtomCount(); return; } Atom[] atoms = atomSetCollection.atoms; int i0 = atomSetCollection.getLastAtomSetAtomIndex(); - for (int i = 0; i < modelAtomCount; i++) { - String[] tokens = getTokensStr(readLine()); - Atom atom = atoms[i + i0]; - setAtomCoordXYZ(atom, parseFloatStr(tokens[1]) * f, - parseFloatStr(tokens[2]) * f, - parseFloatStr(tokens[3]) * f); - } + for (int i = 0; i < modelAtomCount; i++) + setAtomCoordScaled(atoms[i + i0], getTokensStr(readLine()), 1, f); } } Modified: trunk/Jmol/src/org/jmol/adapter/readers/quantum/NWChemReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/readers/quantum/NWChemReader.java 2014-01-27 17:15:44 UTC (rev 19217) +++ trunk/Jmol/src/org/jmol/adapter/readers/quantum/NWChemReader.java 2014-01-27 21:08:46 UTC (rev 19218) @@ -304,11 +304,9 @@ tokens = getTokens(); // get the tokens in the line if (tokens.length < 6) break; // if don't have enough of them: done - Atom atom = atomSetCollection.addNewAtom(); - atom.atomName = fixTag(tokens[1]); - atomTypes.addLast(atom.atomName); - setAtomCoordXYZ(atom, parseFloatStr(tokens[3]), parseFloatStr(tokens[4]), - parseFloatStr(tokens[5])); + String name = fixTag(tokens[1]); + addAtomXYZSymName(tokens, 3, null, name); + atomTypes.addLast(name); } // only if was converged, use the last energy for the name and properties if (converged) { @@ -354,11 +352,9 @@ tokens = getTokens(); // get the tokens in the line if (tokens.length < 8) break; // make sure I have enough tokens - Atom atom = atomSetCollection.addNewAtom(); + Atom atom = setAtomCoordScaled(null, tokens, 2, ANGSTROMS_PER_BOHR); atom.atomName = fixTag(tokens[1]); - setAtomCoordXYZ(atom, parseFloatStr(tokens[2]) * ANGSTROMS_PER_BOHR, - parseFloatStr(tokens[3]) * ANGSTROMS_PER_BOHR, parseFloatStr(tokens[4]) - * ANGSTROMS_PER_BOHR); + // Keep gradients in a.u. (larger value that way) // need to multiply with -1 so the direction is in the direction the // atom needs to move to lower the energy @@ -473,11 +469,7 @@ String tokens[]; while (readLine() != null && line.indexOf("---") < 0) { tokens = getTokens(); - Atom atom = atomSetCollection.addNewAtom(); - atom.atomName = fixTag(tokens[0]); - setAtomCoordXYZ(atom, parseFloatStr(tokens[2]) * ANGSTROMS_PER_BOHR, - parseFloatStr(tokens[3]) * ANGSTROMS_PER_BOHR, parseFloatStr(tokens[4]) - * ANGSTROMS_PER_BOHR); + setAtomCoordScaled(null, tokens, 3, ANGSTROMS_PER_BOHR).atomName = fixTag(tokens[0]); } discardLinesUntilContains("(Projected Frequencies expressed in cm-1)"); Modified: trunk/Jmol/src/org/jmol/adapter/readers/quantum/PsiReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/readers/quantum/PsiReader.java 2014-01-27 17:15:44 UTC (rev 19217) +++ trunk/Jmol/src/org/jmol/adapter/readers/quantum/PsiReader.java 2014-01-27 21:08:46 UTC (rev 19218) @@ -154,9 +154,7 @@ } if (atom.elementNumber < 0) atom.elementNumber = 0; // dummy atoms have -1 -> 0 - setAtomCoordXYZ(atom, parseFloatStr(tokens[1]) * ANGSTROMS_PER_BOHR, - parseFloatStr(tokens[2]) * ANGSTROMS_PER_BOHR, - parseFloatStr(tokens[3]) * ANGSTROMS_PER_BOHR); + setAtomCoordScaled(atom, tokens, 1, ANGSTROMS_PER_BOHR); } } Modified: trunk/Jmol/src/org/jmol/adapter/readers/quantum/QchemReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/readers/quantum/QchemReader.java 2014-01-27 17:15:44 UTC (rev 19217) +++ trunk/Jmol/src/org/jmol/adapter/readers/quantum/QchemReader.java 2014-01-27 21:08:46 UTC (rev 19218) @@ -142,12 +142,12 @@ } -/* Q-chem 2.1 format: - Standard Nuclear Orientation (Angstroms) - I Atom X Y Z - ---------------------------------------------------- - 1 H 0.000000 0.000000 4.756791 -*/ + /* Q-chem 2.1 format: + Standard Nuclear Orientation (Angstroms) + I Atom X Y Z + ---------------------------------------------------- + 1 H 0.000000 0.000000 4.756791 + */ private void readAtoms() throws Exception { atomSetCollection.newAtomSet(); @@ -159,20 +159,11 @@ if (tokens.length < 5) continue; String symbol = tokens[1]; - if (JmolAdapter.getElementNumber(symbol) < 1) - continue; - //q-chem specific offsets - float x = parseFloatStr(tokens[2]); - float y = parseFloatStr(tokens[3]); - float z = parseFloatStr(tokens[4]); - if (Float.isNaN(x) || Float.isNaN(y) || Float.isNaN(z)) - continue; - Atom atom = atomSetCollection.addNewAtom(); - atom.elementSymbol = symbol; - setAtomCoordXYZ(atom, x, y, z); - atomSetCollection.setAtomSetModelProperty(SmarterJmolAdapter.PATH_KEY, - "Calculation "+calculationNumber); - } + if (JmolAdapter.getElementNumber(symbol) > 0) + addAtomXYZSymName(tokens, 2, symbol, null); + } + atomSetCollection.setAtomSetModelProperty(SmarterJmolAdapter.PATH_KEY, + "Calculation " + calculationNumber); } /** Modified: trunk/Jmol/src/org/jmol/adapter/readers/quantum/SpartanArchive.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/readers/quantum/SpartanArchive.java 2014-01-27 17:15:44 UTC (rev 19217) +++ trunk/Jmol/src/org/jmol/adapter/readers/quantum/SpartanArchive.java 2014-01-27 21:08:46 UTC (rev 19218) @@ -148,9 +148,7 @@ : r.atomSetCollection.atoms[atomCount0 - modelAtomCount + i]); atom.elementSymbol = AtomSetCollectionReader .getElementSymbol(parseInt(tokens[0])); - r.setAtomCoordXYZ(atom, parseFloat(tokens[1]) * AtomSetCollectionReader.ANGSTROMS_PER_BOHR, - parseFloat(tokens[2]) * AtomSetCollectionReader.ANGSTROMS_PER_BOHR, - parseFloat(tokens[3]) * AtomSetCollectionReader.ANGSTROMS_PER_BOHR); + r.setAtomCoordScaled(atom, tokens, 1, AtomSetCollectionReader.ANGSTROMS_PER_BOHR); } if (doAddAtoms && Logger.debugging) { Logger.debug(atomCount + " atoms read"); Modified: trunk/Jmol/src/org/jmol/adapter/readers/quantum/SpartanInputReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/readers/quantum/SpartanInputReader.java 2014-01-27 17:15:44 UTC (rev 19217) +++ trunk/Jmol/src/org/jmol/adapter/readers/quantum/SpartanInputReader.java 2014-01-27 21:08:46 UTC (rev 19218) @@ -25,7 +25,6 @@ package org.jmol.adapter.readers.quantum; import org.jmol.adapter.smarter.Bond; -import org.jmol.adapter.smarter.Atom; import org.jmol.adapter.smarter.SmarterJmolAdapter; import org.jmol.api.JmolAdapter; @@ -114,9 +113,7 @@ while (readLine() != null && !line.startsWith("ENDCART")) { String[] tokens = getTokens(); - Atom atom = atomSetCollection.addNewAtom(); - atom.elementSymbol = getElementSymbol(parseIntStr(tokens[0])); - setAtomCoordXYZ(atom, parseFloatStr(tokens[1]), parseFloatStr(tokens[2]), parseFloatStr(tokens[3])); + addAtomXYZSymName(tokens, 1, getElementSymbol(parseIntStr(tokens[0])), null); modelAtomCount++; } atomCount = atomSetCollection.atomCount; Modified: trunk/Jmol/src/org/jmol/adapter/readers/quantum/WebMOReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/readers/quantum/WebMOReader.java 2014-01-27 17:15:44 UTC (rev 19217) +++ trunk/Jmol/src/org/jmol/adapter/readers/quantum/WebMOReader.java 2014-01-27 21:08:46 UTC (rev 19218) @@ -26,7 +26,6 @@ import org.jmol.adapter.smarter.Bond; -import org.jmol.adapter.smarter.Atom; import javajs.util.AU; import javajs.util.List; @@ -132,15 +131,10 @@ String[] tokens = getTokens(); if (tokens.length == 0) continue; - int atNo = parseIntStr(line); - Atom atom = atomSetCollection.addNewAtom(); - if (atNo == Integer.MIN_VALUE) - atom.elementSymbol = tokens[0]; - else - atom.elementSymbol = getElementSymbol(atNo); - setAtomCoordXYZ(atom, parseFloatStr(tokens[1]) * ANGSTROMS_PER_BOHR, - parseFloatStr(tokens[2]) * ANGSTROMS_PER_BOHR, - parseFloatStr(tokens[3])* ANGSTROMS_PER_BOHR); + String sym = tokens[0]; + int atNo = parseIntStr(sym); + setAtomCoordScaled(null, tokens, 1, ANGSTROMS_PER_BOHR).elementSymbol = (atNo == Integer.MIN_VALUE ? sym + : getElementSymbol(atNo)); } } Modified: trunk/Jmol/src/org/jmol/adapter/readers/simple/AlchemyReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/readers/simple/AlchemyReader.java 2014-01-27 17:15:44 UTC (rev 19217) +++ trunk/Jmol/src/org/jmol/adapter/readers/simple/AlchemyReader.java 2014-01-27 21:08:46 UTC (rev 19218) @@ -129,8 +129,7 @@ || name.equals("Du")) ? 2 : 1); atom.elementSymbol = (nChar == 1 ? "" + c1 : "" + c1 + c2); - setAtomCoordXYZ(atom, parseFloatStr(tokens[2]), parseFloatStr(tokens[3]), - parseFloatStr(tokens[4])); + setAtomCoordTokens(atom, tokens, 2); atom.partialCharge = (tokens.length >= 6 ? parseFloatStr(tokens[5]) : 0); atomSetCollection.addAtomWithMappedSerialNumber(atom); } Modified: trunk/Jmol/src/org/jmol/adapter/readers/simple/AmpacReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/readers/simple/AmpacReader.java 2014-01-27 17:15:44 UTC (rev 19217) +++ trunk/Jmol/src/org/jmol/adapter/readers/simple/AmpacReader.java 2014-01-27 21:08:46 UTC (rev 19218) @@ -96,10 +96,7 @@ if (haveFreq) { atomPositions[atomCount] = P3.new3(parseFloatStr(tokens[2]), parseFloatStr(tokens[3]), parseFloatStr(tokens[4])); } else { - String symbol = tokens[1]; - Atom atom = atomSetCollection.addNewAtom(); - atom.elementSymbol = symbol; - setAtomCoordXYZ(atom, parseFloatStr(tokens[2]), parseFloatStr(tokens[3]), parseFloatStr(tokens[4])); + addAtomXYZSymName(tokens, 2, tokens[1], null); } atomCount++; } Modified: trunk/Jmol/src/org/jmol/adapter/readers/simple/CubeReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/readers/simple/CubeReader.java 2014-01-27 17:15:44 UTC (rev 19217) +++ trunk/Jmol/src/org/jmol/adapter/readers/simple/CubeReader.java 2014-01-27 21:08:46 UTC (rev 19218) @@ -25,7 +25,6 @@ package org.jmol.adapter.readers.simple; import org.jmol.adapter.smarter.AtomSetCollectionReader; -import org.jmol.adapter.smarter.Atom; /** * Gaussian cube file format @@ -91,11 +90,9 @@ private void readAtoms() throws Exception { float f = (isAngstroms ? 1 : ANGSTROMS_PER_BOHR); for (int i = 0; i < atomCount; ++i) { - readLine(); - Atom atom = atomSetCollection.addNewAtom(); - atom.elementNumber = (short)parseIntStr(line); //allowing atomicAndIsotope for JVXL format - parseFloat(); - setAtomCoordXYZ(atom, parseFloat() * f, parseFloat() * f, parseFloat() * f); + String[] tokens = getTokensStr(readLine()); + //allowing atomicAndIsotope for JVXL format + setAtomCoordScaled(null, tokens, 2, f).elementNumber = (short)parseIntStr(tokens[0]); } } Modified: trunk/Jmol/src/org/jmol/adapter/readers/simple/GhemicalMMReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/readers/simple/GhemicalMMReader.java 2014-01-27 17:15:44 UTC (rev 19217) +++ trunk/Jmol/src/org/jmol/adapter/readers/simple/GhemicalMMReader.java 2014-01-27 21:08:46 UTC (rev 19218) @@ -151,14 +151,8 @@ void processCoord() throws Exception { Atom[] atoms = atomSetCollection.atoms; int atomCount = atomSetCollection.atomCount; - for (int i = 0; i < atomCount; ++i) { - readLine(); - int atomIndex = parseIntStr(line); - if (atomIndex != i) - throw new Exception("bad atom index in !Coord" + "expected: " + i - + " saw:" + atomIndex); - setAtomCoordXYZ(atoms[i], parseFloat() * 10, parseFloat() * 10, parseFloat() * 10); - } + for (int i = 0; i < atomCount; ++i) + setAtomCoordScaled(atoms[i], getTokensStr(readLine()), 1, 10); } void processCharges() throws Exception { Modified: trunk/Jmol/src/org/jmol/adapter/readers/simple/HyperChemReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/readers/simple/HyperChemReader.java 2014-01-27 17:15:44 UTC (rev 19217) +++ trunk/Jmol/src/org/jmol/adapter/readers/simple/HyperChemReader.java 2014-01-27 21:08:46 UTC (rev 19218) @@ -94,7 +94,6 @@ throw new Exception ("bad atom number sequence ... expected:" + (atomIndex + 1) + " found:" + fileAtomNumber); } - Atom atom = atomSetCollection.addNewAtom(); parseToken(); // discard atom.elementSymbol = parseToken(); Modified: trunk/Jmol/src/org/jmol/adapter/readers/simple/MopacReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/readers/simple/MopacReader.java 2014-01-27 17:15:44 UTC (rev 19217) +++ trunk/Jmol/src/org/jmol/adapter/readers/simple/MopacReader.java 2014-01-27 21:08:46 UTC (rev 19218) @@ -138,8 +138,9 @@ } /** - * Reads the section in MOPAC files with cartesian coordinates. - * These sections look like: + * Reads the section in MOPAC files with cartesian coordinates. These sections + * look like: + * * <pre> * CARTESIAN COORDINATES * @@ -149,12 +150,14 @@ * 2 C 1.3952 0.0000 0.0000 * 3 C 2.0927 1.2078 0.0000 * </pre> + * * In a MOPAC2002 file the columns are different: + * * <pre> * CARTESIAN COORDINATES - * + * * NO. ATOM X Y Z - * + * * 1 H 0.00000000 0.00000000 0.00000000 * 2 O 0.95094500 0.00000000 0.00000000 * 3 H 1.23995160 0.90598439 0.00000000 @@ -164,7 +167,6 @@ */ void processCoordinates() throws Exception { readLines(3); - int expectedAtomNumber = 0; if (!chargesFound) { atomSetCollection.newAtomSet(); baseAtomIndex = atomSetCollection.atomCount; @@ -172,22 +174,19 @@ chargesFound = false; } Atom[] atoms = atomSetCollection.atoms; + int atomNumber; while (readLine() != null) { - int atomNumber = parseIntStr(line); - if (atomNumber == Integer.MIN_VALUE) // blank line + String[] tokens = getTokens(); + if (tokens.length == 0 + || (atomNumber = parseIntStr(tokens[0])) == Integer.MIN_VALUE) break; - ++expectedAtomNumber; - if (atomNumber != expectedAtomNumber) - throw new Exception("unexpected atom number in coordinates"); - String elementSymbol = parseToken(); - Atom atom = atoms[baseAtomIndex + atomNumber - 1]; - if (atom == null) { - atom = atomSetCollection.addNewAtom(); // if no charges were found first - } + if (atom == null) + atom = atomSetCollection.addNewAtom(); // if no charges were found first atom.atomSerial = atomNumber; - setAtomCoordXYZ(atom, parseFloat(), parseFloat(), parseFloat()); - int atno = parseIntStr(elementSymbol); + setAtomCoordTokens(atom, tokens, 2); + String elementSymbol = tokens[1]; + int atno = parseIntStr(elementSymbol); if (atno != Integer.MIN_VALUE) elementSymbol = getElementSymbol(atno); atom.elementSymbol = elementSymbol; Added: trunk/Jmol/src/org/jmol/adapter/readers/simple/TinkerReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/readers/simple/TinkerReader.java (rev 0) +++ trunk/Jmol/src/org/jmol/adapter/readers/simple/TinkerReader.java 2014-01-27 21:08:46 UTC (rev 19218) @@ -0,0 +1,102 @@ +/* $RCSfile$ + * $Author: hansonr $ + * $Date: 2006-10-22 14:12:46 -0500 (Sun, 22 Oct 2006) $ + * $Revision: 5999 $ + * + * Copyright (C) 2003-2005 Miguel, Jmol Development, www.jmol.org + * + * Contact: jmo...@li... + * + * 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.simple; + +import javajs.util.List; + +import org.jmol.adapter.smarter.AtomSetCollectionReader; +import org.jmol.adapter.smarter.Atom; + +import org.jmol.util.Logger; + +/** + * simple Tinker format requires Tinker:: prefix: + * + * load Tinker::mydata.xyz + * + * 1/2014 ha...@st... + * + */ + +public class TinkerReader extends AtomSetCollectionReader { + + @Override + protected boolean checkLine() throws Exception { + int modelAtomCount = parseIntStr(line); + if (modelAtomCount == Integer.MIN_VALUE) { + continuing = false; + return false; + } + atomSetCollection.newAtomSet(); + String name = line.substring(line.indexOf(" ") + 1); + atomSetCollection.setAtomSetName(name); + readAtomsAndBonds(modelAtomCount); + applySymmetryAndSetTrajectory(); + continuing = false; + return false; + } + + private void readAtomsAndBonds(int n) throws Exception { + List<String[]> lines = new List<String[]>(); + String[] tokens; + String types = ""; + // first create the atoms + for (int i = 0; i < n; ++i) { + readLine(); + tokens = getTokens(); + if (tokens.length < 5) { + Logger.warn("line cannot be read for atom data: " + line); + i--; + continue; + } + lines.addLast(tokens); + Atom atom = atomSetCollection.addNewAtom(); + setElementAndIsotope(atom, tokens[1]); + atom.x = parseFloatStr(tokens[2]); + atom.y = parseFloatStr(tokens[3]); + atom.z = parseFloatStr(tokens[4]); + types += tokens[5] + "\n"; + } + // add the atom types + atomSetCollection.setAtomSetAtomProperty("atomType", types, -1); + // now create the bonds + String temp = ""; + for (int i = 0; i < n; i++) { + tokens = lines.get(i); + String index1 = tokens[0]; + int i1 = parseIntStr(index1) - 1; + for (int j = 6; j < tokens.length; j++) { + String index2 = tokens[j]; + int i2 = parseIntStr(index2) - 1; + String key = ";" + (i1 < i2 ? index1 : index2) + ";" + (i1 < i2 ? index2 : index1) + ";"; + if (temp.indexOf(key) >= 0) + continue; + temp += key; + atomSetCollection.addNewBondWithOrder(i1, i2, 1); + } + } + } + +} Property changes on: trunk/Jmol/src/org/jmol/adapter/readers/simple/TinkerReader.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Modified: trunk/Jmol/src/org/jmol/adapter/readers/xml/XmlQEReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/readers/xml/XmlQEReader.java 2014-01-27 17:15:44 UTC (rev 19217) +++ trunk/Jmol/src/org/jmol/adapter/readers/xml/XmlQEReader.java 2014-01-27 21:08:46 UTC (rev 19218) @@ -63,7 +63,7 @@ @Override public void processStartElement(String localName) { - if (Logger.debugging) + if (Logger.debugging) Logger.debug("xmlqe: start " + localName); if (!parent.continuing) @@ -75,12 +75,10 @@ keepChars = true; return; } - + if (localName.startsWith("ATOM.")) { - float[] xyz = getTokensFloat(atts.get("TAU"), null, 3); - atom = atomSetCollection.addNewAtom(); - atom.elementSymbol = atts.get("SPECIES").trim(); - parent.setAtomCoordXYZ(atom, xyz[0] * ANGSTROMS_PER_BOHR, xyz[1] * ANGSTROMS_PER_BOHR, xyz[2] * ANGSTROMS_PER_BOHR); + parent.setAtomCoordScaled(null, getTokensStr(atts.get("TAU")), 0, + ANGSTROMS_PER_BOHR).elementSymbol = atts.get("SPECIES").trim(); } if ("structure".equals(localName)) { if (!parent.doGetModel(++parent.modelNumber, null)) { @@ -94,8 +92,7 @@ } if (!parent.doProcessLines) return; - - + } @Override Modified: trunk/Jmol/src/org/jmol/adapter/readers/xtal/AbinitReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/readers/xtal/AbinitReader.java 2014-01-27 17:15:44 UTC (rev 19217) +++ trunk/Jmol/src/org/jmol/adapter/readers/xtal/AbinitReader.java 2014-01-27 21:08:46 UTC (rev 19218) @@ -1,30 +1,32 @@ package org.jmol.adapter.readers.xtal; /** - * http://cms.mpi.univie.ac.at/vasp/ + * http://www.abinit.org/ * + * allows filter="input" + * * @author Pieremanuele Canepa, MIT, * Department of Material Sciences and Engineering + * @author Bob Hanson, ha...@st... * * * @version 1.0 */ -import javajs.util.PT; - import org.jmol.adapter.smarter.Atom; import org.jmol.adapter.smarter.AtomSetCollectionReader; public class AbinitReader extends AtomSetCollectionReader { - private float[] cellLattice; - private String atomList[]; + private float[] znucl; + private boolean inputOnly; @Override protected void initializeReader() { setSpaceGroupName("P1"); doApplySymmetry = true; - // inputOnly = checkFilter("INPUT"); + setFractionalCoordinates(false); + inputOnly = checkFilterKey("INPUT"); } @Override @@ -42,8 +44,10 @@ readSpaceGroup(); } else if (line.contains("Real(R)+Recip(G)")) { readIntiallattice(); - } else if (line.contains("xred")) { - readIntitfinalCoord(); + if (inputOnly) + continuing = false; + } else if (line.contains("xcart")) { + readAtoms(); } return true; } @@ -64,46 +68,19 @@ nType = parseIntStr(tokens[1]); } - private int typeArray[]; + private float[] typeArray; private void readTypesequence() throws Exception { - typeArray = new int[nAtom]; - int i = 0; - while (line != null && line.indexOf("wtk") < 0) { - String tmp = line; - if (line.contains("type")) - tmp = PT.rep(tmp, "type", ""); - if (line.contains("typat")) - tmp = PT.rep(tmp, "typat", ""); - - String[] tokens = getTokensStr(tmp); - for (int j = 0; j < tokens.length; j++) { - typeArray[i] = parseIntStr(tokens[j]); - i++; - } - readLine(); - } + fillFloatArray(line.substring(10), 0, typeArray = new float[nAtom]); } private void readAtomSpecies() throws Exception { - atomList = new String[nAtom]; - readLine(); + znucl = new float[nType]; //- pspini: atom type 1 psp file is Al.psp - String[] pseudo = getTokensStr(line); - int pseudoType = parseIntStr(pseudo[4]); for (int i = 0; i < nType; i++) { //is this ntype or sequence type ? - int tokenIndex = 0; discardLinesUntilContains("zion"); - String tmp = PT.rep(line, ".", " "); - String[] tokens = getTokensStr(tmp); - if (tokens[0] == "-") - tokenIndex = 1; - int atomicNo = parseIntStr(tokens[tokenIndex]); - if (pseudoType == atomicNo) { - for (int j = 0; j < typeArray.length; j++) { - atomList[j] = getElementSymbol(atomicNo); - } - } + String[] tokens = getTokens(); + znucl[i] = parseFloatStr(tokens[tokens[0] == "-" ? 1 : 0]); } } @@ -111,54 +88,70 @@ private void readSpaceGroup() throws Exception { } + float[] cellLattice; + private void readIntiallattice() throws Exception { - // Real(R)+Recip(G) space primitive vectors, cartesian coordinates (Bohr,Bohr^-1): // R(1)= 25.9374361 0.0000000 0.0000000 G(1)= 0.0385543 0.0222593 0.0000000 // R(2)=-12.9687180 22.4624785 0.0000000 G(2)= 0.0000000 0.0445187 0.0000000 // R(3)= 0.0000000 0.0000000 16.0314917 G(3)= 0.0000000 0.0000000 0.0623772 // Unit cell volume ucvol= 9.3402532E+03 bohr^3 + float f = 0; cellLattice = new float[9]; - String data = ""; - int counter = 0; - while (readLine() != null && line.indexOf("Unit cell volume") < 0) { - data = line; - data = PT.rep(data, "=", "= "); - String[] tokens = getTokensStr(data); - cellLattice[counter++] = parseFloatStr(tokens[1]) * ANGSTROMS_PER_BOHR; - cellLattice[counter++] = parseFloatStr(tokens[2]) * ANGSTROMS_PER_BOHR; - cellLattice[counter++] = parseFloatStr(tokens[3]) * ANGSTROMS_PER_BOHR; + for (int i = 0; i < 9; i++) { + if (i % 3 == 0) { + line = readLine().substring(6); + f = parseFloatStr(line); + } + cellLattice[i] = f * ANGSTROMS_PER_BOHR; + f = parseFloat(); } - setSymmetry(); + applySymmetry(); } - private void setSymmetry() throws Exception { + private boolean doSymmetry; + + private void applySymmetry() throws Exception { + if (cellLattice == null) + return; + setSpaceGroupName("P1"); + for (int i = 0; i < 3; i++) + addPrimitiveLatticeVector(i, cellLattice, i * 3); + if (!doSymmetry) + return; + Atom[] atoms = atomSetCollection.atoms; + int i0 = atomSetCollection.getAtomSetAtomIndex(atomSetCollection.currentAtomSetIndex); + for (int i = atomSetCollection.atomCount; --i >= i0;) + setAtomCoord(atoms[i]); applySymmetryAndSetTrajectory(); - setSpaceGroupName("P1"); - setFractionalCoordinates(false); + doSymmetry = false; } - //xred -7.0000000000E-02 0.0000000000E+00 0.0000000000E+00 - // 7.0000000000E-02 0.0000000000E+00 0.0000000000E+00 - private void readIntitfinalCoord() throws Exception { - // Read crystallographic coordinate of intial and - // final structures. - String data = ""; - int count = 0; - while (readLine() != null && line.contains("znucl")) { + // xcart 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + // 2.5542500000E+00 2.5542500000E+00 2.5542500000E+00 + // xred... + // ... + // z... + + private void readAtoms() throws Exception { + // Read cartesian coordinates + atomSetCollection.newAtomSet(); + doSymmetry = true; + int i0 = atomSetCollection.atomCount; + line = line.substring(10); + while (line != null && !line.contains("x")) { Atom atom = atomSetCollection.addNewAtom(); - atom.atomName = atomList[count++]; - data = line; - if (data.contains("xred")) - PT.rep(data, "xred", ""); - String[] tokens = getTokensStr(data); - float x = parseFloatStr(tokens[0]); - float y = parseFloatStr(tokens[1]); - float z = parseFloatStr(tokens[2]); - setAtomCoordXYZ(atom, x, y, z); + setAtomCoordScaled(atom, getTokensStr(line), 0, ANGSTROMS_PER_BOHR); + readLine(); } - + discardLinesUntilContains("z"); + if (znucl == null) + fillFloatArray(line.substring(11), 0, znucl = new float[nType]); + Atom[] atoms = atomSetCollection.atoms; + for (int i = 0; i < nAtom; i++) + atoms[i + i0].elementNumber = (short) znucl[(int) typeArray[i] - 1]; + applySymmetry(); } } Modified: trunk/Jmol/src/org/jmol/adapter/readers/xtal/AimsReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/readers/xtal/AimsReader.java 2014-01-27 17:15:44 UTC (rev 19217) +++ trunk/Jmol/src/org/jmol/adapter/readers/xtal/AimsReader.java 2014-01-27 21:08:46 UTC (rev 19218) @@ -32,7 +32,6 @@ package org.jmol.adapter.readers.xtal; import org.jmol.adapter.smarter.AtomSetCollectionReader; -import org.jmol.adapter.smarter.Atom; import org.jmol.util.Logger; /** @@ -129,10 +128,7 @@ } if (this.isFractional != isFractional) setFractionalCoordinates(this.isFractional = isFractional); - Atom atom = atomSetCollection.addNewAtom(); - setAtomCoordXYZ(atom, parseFloatStr(tokens[1]), parseFloatStr(tokens[2]), - parseFloatStr(tokens[3])); - atom.elementSymbol = tokens[4]; + addAtomXYZSymName(tokens, 1, tokens[4], null); } /* @@ -152,10 +148,7 @@ } if (this.isFractional) setFractionalCoordinates(this.isFractional = false); - Atom atom = atomSetCollection.addNewAtom(); - setAtomCoordXYZ(atom, parseFloatStr(tokens[1]), parseFloatStr(tokens[2]), - parseFloatStr(tokens[3])); - atom.partialCharge = parseFloatStr(tokens[5]); + addAtomXYZSymName(tokens, 1, null, null).partialCharge = parseFloatStr(tokens[5]); // we generally do not do this: atom.formalCharge = Math.round(atom.partialCharge); } Modified: trunk/Jmol/src/org/jmol/adapter/readers/xtal/CastepReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/readers/xtal/CastepReader.java 2014-01-27 17:15:44 UTC (rev 19217) +++ trunk/Jmol/src/org/jmol/adapter/readers/xtal/CastepReader.java 2014-01-27 21:08:46 UTC (rev 19218) @@ -321,8 +321,7 @@ atom.elementSymbol = tokens[1]; atom.atomName = tokens[1] + tokens[2]; atomSetCollection.addAtomWithMappedName(atom); - setAtomCoordXYZ(atom, parseFloatStr(tokens[3]), parseFloatStr(tokens[4]), - parseFloatStr(tokens[5])); + setAtomCoordTokens(atom, tokens, 3); } } @@ -361,11 +360,7 @@ discardLinesUntilContains("<-- R"); while (line != null && line.contains("<-- R")) { tokens = getTokens(); - Atom atom = atomSetCollection.addNewAtom(); - atom.elementSymbol = tokens[0]; - setAtomCoordXYZ(atom, parseFloatStr(tokens[2]) * ANGSTROMS_PER_BOHR, - parseFloatStr(tokens[3]) * ANGSTROMS_PER_BOHR, parseFloatStr(tokens[4]) - * ANGSTROMS_PER_BOHR); + setAtomCoordScaled(null, tokens, 2, ANGSTROMS_PER_BOHR).elementSymbol = tokens[0]; readLine(); } applySymmetryAndSetTrajectory(); @@ -657,11 +652,7 @@ setFractionalCoordinates(true); while (readLine() != null && line.indexOf("END") < 0) { tokens = getTokens(); - Atom atom = atomSetCollection.addNewAtom(); - setAtomCoordXYZ(atom, parseFloatStr(tokens[1]), parseFloatStr(tokens[2]), - parseFloatStr(tokens[3])); - atom.elementSymbol = tokens[4]; - atom.bfactor = parseFloatStr(tokens[5]); // mass, actually + addAtomXYZSymName(tokens, 1, tokens[4], null).bfactor = parseFloatStr(tokens[5]); // mass, actually } atomCount = atomSetCollection.atomCount; // we collect the atom points, because any supercell business Modified: trunk/Jmol/src/org/jmol/adapter/readers/xtal/GulpReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/readers/xtal/GulpReader.java 2014-01-27 17:15:44 UTC (rev 19217) +++ trunk/Jmol/src/org/jmol/adapter/readers/xtal/GulpReader.java 2014-01-27 21:08:46 UTC (rev 19218) @@ -385,12 +385,8 @@ } line = line.replace('*', ' '); String[] tokens = getTokens(); - if (!tokens[2].equals("c")) - continue; - Atom atom = atomSetCollection.addNewAtom(); - atom.atomName = tokens[1]; - setAtomCoordXYZ(atom, parseFloatStr(tokens[3]), parseFloatStr(tokens[4]), - parseFloatStr(tokens[5])); + if (tokens[2].equals("c")) + addAtomXYZSymName(tokens, 3, null, tokens[1]); } if (finalizeSymmetry) applySymmetryAndSetTrajectory(); Modified: trunk/Jmol/src/org/jmol/adapter/readers/xtal/ShelxReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/readers/xtal/ShelxReader.java 2014-01-27 17:15:44 UTC (rev 19217) +++ trunk/Jmol/src/org/jmol/adapter/readers/xtal/ShelxReader.java 2014-01-27 21:08:46 UTC (rev 19218) @@ -264,12 +264,8 @@ private void processCmdfAtoms() throws Exception { while (readLine() != null && line.length() > 10) { - Atom atom = atomSetCollection.addNewAtom(); tokens = getTokens(); - atom.elementSymbol = getSymbol(tokens[0]); - atom.atomName = tokens[1]; - setAtomCoordXYZ(atom, parseFloatStr(tokens[2]), parseFloatStr(tokens[3]), - parseFloatStr(tokens[4])); + addAtomXYZSymName(tokens, 2, getSymbol(tokens[0]), tokens[1]); } } Modified: trunk/Jmol/src/org/jmol/adapter/readers/xtal/SiestaReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/readers/xtal/SiestaReader.java 2014-01-27 17:15:44 UTC (rev 19217) +++ trunk/Jmol/src/org/jmol/adapter/readers/xtal/SiestaReader.java 2014-01-27 21:08:46 UTC (rev 19218) @@ -70,12 +70,7 @@ while (readLine() != null && line.indexOf("%endblock Atomic") < 0) { String[] tokens = getTokens(); - Atom atom = atomSetCollection.addNewAtom(); - atom.atomName = tokens[4]; - float x = parseFloatStr(tokens[0]); - float y = parseFloatStr(tokens[1]); - float z = parseFloatStr(tokens[2]); - setAtomCoordXYZ(atom, x, y, z); // will be set after reading unit cell + addAtomXYZSymName(tokens, 0, null, tokens[4]); } noAtoms = atomSetCollection.atomCount; } Modified: trunk/Jmol/src/org/jmol/adapter/readers/xtal/VaspOutcarReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/readers/xtal/VaspOutcarReader.java 2014-01-27 17:15:44 UTC (rev 19217) +++ trunk/Jmol/src/org/jmol/adapter/readers/xtal/VaspOutcarReader.java 2014-01-27 21:08:46 UTC (rev 19218) @@ -31,7 +31,6 @@ import javajs.util.List; import org.jmol.adapter.smarter.AtomSetCollectionReader; -import org.jmol.adapter.smarter.Atom; /** * http://cms.mpi.univie.ac.at/vasp/ @@ -100,15 +99,10 @@ private List<String> elementNames = new List<String>(); - private String elementList = ""; private void readElementNames() throws Exception { //TITEL = PAW_PBE Al 04Jan2001 - String[] tokens = getTokensStr(line); - String sym = tokens[3]; - String key = ";" + sym + ";"; - elementList += key; - elementNames.addLast(sym); + elementNames.addLast(getTokens()[3]); } /* @@ -183,15 +177,8 @@ ///This is the initial geometry not the geometry during the geometry dump private void readInitialCoordinates() throws Exception { int counter = 0; - while (readLine() != null && line.length() > 10) { - Atom atom = atomSetCollection.addNewAtom(); - String[] tokens = getTokens(); - atom.atomName = atomNames[counter++]; - float x = parseFloatStr(tokens[0]); - float y = parseFloatStr(tokens[1]); - float z = parseFloatStr(tokens[2]); - setAtomCoordXYZ(atom, x, y, z); - } + while (readLine() != null && line.length() > 10) + addAtomXYZSymName(getTokens(), 0, null, atomNames[counter++]); atomSetCollection.setAtomSetName("Initial Coordinates"); } @@ -211,16 +198,8 @@ private void readPOSITION() throws Exception { int counter = 0; readLines(1); - while (readLine() != null && line.indexOf("----------") < 0) { - Atom atom = atomSetCollection.addNewAtom(); - String[] tokens = getTokens(); - atom.atomName = atomNames[counter]; - float x = parseFloatStr(tokens[0]); - float y = parseFloatStr(tokens[1]); - float z = parseFloatStr(tokens[2]); - setAtomCoordXYZ(atom, x, y, z); - counter++; - } + while (readLine() != null && line.indexOf("----------") < 0) + addAtomXYZSymName(getTokens(), 0, null, atomNames[counter++]); } /* FREE ENERGIE OF THE ION-ELECTRON SYSTEM (eV) Modified: trunk/Jmol/src/org/jmol/adapter/readers/xtal/VaspPoscarReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/readers/xtal/VaspPoscarReader.java 2014-01-27 17:15:44 UTC (rev 19217) +++ trunk/Jmol/src/org/jmol/adapter/readers/xtal/VaspPoscarReader.java 2014-01-27 21:08:46 UTC (rev 19218) @@ -1,7 +1,6 @@ package org.jmol.adapter.readers.xtal; import org.jmol.adapter.smarter.AtomSetCollectionReader; -import org.jmol.adapter.smarter.Atom; import javajs.util.List; import javajs.util.SB; @@ -76,15 +75,8 @@ readLine(); if (line.toLowerCase().contains("cartesian")) setFractionalCoordinates(false); - for (int i = 0; i < atomCount; i++) { - Atom atom = atomSetCollection.addNewAtom(); - String[] tokens = getTokensStr(readLine()); - atom.atomName = atomLabels.get(i); - float x = parseFloatStr(tokens[0]); - float y = parseFloatStr(tokens[1]); - float z = parseFloatStr(tokens[2]); - setAtomCoordXYZ(atom, x, y, z); - } + for (int i = 0; i < atomCount; i++) + addAtomXYZSymName(getTokensStr(readLine()), 0, null, atomLabels.get(i)); } } Modified: trunk/Jmol/src/org/jmol/adapter/readers/xtal/XcrysdenReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/readers/xtal/XcrysdenReader.java 2014-01-27 17:15:44 UTC (rev 19217) +++ trunk/Jmol/src/org/jmol/adapter/readers/xtal/XcrysdenReader.java 2014-01-27 21:08:46 UTC (rev 19218) @@ -1,7 +1,6 @@ package org.jmol.adapter.readers.xtal; import org.jmol.adapter.smarter.AtomSetCollectionReader; -import org.jmol.adapter.smarter.Atom; /** * @@ -84,14 +83,9 @@ setFractionalCoordinates(false); int counter = 0; - while (counter < nAtoms && readLine() != null) { - Atom atom = atomSetCollection.addNewAtom(); + while (counter < nAtoms && readLine() != null) { String[] tokens = getTokens(); - atom.atomName = getElementSymbol(Integer.parseInt(tokens[0])); - float x = parseFloatStr(tokens[1]); - float y = parseFloatStr(tokens[2]); - float z = parseFloatStr(tokens[3]); - setAtomCoordXYZ(atom, x, y, z); + addAtomXYZSymName(tokens, 1, null, getElementSymbol(Integer.parseInt(tokens[0]))); counter++; } atomSetCollection.setAtomSetName(animation ? "Structure " + (animationStep++) : "Initial coordinates"); Modified: trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollectionReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollectionReader.java 2014-01-27 17:15:44 UTC (rev 19217) +++ trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollectionReader.java 2014-01-27 21:08:46 UTC (rev 19218) @@ -1009,6 +1009,29 @@ setAtomCoord(atom); } + public Atom setAtomCoordScaled(Atom atom, String[] tokens, int i, float f) { + if (atom == null) + atom = atomSetCollection.addNewAtom(); + setAtomCoordXYZ(atom, parseFloatStr(tokens[i]) * f, + parseFloatStr(tokens[i + 1]) * f, parseFloatStr(tokens[i + 2]) * f); + return atom; + } + + protected void setAtomCoordTokens(Atom atom, String[] tokens, int i) { + setAtomCoordXYZ(atom, parseFloatStr(tokens[i]), parseFloatStr(tokens[i + 1]), + parseFloatStr(tokens[i + 2])); + } + + public Atom addAtomXYZSymName(String[] tokens, int i, String sym, String name) { + Atom atom = atomSetCollection.addNewAtom(); + if (sym != null) + atom.elementSymbol = sym; + if (name != null) + atom.atomName = name; + setAtomCoordTokens(atom, tokens, i); + return atom; + } + public void setAtomCoord(Atom atom) { // fileScaling is used by the PLOT command to // put data into PDB format, preserving name/residue information, Modified: trunk/Jmol/src/org/jmol/adapter/smarter/Resolver.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/smarter/Resolver.java 2014-01-27 17:15:44 UTC (rev 19217) +++ trunk/Jmol/src/org/jmol/adapter/smarter/Resolver.java 2014-01-27 21:08:46 UTC (rev 19218) @@ -49,10 +49,12 @@ "WebMO;", "pdb.", ";Pdb;Pqr;P2n;", "pymol.", ";PyMOL;", - "simple.", ";Alchemy;Ampac;Cube;FoldingXyz;GhemicalMM;HyperChem;Jme;Mopac;MopacArchive;ZMatrix;JSON;", + "simple.", ";Alchemy;Ampac;Cube;FoldingXyz;GhemicalMM;HyperChem;Jme;JSON;Mopac;MopacArchive;Tinker;ZMatrix;", "xtal.", ";Abinit;Aims;Castep;Crystal;Dmol;Espresso;Gulp;Jana;Magres;Shelx;Siesta;VaspOutcar;" + "VaspPoscar;Wien2k;Xcrysden;" }; + + // Tinker is only as explicit Tinker::fileName.xyz public final static String getReaderClassBase(String type) { String name = type + "Reader"; @@ -412,22 +414,22 @@ private final static String getReaderFromType(String type) { type = type.toLowerCase(); - String base = null; - if ((base = checkType(specialTags, type)) != null) - return base; - if ((base = checkType(fileStartsWithRecords, type)) != null) - return base; - if ((base = checkType(lineStartsWithRecords, type)) != null) - return base; - return checkType(headerContainsRecords, type); - } - - private final static String checkType(String[][] typeTags, String type) { - for (int i = 0; i < typeTags.length; ++i) - if (typeTags[i][0].toLowerCase().equals(type)) - return typeTags[i][0]; + String key = ";" + type + ";"; + for (int i = readerSets.length; --i >= 0;) { + int pt = readerSets[i].toLowerCase().indexOf(key); + if (pt >= 0) + return readerSets[i].substring(pt + 1, readerSets[i].indexOf(";", pt + 2)); + } return null; } +// +// private final static String checkType(String[][] typeTags, String type) { +// for (int i = 0; i < typeTags.length; ++i) +// if (typeTags[i][0].toLowerCase().equals(type)) +// return typeTags[i][0]; +// return null; +// } +// //////////////////////////////////////////////////////////////// // file types that need special treatment Modified: trunk/Jmol/src/org/jmol/viewer/Jmol.properties =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2014-01-27 17:15:44 UTC (rev 19217) +++ trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2014-01-27 21:08:46 UTC (rev 19218) @@ -15,6 +15,8 @@ ___JmolVersion="14.1.8_dev_2014.01.27" +code: reader overhaul for setting atom coordinates in a consistent fashion +bug fix: abinit reader was nonfunctional bug fix: assign atom into into PDB file loses atom names bug fix: y = ([3])[1][1] should be [3] not 3 bug fix: break n nonfunctional This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |