MolPy
The pipeline
From a molecule description to a runnable system¶
Chemistry, coordinates, and force-field parameters stay in separate layers. You can stop after any stage, inspect what you have, and continue — without shuttling everything through disk.
The Quickstart walks through one full system end to end. The Example Gallery collects shorter copy-paste recipes.
In practice
Each stage is a few lines of Python¶
The cards below follow the same six stages. Polymers show up often because crosslinking and polydispersity stress the editing machinery — not because MolPy is limited to polymers.
Describe chemistry as text¶
One line of SMILES or BigSMILES becomes an editable structure — a single molecule or a polymer chain.
Rewire the topology¶
Merge structures, form and break bonds, drop leaving groups, then re-derive angles and dihedrals across the new junction.
Assign force-field types¶
SMARTS matching maps every atom, bond, angle, and dihedral to parameters you can inspect before anything is exported.
Fill a periodic box¶
Clash-free placement at a target density via
molpack — Packmol-grade packing as a
library, no external binary (pip install molcrafts-molpack).
# docs: skip — optional molcrafts-molpack; not a molpy runtime/doc dep
from molpack import InsideBoxRestraint, Molpack, Target
target = (
Target(system, count=500)
.with_restraint(InsideBoxRestraint([0.0, 0.0, 0.0], [30.0, 30.0, 30.0]))
)
system = Molpack().with_seed(42).pack([target], max_loops=200)
Write files your engine runs¶
One call per file: LAMMPS data plus force-field coefficients. GROMACS, PDB,
and Zarr (MolStore) writers share the same pattern.
Turn trajectories into observables¶
Feed the same Frame into the compute layer — neighbor search and \(g(r)\) in two calls, with many more analyses behind them.
By design
Built to be composed, not locked in¶
A library first: one shared data model, a high-performance core, and explicit seams. Take one piece, leave the rest, or extend any layer without forking the package.
- One data structure across the ecosystem
- molpack, molvis, and molmcp speak the same
Frame/Block. No converters between libraries. - A high-performance kernel underneath
- Storage and compute live in the high-performance backend. Python sees zero-copy NumPy views on the public facade.
- Built for LLM agents
- The molmcp suite exposes symbols and docs over MCP so an agent can call the real API instead of guessing from training data.
- Use one piece or all of them
- Parser, builder, typifier, packer, I/O, and compute talk only through explicit data. Import the layer you need and ignore the rest.
- Registries, not hardcoded lists
- Register a compute operator, I/O format, force-field style, or typifier from outside the core without patching the package itself.
- Typed end to end
- Public APIs carry full type hints, checked in CI with Astral’s
ty. Your editor sees real signatures, notAny.
Ecosystem
The structure you build is the structure everything else reads¶
MolPy, molpack, molvis, and molmcp share the same abstract data structure. You do not write glue adapters between them. Figure 1 is molvis drawing that structure in the browser — drag to rotate (needs the published molvis-stage Web Component).
Figure 1. Aspirin (PubChem) in molvis, ball-and-stick, from inline XYZ.
- molpack
- Clash-free packing as a CLI, a library crate, and a Python package — same engine everywhere.
- molmcp
- MCP server for LLM agents: code discovery plus live ecosystem providers.
- Native backend
- The shared high-performance molecular kernel — Frame, Block, and compute, with Python and other bindings.
Integrations
Optional tools, explicit boundaries¶
External packages plug in through adapters and wrappers. Nothing is required beyond the default install; every seam is visible in the API.
- RDKit
- Bidirectional
Atomistic↔Molfor embedding, conformers, and SMILES export. - AmberTools
- antechamber, parmchk2, and tleap driven from Python for GAFF charges and topologies.
- molpack
- Clash-free packing into periodic boxes through a typed restraint interface.
- LAMMPS · CP2K · OpenMM
- Ready-to-run input decks generated from MolPy data objects.
- Native backend · MCP
- High-performance column store and compute underneath; MCP exposes symbols and docs to agents.
Find your page
How the manual is split¶
Tutorials teach: install, a first system, then the data model chapter by chapter. Guides do the work: end-to-end recipes once you know the model. Reach for compute, API, or developer pages when you already know the task.
Tutorials¶
Install, quickstart, then the data model one chapter at a time.
Guides¶
Task recipes — parse, build, typify, pack, export — that assume the tutorials.
Compute¶
Trajectory analysis: distributions, transport, order, spectra, workflows.
API Reference¶
Every public module, from core data structures to engine adapters.
Developer Guide¶
Contributing, architecture, and how to extend compute, I/O, and typifiers.