📄 cmlcoremodule.java
字号:
logger.debug("New coord3 xyz3 found: ", currentChars); try { StringTokenizer st = new StringTokenizer(currentChars); x3.add(st.nextToken()); y3.add(st.nextToken()); z3.add(st.nextToken()); logger.debug("coord3 x3.length: ", x3.size()); logger.debug("coord3 y3.length: ", y3.size()); logger.debug("coord3 z3.length: ", z3.size()); } catch (Exception exception) { logger.error( "CMLParsing error while setting coordinate3!"); logger.debug(exception); } } else { logger.warn("Unknown coordinate3 BUILTIN: " + BUILTIN); } } else if ("string".equals(name)) { if (BUILTIN.equals("elementType")) { logger.debug("Element: ", cData.trim()); elsym.add(cData); } else if (BUILTIN.equals("atomRef")) { curRef++; logger.debug("Bond: ref #", curRef); if (curRef == 1) { bondARef1.add(cData.trim()); } else if (curRef == 2) { bondARef2.add(cData.trim()); } } else if (BUILTIN.equals("order")) { logger.debug("Bond: order ", cData.trim()); order.add(cData.trim()); } else if (BUILTIN.equals("formalCharge")) { // NOTE: this combination is in violation of the CML DTD!!! logger.warn("formalCharge BUILTIN accepted but violating CML DTD"); logger.debug("Charge: ", cData.trim()); String charge = cData.trim(); if (charge.startsWith("+") && charge.length() > 1) { charge = charge.substring(1); } formalCharges.add(charge); } } else if ("float".equals(name)) { if (BUILTIN.equals("x3")) { x3.add(cData.trim()); } else if (BUILTIN.equals("y3")) { y3.add(cData.trim()); } else if (BUILTIN.equals("z3")) { z3.add(cData.trim()); } else if (BUILTIN.equals("x2")) { x2.add(cData.trim()); } else if (BUILTIN.equals("y2")) { y2.add(cData.trim()); } else if (BUILTIN.equals("order")) { // NOTE: this combination is in violation of the CML DTD!!! order.add(cData.trim()); } else if (BUILTIN.equals("charge") || BUILTIN.equals("partialCharge")) { partialCharges.add(cData.trim()); } } else if ("integer".equals(name)) { if (BUILTIN.equals("formalCharge")) { formalCharges.add(cData.trim()); } } else if ("coordinate2".equals(name)) { if (BUILTIN.equals("xy2")) { logger.debug("New coord2 xy2 found.", cData); try { StringTokenizer st = new StringTokenizer(cData); x2.add(st.nextToken()); y2.add(st.nextToken()); } catch (Exception e) { notify("CMLParsing error: " + e, SYSTEMID, 175, 1); } } } else if ("stringArray".equals(name)) { if (BUILTIN.equals("id") || BUILTIN.equals("atomId") || BUILTIN.equals("atomID")) { // invalid according to CML1 DTD but found in OpenBabel 1.x output try { boolean countAtoms = (atomCounter == 0) ? true : false; StringTokenizer st = new StringTokenizer(cData); while (st.hasMoreTokens()) { if (countAtoms) { atomCounter++; } String token = st.nextToken(); logger.debug("StringArray (Token): ", token); elid.add(token); } } catch (Exception e) { notify("CMLParsing error: " + e, SYSTEMID, 186, 1); } } else if (BUILTIN.equals("elementType")) { try { boolean countAtoms = (atomCounter == 0) ? true : false; StringTokenizer st = new StringTokenizer(cData); while (st.hasMoreTokens()) { if (countAtoms) { atomCounter++; } elsym.add(st.nextToken()); } } catch (Exception e) { notify("CMLParsing error: " + e, SYSTEMID, 194, 1); } } else if (BUILTIN.equals("atomRefs")) { curRef++; logger.debug("New atomRefs found: ", curRef); try { boolean countBonds = (bondCounter == 0) ? true : false; StringTokenizer st = new StringTokenizer(cData); while (st.hasMoreTokens()) { if (countBonds) { bondCounter++; } String token = st.nextToken(); logger.debug("Token: ", token); if (curRef == 1) { bondARef1.add(token); } else if (curRef == 2) { bondARef2.add(token); } } } catch (Exception e) { notify("CMLParsing error: " + e, SYSTEMID, 194, 1); } } else if (BUILTIN.equals("atomRef")) { curRef++; logger.debug("New atomRef found: ", curRef); // this is CML1 stuff, we get things like: /* <bondArray> <stringArray builtin="atomRef">a2 a2 a2 a2 a3 a3 a4 a4 a5 a6 a7 a9</stringArray> <stringArray builtin="atomRef">a9 a11 a12 a13 a5 a4 a6 a9 a7 a8 a8 a10</stringArray> <stringArray builtin="order">1 1 1 1 2 1 2 1 1 1 2 2</stringArray> </bondArray> */ try { boolean countBonds = (bondCounter == 0) ? true : false; StringTokenizer st = new StringTokenizer(cData); while (st.hasMoreTokens()) { if (countBonds) { bondCounter++; } String token = st.nextToken(); logger.debug("Token: ", token); if (curRef == 1) { bondARef1.add(token); } else if (curRef == 2) { bondARef2.add(token); } } } catch (Exception e) { notify("CMLParsing error: " + e, SYSTEMID, 194, 1); } } else if (BUILTIN.equals("order")) { logger.debug("New bond order found."); try { StringTokenizer st = new StringTokenizer(cData); while (st.hasMoreTokens()) { String token = st.nextToken(); logger.debug("Token: ", token); order.add(token); } } catch (Exception e) { notify("CMLParsing error: " + e, SYSTEMID, 194, 1); } } } else if ("integerArray".equals(name)) { logger.debug("IntegerArray: builtin = ", BUILTIN); if (BUILTIN.equals("formalCharge")) { try { StringTokenizer st = new StringTokenizer(cData); while (st.hasMoreTokens()) { String token = st.nextToken(); logger.debug("Charge added: ", token); formalCharges.add(token); } } catch (Exception e) { notify("CMLParsing error: " + e, SYSTEMID, 205, 1); } } } else if ("scalar".equals(name)) { if (xpath.endsWith("crystal", "scalar")) { logger.debug("Going to set a crystal parameter: " + crystalScalar, " to ", cData); try { unitcellparams[crystalScalar-1] = Double.parseDouble(cData.trim()); } catch (NumberFormatException exception) { logger.error("Content must a float: " + cData); } } else if (xpath.endsWith("bond", "scalar")) { if (DICTREF.equals("mdl:stereo")) { bondStereo.add(cData.trim()); stereoGiven=true; } } else if (xpath.endsWith("atom", "scalar")) { if (DICTREF.equals("cdk:partialCharge")) { partialCharges.add(cData.trim()); } } else if (xpath.endsWith("molecule", "scalar")) { if (DICTREF.equals("pdb:id")) {// cdo.setObjectProperty("Molecule", DICTREF, cData); currentMolecule.setProperty(new DictRef(DICTREF, cData), cData); } else if (DICTREF.equals("cdk:molecularProperty")) { currentMolecule.setProperty(elementTitle, cData); } } else { logger.warn("Ignoring scalar: " + xpath); } } else if ("floatArray".equals(name)) { if (BUILTIN.equals("x3")) { try { StringTokenizer st = new StringTokenizer(cData); while (st.hasMoreTokens()) x3.add(st.nextToken()); } catch (Exception e) { notify("CMLParsing error: " + e, SYSTEMID, 205, 1); } } else if (BUILTIN.equals("y3")) { try { StringTokenizer st = new StringTokenizer(cData); while (st.hasMoreTokens()) y3.add(st.nextToken()); } catch (Exception e) { notify("CMLParsing error: " + e, SYSTEMID, 213, 1); } } else if (BUILTIN.equals("z3")) { try { StringTokenizer st = new StringTokenizer(cData); while (st.hasMoreTokens()) z3.add(st.nextToken()); } catch (Exception e) { notify("CMLParsing error: " + e, SYSTEMID, 221, 1); } } else if (BUILTIN.equals("x2")) { logger.debug("New floatArray found."); try { StringTokenizer st = new StringTokenizer(cData); while (st.hasMoreTokens()) x2.add(st.nextToken()); } catch (Exception e) { notify("CMLParsing error: " + e, SYSTEMID, 205, 1); } } else if (BUILTIN.equals("y2")) { logger.debug("New floatArray found."); try { StringTokenizer st = new StringTokenizer(cData); while (st.hasMoreTokens()) y2.add(st.nextToken()); } catch (Exception e) { notify("CMLParsing error: " + e, SYSTEMID, 454, 1); } } else if (BUILTIN.equals("partialCharge")) { logger.debug("New floatArray with partial charges found."); try { StringTokenizer st = new StringTokenizer(cData); while (st.hasMoreTokens()) partialCharges.add(st.nextToken()); } catch (Exception e) { notify("CMLParsing error: " + e, SYSTEMID, 462, 1); } } } else if ("basic".equals(name)) { // assuming this is the child element of <identifier> this.inchi = cData; } else if ("name".equals(name)) { if (xpath.endsWith("molecule", "name")) { if (DICTREF.length() > 0) {// cdo.setObjectProperty("Molecule", DICTREF, cData); currentMolecule.setProperty(new DictRef(DICTREF, cData), cData); } else {// cdo.setObjectProperty("Molecule", "Name", cData); currentMolecule.setProperty(CDKConstants.TITLE, cData); } } } else { logger.warn("Skipping element: " + name); } currentChars = ""; BUILTIN = ""; elementTitle = ""; } public void characterData(CMLStack xpath, char[] ch, int start, int length) { currentChars = currentChars + new String(ch, start, length); logger.debug("CD: ", currentChars); } protected void notify(String message, String systemId, int line, int column) { logger.debug("Message: ", message); logger.debug("SystemId: ", systemId); logger.debug("Line: ", line); logger.debug("Column: ", column); } protected void storeData() { if (inchi != null) {// cdo.setObjectProperty("Molecule", "inchi", inchi); currentMolecule.setProperty(CDKConstants.INCHI, inchi); } storeAtomData(); storeBondData(); } protected void storeAtomData() { logger.debug("No atoms: ", atomCounter); if (atomCounter == 0) { return; } boolean hasID = false; boolean has3D = false; boolean has3Dfract = false; boolean has2D = false; boolean hasFormalCharge = false; boolean hasPartialCharge = false; boolean hasHCounts = false; boolean hasSymbols = false; boolean hasTitles = false; boolean hasIsotopes = false;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -