Hi,
2009/10/28 Christian de Bouillé <[email protected]>:
>
> When dealing with a sdf with molecule giving error
> Could you explain how to deal with the error
>
> Taking your example
> m = Chem.MolFromMolFile('data/invalid.mol')
> m is None cannot be used
> The same with try except
>
> I would like the process is not stopped by error
> but taking the exception
When the RDKit reads a molecule that it cannot process, it returns
None. The only time you should see an exception is if you try to read
from a file that does not exist. The best way to do with this when
dealing with a set of molecules is to check for None and skip those
failing molecules. There are some examples of this in the Getting
Started in Python document.
The standard pattern is something like this for reading from an SD file:
supplier = Chem.SDMolSupplier('filename.sdf')
for mol in supplier:
if mol is None: continue
[do something with the molecule]
for a mol file, you can just check:
m = Chem.MolFromMolFile('data/invalid.mol')
if m is None:
print 'bad molecule!'
else:
[ do something with the molecule]
I hope this helps,
-greg
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Rdkit-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss