code: public static int getTotalNegativeFormalCharge(IAtomContainer atomContainer) {
          int charge = 0;
          for (int i = 0; i < atomContainer.getAtomCount(); i++) {
              int chargeI = atomContainer.getAtom(i).getFormalCharge();
              if (chargeI < 0) charge += chargeI;
          }
          return charge;
      }
docs: Get the total formal negative charge on a molecule.
  
  @param atomContainer the atom container to consider
  @return The summed negative formal charges of all atoms in this AtomContainer.