Skip to content

Instantly share code, notes, and snippets.

@goraj
Created October 24, 2019 17:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save goraj/879b58dce21c971e35afdd360aefe5f9 to your computer and use it in GitHub Desktop.
Save goraj/879b58dce21c971e35afdd360aefe5f9 to your computer and use it in GitHub Desktop.
rdkit_iron.py
from rdkit import Chem
from rdkit.Chem.MolStandardize import rdMolStandardize
# works
smiles_charged = '[CH2-][Fe++][CH2-]'
# does not work
smiles_charged = 'CCCC(=O)c1ccc[c-]1[Fe++][c-]1cccc1C(=O)CCC'
smiles_charged = 'Cc1ccc(C(=O)C=Cc2ccc[c-]2[Fe++][c-]2cccc2)c(O)c1'
print(f'smiles_uncharged: {smiles_charged}')
mol = Chem.MolFromSmiles(smiles_charged)
uncharger = rdMolStandardize.Uncharger()
mol_uncharged = uncharger.uncharge(mol)
smiles_uncharged = Chem.MolToSmiles(mol_uncharged)
print(f'smiles_uncharged: {smiles_uncharged}')
assert Chem.MolFromSmiles(smiles_uncharged) != None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment