Unexpected behavior of ResonanceMolSupplier
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 52/100
Direzione di ricerca
Start by running the provided Python reproducer with RDKit versions 2026.03.1 and 2026.03.5, comparing the resonance outputs for the oxygen and sulfur molecules. Done means both starting forms produce the two expected resonance structures consistently, with behavior checked against the flags and issue #8785.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Hi RDKit team,
I found a behavior of the ResonanceMolSupplier that surprised me: in case of the oxygen-containing molecule (see code below), the two resonance forms can be interconverted; starting from either form, you always get the two resonance structures (first two rounds of the for-loop below). For the sulfur analog, it is different (last two rounds of the for-loop). Here, only one resonance structure is returned (the initially provided one), and the two forms cannot be interconverted.
This is related to issue #8785 .
Code (run on Rocky Linux 8.10 (Green Obsidian)):
import rdkit
from rdkit import Chem
print("Version:", rdkit.__version__)
print()
# Definition of the molecules
o_smi_res_form1 = Chem.CanonSmiles("C/C(OC)=[N+](C)/C", useChiral=False) # remove stereochem. to avoid confusion
o_smi_res_form2 = Chem.CanonSmiles("C/C(N(C)C)=[O+]/C", useChiral=False)
o_resonances = [o_smi_res_form1, o_smi_res_form2]
o_resonances.sort()
s_smi_res_form1 = Chem.CanonSmiles("C/C(SC)=[N+](C)/C", useChiral=False)
s_smi_res_form2 = Chem.CanonSmiles("C/C(N(C)C)=[S+]/C", useChiral=False)
s_resonances = [s_smi_res_form1, s_smi_res_form2]
s_resonances.sort()
# Resonance structure generation
flags = Chem.ResonanceFlags()
flags |= Chem.ResonanceFlags.ALLOW_CHARGE_SEPARATION
flags |= Chem.ResonanceFlags.ALLOW_INCOMPLETE_OCTETS
flags |= Chem.ResonanceFlags.KEKULE_ALL
flags |= Chem.ResonanceFlags.UNCONSTRAINED_ANIONS
flags |= Chem.ResonanceFlags.UNCONSTRAINED_CATIONS # Relevant here
for smi in o_resonances + s_resonances:
mol = Chem.MolFromSmiles(smi)
suppl = Chem.ResonanceMolSupplier(mol, flags=flags)
res_smis = [Chem.MolToSmiles(res_mol, isomericSmiles=False) for res_mol in suppl]
res_smis.sort()
print(f"Original SMILES: {smi}")
print(f"Number of found resonance forms: {len(res_smis)} | {res_smis}")
if "O" in smi:
ref_list = o_resonances
else:
ref_list = s_resonances
print(f"Consistent with expected set of resonance forms: {res_smis == ref_list}")
print()
Output:
Version: 2026.03.5
Original SMILES: COC(C)=[N+](C)C
Number of found resonance forms: 2 | ['COC(C)=[N+](C)C', 'C[O+]=C(C)N(C)C']
Consistent with expected set of resonance forms: True
Original SMILES: C[O+]=C(C)N(C)C
Number of found resonance forms: 2 | ['COC(C)=[N+](C)C', 'C[O+]=C(C)N(C)C']
Consistent with expected set of resonance forms: True
Original SMILES: CSC(C)=[N+](C)C
Number of found resonance forms: 1 | ['CSC(C)=[N+](C)C']
Consistent with expected set of resonance forms: False
Original SMILES: C[S+]=C(C)N(C)C
Number of found resonance forms: 1 | ['C[S+]=C(C)N(C)C']
Consistent with expected set of resonance forms: False
One last comment: this is the behavior from version 2026.03.5. With 2026.03.1, the behavior was different: there, the sulfonium starting structure gave the two expected resonances whereas the iminium structure did not and only resulted in returning the initial structure.
In general, I would expect to always obtain the two resonance forms regardless of whether it is the O or S molecule.
Thank you and greetings,
Lukas
- Lingua principale
- HTML
- Stelle
- 3.6k
- Fork
- 1.1k
- Merge medio
- 3g 8h
- PR unite (30g)
- 44
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di rdkit/rdkit
-
Clarify mol_from_smiles vs qmol_from_smarts for substruct_count queries in Postgresql cartridge Apertaenhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
-
bug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 70/100
-
bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 65/100
-
enhancement
Difficoltà 4/5 3-5 giorni Idoneità per principianti 50/100
-
Improve depiction of RNA Apertaenhancement
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
-
external-issue to-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
googleapis/google-cloud-swift#1151 ·
-
SqliteSaver.list(filter=...) silently misses nested metadata values containing non-ASCII text Apertaexternal
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
langchain-ai/langgraph#9074 · 1 commento ·
-
documentation specification
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
openai/openai-openapi#584 ·