📄 cmlcoremodule.java
字号:
boolean hasDictRefs = false; boolean hasSpinMultiplicities = false; boolean hasOccupancies = false; if (elid.size() == atomCounter) { hasID = true; } else { logger.debug("No atom ids: " + elid.size(), " != " + atomCounter); } if (elsym.size() == atomCounter) { hasSymbols = true; } else { logger.debug( "No atom symbols: " + elsym.size(), " != " + atomCounter); } if (eltitles.size() == atomCounter) { hasTitles = true; } else { logger.debug( "No atom titles: " + eltitles.size(), " != " + atomCounter); } if ((x3.size() == atomCounter) && (y3.size() == atomCounter) && (z3.size() == atomCounter)) { has3D = true; } else { logger.debug( "No 3D info: " + x3.size(), " " + y3.size(), " " + z3.size(), " != " + atomCounter); } if ((xfract.size() == atomCounter) && (yfract.size() == atomCounter) && (zfract.size() == atomCounter)) { has3Dfract = true; } else { logger.debug( "No 3D fractional info: " + xfract.size(), " " + yfract.size(), " " + zfract.size(), " != " + atomCounter); } if ((x2.size() == atomCounter) && (y2.size() == atomCounter)) { has2D = true; } else { logger.debug( "No 2D info: " + x2.size(), " " + y2.size(), " != " + atomCounter); } if (formalCharges.size() == atomCounter) { hasFormalCharge = true; } else { logger.debug( "No formal Charge info: " + formalCharges.size(), " != " + atomCounter); } if (partialCharges.size() == atomCounter) { hasPartialCharge = true; } else { logger.debug( "No partial Charge info: " + partialCharges.size(), " != " + atomCounter); } if (hCounts.size() == atomCounter) { hasHCounts = true; } else { logger.debug( "No hydrogen Count info: " + hCounts.size(), " != " + atomCounter); } if (spinMultiplicities.size() == atomCounter) { hasSpinMultiplicities = true; } else { logger.debug( "No spinMultiplicity info: " + spinMultiplicities.size(), " != " + atomCounter); } if (occupancies.size() == atomCounter) { hasOccupancies = true; } else { logger.debug( "No occupancy info: " + occupancies.size(), " != " + atomCounter); } if (atomDictRefs.size() == atomCounter) { hasDictRefs = true; } else { logger.debug( "No dictRef info: " + atomDictRefs.size(), " != " + atomCounter); } if (isotope.size() == atomCounter) { hasIsotopes = true; } else { logger.debug( "No isotope info: " + isotope.size(), " != " + atomCounter); } for (int i = 0; i < atomCounter; i++) { logger.info("Storing atom: ", i);// cdo.startObject("Atom"); currentAtom = currentChemFile.getBuilder().newAtom("H"); logger.debug("Atom # " + atomCounter); if (hasID) {// cdo.setObjectProperty("Atom", "id", (String)elid.get(i)); logger.debug("id: ", (String)elid.get(i)); currentAtom.setID((String)elid.get(i)); atomEnumeration.put((String)elid.get(i), currentAtom); } if (hasTitles) { if (hasSymbols) { String symbol = (String)elsym.get(i); if (symbol.equals("Du") || symbol.equals("Dummy")) {// cdo.setObjectProperty("PseudoAtom", "label", (String)eltitles.get(i)); if (!(currentAtom instanceof IPseudoAtom)) { currentAtom = currentChemFile.getBuilder().newPseudoAtom(currentAtom); if (hasID) atomEnumeration.put((String)elid.get(i), currentAtom); } ((IPseudoAtom)currentAtom).setLabel((String)eltitles.get(i)); } else {// cdo.setObjectProperty("Atom", "title", (String)eltitles.get(i)); // FIXME: huh? if (eltitles.get(i) != null) currentAtom.setProperty(CDKConstants.TITLE, (String)eltitles.get(i)); } } else {// cdo.setObjectProperty("Atom", "title", (String)eltitles.get(i)); // FIXME: huh? if (eltitles.get(i) != null) currentAtom.setProperty(CDKConstants.TITLE, (String)eltitles.get(i)); } } // store optional atom properties if (hasSymbols) { String symbol = (String)elsym.get(i); if (symbol.equals("Du") || symbol.equals("Dummy")) { symbol = "R"; }// cdo.setObjectProperty("Atom", "type", symbol); if (symbol.equals("R") && !(currentAtom instanceof IPseudoAtom)) { currentAtom = currentChemFile.getBuilder().newPseudoAtom(currentAtom); if (hasID) atomEnumeration.put((String)elid.get(i), currentAtom); } currentAtom.setSymbol(symbol); try{ IsotopeFactory.getInstance(currentAtom.getBuilder()).configure(currentAtom); }catch(Exception ex){ logger.warn("Could not configure atom"); } } if (has3D) {// cdo.setObjectProperty("Atom", "x3", (String)x3.get(i));// cdo.setObjectProperty("Atom", "y3", (String)y3.get(i));// cdo.setObjectProperty("Atom", "z3", (String)z3.get(i)); if (x3.get(i) != null && y3.get(i) != null && z3.get(i) != null) { currentAtom.setPoint3d( new Point3d( Double.parseDouble((String)x3.get(i)), Double.parseDouble((String)y3.get(i)), Double.parseDouble((String)z3.get(i)) ) ); } } if (has3Dfract) { // ok, need to convert fractional into eucledian coordinates// cdo.setObjectProperty("Atom", "xFract", (String)xfract.get(i));// cdo.setObjectProperty("Atom", "yFract", (String)yfract.get(i));// cdo.setObjectProperty("Atom", "zFract", (String)zfract.get(i)); currentAtom.setFractionalPoint3d( new Point3d( Double.parseDouble((String)xfract.get(i)), Double.parseDouble((String)yfract.get(i)), Double.parseDouble((String)zfract.get(i)) ) ); } if (hasFormalCharge) {// cdo.setObjectProperty("Atom", "formalCharge", // (String)formalCharges.get(i)); currentAtom.setFormalCharge(Integer.parseInt((String)formalCharges.get(i))); } if (hasPartialCharge) { logger.debug("Storing partial atomic charge...");// cdo.setObjectProperty("Atom", "partialCharge", // (String)partialCharges.get(i)); currentAtom.setCharge(Double.parseDouble((String)partialCharges.get(i))); } if (hasHCounts) {// cdo.setObjectProperty("Atom", "hydrogenCount", (String)hCounts.get(i)); // FIXME: the hCount in CML is the total of implicit *and* explicit currentAtom.setHydrogenCount(Integer.parseInt((String)hCounts.get(i))); } if (has2D) { if (x2.get(i) != null && y2.get(i) != null) {// cdo.setObjectProperty("Atom", "x2", (String)x2.get(i));// cdo.setObjectProperty("Atom", "y2", (String)y2.get(i)); currentAtom.setPoint2d( new Point2d( Double.parseDouble((String)x2.get(i)), Double.parseDouble((String)y2.get(i)) ) ); } } if (hasDictRefs) {// cdo.setObjectProperty("Atom", "dictRef", (String)atomDictRefs.get(i)); if (atomDictRefs.get(i) != null) currentAtom.setProperty("org.openscience.cdk.dict", (String)atomDictRefs.get(i)); } if (hasSpinMultiplicities && spinMultiplicities.get(i) != null) {// cdo.setObjectProperty("Atom", "spinMultiplicity", (String)spinMultiplicities.get(i)); int unpairedElectrons = Integer.parseInt((String)spinMultiplicities.get(i))-1; for (int sm=0; sm<unpairedElectrons; sm++) { currentMolecule.addSingleElectron(currentChemFile.getBuilder().newSingleElectron(currentAtom)); } } if (hasOccupancies && occupancies.get(i) != null) {// cdo.setObjectProperty("Atom", "occupanciy", (String)occupancies.get(i)); // FIXME: this has no ChemFileCDO equivalent, not even if spelled correctly } if (hasIsotopes) {// cdo.setObjectProperty("Atom", "massNumber", (String)isotope.get(i)); if (isotope.get(i) != null) currentAtom.setMassNumber((int)Double.parseDouble((String)isotope.get(i))); }// cdo.endObject("Atom"); currentMolecule.addAtom(currentAtom); } if (elid.size() > 0) { // assume this is the current working list bondElid = elid; } newAtomData(); } protected void storeBondData() { logger.debug( "Testing a1,a2,stereo,order = count: " + bondARef1.size(), "," + bondARef2.size(), "," + bondStereo.size(), "," + order.size(), "=" + bondCounter); if ((bondARef1.size() == bondCounter) && (bondARef2.size() == bondCounter)) { logger.debug("About to add bond info..."); Iterator orders = order.iterator(); Iterator ids = bondid.iterator(); Iterator bar1s = bondARef1.iterator(); Iterator bar2s = bondARef2.iterator(); Iterator stereos = bondStereo.iterator(); Iterator aroms = bondAromaticity.iterator(); while (bar1s.hasNext()) {// cdo.startObject("Bond");// if (ids.hasNext()) {// cdo.setObjectProperty("Bond", "id", (String)ids.next());// }// cdo.setObjectProperty("Bond", "atom1", // new Integer(bondElid.indexOf(// (String)bar1s.next())).toString());// cdo.setObjectProperty("Bond", "atom2", // new Integer(bondElid.indexOf(// (String)bar2s.next())).toString()); IAtom a1 = (IAtom)atomEnumeration.get((String)bar1s.next()); IAtom a2 = (IAtom)atomEnumeration.get((String)bar2s.next()); currentBond = currentChemFile.getBuilder().newBond(a1, a2); if (ids.hasNext()) { currentBond.setID((String)ids.next()); } if (orders.hasNext()) { String bondOrder = (String)orders.next(); if ("S".equals(bondOrder)) {// cdo.setObjectProperty("Bond", "order", "1"); currentBond.setOrder(CDKConstants.BONDORDER_SINGLE); } else if ("D".equals(bondOrder)) {// cdo.setObjectProperty("Bond", "order", "2"); currentBond.setOrder(CDKConstants.BONDORDER_DOUBLE); } else if ("T".equals(bondOrder)) {// cdo.setObjectProperty("Bond", "order", "3"); currentBond.setOrder(CDKConstants.BONDORDER_TRIPLE); } else if ("A".equals(bondOrder)) {// cdo.setObjectProperty("Bond", "order", "1.5"); currentBond.setOrder(CDKConstants.BONDORDER_SINGLE); currentBond.setFlag(CDKConstants.ISAROMATIC, true); } else {// cdo.setObjectProperty("Bond", "order", bondOrder); currentBond.setOrder(Double.parseDouble(bondOrder)); } } if (stereos.hasNext()) {// cdo.setObjectProperty("Bond", "stereo", // (String)stereos.next()); String nextStereo = (String)stereos.next(); if ("H".equals(nextStereo)) { currentBond.setStereo(CDKConstants.STEREO_BOND_DOWN); } else if ("W".equals(nextStereo)) { currentBond.setStereo(CDKConstants.STEREO_BOND_UP); } else if (nextStereo != null){ logger.warn("Cannot interpret stereo information: " + nextStereo); } } if (aroms.hasNext()) { Object nextArom = aroms.next(); if (nextArom != null && nextArom == Boolean.TRUE) { currentBond.setFlag(CDKConstants.ISAROMATIC, true); } }// cdo.endObject("Bond"); currentMolecule.addBond(currentBond); } } newBondData(); } protected int addArrayElementsTo(List toAddto, String array) { StringTokenizer tokenizer = new StringTokenizer(array); int i = 0; while (tokenizer.hasMoreElements()) { toAddto.add(tokenizer.nextToken()); i++; } return i; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -