/**
   * Get the summed exact mass of all isotopes from an MolecularFormula. It assumes isotope masses
   * to be preset, and returns 0.0 if not.
   *
   * @param formula The IMolecularFormula to calculate
   * @return The summed exact mass of all atoms in this MolecularFormula
   */
  public static double getTotalExactMass(IMolecularFormula formula) {
    Double mass = 0.0;

    for (IIsotope isotope : formula.isotopes()) {
      if (isotope.getExactMass() == CDKConstants.UNSET) {
        try {
          IIsotope majorIsotope = Isotopes.getInstance().getMajorIsotope(isotope.getSymbol());
          if (majorIsotope != null) {
            mass += majorIsotope.getExactMass() * formula.getIsotopeCount(isotope);
          }
        } catch (IOException e) {
          throw new RuntimeException("Could not instantiate the IsotopeFactory.");
        }
      } else mass += isotope.getExactMass() * formula.getIsotopeCount(isotope);
    }
    if (formula.getCharge() != null) mass = correctMass(mass, formula.getCharge());
    return mass;
  }
 /**
  * Get the summed major isotopic mass of all elements from an MolecularFormula.
  *
  * @param formula The IMolecularFormula to calculate
  * @return The summed exact major isotope masses of all atoms in this MolecularFormula
  */
 public static double getMajorIsotopeMass(IMolecularFormula formula) {
   double mass = 0.0;
   IsotopeFactory factory;
   try {
     factory = Isotopes.getInstance();
   } catch (IOException e) {
     throw new RuntimeException("Could not instantiate the IsotopeFactory.");
   }
   for (IIsotope isotope : formula.isotopes()) {
     IIsotope major = factory.getMajorIsotope(isotope.getSymbol());
     if (major != null) {
       mass += major.getExactMass() * formula.getIsotopeCount(isotope);
     }
   }
   return mass;
 }