@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); } }
/** * */ @Test public void testAssignGasteigerSigmaMarsiliFactors_IAtomContainer() throws Exception { GasteigerMarsiliPartialCharges peoe = new GasteigerMarsiliPartialCharges(); IAtomContainer molecule = builder.newInstance(IAtomContainer.class); molecule.addAtom(new Atom("C")); molecule.getAtom(0).setCharge(0.0); molecule.addAtom(new Atom("F")); molecule.getAtom(1).setCharge(0.0); molecule.addBond(0, 1, IBond.Order.SINGLE); addExplicitHydrogens(molecule); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(molecule); lpcheck.saturate(molecule); for (IAtom atom : molecule.atoms()) atom.setCharge(0.0); Assert.assertThat(peoe.assignGasteigerSigmaMarsiliFactors(molecule).length, is(not(0))); }
/** * */ @Test public void testAssignGasteigerMarsiliSigmaPartialCharges_IAtomContainer_Boolean() 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.assignGasteigerMarsiliSigmaPartialCharges(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.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++) { //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); } }