code: private static Map<String, Integer> generateAtomNumberMap(AbstractMolecule molecule, Map<String, Integer> mapAtoms) throws BuilderMoleculeException, CTKException, ChemistryException {
      molecule = BuilderMolecule.mergeRgroups(molecule);
      LOG.info("Merge group is finished");
      String formula = Chemistry.getInstance().getManipulator().getMoleculeInfo(molecule).getMolecularFormula();
      String atom = "";
      String number = "";
  
      for (int i = 0; i < formula.length(); i++) {
        String oneChar = String.valueOf(formula.charAt(i));
        if (oneChar.matches("[A-Z]")) {
          if (atom.length() == 0) {
            atom = oneChar;
          } else {
            if (number == "") {
              number = "1";
            }
            if (mapAtoms.get(atom) != null) {
              mapAtoms.put(atom, mapAtoms.get(atom) + Integer.valueOf(number));
            } else {
  
              mapAtoms.put(atom, Integer.valueOf(number));
            }
            atom = oneChar;
            number = "";
          }
        } else if (oneChar.matches("[a-z]")) {
          if (atom.length() > 0) {
            atom = atom + oneChar;
          }
        } else {
          if (number.length() == 0) {
            number = oneChar;
          } else {
            number = number + oneChar;
          }
        }
      }
  
      if (number == "") {
        number = "1";
      }
  
      if (mapAtoms.get(atom) != null) {
        mapAtoms.put(atom, mapAtoms.get(atom) + Integer.valueOf(number));
      } else {
  
        mapAtoms.put(atom, Integer.valueOf(number));
      }
      return mapAtoms;
    }
docs: method to get for every atom the number of occurences
  
  @param molecule input Molecule
  @param mapAtoms Map of atoms with the number its occurences
  @return Map of atoms with the number of its occurences
  @throws BuilderMoleculeException if the Rgroups of the molecule can not be
  merged into it
  @throws CTKException
  @throws ChemistryException if the Chemistry Engine can not be initialized