Hi Hongbin,
I think rdmolops.GetShortestPath() might help you with this.
Cheers,
p.
On 10/20/16 09:47, 杨弘宾 wrote:
Hi, guys.
I wanted to calculate the topological distance between two
substructures. For example, the distance between carboxyl and acetyl
in aspirin is 3 (or 4 if consider bond numbers) which are carbon,
carbon and oxygen.
My idea is to compare all the matched atoms between the two
substructures.
>>> m = Chem.MolFromSmiles('CC(=O)Oc1ccccc1C(=O)O')
>>> carboxyl = Chem.MolFromSmarts('C(=O)[OH]')
>>> m.GetSubstructMatch(carboxyl)
(10, 11, 12)
>>> acetyl = Chem.MolFromSmarts('[CH3]C(=O)O')
>>> m.GetSubstructMatch(acetyl)
(0, 1, 2, 3)
So, What I want is :
a = [10,11,12]
b = [0,1,2,3]
def distrance(id1,id2):
m = Chem.MolFromSmiles('CC(=O)Oc1ccccc1C(=O)O')
...
return d
>>> min ( map(distance, [(x,y) for x in a for y in b] ) )
3 ( or 4)
Unnecessary to consider that using m as a parameter is better.
Is it possible to define the distrance function with rdkit python API
? I tried to use atom pair but found that it seemed helpless.
------------------------------------------------------------------------
Hongbin Yang
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss