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.









On Fri, Oct 22, 2010 at 8:51 AM, <nikolaus.sti...@novartis.com> wrote:

>
> Hi,
>
> your molecule itself is not ok - the Sn has a larger valence then
> permitted. There was a similar case recently about phosphor. I would guess
> that you should fix your molecule first.
>
> In your code example below your molecule m is None and hence the rest will
> not work.
>
> Hope that helps
>
> Cheers
> Nik
>
>
>
>  *<sridhar.kuntamukk...@thomsonreuters.com>*
>
> 10/22/2010 04:41 PM
>   To
> <rdkit-discuss@lists.sourceforge.net>
>  cc
>   Subject
> [Rdkit-discuss] How to trap the exceptions in RDKit?
>
>
>
>
> Hi,
> I have the following code which raises an exception because the molecule is
> not up to its expectations. But I can’t find a way to trap the exception.
> Can someone suggest one, please?
>
> from rdkit import Chem
> from rdkit.Chem import AvailDescriptors
> from rdkit.Chem import Crippen
>
>
> m=Chem.MolFromSmiles('c1ccc2c(c1)/C=N/c3ccccc3S[Ti]O2.[CH]1[CH][CH][CH][CH]1.Cl[Sn-](Cl)(Cl)(Cl)Cl')
> # I tried this way
>     molog = Crippen.MolLogP(m)
>     print molog
> # and also this way first
> if AvailDescriptors.descDict['MolLogP'](m):
>        mollogp = AvailDescriptors.descDict['MolLogP'](m)
>
> I also wanted to calc. NumHDonors and NumHAcceptors. But if it failed on
> one descriptor, will it fail on other descriptors as well?
> Any suggestions?
> Thanks
> Sridhar
>
> p.s. to Eddie. Turned out my server has the 11g client and the installation
> on the server works fine. I guess I must have missed a line or two of
> instructions that the client must be 11g’s and not the DB itself. My PC had
> oracle 9 and 10 clients.
>
> *From:* Eddie Cao [mailto:cao.yi...@gmail.com] *
> Sent:* Wednesday, October 20, 2010 4:26 PM*
> To:* Kuntamukkula, Sridhar (Hlthcr&Science)*
> Cc:* rdkit-disc...@lists.sourceforge.net*
> Subject:* Re: [Rdkit-discuss] [Rdkit-devel] How to build the RDKit?
>
> Hi,
>
> Being not an Oracle user, I cannot give you a concrete answer, but a quick
> Google search indicates that it might be a version inconsistency between the
> client and the server. Are you sure you are connecting to 11g? Please
> contact your database administrator for problems regarding Oracle database
> or ask the folks on the cx_Oracle mailing list:
>
> *http://lists.sourceforge.net/lists/listinfo/cx-oracle-users*<http://lists.sourceforge.net/lists/listinfo/cx-oracle-users>
>
> -Eddie
>
>
> On Oct 20, 2010, at 11:03 AM, 
> *sridhar.kuntamukk...@thomsonreuters.com*<sridhar.kuntamukk...@thomsonreuters.com>wrote:
>
>
> Hi,
> I have downloaded the “*Windows x86 
> Installer*<http://prdownloads.sourceforge.net/cx-oracle/cx_Oracle-5.0.4-11g.win32-py2.5.msi?download>(Oracle
>  11g, Python 2.5)” to my PC and installed it.
> From Python command-line, when I try to connect to oracle, I get the
> following error.
>
> C:\RDkit>python
> Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)]
> on win
> 32
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import cx_Oracle
> >>> con = cx_Oracle.connect("user", "pwd", "chemdev")
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> cx_Oracle.DatabaseError: ORA-24315: illegal attribute type
>
> I have originally used the connstr=user/p...@chemdev' and this gave me the
> same error as above.
> Then I found the above syntax in the cx_oracle_doc folder’s readme.txt and
> am lost now.
>
> MY PC has Windows XP, Oracle is on a different server (with a TNS entry
> “chemdev”) and I just added TNS_ADMIN Registry_entry and the path of
> TNS_ADMIN to the PATH env. Variable.
> From a command prompt, sqlplus user/p...@chemdev works fine.
>
> Any thoughts?
>
> Many thanks
> Sridhar
>
> *From:* *nikolaus.sti...@novartis.com* <nikolaus.sti...@novartis.com>[mailto:
> nikolaus.sti...@novartis.com] *
> Sent:* Wednesday, October 20, 2010 2:07 AM*
> To:* Eddie Cao*
> Cc:* *rdkit-de...@lists.sourceforge.net*<rdkit-de...@lists.sourceforge.net>;
> Kuntamukkula, Sridhar (Hlthcr&Science); *
> rdkit-disc...@lists.sourceforge.net* <rdkit-discuss@lists.sourceforge.net>
> *
> Subject:* Re: [Rdkit-devel] How to build the RDKit?
>
>
> Hi Sridhar,
>
> congrats on getting things working. One more comment - maybe you want to
> post these kind of questions rather in the discuss than the devel list. It
> is much more populated and you will for sure get replies quicker.
>
> Cheers
> Nik
>
>   *Eddie Cao <**cao.yi...@gmail.com* <cao.yi...@gmail.com>*>*
>
> 10/19/2010 11:49 PM
>
>   To
> *sridhar.kuntamukk...@thomsonreuters.com*<sridhar.kuntamukk...@thomsonreuters.com>
> cc
> *rdkit-de...@lists.sourceforge.net* <rdkit-de...@lists.sourceforge.net>
> Subject
> Re: [Rdkit-devel] How to build the RDKit?
>
>
>
>
>
>
>
>
> Hi Sridhar,
>
> Congratulations! If from rdkit import Chem gives you >>>, then it is very
> good sign that things are all in place.
>
> To load molecules from Oracle database, you need a database connector
> called cx_Oracle. After installing this module, you will be able to send
> SQL statement to Oracle to retrieve molecule SMILES or SDF, depending on how
> molecules are stored in your database. You might need to consult your
> database administrator.
>
> To download cx_Oracle: 
> *http://cx-oracle.sourceforge.net/*<http://cx-oracle.sourceforge.net/>
> For a simple example about how to use it: *
> http://wiki.oracle.com/page/Python* <http://wiki.oracle.com/page/Python>
>
> Check Section 14 of the Getting Started in Python Guide for  a complete
> list of descriptors you can calculate using RDKit:
> *
> **http://rdkit.org/GettingStartedInPython.pdf*<http://rdkit.org/GettingStartedInPython.pdf>
>
> Regards,
> Eddie
>
> On Oct 19, 2010, at 2:31 PM, 
> *sridhar.kuntamukk...@thomsonreuters.com*<sridhar.kuntamukk...@thomsonreuters.com>wrote:
>
> Hi Nik,
> Looks like I had a version issue with the RDkit I downloaded. I needed
> Q22010_1 for Python2.5 but I downloaded Q22009_1 in which, it was looking
> for Python2.5 (hardcoded path from one of the libs, looked like) when I ran
> the test command (hence I downloaded and installed Python2.5 and removed
> 2.6).
> Now that I have a clean install of Py2.5 and fresh download of RDkit
> Q22010_1 for Py2.5, the test command ran well and passed the test.
>
> I just have to go to the next step.
> I need to create molLogP, NumHAcceptors, NumHDonors etc.. values for a
> given molecule.
> My molecules are actually stored in an Oracle DB.
> So, Where do I begin?
>
> I just got your other mail. The install is set and OK now as it seems.
> I ran the command “from rdkit import Chem” from the command-line and it
> put me back to the >>> prompt, no add’l msgs.
> As for sending to the whole group, it was an honest mistake. I just clicked
> “Reply”. Some other lists that I subscribed to, send to the list
> automagically. I realized my mistake when I didn’t receive the mail back to
> me and fixed it in this one.
>
> Regards,
> Sridhar
>
>
> ------------------------------------------------------------------------------
> Download new Adobe(R) Flash(R) Builder(TM) 4
> The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly
> Flex(R) Builder(TM)) enable the development of rich applications that run
> across multiple browsers and platforms. Download your free trials today!*
> **
> http://p.sf.net/sfu/adobe-dev2dev_______________________________________________
> *<http://p.sf.net/sfu/adobe-dev2dev_______________________________________________>
> Rdkit-devel mailing list*
> **rdkit-de...@lists.sourceforge.net* <rdkit-de...@lists.sourceforge.net>*
> **https://lists.sourceforge.net/lists/listinfo/rdkit-devel*<https://lists.sourceforge.net/lists/listinfo/rdkit-devel>
>
>
> _________________________
>
> CONFIDENTIALITY NOTICE
>
> The information contained in this e-mail message is intended only for the
> exclusive use of the individual or entity named above and may contain
> information that is privileged, confidential or exempt from disclosure under
> applicable law. If the reader of this message is not the intended recipient,
> or the employee or agent responsible for delivery of the message to the
> intended recipient, you are hereby notified that any dissemination,
> distribution or copying of this communication is strictly prohibited. If you
> have received this communication in error, please notify the sender
> immediately by e-mail and delete the material from any computer.  Thank you.
>
> ------------------------------------------------------------------------------
> 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_______________________________________________
> *<http://p.sf.net/sfu/nokia-dev2dev_______________________________________________>
> Rdkit-discuss mailing list*
> **rdkit-disc...@lists.sourceforge.net*<Rdkit-discuss@lists.sourceforge.net>
> *
> **https://lists.sourceforge.net/lists/listinfo/rdkit-discuss*<https://lists.sourceforge.net/lists/listinfo/rdkit-discuss>
>
> ------------------------------------------------------------------------------
> 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
>
>
> _________________________
>
> CONFIDENTIALITY NOTICE
>
> The information contained in this e-mail message is intended only for the
> exclusive use of the individual or entity named above and may contain
> information that is privileged, confidential or exempt from disclosure under
> applicable law. If the reader of this message is not the intended recipient,
> or the employee or agent responsible for delivery of the message to the
> intended recipient, you are hereby notified that any dissemination,
> distribution or copying of this communication is strictly prohibited. If you
> have received this communication in error, please notify the sender
> immediately by e-mail and delete the material from any computer.  Thank you.
>
>
> ------------------------------------------------------------------------------
> 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
>
>
------------------------------------------------------------------------------
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

Reply via email to