Hi Donald,
The properties within the CTAB portions of the SD file is not parsed as regular
properties of the molecule. In your specific case, the line is parsed as an R
Group Label and is attached as a property of the corresponding atom. See the
following:
>>> from rdkit.Chem import *
>>> m = MolFromMolFile('test.sd')
>>> a = m.GetAtoms()[6]
>>> prop = a.GetPropNames()[0]
>>> prop
'_MolFileRLabel'
You see that atom at position 6 - actually the 7th atom since Python's array
index starts from 0 - has a property '_MolFileRLabel' set. Unfortunately, you
cannot read the value for this property - this could be a bug:
>>> a.GetProp(prop)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
RuntimeError: boost::bad_any_cast: failed conversion using boost::any_cast
Regards,
Eddie
On Jun 7, 2011, at 4:58 PM, Donald Keidel wrote:
> Hi,
>
> I am fairly new to RDKit and I apologize in advance if this question is
> rather basic in nature.
>
> I am reading a molecule the following way and trying to display the
> properties from the sdf:
>
> [dkeidel-desktop:dkeidel] /emi/doc/sod/villa $ python
> Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41)
> [GCC 4.4.3] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>>>> import os, sys, copy
>>>> from rdkit.Chem import rdDepictor
>>>> from rdkit import Geometry
>>>>
>>>> from rdkit import Chem
>>>> from rdkit.Chem import AllChem
>>>> from rdkit.Chem.Draw import MolDrawing
>>>> from rdkit.Chem.AvailDescriptors import descDict
> [15:14:22] WARNING: The AvailDescriptors module is deprecated. Please
> switch to using the Descriptors module.
>>>>
>>>> import rdkit.DataStructs
>>>> import rdkit.Chem.MACCSkeys
>>>> import rdkit.Chem.AtomPairs.Pairs
>>>> import rdkit.Chem.AtomPairs.Torsions
>>>> suppl = Chem.SDMolSupplier('/emi/doc/sod/villa/R1_060A.sdf')
>>>> mb = suppl.GetItemText(0)
>>>> nsuppl = Chem.SDMolSupplier()
>>>> nsuppl.SetData(mb)
>>>> mol = nsuppl.next()
>>>> list(mol.GetPropNames(includePrivate=True, includeComputed=True))
> ['Template', '_MolFileComments', '_MolFileInfo', '_Name',
> '_StereochemDone', '__computedProps', 'numArom']
>>>> mol.GetProp('Template')
> '060A/11'
>
> As you can see I have successfully done this. However, I want to get
> access to other properties from the properties block in the sd file.
> Here is the sd file I am referring to:
>
> -ISIS- 03241116262D
>
> 7 6 0 0 0 0 0 0 0 0999 V2000
> 7.9102 -2.4208 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
> 6.4770 -2.4208 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
> 5.0437 -2.4208 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
> 7.1916 -2.0137 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
> 5.7583 -2.0137 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
> 4.3292 -2.0137 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
> 7.9148 -3.2458 0.0000 R# 0 0 0 0 0 0 0 0 0 0 0 0
> 2 4 1 0 0 0 0
> 3 5 1 0 0 0 0
> 4 1 1 0 0 0 0
> 5 2 1 0 0 0 0
> 6 3 1 0 0 0 0
> 1 7 1 0 0 0 0
> M RGP 1 7 1
> M END
>> <Template>
> 060A/11
>
> $$$$
>
>
> My question is the following. When I have the RDKit mol object, can I
> Get the property M RGP or Set it to something different? Or should I
> deal with this information as a string and write it out to a new sdf if
> I want to change some numbers on the M RGP line?
>
> Thank you in advance for any help.
>
> Don
>
> ------------------------------------------------------------------------------
> EditLive Enterprise is the world's most technically advanced content
> authoring tool. Experience the power of Track Changes, Inline Image
> Editing and ensure content is compliant with Accessibility Checking.
> http://p.sf.net/sfu/ephox-dev2dev
> _______________________________________________
> Rdkit-discuss mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
Rdkit-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss