[Rdkit-discuss] Is there any function that can calculate the 2D distance between two atoms?
Open-Source Cheminformatics and Machine Learning
Brought to you by:
glandrum
From: 杨弘宾 <yan...@16...> - 2016-10-20 09:03:27
|
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? |