/** * @cdk.bug 2013689 * @throws Exception */ @Test public void testAromaticBondOrders() throws Exception { GasteigerPEPEPartialCharges peoe = new GasteigerPEPEPartialCharges(); String smiles1 = "c1ccccc1"; SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol1 = sp.parseSmiles(smiles1); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol1); Aromaticity.cdkLegacy().apply(mol1); addExplicitHydrogens(mol1); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol1); lpcheck.saturate(mol1); List<Boolean> oldBondOrders = new ArrayList<Boolean>(); for (int i = 0; i < mol1.getBondCount(); i++) oldBondOrders.add(mol1.getBond(i).getFlag(CDKConstants.ISAROMATIC)); peoe.calculateCharges(mol1); List<Boolean> newBondOrders = new ArrayList<Boolean>(); for (int i = 0; i < mol1.getBondCount(); i++) newBondOrders.add(mol1.getBond(i).getFlag(CDKConstants.ISAROMATIC)); for (int i = 0; i < oldBondOrders.size(); i++) { Assert.assertEquals("bond " + i + " does not match", oldBondOrders.get(i), newBondOrders.get(i)); } }
/** * */ @Test public void testAssignrPiMarsilliFactors_IAtomContainerSet() throws Exception { GasteigerPEPEPartialCharges peoe = new GasteigerPEPEPartialCharges(); IAtomContainer molecule = builder.newInstance(IAtomContainer.class); molecule.addAtom(new Atom("C")); molecule.addAtom(new Atom("F")); molecule.addBond(0, 1, IBond.Order.SINGLE); addExplicitHydrogens(molecule); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(molecule); lpcheck.saturate(molecule); for (Iterator<IAtom> it = molecule.atoms().iterator(); it.hasNext();) it.next().setCharge(0.0); IAtomContainerSet set = builder.newInstance(IAtomContainerSet.class); set.addAtomContainer(molecule); set.addAtomContainer(molecule); addExplicitHydrogens(molecule); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(molecule); lpcheck.saturate(molecule); Assert.assertNotNull(peoe.assignrPiMarsilliFactors(set)); } }
@Test public void testAromaticAndNonAromatic() throws Exception { GasteigerPEPEPartialCharges peoe = new GasteigerPEPEPartialCharges(); String smiles1 = "c1ccccc1"; String smiles2 = "C1=CC=CC=C1"; SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol1 = sp.parseSmiles(smiles1); IAtomContainer mol2 = sp.parseSmiles(smiles2); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol1); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol2); Aromaticity.cdkLegacy().apply(mol1); Aromaticity.cdkLegacy().apply(mol2); addExplicitHydrogens(mol1); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol1); lpcheck.saturate(mol1); addExplicitHydrogens(mol2); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol2); lpcheck.saturate(mol2); peoe.calculateCharges(mol1); peoe.calculateCharges(mol2); for (int i = 0; i < mol1.getAtomCount(); i++) { Assert.assertEquals("charge on atom " + i + " does not match", mol1.getAtom(i).getCharge(), mol2.getAtom(i) .getCharge(), 0.01); } }
/** * */ @Test public void testAssignGasteigerPiPartialCharges_IAtomContainer_Boolean() throws Exception { double[] testResult = {0.0, 0.0, 0.0, 0.0, 0.0}; GasteigerPEPEPartialCharges peoe = new GasteigerPEPEPartialCharges(); IAtomContainer molecule = builder.newInstance(IAtomContainer.class); molecule.addAtom(new Atom("C")); molecule.addAtom(new Atom("F")); molecule.addBond(0, 1, IBond.Order.SINGLE); addExplicitHydrogens(molecule); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(molecule); lpcheck.saturate(molecule); peoe.assignGasteigerPiPartialCharges(molecule, true); for (int i = 0; i < molecule.getAtomCount(); i++) { //logger.debug("Charge for atom:"+i+" S:"+mol.getAtomAt(i).getSymbol()+" Charge:"+mol.getAtomAt(i).getCharge()); Assert.assertEquals(testResult[i], molecule.getAtom(i).getCharge(), 0.01); } }
/** * A unit test for JUnit with methylenfluoride * * @cdk.inchi InChI=1/CH3F/c1-2/h1H3 */ @Test public void testCalculateCharges_IAtomContainer() throws Exception { double[] testResult = {0.0, 0.0, 0.0, 0.0, 0.0}; GasteigerPEPEPartialCharges peoe = new GasteigerPEPEPartialCharges(); IAtomContainer molecule = builder.newInstance(IAtomContainer.class); molecule.addAtom(new Atom("C")); molecule.addAtom(new Atom("F")); molecule.addBond(0, 1, IBond.Order.SINGLE); addExplicitHydrogens(molecule); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(molecule); lpcheck.saturate(molecule); peoe.calculateCharges(molecule); for (int i = 0; i < molecule.getAtomCount(); i++) { //logger.debug("Charge for atom:"+i+" S:"+mol.getAtomAt(i).getSymbol()+" Charge:"+mol.getAtomAt(i).getCharge()); Assert.assertEquals(testResult[i], molecule.getAtom(i).getCharge(), 0.01); } }