/** * Get the total formal charge on a molecule. * * @param atomContainer the atom container to consider * @return The summed formal charges of all atoms in this AtomContainer. */ public static int getTotalFormalCharge(IAtomContainer atomContainer) { int chargeP = getTotalNegativeFormalCharge(atomContainer); int chargeN = getTotalPositiveFormalCharge(atomContainer); return chargeP + chargeN; }
/** * Test total positive formal charge. * */ @Test public void testGetTotalPositiveFormalCharge_IAtomContainer() throws Exception { SmilesParser parser = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol = parser.parseSmiles("[O-]C([N+])C([N+])C"); int totalCharge = AtomContainerManipulator.getTotalPositiveFormalCharge(mol); Assert.assertEquals(2, totalCharge); }
int totalPCharge1 = AtomContainerManipulator.getTotalPositiveFormalCharge(atomContainer);
int totalPCharge1 = AtomContainerManipulator.getTotalPositiveFormalCharge(atomContainer);