Skip to content

Instantly share code, notes, and snippets.

@johnmay
Created June 8, 2015 21:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnmay/711a42227f86fb339e9f to your computer and use it in GitHub Desktop.
Save johnmay/711a42227f86fb339e9f to your computer and use it in GitHub Desktop.
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