private static void initializeMolecule(IAtomContainer molecule) throws CDKException { CDKHydrogenAdder adder = CDKHydrogenAdder.getInstance(SilentChemObjectBuilder.getInstance()); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(molecule); adder.addImplicitHydrogens(molecule); removeStrangeImidoSubstructure(molecule); }
static public IAtomContainer prepareMolecule(IAtomContainer molecule) throws CDKException { if(!ConnectivityChecker.isConnected(molecule)){ throw new CDKException("The structure is not fully connected"); } AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(molecule); CDKHueckelAromaticityDetector.detectAromaticity(molecule); CDKHydrogenAdder hydrogenator = CDKHydrogenAdder.getInstance(molecule.getBuilder()); hydrogenator.addImplicitHydrogens(molecule); AtomContainerManipulator.convertImplicitToExplicitHydrogens(molecule); return molecule; }
/** * Test to recognize if this IAtomContainer_2 matches correctly into the CDKAtomTypes. */ @Test public void testAtomTypesAtomContainer2() throws Exception { IAtomContainer moleculeTest = getExpectedProducts().getAtomContainer(0); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(moleculeTest); makeSureAtomTypesAreRecognized(moleculeTest); }
@Test public void testOmeprazol() throws InvalidSmilesException, CDKException { IAtomContainer methane = smilesParser.parseSmiles("COc2ccc1[nH]c(nc1c2)S(=O)Cc3ncc(C)c(OC)c3C"); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(methane); double volume = VABCVolume.calculate(methane); Assert.assertEquals(292.23, volume, 0.01); }
@Test public void testAdeforir() throws InvalidSmilesException, CDKException { IAtomContainer methane = smilesParser.parseSmiles("Nc1ncnc2n(CCOCP(=O)(O)O)cnc12"); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(methane); double volume = VABCVolume.calculate(methane); Assert.assertEquals(199.84, volume, 0.01); }
@Test public void testMethaneWithExplicitHydrogens() throws InvalidSmilesException, CDKException { IAtomContainer methane = smilesParser.parseSmiles("[H]C([H])([H])[H]"); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(methane); double volume = VABCVolume.calculate(methane); Assert.assertEquals(25.8524433266667, volume, 0.01); }
@Test public void testCS2() throws InvalidSmilesException, CDKException { IAtomContainer methane = smilesParser.parseSmiles("S=C=S"); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(methane); double volume = VABCVolume.calculate(methane); Assert.assertEquals(57.5975740402667, volume, 0.01); }
@Test public void testTriEthylPhosphite() throws InvalidSmilesException, CDKException { IAtomContainer methane = smilesParser.parseSmiles("CCOP(=O)(OCC)OCC"); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(methane); double volume = VABCVolume.calculate(methane); Assert.assertEquals(167.320526666244, volume, 0.01); }
@Test public void testMF4() throws Exception { IAtomContainer mol = smilesParser.parseSmiles("c1ccc(cc1)c2c(oc(n2)N(CCO)CCO)c3ccccc3"); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol); fragmenter.generateFragments(mol); List<String> frameworks = Arrays.asList(fragmenter.getFrameworks()); Assert.assertEquals(3, frameworks.size()); assertThat(frameworks, hasItems("n1coc(c1)-c2ccccc2", "n1coc(-c2ccccc2)c1-c3ccccc3", "n1cocc1-c2ccccc2")); }
@Test public void testAmineOxide() throws Exception { String smiles = "CN(C)(=O)CCC=C2c1ccccc1CCc3ccccc23"; IAtomContainer mol = smilesParser.parseSmiles(smiles); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol); Assert.assertEquals("N.oxide", mol.getAtom(1).getAtomTypeName()); }
@Test public void testGetFragmentsAsContainers() throws Exception { IAtomContainer biphenyl = TestMoleculeFactory.makeBiphenyl(); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(biphenyl); Aromaticity.cdkLegacy().apply(biphenyl); MurckoFragmenter fragmenter = new MurckoFragmenter(true, 6); fragmenter.generateFragments(biphenyl); IAtomContainer[] fragments = fragmenter.getFragmentsAsContainers(); assertThat(fragments.length, is(2)); assertThat(fragments[0].getAtomCount(), is(12)); assertThat(fragments[1].getAtomCount(), is(6)); }
@Test public void testFingerprinter() throws java.lang.Exception { ShortestPathFingerprinter fingerprinter = new ShortestPathFingerprinter(); Assert.assertNotNull(fingerprinter); IAtomContainer mol = TestMoleculeFactory.makeIndole(); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol); BitSet bs = fingerprinter.getBitFingerprint(mol).asBitSet(); IAtomContainer frag1 = TestMoleculeFactory.makePyrrole(); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(frag1); BitSet bs1 = fingerprinter.getBitFingerprint(frag1).asBitSet(); Assert.assertTrue(FingerprinterTool.isSubset(bs, bs1)); }
@Test public void testFingerprinter_int() throws java.lang.Exception { ShortestPathFingerprinter fingerprinter = new ShortestPathFingerprinter(512); Assert.assertNotNull(fingerprinter); IAtomContainer mol = TestMoleculeFactory.makeIndole(); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol); BitSet bs = fingerprinter.getBitFingerprint(mol).asBitSet(); IAtomContainer frag1 = TestMoleculeFactory.makePyrrole(); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(frag1); BitSet bs1 = fingerprinter.getBitFingerprint(frag1).asBitSet(); Assert.assertTrue(FingerprinterTool.isSubset(bs, bs1)); }
@Test public void testFingerprinter_int_int() throws java.lang.Exception { ShortestPathFingerprinter fingerprinter = new ShortestPathFingerprinter(1024); Assert.assertNotNull(fingerprinter); IAtomContainer mol = TestMoleculeFactory.makeIndole(); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol); BitSet bs = fingerprinter.getBitFingerprint(mol).asBitSet(); IAtomContainer frag1 = TestMoleculeFactory.makePyrrole(); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(frag1); BitSet bs1 = fingerprinter.getBitFingerprint(frag1).asBitSet(); Assert.assertTrue(FingerprinterTool.isSubset(bs, bs1)); }
@Test public void testGenerateFingerprintAnthracene() throws InvalidSmilesException, Exception { String smiles = "C1=CC2=CC3=CC=CC=C3C=C2C=C1"; SmilesParser smilesParser = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer molecule = smilesParser.parseSmiles(smiles); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(molecule); Aromaticity.cdkLegacy().apply(molecule); ShortestPathFingerprinter fingerprint = new ShortestPathFingerprinter(1024); BitSet fingerprint1; fingerprint1 = fingerprint.getBitFingerprint(molecule).asBitSet(); org.junit.Assert.assertEquals(10, fingerprint1.cardinality()); }
@Test public void testGenerateFingerprintNaphthalene() throws InvalidSmilesException, Exception { String smiles = "C1=CC2=CC=CC=C2C=C1"; SmilesParser smilesParser = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer molecule = smilesParser.parseSmiles(smiles); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(molecule); Aromaticity.cdkLegacy().apply(molecule); ShortestPathFingerprinter fingerprint = new ShortestPathFingerprinter(1024); BitSet fingerprint1; fingerprint1 = fingerprint.getBitFingerprint(molecule).asBitSet(); org.junit.Assert.assertEquals(8, fingerprint1.cardinality()); }
@Test public void testAmideIncluded() throws Exception { String amide = "CCNC(=O)CC(C)C"; // N-ethyl-3-methylbutanamide SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol = sp.parseSmiles(amide); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol); addExplicitHydrogens(mol); IMolecularDescriptor descriptor = new RotatableBondsCountDescriptor(); descriptor.setParameters(new Object[]{false, false}); DescriptorValue result = descriptor.calculate(mol); Assert.assertThat(((IntegerResult) result.getValue()).intValue(), is(4)); }
@Test public void testgetBitFingerprint_IAtomContainer() throws java.lang.Exception { ShortestPathFingerprinter fingerprinter = new ShortestPathFingerprinter(); IAtomContainer mol = TestMoleculeFactory.makeIndole(); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol); IBitFingerprint bs = fingerprinter.getBitFingerprint(mol); Assert.assertNotNull(bs); Assert.assertEquals(fingerprinter.getSize(), bs.size()); }
@Test public void testAnOtherDoubleRing() throws CDKException { IAtomContainer mol = sp.parseSmiles("c1cccc2cccc2c1"); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol); atasc.decideBondOrder(mol, true); Assert.assertEquals(mol.getAtom(1).getHybridization(), IAtomType.Hybridization.SP2); int doubleBondCount = 0; for (IBond bond : mol.bonds()) { if (bond.getOrder() == IBond.Order.DOUBLE) doubleBondCount++; } Assert.assertEquals(5, doubleBondCount); }
@Test public void testCyclobutadiene() throws CDKException { IAtomContainer mol = sp.parseSmiles("c1ccc1"); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol); atasc.decideBondOrder(mol, true); Assert.assertEquals(mol.getAtom(1).getHybridization(), IAtomType.Hybridization.SP2); Assert.assertEquals(IBond.Order.DOUBLE, mol.getBond(0).getOrder()); Assert.assertEquals(IBond.Order.SINGLE, mol.getBond(1).getOrder()); Assert.assertEquals(IBond.Order.DOUBLE, mol.getBond(2).getOrder()); Assert.assertEquals(IBond.Order.SINGLE, mol.getBond(3).getOrder()); }