Repository navigation
Releases
v0.1.11
MolGR v0.1.11
MolGR now uses ligand geometry and electron assignments together to rank candidate molecular graphs for metal complexes. Both reconstruction backends also check that the explicit-hydrogen graph survives an RDKit SMILES round trip. The primary result remains an RDKit Mol with the input atom order, all hydrogen atoms and the original 3D coordinates.
Molecular graph reconstruction
- Ligand and metal electronic states. The C++ and Python backends retain competing ligand bond orders, formal charges and radical assignments under the specified total charge and spin multiplicity. Bond lengths and local geometry help distinguish nitrosyl, hydrazido, carbene and conjugated redox states. Both backends now resolve tied mixed-metal candidates in the same order. PR #11 · PR #12
- Metal coordination. Donor orientation helps distinguish terminal, bridging and side-on contacts. For example, a phosphine donates through the open face of its pyramid, while a bent ether can offer two donor directions. The revised rules also restore missing contacts in aromatic haptic coordination and avoid assigning extra contacts across the middle of a chelate. PR #12
- Ring connectivity and Python performance. Both backends preserve covalent C–N bridges that the four-membered-ring cleanup could previously remove as diagonals. The Python backend also reuses ligand topology and resonance scores and makes fewer Open Babel graph traversals during electronic-state cleanup. PR #14
RDKit output and graph equivalence
- SMILES round trips. Successful reconstructions now undergo graph validation with the installed RDKit by default. The check compares explicit hydrogen nodes, formal charges, bond orders, aromaticity and dative-bond direction under the writer’s atom mapping. Use
molgr.mol_from_smiles()to read the explicit-H graph ormolgr.validate_smiles_roundtrip(mol, check_stereochemistry=True)to check stereo labels as well. Keep the returnedMolfor 3D coordinates and MolGR electronic annotations. SMILES round-trip contract - Resonance equivalence. The native evaluator tries short resonance paths across compatible atom mappings before deepening the search. Regions, mappings and retries share one budget. The default
max_resonancerises from 1,000 to 5,000, allowing up to 10,000 generated states across both directions. A search that exhausts its budget without a proof returnsinconclusive. Graph equivalence
Upgrading from v0.1.10
- Callers that compare saved SMILES strings or individual atomic charges may see changes. Aromaticity is refreshed after coordination edits. For metal acceptors with restricted RDKit valence, a contact can be written as an ordinary bond with compensating formal-charge changes on the donor and metal. The total charge is preserved. Single and batch reconstruction accept
kekulize=Falsefor aromatic bond types. PR #10 - A failed automatic SMILES check is reported as
SMILES_ROUNDTRIP_FAILED. To disable that check explicitly, setconfig.interface.require_smiles_roundtrip = False. Batch callers can attach arequest_idto aReconstructionBatchRequestand recover it from the result or the item exception, including on failure. API reference - For reconstruction, the default
config.resonance.max_depthincreases from 2 to 3 andlimited_discrepancy_max_discrepancyfrom 1 to 2. These control candidate generation. To retain the previous budget for comparing two completed graphs, passmax_resonance=1000toevaluate_equivalence(). Removeenable_target_bucket_score_bundle_preheatfrom custom C++ backend configurations. - The
benchmarks.dataset_xyz_benchmarktools replace the legacy tmQMg CSV runner. The local review web service, its Docker image and queue commands have been removed. The reconstruction trace remains available for offline inspection. Benchmark migration
Reconstruction benchmark
Seven methods each processed the same 560,384 eligible structures across GEOM-QM9, GEOM-Drugs, BorylXAT-DB, tmQMg-Corrected and BDE, for 3,922,688 reconstruction attempts. MolGR C++ matched 97.22% to 99.97% of the reference graphs across the five datasets. Each percentage uses all eligible structures in that dataset. Scoring allows resonance equivalence and ignores stereo labels and metal coordination edges by default. The figure gives all seven methods’ match rates, outcome counts and runtime distributions. Benchmark figure and results
The two GEOM cohorts ship with fixed parent and conformer indices. The BorylXAT-DB and BDE importers use released geometries and radical references, and the adapters receive charge and spin information independently of the reference graph. Cohort definitions
The frozen run used 64 single-threaded workers pinned to physical cores in the same Docker image. Reconstruction had a 10-second limit and reference comparison a separate 5-second limit. Reconstruction timeouts contribute 10 seconds to the timing distribution. Input timeouts are counted separately and have no reconstruction time. The runner records the environment and retries failed worker starts and task delivery. Scoring protocol
The benchmark asset is molgr-benchmark-0714b6eac847eaacae8bff0fa66f97f73df87b70.zip, with a companion .sha256 file. It contains the 35-run summary, per-structure outcomes, case IDs and environment records. The filename identifies the measured source commit. Reproduction guide
Documentation and validation
The versioned English and Simplified Chinese guides cover reconstruction, batch processing, diagnostics and graph equivalence. The 338-S tutorial reconstructs an Fe–Pd–Fe complex and draws its coordination bonds from the returned molecule. Documentation · 338-S tutorial
The macOS wheel workflow builds for Apple Silicon and Intel with a macOS 14.0 deployment target. Maintainers can resume an interrupted stable release from its existing tag. Release workflow changes
CI passed on Linux, macOS and Windows for Python 3.8 through 3.14. Ubuntu with Python 3.11 ran the full suite, including exhaustive fixtures and stress tests. The bilingual documentation build and deployment also passed. CI results · Documentation build
v0.1.10
What's Changed
- Boron radical handling: improve processing efficiency and support for boron radical anions, with consistent electron counting across C++ and Python and expanded BorylXAT regression coverage.
- RDKit post-processing: fix incorrect 3D stereochemical assignments and stale electronic annotations after coordination edits.
- Equivalence checking: introduce a faster C++ evaluator with regional bidirectional resonance search, improved electronic-property and stereo handling, and more reliable benchmark scoring. See PR #7.
Compared with v0.1.9
Sequential evaluation of the same 4,929 saved tmQMg molecule pairs, averaged over two runs per version:
| Stereo checking | Version | Time | EQ | NEQ | INC |
|---|---|---|---|---|---|
| Off | v0.1.9 | 80.821 s | 3,987 | 844 | 98 |
| Off | v0.1.10 | 3.832 s | 4,450 | 460 | 19 |
| On | v0.1.9 | 88.760 s | 3,088 | 1,683 | 158 |
| On | v0.1.10 | 4.974 s | 3,730 | 460 | 739 |
Evaluation is 21.1x faster with stereo checking off and 17.8x faster with it on, using each version's default resonance budget. Timings exclude SMILES parsing and XYZ reconstruction. The reference SMILES lack stereo tags; increased INC with stereo checking reflects more conservative handling of missing information. Higher EQ counts do not by themselves establish higher accuracy.
Compatibility Notes
- Default resonance budget increases to
max_resonance=1000, withmax_resonance_steps=24. - Stereo checking is now disabled by default; metal coordination bonds are ignored by default.
- Remove
resonance_flagsfrom calls. Options aftermax_resonanceare now keyword-only. - EQ requires structural evidence; unsupported or exhausted searches remain INC. Use
evaluate_equivalence(...).decisionto distinguish INC from NEQ.
Validation
Cross-platform CI passed on Linux, macOS, and Windows with Python 3.8–3.14. Full local suite: 1412 passed, 22 skipped, 1 xfailed.
Contributors
- @gentle1999 (Miao-Jiong Tang): project and main-branch maintenance, boron radical and stereo fixes, equivalence revisions and performance optimization, and release integration.
- @Hyperbolica-dev: evaluator v2 and benchmark validation contributions in PR #7.
Full Changelog: v0.1.9...v0.1.10
v0.1.9
What's Changed
- feat(equivalence): add conservative tri-state molecular representation evaluator by @Hyperbolica-dev in #6
New Contributors
- @Hyperbolica-dev made their first contribution in #6
Full Changelog: v0.1.8...v0.1.9
This release introduces a more conservative and auditable evaluator for comparing molecular representations, together with improved regression and review tooling.
Highlights
- Added
evaluate_equivalence(...) -> EquivalenceResultwith three explicit decisions:EQUIVALENTNOT_EQUIVALENTINCONCLUSIVE
- Added structured evaluation evidence, including invariant checks, comparison relations, contradiction reasons, raw molecule diagnostics, normalization effects, and bounded-search metadata.
- Strengthened open-shell equivalence handling:
- InChIKey agreement and heuristic similarity no longer prove equivalence by themselves.
- Added explicit three-center open-shell resonance witness matching.
- Bounded or exhausted searches now report
INCONCLUSIVE.
- Updated benchmark, tmQMg regression, and review tools to preserve inconclusive outcomes instead of treating them as ordinary mismatches.
- Added a compact architecture overview figure in SVG format, together with its editable Drawio source.
- Expanded regression coverage for open-shell resonance, identifier-only evidence, bounded searches, metal normalization, RDKit representation differences, and C++/Python backend parity.
Compatibility Notes
check_equivalence(...)remains available with its existing(bool, result)return shape.- Its boolean result is
Falsefor bothNOT_EQUIVALENTandINCONCLUSIVE. Useevaluate_equivalence(...).decisionwhen the distinction matters. - Metal-complex equivalence remains scoped to the normalized organic graph and metal element/formal-charge state. It does not establish full coordination connectivity, oxidation-state assignment, or metal spin-state identity.
Validation
Targeted equivalence, backend parity, SMILES regression, and tmQMg fixture tests pass.
v0.1.8
Full Changelog: v0.1.7...v0.1.8
Improved fallback resonance cleaning for adjacent unresolved electron centers and radicals.
Changes
- Unified Python and C++ clean_neighbor_radicals electron-budget handling.
- Treat unresolved centers as two-electron capacities.
- Support budget-limited partial closure into double bonds.
- Preserve remaining electrons for subsequent charge and radical classification.
- Added regression tests for full, partial, and blocked closure.
- Added two charge-1 doublet XYZ stress fixtures.
Validation
uv run pytest -q passes, with one existing expected XFAIL.
v0.1.7
Full Changelog: v0.1.6...v0.1.7
Highlights
-
Fixed fallback reconstruction for charged open-shell geometries by re-checking the target radical count during every negative-charge elimination iteration.
-
Improved resonance cleanup for adjacent unresolved two-electron centers by closing the corresponding single bond into a triple bond.
-
Added azide resonance normalization:
[*]-N=N-[N]→[*]-N=[N+]=[N-] -
Synchronized the Python and C++ implementations, SMARTS patterns, bindings, and type declarations.
-
Added regression coverage and geometry fixtures for all three reconstruction cases.
-
Exposed
make_dative_bondthrough the public Python API.
Validation
- C++ build completed successfully.
- Ruff checks and formatting checks passed.
- Full test suite passed with one expected existing
xfail.
v0.1.6
Full Changelog: v0.1.5...v0.1.6
This release hardens MolGR’s native concurrency boundaries around Open Babel, with particular attention to forked processes, nested parallelism, native resource lifetimes, and Windows runners.
Highlights
-
Added fork-after-import detection.
- MolGR now rejects protected native API calls from a POSIX child created with fork after MolGR/Open Babel has been initialized.
- spawn, fork-before-import, and fork followed immediately by exec remain supported.
-
Isolated process-lived native resources.
- Native executor lifetime is tied to the process.
- Open Babel and UFF thread-local ownership and cleanup boundaries were tightened.
- Shared SMILES conversion state is accessed through a controlled native boundary.
-
Added dangerous-use warnings.
- Low-level APIs exposing raw OBMol* pointers emit a one-time [UNSAFE_OPENBABEL] warning.
- Raw Open Babel objects must not be shared across threads or processes and must be released exactly once.
-
Improved native batch scheduling.
- The native batch scheduler owns the outer worker budget.
- Nested target-bucket and candidate-scoring parallelism is disabled when multiple batch workers are active.
-
Clarified spawn process support.
- Calling molgr.interface.xyz_to_rdmol() directly from a spawn worker is supported.
- Windows stress tests keep native batch workers within the documented max_threads=1 safety boundary.
-
Expanded concurrency stress coverage.
- Added native-batch and spawn-process stress modes.
- Tests process at least 1,000 XYZ inputs.
- Repository XYZ fixtures are used automatically when the full tmQMg dataset is unavailable.
- Worker counts are derived from the runner’s available CPU budget, including CPU affinity and Linux cgroup limits.
- Stress output records the detected CPU budget and effective worker configuration.
Recommended Usage
- Prefer iter_xyz_to_rdmol_batch() for high-throughput workloads.
- Use multiprocessing.get_context("spawn") for multiprocessing on Linux and macOS.
- Do not call MolGR native APIs from a child created by fork after MolGR/Open Babel import.
- Do not share OBMol*, Pybel objects, or other raw Open Babel objects across threads or processes.
- Do not wrap the native batch API in an additional Python thread or process pool.
- Keep CONFIG.cpp_backend.max_threads=1 on Windows unless the complete workload has been independently validated.
Validation
- Full local test suite: 667 passed
- Process guard and spawn stress tests passed
- Native batch and spawn XYZ stress tests passed
- Ruff checks, formatting checks, and git diff --check passed
Compatibility Notes
This release substantially tightens MolGR’s own concurrency and lifetime boundaries, but it does not claim that every Open Babel API is thread-safe under every calling pattern. Applications using unrelated
raw Open Babel/Pybel APIs, untrusted inputs, or shared native objects should continue to use process-level isolation.
v0.1.5
Full Changelog: v0.1.4...v0.1.5
This release adds production-ready native batch reconstruction, structured failure diagnostics, and safer native concurrency management.
Highlights
- Added stable reconstruction diagnostics:
ReconstructionFailureCodeRECONSTRUCTION_FAILURE_CODESReconstructionDiagnosticsReconstructionError
- Replaced the generic
xyz2omol failedmessage with machine-readable failure codes, execution stages, counters, details, and root causes. - Added the streaming native batch API:
from molgr import ReconstructionBatchRequest, iter_xyz_to_rdmol_batch requests = ( ReconstructionBatchRequest(xyz, total_charge=0, spin_multiplicity=1) for xyz in xyz_blocks ) for request, molecule, status in iter_xyz_to_rdmol_batch( requests, backend="cpp", max_workers=None, ): ...
- Batch results use the (input, result, status) protocol, preserving input/result correspondence even with ordered=False.
- Batch failures are isolated per item by default; raise_on_error=True is available for fail-fast workflows.
- Native batch scheduling now owns the outer worker budget and prevents nested target-bucket and candidate-scoring oversubscription.
- Single-molecule calls retain C++ metal target-bucket parallelism for low-latency execution.
- The Python backend remains sequential as the semantic reference implementation.
- Improved Open Babel thread-lifetime handling for persistent native workers and repeated batch execution.
- Updated tmQMg and SMILES/XYZ benchmarks and scripts to use native batch execution.
- Added a reproducible 1,000-item throughput benchmark and report.
- Updated English and Chinese documentation with the recommended parallel execution strategy.
Performance
On 1,000 unique tmQMg XYZ inputs with automatic native worker selection:
| Interface | Throughput | Success |
|---|---|---|
| High-level C++ batch with RDKit post-processing | 264.8 molecules/s | 998/1000 |
| Native data-layer batch | 267.1 molecules/s | 998/1000 |
The two failed inputs were reported as NO_VALID_ORGANIC_CANDIDATE rather than being collapsed into a generic backend failure.
Compatibility
- xyz_to_rdmol() remains the default single-molecule entrypoint.
- ReconstructionError remains ValueError compatible.
- Existing suspicious-fallback behavior is preserved.
- Use the high-level batch API when downstream code requires rdkit.Chem.Mol.
- Use the lower-level native batch interface only when downstream code directly consumes native MoleculeData.
Validation
- All CI jobs passed.
- Local test suite: 649 passed.
- Coverage: 89%.
- C++ editable rebuild, Ruff, Mypy, Pyright, lock-file validation, and staged diff checks passed.
v0.1.4
What's Changed
- Develop by @gentle1999 in #5
Full Changelog: v0.1.3...v0.1.4
Highlights
- Reclaim thread-local native resources with RAII ownership, including Open Babel conversions, SMARTS patterns, force-field caches, and compiled UFF rules.
- Release worker-local allocations when external worker threads exit, with regression coverage for worker churn and RSS growth.
- Keep MolGR-owned UFF instances private and unregistered from Open Babel's global plugin registry.
- Fail fast when the XYZ or SMILES output serializers are unavailable.
- Add cross-platform ownership checks for native thread-local resources, including Windows path normalization.
CI and Packaging
- Build Linux
x86_64andaarch64wheels on native runners instead of QEMU. - Continue publishing wheels across Python 3.8-3.14 for Linux, Windows, and macOS.
- Keep the wheel smoke test focused on importing
molgr,molgr._core, and the public reconstruction entry point.
Compatibility
- No public Python API changes.
- The existing Windows default of single-threaded C++ execution remains unchanged.
v0.1.3
What's Changed
- Develop by @gentle1999 in #3
Full Changelog: v0.1.1...v0.1.3
MolGR 0.1.3 fixes cross-version reconstruction of aromatic sulfur oxides and improves charge and radical cleanup consistency between the
Python and C++ backends.
Fixed
- Normalize hypervalent sulfur-oxygen bonds during pre-cleaning even when Open Babel perceives sulfur as aromatic.
- Assign negative charge around positive high-valence centers in descending electronegativity order.
- Stop local charge assignment once the positive center is neutralized, preventing lower-electronegativity nitrogen atoms from being
incorrectly converted toN-. - Resolve continuous four-center radical or unresolved two-electron states into the conjugated
A=B-C=Dpattern immediately after possible
1,3-dipole cleanup. - Restore the chemically appropriate
[S+][O-]state without requiring identical aromaticity perception across Open Babel versions. - Keep Python and C++ reconstruction behavior and trace ordering aligned.
Compatibility
The regression is fixed with both supported Open Babel behavior families:
- Python 3.8 / Open Babel 3.1
- Python 3.10 / Open Babel 3.2
No public API changes are introduced.
Validation
- Python 3.8 / Open Babel 3.1: 630 tests passed
- Python 3.10 / Open Babel 3.2: 630 tests passed
- Ruff checks and formatting checks passed