Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Unexpected behavior of ResonanceMolSupplier

Aperta
#9,458 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
52/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
python
Ambito
api

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

bug

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

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di rdkit/rdkit

Tutte le issue di rdkit/rdkit

Issue simili

Altre issue su Backend & API Design

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.