Skip to content

Diagnose a failed reconstruction

Documentation · 简体中文

Single-molecule reconstruction raises ReconstructionError on invalid input, an unsatisfied reconstruction target, or backend/post-processing failure. Inspect the diagnostic instead of parsing exception text:

from molgr import ReconstructionError
from molgr.interface import xyz_to_rdmol

try:
    # One electron cannot have singlet multiplicity.
    xyz_to_rdmol("1\nhydrogen\nH 0 0 0\n", spin_multiplicity=1)
except ReconstructionError as exc:
    print(exc.diagnostics.code.value)
    print(exc.diagnostics.stage)
INVALID_ELECTRONIC_TARGET
input.electronic_state

For the hydrogen example above, the neutral atom has one electron. If the intended target is neutral atomic hydrogen, repeat the call with spin_multiplicity=2. For a failed batch item, inspect its status and retain the corresponding request when retrying.

For exploratory inspection, config.interface.reconstruction_failure_policy = "return_suspicious" can return Open Babel's initial bond perception after a reconstruction failure. Such a molecule is untrusted, carries _MolGRReconstructionStatus="suspicious_fallback", and must be reviewed; input validation can still raise. In batches, a suspicious molecule retains a non-None status. Diagnostic codes and fields

Diagnostic codes and failure policy