private List<String> getSmilesFromAtomContainers(Collection<IAtomContainer> mols) { List<String> smis = new ArrayList<String>(); for (IAtomContainer mol : mols) { try { AtomContainerManipulator.clearAtomConfigurations(mol); for (IAtom atom : mol.atoms()) atom.setImplicitHydrogenCount(null); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol); CDKHydrogenAdder.getInstance(mol.getBuilder()).addImplicitHydrogens(mol); Aromaticity.cdkLegacy().apply(mol); smis.add(smigen.create(mol)); } catch (CDKException e) { LoggingToolFactory.createLoggingTool(getClass()).error(e); } } return smis; }
/** * * @param molecule * @throws CDKException */ public static void aromatizeCDK(IAtomContainer molecule) throws CDKException { ElectronDonation model = ElectronDonation.cdk(); CycleFinder cycles = Cycles.cdkAromaticSet(); Aromaticity aromaticity = new Aromaticity(model, cycles); ExtAtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(molecule); try { aromaticity.apply(molecule); } catch (CDKException e) { logger.log(Level.WARNING, "Aromaticity detection failed due to presence of unset " + "atom hybridisation", molecule.getID()); } }
private void perceiveAromaticity() { try { if (cdkAromaticBonds==null) { cdkAromaticBonds = Aromaticity.cdkLegacy().findBonds(molecule); } // clear existing flags molecule.setFlag(ISAROMATIC, false); for (IBond bond : molecule.bonds()) bond.setIsAromatic(false); for (IAtom atom : molecule.atoms()) atom.setIsAromatic(false); // set the new flags for (final IBond bond : cdkAromaticBonds) { bond.setIsAromatic(true); bond.getBegin().setIsAromatic(true); bond.getEnd().setIsAromatic(true); } molecule.setFlag(ISAROMATIC, !cdkAromaticBonds.isEmpty()); } catch (CDKException e) { throw new RuntimeException(e); } }
@Override public Map<String, Integer> getRawFingerprint(IAtomContainer atomContainer) throws CDKException { aromaticity.apply(atomContainer); final String smiles = replaceDigits(gen.create(atomContainer)); final Map<String, Integer> map = new HashMap<String, Integer>(); for (int i = 0, l = smiles.length() - n + 1; i < l; i++) { String subsmi = smiles.substring(i, i + n); Integer count = map.get(subsmi); if (count == null) map.put(subsmi, 1); else map.put(subsmi, count + 1); } return map; }
static void prepare(IAtomContainer target) { // apply the daylight aromaticity model try { Cycles.markRingAtomsAndBonds(target); arom.apply(target); } catch (CDKException e) { LoggingToolFactory.createLoggingTool(SmartsPattern.class).error(e); } }
private List<String> getSmilesFromAtomContainers(Collection<IAtomContainer> mols) { List<String> smis = new ArrayList<String>(); for (IAtomContainer mol : mols) { try { AtomContainerManipulator.clearAtomConfigurations(mol); for (IAtom atom : mol.atoms()) atom.setImplicitHydrogenCount(null); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol); CDKHydrogenAdder.getInstance(mol.getBuilder()).addImplicitHydrogens(mol); Aromaticity.cdkLegacy().apply(mol); smis.add(smigen.create(mol)); } catch (CDKException e) { LoggingToolFactory.createLoggingTool(getClass()).error(e); } } return smis; }
/** * * @param molecule * @throws CDKException */ public static void aromatizeCDK(IAtomContainer molecule) throws CDKException { ElectronDonation model = ElectronDonation.cdk(); CycleFinder cycles = Cycles.cdkAromaticSet(); Aromaticity aromaticity = new Aromaticity(model, cycles); ExtAtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(molecule); try { aromaticity.apply(molecule); } catch (CDKException e) { logger.log(Level.WARNING, "Aromaticity detection failed due to presence of unset " + "atom hybridisation", molecule.getID()); } }
public static void prepare(IAtomContainer target) { // apply the daylight aromaticity model try { Cycles.markRingAtomsAndBonds(target); arom.apply(target); } catch (CDKException e) { LoggingToolFactory.createLoggingTool(SmartsPattern.class).error(e); } }
@Test public void subset() throws Exception { assertThat(daylight.findBonds(smiles("[O-][Cu++]123([O-])CN4C=NC5=C4C(N=CN5)=[O+]1.O=S(=O)([OH+]2)[OH+]3")) .size(), is(5)); }
@Ignore("moved to SMILES2Mol2WriterTest") public void testWriterForAmide() throws Exception { IAtomContainer molecule = mock(IAtomContainer.class); Aromaticity.cdkLegacy().apply(molecule); StringWriter swriter = new StringWriter(); Mol2Writer writer = new Mol2Writer(swriter); writer.write(molecule); writer.close(); Assert.assertTrue(swriter.getBuffer().toString().indexOf("1 C1 0.000 0.000 0.000 C.3") > 0); Assert.assertTrue(swriter.getBuffer().toString().indexOf("3 O3 0.000 0.000 0.000 O.") > 0); Assert.assertTrue(swriter.getBuffer().toString().indexOf("4 N4 0.000 0.000 0.000 N.a") > 0); Assert.assertTrue(swriter.getBuffer().toString().indexOf("1 2 1 1") > 0); Assert.assertTrue("Amide bond not properly reported", swriter.getBuffer().toString().indexOf("3 4 2 am") > 0); Assert.assertTrue(swriter.getBuffer().toString().indexOf("4 5 4 1") > 0); }
@Override public IBitFingerprint getBitFingerprint(IAtomContainer atomContainer) throws CDKException { int bitsetLength = queries.length; BitSet fingerPrint = new BitSet(bitsetLength); { SmartsMatchers.prepare(atomContainer, true); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(atomContainer); Aromaticity aroma = new Aromaticity(ElectronDonation.cdk(), Cycles.cdkAromaticSet()); aroma.apply(atomContainer); } for (int i = 0; i < queries.length; i++) { boolean status = queries[i].matches(atomContainer); if (status) fingerPrint.set(i, true); } return new BitSetFingerprint(fingerPrint); }
@Test public void clearFlags_cyclobutadiene() throws Exception { IAtomContainer cyclobutadiene = smiles("c1ccc1"); daylight.apply(cyclobutadiene); for (IBond bond : cyclobutadiene.bonds()) assertFalse(bond.getFlag(CDKConstants.ISAROMATIC)); for (IAtom atom : cyclobutadiene.atoms()) assertFalse(atom.getFlag(CDKConstants.ISAROMATIC)); }
@Ignore("moved to SMILES2Mol2WriterTest") public void testWriter2() throws Exception { IAtomContainer molecule = mock(IAtomContainer.class); Aromaticity.cdkLegacy().apply(molecule); StringWriter swriter = new StringWriter(); Mol2Writer writer = new Mol2Writer(swriter); writer.write(molecule); writer.close(); Assert.assertTrue("Aromatic atom not properly reported", swriter.getBuffer().toString().indexOf("1 C1 0.000 0.000 0.000 C.ar") > 0); Assert.assertTrue(swriter.getBuffer().toString().indexOf("8 O8 0.000 0.000 0.000 O.2") > 0); Assert.assertTrue(swriter.getBuffer().toString().indexOf("7 C7 0.000 0.000 0.000 C.2") > 0); Assert.assertTrue("Aromatic bond not properly reported", swriter.getBuffer().toString().indexOf("1 2 1 ar") > 0); Assert.assertTrue(swriter.getBuffer().toString().indexOf("8 8 7 2") > 0); }
/** * * @param molecule * @throws CDKException */ public static void aromatizeDayLight(IAtomContainer molecule) throws CDKException { ElectronDonation model = ElectronDonation.daylight(); CycleFinder cycles = Cycles.or(Cycles.all(), Cycles.relevant()); Aromaticity aromaticity = new Aromaticity(model, cycles); try { aromaticity.apply(molecule); } catch (CDKException e) { logger.log(Level.WARNING, "Aromaticity detection failed due to presence of unset " + "atom hybridisation", molecule.getID()); } }
@Test public void clearFlags_quinone() throws Exception { IAtomContainer quinone = smiles("O=c1ccc(=O)cc1"); daylight.apply(quinone); for (IBond bond : quinone.bonds()) assertFalse(bond.getFlag(CDKConstants.ISAROMATIC)); for (IAtom atom : quinone.atoms()) assertFalse(atom.getFlag(CDKConstants.ISAROMATIC)); }
@Test public void test2() throws java.lang.Exception { IAtomContainer mol = TestMoleculeFactory.makeAlphaPinene(); IAtomContainer frag1 = TestMoleculeFactory.makeCyclohexane(); // no double bond in ring AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(frag1); Aromaticity.cdkLegacy().apply(mol); Aromaticity.cdkLegacy().apply(frag1); if (standAlone) { System.out.println("Cyclohexane is a subgraph of alpha-Pinen: " + uiTester.isSubgraph(mol, frag1)); } else { Assert.assertTrue(!uiTester.isSubgraph(mol, frag1)); } }