Created
June 8, 2015 21:07
-
-
Save johnmay/711a42227f86fb339e9f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BufferedReader brdr = ...; | |
// create once and reuse | |
IChemObjectBuilder bldr = SilentChemObjectBuilder.getInstance(); | |
Aromaticity arom = new Aromaticity(ElectronDonation.daylight(), | |
Cycles.or(Cycles.all(), Cycles.all(6))); | |
// SMILES, implicit h already present | |
SmilesParser smipar = new SmilesParser(bldr); | |
String line; | |
while ((line = brdr.readLine()) != null) { | |
try { | |
IAtomContainer mol = smipar.parseSmiles(line); | |
arom.apply(mol); | |
AtomContainerManipulator.suppressHydrogens(mol); | |
} catch (InvalidSmilesException ex) { | |
// log.. normally bad Kekulé input | |
} catch (CDKException e) { | |
// log.. complex ring system couldn't calc arom - avoid SSSR | |
} | |
} | |
// SDfile V2000, implicit h already present | |
MDLV2000Reader mdlr = new MDLV2000Reader(brdr); | |
IAtomContainer mol; | |
while ((mol = mdlr.read(bldr.newInstance(IAtomContainer.class, 0,0,0,0))) != null) { | |
try { | |
arom.apply(mol); | |
AtomContainerManipulator.suppressHydrogens(mol); | |
} catch (CDKException e) { | |
// log.. complex ring system couldn't calc arom - avoid SSSR | |
} | |
} | |
// InChI, implicit h already present | |
// CML, implicit h maybe present -> atom type + guess hydrogen counts |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment