-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SmallMoleculeComponent round trip does not save atom hybridization #407
Comments
My initial idea of changing to use the rdkit internal JSON representation in the from rdkit import Chem
from gufe import SmallMoleculeComponent
settings = Chem.rdMolInterchange.JSONWriteParameters()
settings.useRDKitExtensions = True
# generate an rdkit molecule
ethane = Chem.MolFromSmiles("CC")
ethane = Chem.AddHs(methane)
Chem.rdDistGeom.EmbedMolecule(methane, useRandomCoords=False, randomSeed=0)
# check the state of each carbon
for atom in methane.GetAtoms():
if atom.GetAtomicNum() == 6:
print(atom.GetHybridization())
# create the SMC
smc = SmallMoleculeComponent(methane, name="methane")
# round trip to dict
smc_dict = smc.to_dict()
# remove the original object
del smc
smc_2 = SmallMoleculeComponent.from_dict(smc_dict)
# check the state again
for atom in smc_2.to_rdkit().GetAtoms():
if atom.GetAtomicNum() == 6:
print(atom.GetHybridization())
json_str = Chem.MolToJSON(smc_2.to_rdkit(), settings)
print(json_str)
json_mol = Chem.JSONToMols(json_str)[0]
for atom in json_mol.GetAtoms():
if atom.GetAtomicNum() == 6:
print(atom.GetHybridization())
So I think I just need to add this property to the to and from dict method. |
Oh shoot, I'm glad we tried at least! Does |
I noticed the hybridization of each atom was set as
UNSPECIFIED
when working on a ligand from a graphml object I think this is due to theto_dict
method not saving the hybridization of the atom. See this simplified exampleThe text was updated successfully, but these errors were encountered: