GasteigerMarsiliPartialCharges implements IChargeCalculator { @Override public void calculateCharges(IAtomContainer container) throws CDKException { try { this.assignGasteigerMarsiliSigmaPartialCharges(container, true); } catch (Exception exception) { throw new CDKException("Could not calculate Gasteiger-Marsili sigma charges: " + exception.getMessage(), exception); } } GasteigerMarsiliPartialCharges(); void setChiCatHydrogen(double chiCat); void setMaxGasteigerDamp(double damp); void setMaxGasteigerIters(double iters); double getChiCatHydrogen(); double getMaxGasteigerDamp(); double getMaxGasteigerIters(); IAtomContainer assignGasteigerMarsiliSigmaPartialCharges(IAtomContainer ac, boolean setCharge); @Override void calculateCharges(IAtomContainer container); int getStepSize(); void setStepSize(int step); double[] assignGasteigerSigmaMarsiliFactors(IAtomContainer ac);  }
@Test public void testCalculateCharges_IAtomContainer() throws Exception { double[] testResult = {0.07915, -0.25264, 0.05783, 0.05783, 0.05783}; GasteigerMarsiliPartialCharges peoe = new GasteigerMarsiliPartialCharges(); 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++) { Assert.assertEquals(testResult[i], molecule.getAtom(i).getCharge(), 0.01); } }
@Test(expected = CDKException.class) public void testUndefinedPartialCharge() throws Exception { String filename = "data/mdl/burden_undefined.sdf"; InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); ISimpleChemObjectReader reader = new MDLV2000Reader(ins); ChemFile content = reader.read(new ChemFile()); reader.close(); List<IAtomContainer> cList = ChemFileManipulator.getAllAtomContainers(content); IAtomContainer ac = cList.get(0); Assert.assertNotNull(ac); addExplicitHydrogens(ac); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(ac); Aromaticity.cdkLegacy().apply(ac); addExplicitHydrogens(ac); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(ac); lpcheck.saturate(ac); GasteigerMarsiliPartialCharges peoe = new GasteigerMarsiliPartialCharges(); peoe.calculateCharges(ac); }