Dear Robert, On Sat, Oct 23, 2010 at 1:53 AM, Robert DeLisle <rkdeli...@gmail.com> wrote: > > The easiest trap is simply this: > > if (m is None): > #error handling code > > The problem that I have had is that this will effectively skip bad molecules, > but in a large SD file, it is difficult to find out which molecules they were. > > sd = Chem.SDMolSupplier("test.sdf") > > for m in sd: > if m is None: > #how do I get more information about the broken molecules? > else: > #do the normal stuff. >
My solution to this is normally to use this pattern: #-------------- sd = Chem.SDMolSupplier("test.sdf") errf = file('failures.sdf","w+") for i,m in enumerate(sd): if m is None: errf.write(sd.GetItemText(i) continue else: # process the molecule. #-------------- This doesn't tell you what went wrong (that information is, unfortunately, not current accessible), but it does at least collect all the "bad" molecules in one place so you can look at them later (using some other software, of course). Best Regards, -greg ------------------------------------------------------------------------------ Nokia and AT&T present the 2010 Calling All Innovators-North America contest Create new apps & games for the Nokia N8 for consumers in U.S. and Canada $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store http://p.sf.net/sfu/nokia-dev2dev _______________________________________________ Rdkit-discuss mailing list Rdkit-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rdkit-discuss