Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Perceive atom types also when aromaticity from the SMILES is kept
  • Loading branch information
egonw committed Nov 1, 2011
1 parent d6b8c8e commit 2413197
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions src/main/org/openscience/cdk/smiles/SmilesParser.java
Expand Up @@ -254,25 +254,28 @@ public IMolecule parseSmiles(String smiles) throws InvalidSmilesException {
molecule.addStereoElement(l4Chiral);
}

if (!preservingAromaticity ) {
// perceive atom types
CDKAtomTypeMatcher matcher = CDKAtomTypeMatcher.getInstance(molecule.getBuilder());
int i = 0;
for (IAtom atom : molecule.atoms()) {
i++;
try {
IAtomType type = matcher.findMatchingAtomType(molecule, atom);
AtomTypeManipulator.configure(atom, type);
} catch (NoSuchAtomTypeException exception) {
logger.warn("Cannot percieve atom type for the ", i, "th atom: ", atom.getSymbol());
// perceive atom types
CDKAtomTypeMatcher matcher = CDKAtomTypeMatcher.getInstance(molecule.getBuilder());
int i = 0;
for (IAtom atom : molecule.atoms()) {
i++;
try {
IAtomType type = matcher.findMatchingAtomType(molecule, atom);
boolean isAromatic = atom.getFlag(CDKConstants.ISAROMATIC);
AtomTypeManipulator.configure(atom, type);
atom.setFlag(CDKConstants.ISAROMATIC, isAromatic);
} catch (NoSuchAtomTypeException exception) {
logger.warn("Cannot percieve atom type for the ", i, "th atom: ", atom.getSymbol());
atom.setAtomTypeName("X");
} catch (Exception exception) {
logger.error("Caught unexpected Exception during atom typing.");
logger.debug(exception);
atom.setAtomTypeName("X");
} catch (Exception exception) {
logger.error("Caught unexpected Exception during atom typing.");
logger.debug(exception);
atom.setAtomTypeName("X");
}
}
this.addImplicitHydrogens(molecule);
}
this.addImplicitHydrogens(molecule);

if (!preservingAromaticity ) {
this.perceiveAromaticity(molecule);
}
else {
Expand Down

0 comments on commit 2413197

Please sign in to comment.