Hi TJ,

On Thu, Dec 30, 2010 at 2:27 AM, TJ O'Donnell <t...@acm.org> wrote:
> I can see how to read an sd file using SDMolSupplier and using mol.GetProp()
> to get the tag data from the file.
> But, I have each molblock (chunk of lines between $$$$ in an sdf file)
> in a separate string.  I don't see a way to get properties from that
> molblock string or
> even better from the mol=Chem.MolFromMolBlock(molblock)
> E.g. mol.GetPropNames() returns a null array (or just the private and
> computed props if mol.GetPropNames(True,True)
> Can you give me some hints on how I might get the property tag data
> from a string molblock?

The easiest way I can think to do it is by constructing an
SDMolSupplier and using its SetData method:

To have some sample data I start by getting a block of data from an SDF:
In [2]: suppl = Chem.SDMolSupplier('activity_classes.sdf')
In [3]: mb = suppl.GetItemText(12)

Set up a new SDMolSupplier using that:
In [5]: nsuppl = Chem.SDMolSupplier()
In [6]: nsuppl.SetData(mb)

And then grab the molecule:
In [7]: mol = nsuppl.next()
[05:29:05]  deprecated group abbreviation ignored
[05:29:05]  deprecated group abbreviation ignored
In [8]: list(mol.GetPropNames())
Out[8]: ['ACTIV_CLASS', 'ACTIV_INDEX', 'EXTREG', 'MOLREGNO']

You can no doubt do the same thing with Chem.MolFromMolBlock to build
the molecule, a regular expression to extract the data from the SD
block, and a series of SetProp() calls, but the above somehow seems
easier. :-)

Best Regards,
-greg

------------------------------------------------------------------------------
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and, 
should the need arise, upgrade to a full multi-node Oracle RAC database 
without downtime or disruption
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

Reply via email to