Skip to content

Instantly share code, notes, and snippets.

@ljmartin
Last active February 9, 2024 03:37
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 ljmartin/9358657b4b90c3df04c78bb6628abd74 to your computer and use it in GitHub Desktop.
Save ljmartin/9358657b4b90c3df04c78bb6628abd74 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ljmartin
Copy link
Author

ljmartin commented Feb 9, 2024

after all this, note that this works too (on the hydrogen issue, not aromaticity):

reactant = Chem.MolFromSmarts('[#6]1(=[#7])-[#6](=[#7])-[#7](-[#1])-[#6]=,:[#7]-[#7]-1-[#1]')
product = Chem.MolFromSmarts('[#6]1(-[#7])-[#6](-[#7])=[#7]-[#6]:[#7]-[#7]=1')
rxn = rdChemReactions.ReactionFromSmarts(
    Chem.MolToSmarts(reactant)+'>>'+Chem.MolToSmarts(product)
)
from rdkit.Chem import AllChem
AllChem.SanitizeRxn(rxn)

mol = Chem.MolFromSmiles('N=C1NC=NNC1=N')
Chem.Kekulize(mol, clearAromaticFlags=True)
rxn.RunReactant(mol, 0)[0][0]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment