Skip to content

Meeko ligand preparation fails on certain molecules with terminal triple bonds #364

@Chryzl

Description

@Chryzl

Bug Description

Meeko ligand preparation crashes with ValueError: list.remove(x): x not in list when processing molecules containing certain terminal triple bonds. The failure occurs during the MoleculePreparation.prepare() step and is caused by a bond canonicalization bug in the BondTyperLegacy class.

Root Cause

The error originates in meeko/bondtyper.py at line 45 in the BondTyperLegacy.__call__() method during the single_triple_single processing loop:

triple_bonds = [(x[0], x[1]) for x in setup.find_pattern("[*]#[*]")]
single_triple_single = [
    (x[0], x[1], x[2], x[3]) for x in setup.find_pattern("[*]-[*]#[*]-[*]")
]
single_to_rigidify = []
for i, j, k, m in single_triple_single:
    triple_bonds.remove((j, k))  # ❌ BUG: Bond not canonicalized
    single_to_rigidify.append((i, j))
    single_to_rigidify.append((k, m))

The problem occurs because:

  1. triple_bonds: [(0, 1)]
  2. single_triple_single: pattern matching returns bonds in their original order from the SMARTS pattern [*]-[*]#[*]-[*] --> [(2, 1, 0, 21)]
  3. When trying to remove (1, 0) from triple_bonds, it's not found in the list, causing the ValueError

Minimal Reproduction

from rdkit import Chem
from scrubber import Scrub
from meeko import MoleculePreparation

# SMILES with terminal triple bond that triggers the bug
smiles = "C#CCCOC(=O)N1C[C@@H](c2nc(C)n[nH]2)[C@H](C2CC2)C1"

# Ligand preparation pipeline
mol = Chem.MolFromSmiles(smiles)
scrub = Scrub(ph_low=7.4, ph_high=7.4, skip_tautomers=True)
mol_states = list(scrub(mol))

# This fails during bond typing
mk_prep = MoleculePreparation()
for mol_state in mol_states:
    molsetup_list = mk_prep.prepare(mol_state)  # ❌ Crashes here

Error:

File "minimal_triple_bond_bug.py", line 14, in <module>
    molsetup_list = mk_prep.prepare(mol_state)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/chem2017/Meeko/meeko/preparation.py", line 565, in prepare
    self._bond_typer(
  File "/home/chem2017/Meeko/meeko/bondtyper.py", line 45, in __call__
    triple_bonds.remove((j, k))
ValueError: list.remove(x): x not in list

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions