I am working on a QSAR project where the 3D structural descriptors are an input to a machine learning model. I am generating the descriptors using the python Mordred API (which uses rdkit).
from rdkit import Chem
from mordred import Calculator,descriptors
import pandas as pd
data = pd.read_csv('output_data.csv') # contains SMILES string of all molecules
calc = Calculator(descriptors,ignore_3D=False)
for index,row in data.iterrows():
mol = Chem.MolFromSmiles(row['SMILES']) # get the SMILES string from each row
# I need to put in the 3D coordinates from an xyz into 'mol' object here
descs = list(calc(mol))
# ... processing descriptors...
The problem is that if I use rdkit to generate 3D coordinates from the SMILES, it will generate slightly different structures every time. However, I have optimized structure for each of those molecules as xyz files from the calculation that I ran on Orca. I wish to use the optimized structures for the 3D descriptors generation.
How do I do this? The SMILES has the connectivity data, but the xyz has the coordinate data.
I am open to using OpenBabel or any other tool that can be used from Python or the command line, but the main point is to combine connectivity of SMILES with the coordinates of xyz.