On Mon, Jan 30, 2012 at 1:26 PM, JP <jeanpaul.ebe...@inhibox.com> wrote: > > But then I will have to add the "if not clean_mol.GetNumAtoms():" > before/after replacing/editing molecule parts, after reading molecules, > before writing them etc. i.e. I'd need this statement in a lot of places. > This is why I asked if it should be considered a valid molecule - because if > these moves in SanitizeMol I wouldn't need any of that e.g. I can assume > that the molecule I have in hand, is valid and if I still wanted these > molecules (for some not so clear reason) I could just switch of sanitization > off, on the methods that allow it. > > Just asking, there is probably some good design decision for this which I am > missing... (hence the question)
It's not an easy one. I believe there's not really a strong argument for either behavior. As you've seen, the current behavior of the RDKit is to treat molecules without atoms as completely legal entities. You can test for this case the way Nik pointed out. I'm playing with the idea of making the SanitizeMol routine configurable, so you could pass in a set of flags to control which operations are carried out. If this happens, a "check for zero atoms" flag that defaults to false could be added. I just created a feature request for this: https://sourceforge.net/tracker/?func=detail&aid=3481729&group_id=160139&atid=814653 In the meantime, if you'd like to change the definition of sanitization, the easiest way to do so would be to write your own function, perhaps something like this (not tested): def mySanitize(mol): if not mol.GetNumAtoms(): raise ValueError,'molecule has no atoms' Chem.SanitizeMol(mol) Note: for the particular case of salt stripping, you can ensure that the salt stripper doesn't remove all atoms using the dontRemoveEverything optional argument. Take a look at the help for SaltRemover.StripMol: http://rdkit.org/docs/api/rdkit.Chem.SaltRemover.SaltRemover-class.html#StripMol -greg ------------------------------------------------------------------------------ Try before you buy = See our experts in action! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-dev2 _______________________________________________ Rdkit-discuss mailing list Rdkit-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rdkit-discuss