Skip to content

Instantly share code, notes, and snippets.

@johnmay
Created October 15, 2015 11:42
Show Gist options
  • Select an option

  • Save johnmay/3ee0e6fa913464b1a9f7 to your computer and use it in GitHub Desktop.

Select an option

Save johnmay/3ee0e6fa913464b1a9f7 to your computer and use it in GitHub Desktop.
// Pattern interface should be used for matching rather than SMARTSQueryTool,
// more efficient and easier to use.
Pattern carboxy = SmartsPattern.compile("[Ov2X2H1+0]-[Cv4X3]=[Ov2X1H0]", bldr);
// Mappings object has several utils, we need basics only here
for (int[] mapping : caboxy.matchAll(mol).uniqueAtoms()) {
IAtom hydroxy = mol.getAtom(mapping[0]);
hydroxy.setImplicitHydrogenCount(0);
hydroxy.setFormalCharge(-1);
}
// don't output Canonical SMILES
String smi = SmilesGenerator.isomeric().create(mol);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment