Reputation: 31
Question: How to convert atom indices into mol file?
Goal: Convert shortest path between atoms into mol file.
I have an initial mol file and am analyzing it using RDKit. I am getting the shortest path between two atoms using their indices. Example is shown in the figure where the shortest path is highlighted.
Specific function from RDKit: GetShortestPath The input are the two atom indices and the output is a tuple, I am able to convert these tuple values into specific cells of data frame. I am unable to convert the path indices into a mol file where the shortest path becomes the new molecule. I am unsure what methods can be used or what processes. There seems to be no function available to go from mol-atom indices into separate mol-file.
Output of GetShortestPath in tuple form where initial at is 39 and ending atom is 25.
(39, 18, 21, 43, 25)
Big molecule with highlighted shortest path between 39 and 25
I had tried searching for functions to convert mol-atom indices into seperate mol files but I have not found such functions. At this time I am uncertain what direction to go.
The fragment or substructure functions of RDKIT don't allow input from atom indices, from what I can tell. I would appreciate any assistance in this matter and if you suggest different direction, that would be welcomed as well.
I expected to find a function converting paths into mol files based on atom indices but did not find any.
Upvotes: 1
Views: 469
Reputation: 31
Using the mol file and the atom indices from "GetShortestPath", I was able to generate SMILES notation. Though not shown, I can convert the SMILES notation to mol and then obtain *.mol file.
Example:
mol = Chem.MolFromMolFile('PrettyDimer.mol')
l = 39 # Initial Atom
m = 25 # End Atom
shortest_path = Chem.rdmolops.GetShortestPath((mol), (l), (m))
print(shortest_path) #Atom indices of path
print(Chem.MolFragmentToSmiles(mol, shortest_path))
OUTPUT:
(39, 18, 21, 43, 25)
COCco
Upvotes: 0