Skip to content

Return a clear diagnostic for absent group attributes on group-free MolSys #233

Description

@dprada

Observed behavior

A valid molsysmt.MolSys converted from a group-free RDKit molecule has n_groups == 0 and msm.has_attribute(system, 'group_name') == False. Querying msm.get(system, element='atom', group_name=True) raises a raw NumPy IndexError: arrays used as indices must be of integer (or boolean) type.

Reproduced with MolSysMT 0.21.0+606.ga03eb4bf6:

import molsysmt as msm
from rdkit import Chem

rdmol = Chem.AddHs(Chem.MolFromSmiles('c1ccccc1'))
system = msm.convert(rdmol, to_form='molsysmt.MolSys')
assert msm.get(system, n_groups=True) == 0
assert not msm.has_attribute(system, 'group_name')
msm.get(system, element='atom', group_name=True)  # raw IndexError

Expected behavior

A missing group-level attribute should produce the documented unavailable-attribute result or a MolSysMT diagnostic. The user should not receive an internal indexing error. This issue does not ask MolSysMT to invent residue groups for RDKit molecules.

DockingMT impact and temporary workaround

uibcdf/dockingmt#9 accepts molecular inputs convertible to MolSysMT. An RDKit ligand with valid coordinates and chemistry failed in DockingMT preparation solely because it queried group_name. DockingMT now checks has_attribute first and supplies a local LIG label for its PDBQT projection when groups are absent. The workaround can be removed when the general MolSysMT query contract handles absent groups predictably. The ligand-readiness proposal #217 remains related but concerns chemical completeness, not this query failure.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions