code: static void countHetero(List<IRingSet> rsets) {
          for (IRingSet rset : rsets) {
              int numHeteroAtoms = 0;
              int numHeteroRings = 0;
              for (IAtomContainer ring : rset.atomContainers()) {
                  int prevNumHeteroAtoms = numHeteroAtoms;
                  for (IAtom atom : ring.atoms()) {
                      Integer elem = atom.getAtomicNumber();
                      if (elem != null && elem != 6 && elem != 1)
                          numHeteroAtoms++;
                  }
                  if (numHeteroAtoms > prevNumHeteroAtoms)
                      numHeteroRings++;
              }
              rset.setProperty(NUM_HETERO_ATOMS, numHeteroAtoms);
              rset.setProperty(NUM_HETERO_RINGS, numHeteroRings);
          }
      }
docs: Counds the number of hetero atoms and hetero rings in a ringset. The
  properties {@code sdg:numHeteroRings} and {@code sdg:numHeteroAtoms}
  are set.
  
  @param rsets ring systems