Hi Michal,
On Wed, Aug 28, 2013 at 1:16 PM, Michał Nowotka <[email protected]> wrote:
> Imagine this scenario:
>
> I read random molfile and I want to produce an image of it:
>
> 1. If the molfile already contains coordinates, use them
> 2. If the molfile coordinates are all zeros, compute them
>
> I don't know how to check if Mol (python object) has coordinates without
> parsing original molfile, which doesn't seem to be a good idea.
> And Compute2DCoords doesn't respect coordinates but computes them from
> scratch.
>
> So, do you know any way to check if Mol (python object) already contains
> not trivial (all zeros) coordinates, so I can call Compute2DCorrds only on
> those of them which doesn't have coords?
>
>
There's no easy way I can think of that's built in, but you could do
something like this:
In [19]: def CoordsAreAllZero(m,confId=-1):
....: conf = m.GetConformer(confId)
....: for i in range(m.GetNumAtoms()):
....: if list(conf.GetAtomPosition(i))!=[0.0,0.0,0.0]:
....: return False
....: return True
....:
In [20]: print mb
RDKit
2 1 0 0 0 0 0 0 0 0999 V2000
0.0000 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
0.0000 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
1 2 1 0
M END
In [21]: m = Chem.MolFromMolBlock(mb)
In [22]: CoordsAreAllZero(m)
Out[22]: True
In [25]: AllChem.Compute2DCoords(m)
Out[25]: 0
In [26]: CoordsAreAllZero(m)
Out[26]: False
That ought to work at least most of the time.
-greg
------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58040911&iu=/4140/ostg.clktrk
_______________________________________________
Rdkit-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss