From: <ha...@us...> - 2010-05-05 15:36:25
|
Revision: 13019 http://jmol.svn.sourceforge.net/jmol/?rev=13019&view=rev Author: hansonr Date: 2010-05-05 15:36:14 +0000 (Wed, 05 May 2010) Log Message: ----------- version=12.0.RC10_dev # new feature: smiles/smarts/substructure with tetrahedral chirality # select smarts("C[C@@]([C]=O)([CH])[CH2]") Modified Paths: -------------- trunk/Jmol/src/org/jmol/script/ScriptMathProcessor.java trunk/Jmol/src/org/jmol/smiles/SmilesAtom.java trunk/Jmol/src/org/jmol/smiles/SmilesMatcher.java trunk/Jmol/src/org/jmol/smiles/SmilesParser.java trunk/Jmol/src/org/jmol/smiles/SmilesSearch.java trunk/Jmol/src/org/jmol/viewer/Jmol.properties trunk/Jmol/test/org/jmol/smiles/TestSmilesParser.java Removed Paths: ------------- trunk/Jmol/src/org/jmol/smiles/SmartsParser.java Modified: trunk/Jmol/src/org/jmol/script/ScriptMathProcessor.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptMathProcessor.java 2010-05-05 06:34:14 UTC (rev 13018) +++ trunk/Jmol/src/org/jmol/script/ScriptMathProcessor.java 2010-05-05 15:36:14 UTC (rev 13019) @@ -2056,6 +2056,7 @@ matches[j] = Escape.escape(b[j]); return matches; } catch (Exception e) { + //e.printStackTrace(); eval.evalError(e.getMessage(), null); return null; // unattainable } Deleted: trunk/Jmol/src/org/jmol/smiles/SmartsParser.java =================================================================== --- trunk/Jmol/src/org/jmol/smiles/SmartsParser.java 2010-05-05 06:34:14 UTC (rev 13018) +++ trunk/Jmol/src/org/jmol/smiles/SmartsParser.java 2010-05-05 15:36:14 UTC (rev 13019) @@ -1,66 +0,0 @@ -/* $RCSfile$ - * $Author: hansonr $ - * $Date: 2010-05-04 07:53:26 -0500 (Tue, 04 May 2010) $ - * $Revision: 13011 $ - * - * Copyright (C) 2005 The Jmol Development Team - * - * 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.smiles; - -/** - * Parses a SMARTS String to create a <code>SmilesMolecule</code>. - * The SMILES specification has been found at the - * <a href="http://www.daylight.com/smiles/">SMILES Home Page</a>. - * An other explanation can be found in the - * <a href="http://www.daylight.com/dayhtml/doc/theory/theory.smarts.html">Daylight Smarts Theory Manual</a>. <br> - * - * Currently this parser supports only parts of the SMARTS specification. <br> - * - * An example on how to use it: - * <pre><code> - * try { - * SmartsParser sp = new SmartsParser(); - * SmilesMolecule sm = sp.parseSmarts("CC(C)C(=O)O"); - * // Use the resulting molecule - * } catch (InvalidSmilesException e) { - * // Exception management - * } - * </code></pre> - * - * @see <a href="http://www.daylight.com/smiles/">SMILES Home Page</a> - */ -public class SmartsParser extends SmilesParser { - - public static SmilesSearch getMolecule(String smarts) throws InvalidSmilesException { - return (new SmartsParser()).parse(smarts); - } - - /** - * Parses a SMARTS String - * - * @param smarts SMILES String - * @return Molecule corresponding to <code>smiles</code> - * @throws InvalidSmilesException - */ - SmilesSearch parse(String smarts) throws InvalidSmilesException { - isSmarts = true; - return super.parse(smarts); - } -} Modified: trunk/Jmol/src/org/jmol/smiles/SmilesAtom.java =================================================================== --- trunk/Jmol/src/org/jmol/smiles/SmilesAtom.java 2010-05-05 06:34:14 UTC (rev 13018) +++ trunk/Jmol/src/org/jmol/smiles/SmilesAtom.java 2010-05-05 15:36:14 UTC (rev 13019) @@ -55,49 +55,45 @@ } /** - * Creates missing hydrogen atoms in a <code>SmilesMolecule</code>. + * Finalizes the hydrogen count for implicit hydrogens in a <code>SmilesMolecule</code>. * * @param molecule Molecule containing the atom. + * @return false if inappropriate */ - public void createMissingHydrogen(SmilesSearch molecule) { - // Determining max count + public boolean setHydrogenCount(SmilesSearch molecule) { + if (hydrogenCount != Integer.MIN_VALUE) + return true; + // Determining max count int count = 0; - if (hydrogenCount == Integer.MIN_VALUE) { // not a complete set... // B, C, N, O, P, S, F, Cl, Br, and I // B (3), C (4), N (3,5), O (2), P (3,5), S (2,4,6), and 1 for the halogens switch (atomicNumber) { - case -1: - break; - case 5: // B - count = 3; - break; + default: + return false; + case 0: + return true; case 6: // C count = (isAromatic ? 3 : 4); break; case 8: // O - count = 2; - break; - case 7: // N - count = 3; - break; case 16: // S count = 2; break; + case 5: // B + case 7: // N case 15: // P count = 3; break; case 9: // F case 17: // Cl case 35: // Br - case 85: // I + case 53: // I count = 1; break; } - - //System.out.println(" assigning " + count + " valence to atom " + number + " " + atomicNumber); - + for (int i = 0; i < bondsCount; i++) { SmilesBond bond = bonds[i]; switch (bond.getBondType()) { @@ -114,19 +110,10 @@ break; } } - } else { - count = Math.abs(hydrogenCount); - hydrogenCount = Integer.MIN_VALUE; - } - - - // Adding hydrogens - //System.out.println(" adding " + count + " H atoms to atom " + index); - for (int i = 0; i < count; i++) { - SmilesAtom hydrogen = molecule.createAtom(); - hydrogen.setAtomicNumber((short) 1); - molecule.createBond(this, hydrogen, SmilesBond.TYPE_SINGLE); - } + + if (count > 0) + hydrogenCount = count; + return true; } /** @@ -174,10 +161,6 @@ return atomicNumber; } - private void setAtomicNumber(short i) { - atomicNumber = i; - } - /** * Returns the atomic mass of the atom. * @@ -242,7 +225,7 @@ final static int CHIRALITY_SQUARE_PLANAR = 8; static int getChiralityClass(String xx) { - return (" ;AL;OH;SP;TH;TP".indexOf(xx) + 1)/ 3; + return ("0;11;AL;33;TH;TP;OC;77;SP;".indexOf(xx) + 1)/ 3; } /** @@ -343,4 +326,5 @@ return (b.getAtom1() == this ? b.getAtom2() : b.getAtom1()).matchingAtom; } + } Modified: trunk/Jmol/src/org/jmol/smiles/SmilesMatcher.java =================================================================== --- trunk/Jmol/src/org/jmol/smiles/SmilesMatcher.java 2010-05-05 06:34:14 UTC (rev 13018) +++ trunk/Jmol/src/org/jmol/smiles/SmilesMatcher.java 2010-05-05 15:36:14 UTC (rev 13019) @@ -93,7 +93,7 @@ BitSet[] list = null; try { // create a topological model set from smiles - SmilesSearch search = (new SmilesParser()).parse(smiles); + SmilesSearch search = (new SmilesParser(false)).parse(smiles); search.isAll = isAll; int atomCount = search.patternAtomCount; Atom[] atoms = new Atom[atomCount]; @@ -162,7 +162,7 @@ */ public BitSet getSubstructureSet(String smiles, Atom[] atoms, int atomCount, boolean asSmarts, boolean isAll) throws Exception { - SmilesSearch search = (asSmarts ? SmartsParser.getMolecule(smiles) : SmilesParser.getMolecule(smiles)); + SmilesSearch search = SmilesParser.getMolecule(asSmarts, smiles); search.jmolAtoms = atoms; search.jmolAtomCount = atomCount; search.isAll = isAll; @@ -187,7 +187,7 @@ BitSet bsSelected, BitSet bsRequired, BitSet bsNot, boolean asSmarts, boolean isAll) throws Exception { - SmilesSearch search = (asSmarts ? SmartsParser.getMolecule(smiles) : SmilesParser.getMolecule(smiles)); + SmilesSearch search = SmilesParser.getMolecule(asSmarts, smiles); search.bsSelected = bsSelected; search.bsRequired = (bsRequired != null && bsRequired.cardinality() > 0 ? bsRequired : null); search.bsNot = bsNot; Modified: trunk/Jmol/src/org/jmol/smiles/SmilesParser.java =================================================================== --- trunk/Jmol/src/org/jmol/smiles/SmilesParser.java 2010-05-05 06:34:14 UTC (rev 13018) +++ trunk/Jmol/src/org/jmol/smiles/SmilesParser.java 2010-05-05 15:36:14 UTC (rev 13019) @@ -52,9 +52,13 @@ protected SmilesBond[] ringBonds; - public static SmilesSearch getMolecule(String pattern) throws InvalidSmilesException { - return (new SmilesParser()).parse(pattern); + public SmilesParser(boolean isSmarts) { + this.isSmarts = isSmarts; } + + public static SmilesSearch getMolecule(boolean isSmarts, String pattern) throws InvalidSmilesException { + return (new SmilesParser(isSmarts)).parse(pattern); + } /** * Parses a SMILES String @@ -74,15 +78,17 @@ if (!isSmarts) for (int i = molecule.patternAtomCount; --i >= 0; ) - molecule.getAtom(i).createMissingHydrogen(molecule); - - fixChirality(molecule); + if (!molecule.getAtom(i).setHydrogenCount(molecule)) + throw new InvalidSmilesException("unbracketed atoms must be one of: B C N O P S F Cl Br I"); + // Check for rings if (ringBonds != null) for (int i = 0; i < ringBonds.length; i++) if (ringBonds[i] != null) throw new InvalidSmilesException("Open ring"); + fixChirality(molecule); + return molecule; } @@ -91,7 +97,7 @@ SmilesAtom sAtom = molecule.getAtom(i); int chiralClass = sAtom.getChiralClass(); int nBonds = sAtom.getHydrogenCount(); - if (nBonds < 0) + if (nBonds < 0 || nBonds == Integer.MAX_VALUE) nBonds = 0; nBonds += sAtom.getBondsCount(); switch (chiralClass) { @@ -125,29 +131,31 @@ /** * Parses a part of a SMILES String - * - * @param molecule Resulting molecule - * @param pattern SMILES String - * @param currentAtom Current atom + * + * @param molecule + * Resulting molecule + * @param pattern + * SMILES String + * @param currentAtom + * Current atom * @throws InvalidSmilesException */ - protected void parseSmiles( - SmilesSearch molecule, - String pattern, - SmilesAtom currentAtom) throws InvalidSmilesException { - if ((pattern == null) || (pattern.length() == 0)) { + protected void parseSmiles(SmilesSearch molecule, String pattern, + SmilesAtom currentAtom) + throws InvalidSmilesException { + + if (pattern == null || pattern.length() == 0) return; - } // Branching int index = 0; + int len = pattern.length(); char ch = pattern.charAt(0); if (ch == '(') { index++; int currentIndex = index; int parenthesisCount = 1; - while ((currentIndex < pattern.length()) && - (parenthesisCount > 0)) { + while ((currentIndex < len) && (parenthesisCount > 0)) { switch (pattern.charAt(currentIndex)) { case '(': parenthesisCount++; @@ -163,7 +171,7 @@ String subSmiles = pattern.substring(index, currentIndex - 1); parseSmiles(molecule, subSmiles, currentAtom); index = currentIndex; - if (index >= pattern.length()) + if (index >= len) throw new InvalidSmilesException("Pattern must not end with ')'"); } @@ -179,7 +187,7 @@ // Atom ch = pattern.charAt(index); - if ((ch >= '0') && (ch <= '9')) { + if (Character.isDigit(ch)) { // Ring String subSmiles = pattern.substring(index, index + 1); parseRing(molecule, subSmiles, currentAtom, bondType); @@ -191,11 +199,9 @@ throw new InvalidSmilesException("Ring number must follow the % sign"); } int currentIndex = index; - while ((currentIndex < pattern.length()) && - (pattern.charAt(currentIndex) >= '0') && - (pattern.charAt(currentIndex) <= '9')) { + while (currentIndex < len + && Character.isDigit(pattern.charAt(currentIndex))) currentIndex++; - } String subSmiles = pattern.substring(index, currentIndex); parseRing(molecule, subSmiles, currentAtom, bondType); index = currentIndex; @@ -203,41 +209,30 @@ // Atom definition index++; int currentIndex = index; - while ((currentIndex < pattern.length()) && - (pattern.charAt(currentIndex) != ']')) { + while ((currentIndex < len) && (pattern.charAt(currentIndex) != ']')) { currentIndex++; } - if (currentIndex >= pattern.length()) { + if (currentIndex >= len) { throw new InvalidSmilesException("Unmatched ["); } String subSmiles = pattern.substring(index, currentIndex); currentAtom = parseAtom(molecule, subSmiles, currentAtom, bondType, true); index = currentIndex + 1; - } else if (((ch >= 'a') && (ch <= 'z')) || - ((ch >= 'A') && (ch <= 'Z')) || - (ch == '*')) { + } else if (ch == '*' || Character.isLetter(ch)) { // Atom definition - int size = 1; - if (index + 1 < pattern.length()) { - char secondChar = pattern.charAt(index + 1); - if ((ch >= 'A') && (ch <= 'Z') && - (secondChar >= 'a') && (secondChar <= 'z')) { - size = 2; - } - } + int size = (index + 1 < len + && Character.isLowerCase(pattern.charAt(index + 1)) ? 2 : 1); String subSmiles = pattern.substring(index, index + size); currentAtom = parseAtom(molecule, subSmiles, currentAtom, bondType, false); index += size; } // Next part of the SMILES String - if (index == 0) { - throw new InvalidSmilesException("Unexpected character: " + pattern.charAt(0)); - } - if (index < pattern.length()) { - String subSmiles = pattern.substring(index); - parseSmiles(molecule, subSmiles, currentAtom); - } + if (index == 0) + throw new InvalidSmilesException("Unexpected character: " + + pattern.charAt(0)); + if (index < len) + parseSmiles(molecule, pattern.substring(index), currentAtom); } /** @@ -300,7 +295,6 @@ + pattern.substring(index + 1, index + size))) throw new InvalidSmilesException("Invalid atom symbol"); index += size; - checkHydrogenCount(complete, pattern, index, newAtom); // Final check @@ -318,31 +312,31 @@ // Hydrogen count int hydrogenCount = Integer.MIN_VALUE; int len = pattern.length(); - if (index >= len) - return; - char ch = pattern.charAt(index); - if (ch == 'H' || isSmarts && ch == 'h') { - index++; - int pt = index; - while (pt < len && Character.isDigit(pattern.charAt(pt))) - pt++; - if (pt > index) { - try { - hydrogenCount = Integer.parseInt(pattern.substring(index, pt)); - } catch (NumberFormatException e) { - throw new InvalidSmilesException("Non numeric hydrogen count"); + if (index < len) { + char ch = pattern.charAt(index); + if (ch == 'H' || isSmarts && ch == 'h') { + index++; + int pt = index; + while (pt < len && Character.isDigit(pattern.charAt(pt))) + pt++; + if (pt > index) { + try { + hydrogenCount = Integer.parseInt(pattern.substring(index, pt)); + } catch (NumberFormatException e) { + throw new InvalidSmilesException("Non numeric hydrogen count"); + } + } else { + hydrogenCount = 1; } - } else { - hydrogenCount = 1; + index = pt; } - index = pt; + if (index < len) + throw new InvalidSmilesException( + "Unexpected characters after atom definition: " + + pattern.substring(index)); + if (ch == 'h') // minimum count + hydrogenCount = -hydrogenCount; } - if (index < len) - throw new InvalidSmilesException( - "Unexpected characters after atom definition: " - + pattern.substring(index)); - if (ch == 'h') // minimum count - hydrogenCount = -hydrogenCount; if (hydrogenCount == Integer.MIN_VALUE && complete) hydrogenCount = Integer.MAX_VALUE; newAtom.setHydrogenCount(hydrogenCount); Modified: trunk/Jmol/src/org/jmol/smiles/SmilesSearch.java =================================================================== --- trunk/Jmol/src/org/jmol/smiles/SmilesSearch.java 2010-05-05 06:34:14 UTC (rev 13018) +++ trunk/Jmol/src/org/jmol/smiles/SmilesSearch.java 2010-05-05 15:36:14 UTC (rev 13019) @@ -52,13 +52,13 @@ boolean isAll; boolean isSmarts; + private final static int INITIAL_ATOMS = 16; private SmilesAtom[] atoms = new SmilesAtom[INITIAL_ATOMS]; int patternAtomCount; boolean asVector; private Vector vReturn; private BitSet bsReturn = new BitSet(); - /* ============================================================= */ /* Atoms */ @@ -312,8 +312,15 @@ if (!checkChirality()) return true; BitSet bs = new BitSet(); - for (int k = 0; k < patternAtomCount; k++) - bs.set(atoms[k].getMatchingAtom()); + for (int k = 0; k < patternAtomCount; k++) { + int iAtom = atoms[k].getMatchingAtom(); + bs.set(iAtom); + if (!isSmarts) { + npH = atoms[k].getHydrogenCount(); + if (npH != Integer.MIN_VALUE && npH != Integer.MAX_VALUE) + getHydrogens(jmolAtoms[iAtom], bs); + } + } if (bsRequired != null && !bsRequired.intersects(bs)) return true; if (asVector) { @@ -358,11 +365,7 @@ atom1 = jmolAtoms[sAtom.getMatchingBondedAtom(0)]; break; case 1: - Atom atom = jmolAtoms[sAtom.getMatchingAtom()]; - Bond[] b = atom.getBonds(); - for (int i = 0; i < b.length; i++) - if ((atom = jmolAtoms[atom.getBondedAtomIndex(i)]).getElementNumber() == 1) - break; + atom1 = getHydrogens(jmolAtoms[sAtom.getMatchingAtom()], null); break; default: continue; @@ -380,7 +383,20 @@ return true; } - + private Atom getHydrogens(Atom atom, BitSet bsHydrogens) { + Bond[] b = atom.getBonds(); + Atom atomH = null; + for (int k = 0, i = 0; i < b.length; i++) + if ((atomH = jmolAtoms[k = atom.getBondedAtomIndex(i)]).getElementNumber() == 1) { + if (bsHydrogens == null) + break; + bsHydrogens.set(k); + } + return atomH; + } + + + Vector3f vTemp = new Vector3f(); Vector3f vA = new Vector3f(); Vector3f vB = new Vector3f(); Modified: trunk/Jmol/src/org/jmol/viewer/Jmol.properties =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2010-05-05 06:34:14 UTC (rev 13018) +++ trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2010-05-05 15:36:14 UTC (rev 13019) @@ -3,6 +3,8 @@ version=12.0.RC10_dev +# code: Smiles refactoring and efficiencies +# new feature: "smarts" does not include attached hydrogens in match # new feature: smiles/smarts/substructure with tetrahedral chirality # select smarts("C[C@@]([C]=O)([CH])[CH2]") @@ -15,7 +17,6 @@ # new feature: JME data saved in variable "jmeString" for later generation of 2D data # new feature: "smilesString".find("SMILES","smilesString" [, isAll (FALSE)] ) -# code: Smiles refactoring and efficiencies # bug fix: SMILES parser not properly checking explicit double bond check # new feature: SMILES matching expanded to aromatic types # bug fix: Spartan reader (compound document) misread# code: frequency reading standardized -- using auxiliaryInfo.modelProperties more effectively Modified: trunk/Jmol/test/org/jmol/smiles/TestSmilesParser.java =================================================================== --- trunk/Jmol/test/org/jmol/smiles/TestSmilesParser.java 2010-05-05 06:34:14 UTC (rev 13018) +++ trunk/Jmol/test/org/jmol/smiles/TestSmilesParser.java 2010-05-05 15:36:14 UTC (rev 13019) @@ -259,7 +259,7 @@ SmilesAtom atomN = molecule.createAtom(); atomN.setSymbol("N"); SmilesAtom atomC1 = molecule.createAtom(); - atomC1.setChiralClass(""); + atomC1.setChiralClass(SmilesAtom.CHIRALITY_TETRAHEDRAL); atomC1.setChiralOrder(2); atomC1.setSymbol("C"); molecule.createBond(atomN, atomC1, SmilesBond.TYPE_SINGLE); @@ -289,7 +289,7 @@ SmilesAtom atomO1 = molecule.createAtom(); atomO1.setSymbol("O"); SmilesAtom atomC1 = molecule.createAtom(); - atomC1.setChiralClass(""); + atomC1.setChiralClass(SmilesAtom.CHIRALITY_TETRAHEDRAL); atomC1.setChiralOrder(1); atomC1.setSymbol("C"); molecule.createBond(atomO1, atomC1, SmilesBond.TYPE_SINGLE); @@ -307,7 +307,7 @@ atomC5.setSymbol("C"); molecule.createBond(atomC4, atomC5, SmilesBond.TYPE_SINGLE); SmilesAtom atomC6 = molecule.createAtom(); - atomC6.setChiralClass(""); + atomC6.setChiralClass(SmilesAtom.CHIRALITY_TETRAHEDRAL); atomC6.setChiralOrder(1); atomC6.setSymbol("C"); molecule.createBond(atomC5, atomC6, SmilesBond.TYPE_SINGLE); @@ -1041,7 +1041,7 @@ SmilesAtom atomN = molecule.createAtom(); atomN.setSymbol("N"); SmilesAtom atomC1 = molecule.createAtom(); - atomC1.setChiralClass(""); + atomC1.setChiralClass(SmilesAtom.CHIRALITY_TETRAHEDRAL); atomC1.setChiralOrder(1); atomC1.setSymbol("C"); molecule.createBond(atomN, atomC1, SmilesBond.TYPE_SINGLE); @@ -1078,7 +1078,7 @@ atomC2.setSymbol("C"); molecule.createBond(atomC1, atomC2, SmilesBond.TYPE_SINGLE); SmilesAtom atomC3 = molecule.createAtom(); - atomC3.setChiralClass(""); + atomC3.setChiralClass(SmilesAtom.CHIRALITY_TETRAHEDRAL); atomC3.setChiralOrder(1); atomC3.setSymbol("C"); molecule.createBond(atomC2, atomC3, SmilesBond.TYPE_SINGLE); @@ -1096,7 +1096,7 @@ atomC7.setSymbol("C"); molecule.createBond(atomC6, atomC7, SmilesBond.TYPE_SINGLE); SmilesAtom atomC8 = molecule.createAtom(); - atomC8.setChiralClass(""); + atomC8.setChiralClass(SmilesAtom.CHIRALITY_TETRAHEDRAL); atomC8.setChiralOrder(1); atomC8.setSymbol("C"); molecule.createBond(atomC7, atomC8, SmilesBond.TYPE_SINGLE); @@ -1141,7 +1141,7 @@ atomCl.setSymbol("Cl"); molecule.createBond(atomC1, atomCl, SmilesBond.TYPE_SINGLE); SmilesAtom atomC2 = molecule.createAtom(); - atomC2.setChiralClass(""); + atomC2.setChiralClass(SmilesAtom.CHIRALITY_ALLENE); atomC2.setChiralOrder(1); atomC2.setSymbol("C"); molecule.createBond(atomC1, atomC2, SmilesBond.TYPE_DOUBLE); @@ -1171,7 +1171,7 @@ atomCl.setSymbol("Cl"); molecule.createBond(atomC1, atomCl, SmilesBond.TYPE_SINGLE); SmilesAtom atomC2 = molecule.createAtom(); - atomC2.setChiralClass("AL"); + atomC2.setChiralClass(SmilesAtom.CHIRALITY_ALLENE); atomC2.setChiralOrder(1); atomC2.setSymbol("C"); molecule.createBond(atomC1, atomC2, SmilesBond.TYPE_DOUBLE); @@ -1195,7 +1195,7 @@ SmilesAtom atomF = molecule.createAtom(); atomF.setSymbol("F"); SmilesAtom atomPo = molecule.createAtom(); - atomPo.setChiralClass("SP"); + atomPo.setChiralClass(SmilesAtom.CHIRALITY_SQUARE_PLANAR); atomPo.setChiralOrder(1); atomPo.setSymbol("Po"); molecule.createBond(atomF, atomPo, SmilesBond.TYPE_SINGLE); @@ -1218,7 +1218,7 @@ atomC.setSymbol("C"); molecule.createBond(atomO, atomC, SmilesBond.TYPE_DOUBLE); SmilesAtom atomAs = molecule.createAtom(); - atomAs.setChiralClass(""); + atomAs.setChiralClass(SmilesAtom.CHIRALITY_TRIGONAL_BIPYRAMIDAL); atomAs.setChiralOrder(1); atomAs.setSymbol("As"); molecule.createBond(atomC, atomAs, SmilesBond.TYPE_SINGLE); @@ -1246,7 +1246,7 @@ atomC.setSymbol("C"); molecule.createBond(atomO, atomC, SmilesBond.TYPE_DOUBLE); SmilesAtom atomCo = molecule.createAtom(); - atomCo.setChiralClass(""); + atomCo.setChiralClass(SmilesAtom.CHIRALITY_OCTAHEDRAL); atomCo.setChiralOrder(1); atomCo.setSymbol("Co"); molecule.createBond(atomC, atomCo, SmilesBond.TYPE_SINGLE); @@ -1278,7 +1278,7 @@ */ private static void checkMolecule(String smiles, SmilesSearch expected) { try { - SmilesSearch molecule = SmilesParser.getMolecule(smiles); + SmilesSearch molecule = SmilesParser.getMolecule(false, smiles); assertTrue(areMoleculesEqual(molecule, expected)); } catch (InvalidSmilesException e) { fail("InvalidSmilesException: " + e.getMessage()); @@ -1292,6 +1292,8 @@ * @param bonded Other atom to bond to */ private void addHydrogen(SmilesSearch molecule, SmilesAtom bonded) { + if (true) + return; SmilesAtom atomH = molecule.createAtom(); atomH.setSymbol("H"); if (bonded != null) { @@ -1379,15 +1381,7 @@ atom2.getCharge() + ")"); return false; } - if (atom1.getChiralClass() == null) { - if (atom2.getChiralClass() != null) { - Logger.error( - "Atom " + i + " chiral class (" + - atom1.getChiralClass() + "," + - atom2.getChiralClass() + ")"); - return false; - } - } else if (!atom1.getChiralClass().equals(atom2.getChiralClass())) { + if (atom1.getChiralClass() != atom2.getChiralClass()) { Logger.error( "Atom " + i + " chiral class (" + atom1.getChiralClass() + "," + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |