Re: [Rdkit-discuss] pharmacophore align
Open-Source Cheminformatics and Machine Learning
Brought to you by:
glandrum
|
From: Greg L. <gre...@gm...> - 2012-07-22 10:30:56
|
Dear Taka,
On Sun, Jul 22, 2012 at 12:20 AM, Taka Seri <ser...@gm...> wrote:
>
> And I have one question.
> Can I get selected pharmacophore feature positions from AtomIds?
> Or how can I get selected pharmacophore features from AtomIds?
> From feature object, it is easy to do that by useing "feature.GetPos()" method.
> I want to do same thing by using AtomIds.
There's not really a direct way to find the features that an atom is
involved in, but you can find the atoms that make up a feature using
the method MolChemicalFeature.GetAtomIds(). Given that you can do the
following:
def GetFeatsPerAtom(feats):
""" Returns a dictionary keyed by atom id, with lists of features as
the values
"""
res = {}
for feat in feats:
for atomId in feat.GetAtomIds():
if res.has_key(atomId):
res[atomId].append(feat)
else:
res[atomId] = [feat]
return res
(this code, which could really be improved using a python defaultdict,
is taken from: http://rdkit.svn.sourceforge.net/viewvc/rdkit/trunk/Python/qtGui/Search3D/SearchUtils.py?revision=2&view=markup&pathrev=2
)
To get the position of the Atoms themselves, you need to use the
owning molecule's Conformer. something like this:
In [6]: conf = atom.GetOwningMol().GetConformer()
In [7]: conf.GetAtomPosition(atom.GetIdx())
Out[7]: <rdkit.Geometry.rdGeometry.Point3D at 0x1045ebe20>
I hope this helps,
-greg
-greg
|