code: public static IAtomContainer checkAndCleanMolecule(IAtomContainer molecule) {
          boolean isMarkush = false;
          for (IAtom atom : molecule.atoms()) {
              if (atom.getSymbol().equals("R")) {
                  isMarkush = true;
                  break;
              }
          }
  
          if (isMarkush) {
              System.err.println("Skipping Markush structure for sanity check");
          }
  
          // Check for salts and such
          if (!ConnectivityChecker.isConnected(molecule)) {
              // lets see if we have just two parts if so, we assume its a salt and just work
              // on the larger part. Ideally we should have a check to ensure that the smaller
              //  part is a metal/halogen etc.
              IAtomContainerSet fragments = ConnectivityChecker.partitionIntoMolecules(molecule);
              if (fragments.getAtomContainerCount() > 2) {
                  System.err.println("More than 2 components. Skipped");
              } else {
                  IAtomContainer frag1 = fragments.getAtomContainer(0);
                  IAtomContainer frag2 = fragments.getAtomContainer(1);
                  if (frag1.getAtomCount() > frag2.getAtomCount()) {
                      molecule = frag1;
                  } else {
                      molecule = frag2;
                  }
              }
          }
          configure(molecule);
          return molecule;
      }
docs: Modules for cleaning a molecule
  @param molecule
  @return cleaned AtomContainer