code: private static String calculateMolecularFormula(List<AbstractMolecule> molecules) throws BuilderMoleculeException, CTKException, ChemistryException {
      Map<String, Integer> atomNumberMap = new TreeMap<String, Integer>();
      for (AbstractMolecule molecule : molecules) {
        LOG.info(molecule.getMolecule().toString());
        atomNumberMap = generateAtomNumberMap(molecule, atomNumberMap);
      }
      LOG.info("GET map");
      StringBuilder sb = new StringBuilder();
      Set<String> atoms = atomNumberMap.keySet();
      for (Iterator<String> i = atoms.iterator(); i.hasNext();) {
        String atom = i.next();
        String num = atomNumberMap.get(atom).toString();
        if (num.equals("1")) {
          num = "";
        }
        sb.append(atom);
        sb.append(num.toString());
      }
      return sb.toString();
    }
docs: intern method to calculate the molecular formular for a list of molecules
  
  @param molecules
  @return
  @throws BuilderMoleculeException
  @throws CTKException
  @throws ChemistryException if the Chemistry Engine can not be initialized