Hi, I am trying to append (update) a pandas dataframe (created by Pnadatools
from a CSV file) with potential stereoisomers for each molecule in the
dataframe.My understanding is that the EnumerateStereoisomers function returns
a generator that I can loop through and use the mol object (or smiles created
using the Chem.MolToSmiles function) to create new rows and then append this
row to the end of the data frame, I tried the following code but nothing is
appended:
from rdkit.Chem.EnumerateStereoisomers import EnumerateStereoisomers,
StereoEnumerationOptions
def generate_Stereoisomers(x): opts =
StereoEnumerationOptions(tryEmbedding=True) isomers =
tuple(EnumerateStereoisomers(x, options=opts)) return isomers
input_smiles_df["stereo_isomers"] =
input_smiles_df["Cannonical_tautomer"].apply(lambda m:generate_Stereoisomers(m))
for index, row in input_smiles_df.iterrows():
isomers_list = row["stereo_isomers"] print("Number of
stereoisomer is: ", len(isomers_list)) ##This line always gives 1 back,
although the molecules have many stereocenters for smi
in sorted(rdkit.Chem.MolToSmiles(x,isomericSmiles=True) for x in isomers_list):
print(smi) new_row
= {'Cannonical_tautomer':None, id_col_name:str(row[id_col_name]),\
smiles_col_name:row[smiles_col_name], 'standardized_smiles':smi,\
'num_stereo_isomers':row["num_stereo_isomers"]}
input_smiles_df.append(new_row,ignore_index=True)
Any suggestion ?
Thanks
_______________________________________________
Rdkit-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss