Original code will skip the cases where the rdkit cannot kekulize molecules correctly and so could not layout the image in the final graph properly for those molecules. Looking at this in details, the "cannot kekulize error" happens in AllChem.RemoveHs (rdkit has a bad hydrogen detection?). So here, for molecules failed the AllChem.RemoveHs function, just skip this function but still compute the 2D coordinate and draw to image files. It improve the layout and all the molecules could be drew in the final graph and some molecules which original cannot be kekulized will have hydrogens.
Original code will skip the cases where the rdkit cannot kekulize molecules correctly and so could not layout the image in the final graph properly for those molecules. Looking at this in details, the "cannot kekulize error" happens in AllChem.RemoveHs (rdkit has a bad hydrogen detection?). So here, for molecules failed the AllChem.RemoveHs function, just skip this function but still compute the 2D coordinate and draw to image files. It improve the layout and all the molecules could be drew in the final graph and some molecules which original cannot be kekulized will have hydrogens.