📄 gaussian03reader.java
字号:
// if frequencies are to be read because Gaussian // does not report dummy atoms in frequencies, and // the number of atoms is used for reading frequencies. continue; } } else { throw new IOException("Error reading coordinates"); } token.nextToken(); // ignore third token double x = 0.0; double y = 0.0; double z = 0.0; if (token.nextToken() == StreamTokenizer.TT_NUMBER) { x = token.nval; } else { throw new IOException("Error reading coordinates"); } if (token.nextToken() == StreamTokenizer.TT_NUMBER) { y = token.nval; } else { throw new IOException("Error reading coordinates"); } if (token.nextToken() == StreamTokenizer.TT_NUMBER) { z = token.nval; } else { throw new IOException("Error reading coordinates"); } String symbol = "Du"; try { symbol = IsotopeFactory.getInstance(model.getBuilder()).getElementSymbol(atomicNumber); } catch (Exception exception) { throw new CDKException("Could not determine element symbol!", exception); } IAtom atom = model.getBuilder().newAtom(symbol); atom.setPoint3d(new Point3d(x, y, z)); container.addAtom(atom); } IMoleculeSet moleculeSet = model.getBuilder().newMoleculeSet(); moleculeSet.addMolecule(model.getBuilder().newMolecule(container)); model.setMoleculeSet(moleculeSet); } /** * Reads partial atomic charges and add the to the given ChemModel. */ private void readPartialCharges(IChemModel model) throws CDKException, IOException { logger.info("Reading partial atomic charges"); IMoleculeSet moleculeSet = model.getMoleculeSet(); IMolecule molecule = moleculeSet.getMolecule(0); String line = input.readLine(); // skip first line after "Total atomic charges" while (input.ready()) { line = input.readLine(); logger.debug("Read charge block line: " + line); if ((line == null) || (line.indexOf("Sum of Mulliken charges") >= 0)) { logger.debug("End of charge block found"); break; } StringReader sr = new StringReader(line); StreamTokenizer tokenizer = new StreamTokenizer(sr); if (tokenizer.nextToken() == StreamTokenizer.TT_NUMBER) { int atomCounter = (int) tokenizer.nval; tokenizer.nextToken(); // ignore the symbol double charge = 0.0; if (tokenizer.nextToken() == StreamTokenizer.TT_NUMBER) { charge = (double) tokenizer.nval; logger.debug("Found charge for atom " + atomCounter + ": " + charge); } else { throw new CDKException("Error while reading charge: expected double."); } IAtom atom = molecule.getAtom(atomCounter - 1); atom.setCharge(charge); } } } /** * Reads a set of vibrations into ChemModel. * * @param model the destination ChemModel * @throws IOException if an I/O error occurs */// private void readFrequencies(IChemModel model) throws IOException { /* This is yet to be ported. Vibrations don't exist yet in CDK. String line = input.readLine(); line = input.readLine(); line = input.readLine(); line = input.readLine(); line = input.readLine(); while ((line != null) && line.startsWith(" Frequencies --")) { Vector currentVibs = new Vector(); StringReader vibValRead = new StringReader(line.substring(15)); StreamTokenizer token = new StreamTokenizer(vibValRead); while (token.nextToken() != StreamTokenizer.TT_EOF) { Vibration vib = new Vibration(Double.toString(token.nval)); currentVibs.addElement(vib); } line = input.readLine(); // skip "Red. masses" line = input.readLine(); // skip "Rfc consts" line = input.readLine(); // skip "IR Inten" while (!line.startsWith(" Atom AN")) { // skip all lines upto and including the " Atom AN" line line = input.readLine(); // skip } for (int i = 0; i < frame.getAtomCount(); ++i) { line = input.readLine(); StringReader vectorRead = new StringReader(line); token = new StreamTokenizer(vectorRead); token.nextToken(); // ignore first token token.nextToken(); // ignore second token for (int j = 0; j < currentVibs.size(); ++j) { double[] v = new double[3]; if (token.nextToken() == StreamTokenizer.TT_NUMBER) { v[0] = token.nval; } else { throw new IOException("Error reading frequency"); } if (token.nextToken() == StreamTokenizer.TT_NUMBER) { v[1] = token.nval; } else { throw new IOException("Error reading frequency"); } if (token.nextToken() == StreamTokenizer.TT_NUMBER) { v[2] = token.nval; } else { throw new IOException("Error reading frequency"); } ((Vibration) currentVibs.elementAt(j)).addAtomVector(v); } } for (int i = 0; i < currentVibs.size(); ++i) { frame.addVibration((Vibration) currentVibs.elementAt(i)); } line = input.readLine(); line = input.readLine(); line = input.readLine(); } */// } /** * Reads NMR nuclear shieldings. */// private void readNMRData(IChemModel model, String labelLine) throws IOException { /* FIXME: this is yet to be ported. CDK does not have shielding stuff. // Determine label for properties String label; if (labelLine.indexOf("Diamagnetic") >= 0) { label = "Diamagnetic Magnetic shielding (Isotropic)"; } else if (labelLine.indexOf("Paramagnetic") >= 0) { label = "Paramagnetic Magnetic shielding (Isotropic)"; } else { label = "Magnetic shielding (Isotropic)"; } int atomIndex = 0; for (int i = 0; i < frame.getAtomCount(); ++i) { String line = input.readLine().trim(); while (line.indexOf("Isotropic") < 0) { if (line == null) { return; } line = input.readLine().trim(); } StringTokenizer st1 = new StringTokenizer(line); // Find Isotropic label while (st1.hasMoreTokens()) { if (st1.nextToken().equals("Isotropic")) { break; } } // Find Isotropic value while (st1.hasMoreTokens()) { if (st1.nextToken().equals("=")) { break; } } double shielding = Double.valueOf(st1.nextToken()).doubleValue(); NMRShielding ns1 = new NMRShielding(label, shielding); ((org.openscience.jmol.Atom)frame.getAtomAt(atomIndex)).addProperty(ns1); ++atomIndex; } */// } /** * Select the theory and basis set from the first archive line. */ /*private String parseLevelOfTheory(String line) { StringTokenizer st1 = new StringTokenizer(line, "\\"); // Must contain at least 6 tokens if (st1.countTokens() < 6) { return null; } // Skip first four tokens for (int i = 0; i < 4; ++i) { st1.nextToken(); } return st1.nextToken() + "/" + st1.nextToken(); }*/}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -