pluskal-lab / DreaMS

DreaMS (Deep Representations Empowering the Annotation of Mass Spectra)
https://dreams-docs.readthedocs.io
MIT License
17 stars 5 forks source link

break_rings is broken #5

Closed tornikeo closed 1 week ago

tornikeo commented 1 month ago

A molecule:

image

causes the break_rings to break:

from dreams.algorithms.murcko_hist.murcko_hist import break_rings
from rdkit import Chem
mol = Chem.MolFromInchi('InChI=1S/C28H22O6/c29-21-3-1-9-25-23(31)19-7-5-15(11-17(19)13-27(21,25)33-25)16-6-8-20-18(12-16)14-28-22(30)4-2-10-26(28,34-28)24(20)32/h5-8,11-12H,1-4,9-10,13-14H2')
break_rings(mol, rings_size=3)

Why? Well, we are modifying the mol in-the-loop, while using an outdated list of rings, from the original molecule, br = [set(r) for r in mol.GetRingInfo().BondRings()]. Instead, we need to iteratively (while has_rings) remove rings to avoid this.

roman-bushuiev commented 1 week ago

Great find! Thank you for looking into this! I will merge the pull request.