Dear Michal,

You can use

http://rdkit.org/docs/source/rdkit.Chem.rdmolops.html?highlight=path#rdkit.Chem.rdmolops.GetShortestPath

or

http://rdkit.org/docs/source/rdkit.Chem.rdmolops.html?highlight=distance#rdkit.Chem.rdmolops.GetDistanceMatrix

e.g.:

from  rdkit  import  Chem

cx=Chem.MolFromSmiles('C1CCCCC1')
bonds=(cx.GetBondBetweenAtoms(1,2).GetIdx(),  
cx.GetBondBetweenAtoms(3,4).GetIdx())
fragmented=Chem.FragmentOnBonds(cx,bonds)

mat  =  Chem.GetDistanceMatrix(cx)

mat[1,2]

1.0

Chem.GetShortestPath(cx,  1,  2)

(1, 2)

mat  =  Chem.GetDistanceMatrix(fragmented)

mat[1, 2]

100000000.0

Chem.GetShortestPath(fragmented,  1,  2)

()


Cheers,
p.

On 04/06/2020 16:17, Michal Krompiec wrote:
Hello,
When a molecule is fragmented with Chem.FragmentOnBonds, how can I check if there still is a path between two given atoms? For example, this snippet breaks C1-C2 and C3-C4 bonds in cyclohexane, producing two fragments:

from rdkit import Chem
cx=Chem.MolFromSmiles('C1CCCCC1')
bonds=(cx.GetBondBetweenAtoms(1,2).GetIdx(), cx.GetBondBetweenAtoms(3,4).GetIdx())
fragmented=Chem.FragmentOnBonds(cx,bonds)

Is there a way in RDKit to check if there is a path between, say, C1 and C2, without having to manually traverse the whole molecular graph? I guess the alternative is to load everything into a graph library like networkx...

Best wishes,
Michal Krompiec
Merck KGaA


_______________________________________________
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
_______________________________________________
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

Reply via email to