This release is a pre-release and may not be stable for production use.
molpy
A programmable toolkit for molecular simulation workflows
MolPy is a Python toolkit for the full molecular-system workflow — parsing, building, editing, typing, analyzing, and reading/writing simulation formats. Packing a box is the job of the companion package molpack.
Under active development. Public APIs may change between minor releases.
Vision
Molecular modeling is fragmented. Every simulation code has its own file formats and conventions; every task — parsing, building, typing, analysis, visualization — lives in a separate library; and moving a system between them means writing throwaway glue.
molpy aims to be the common foundation beneath that workflow: one explicit, programmable representation of a molecular system that every stage can share. Parse a structure into it, build on it, type and analyze it — then hand the same object onward, with no conversion step in between.
That representation is meant to be built on, not just used. It is the data model the MolCrafts ecosystem extends — visualization, experiment management, agent access — and it reads the same whether a human writes it or an agent calls it.
Capabilities
Every name is reached through import molpy as mp, and molpy is a thin layer
over the native core (molrs): every native name is the molrs object. Every
molrs subsystem is mirrored by a molpy module (mp.core for molrs.core —
stores, graphs, box, neighbour search and units — then mp.io, mp.ff, mp.perceive,
mp.compute, mp.builder, …). The core data classes you handle directly
(mp.Frame, mp.Block, mp.Trajectory, mp.Box, mp.Atomistic, …) are
promoted to the root, as the same objects.
| Where | Capability |
|---|---|
mp.*, core, perceive, conformer, optimize |
Explicit data model — Frame / Block columnar arrays, Trajectory, editable Atomistic / CoarseGrain graphs and Box on the root; regions, neighbour search, units, molpy's selectors and trajectory splitters in mp.core; perception and SMARTS (mp.perceive.SmartsPattern), 3D conformers (mp.conformer.Conformer), the mp.optimize.Lbfgs minimizer |
ff |
Force fields, mirroring molrs.ff — forcefield (the ForceField data model), potential (kernels), compile (PotentialCompiler), typifier (OPLS-AA, MMFF94, GAFF / GAFF2 natively; AM1-BCC charges via AmberTools), charge, ir (the IR's vocabulary), style_registry (your own styles from Python), params, clpol_scaling |
builder |
Site-graph assembly (Assembler), graphene and nanotubes, polymer planning and polydispersity, crystals, virtual sites, packing templates |
compute |
Analysis — Rdf, Msd, conductivity, order parameters, Voronoi, dielectric and vibrational spectra, time-correlation functions, … (native kernels) |
io |
Read/write — PDB, GRO, LAMMPS data, XYZ, AMBER, SMILES / CGsmiles, trajectories, *.mrec records, … |
engine |
MD input generation & run management — LAMMPS, GROMACS, OpenMM, CP2K |
wrapper · adapter |
External CLIs (Antechamber, tleap, …) and optional RDKit in-memory bridge |
Install
pip install molcrafts-molpy
# Browser (Pyodide) — needs molcrafts-molrs Pyodide wheel on PyPI:
# await micropip.install("molcrafts-molrs")
# await micropip.install("molcrafts-molpy")
Core dependencies: NumPy and
molrs on molpy's own major.minor line
(molpy X.Y.* needs molcrafts-molrs>=X.Y.0,<X.(Y+1); import molpy checks it)
plus the MolCrafts logging/config packages. Optional: RDKit (adapter example),
AmberTools (AM1-BCC charges and AMBER polymer chains; GAFF typing itself is
native).
Nightly builds. Bleeding-edge snapshots are published to the separate project
molcrafts-molpy-nightly(versionedX.Y.Z.devN) on every push to thenightlybranch. Install withpip install --pre molcrafts-molpy-nightly. It imports asmolpy, so it cannot be installed alongside the stablemolcrafts-molpy(same astensorflowvstf-nightly).
Install from source (development)
git clone https://github.com/MolCrafts/molpy.git
cd molpy
uv sync --extra dev
pre-commit install --hook-type pre-commit --hook-type pre-push
# the two gates (same as the hooks / CI):
uv run --no-project --with 'tox>=4.23' --with ruff==0.16.1 --with ty==0.0.65 tox -e lint
uv run --extra dev python -m pytest tests/ -n auto
uv sync does not install the partners from PyPI: [tool.uv.sources] points
molcrafts-molrs, molcrafts-mollog and molcrafts-molcfg at sibling
checkouts (../molrs/molrs-python, ../mollog, ../molcfg) and builds molrs
from source, so clone them beside molpy first, or run python scripts/check.py verify, which resolves the pinned partner commits into a cached layout. Only
pip install molcrafts-molpy takes molrs from PyPI.
See docs/developer/development-setup for the full workflow.
Quick start
Parse a SMILES string, assign OPLS-AA types, and write LAMMPS input files:
import molpy as mp
from pathlib import Path
mol = mp.io.smiles.SmilesIr("CCO").to_atomistic() # ethanol from SMILES
mol3d, _ = mp.conformer.Conformer(seed=42).generate(mol) # hydrogens + 3D coordinates
typifier = mp.ff.typifier.OplsAaTypifier() # carries the OPLS-AA library
typed = typifier.typify(mol3d)
ff = typifier.forcefield() # parameters of the assigned types
system = typed.to_frame()
system.box = mp.Box.cube(30.0)
system["atoms"]["mol_id"] = mp.Topology.from_frame(system).connected_components() + 1
# the pair cutoff is a run setting: you declare it, molpy never invents one
ff.get_style("pair", "lj/cut")["cutoff"] = 10.0
ff.get_style("pair", "coul/cut")["cutoff"] = 10.0
out = Path("output"); out.mkdir(exist_ok=True)
mp.io.write_lammps_data(out / "system.data", system)
mp.io.write_lammps_forcefield(out / "system.ff", ff, system)
More workflows — packed solvent boxes, virtual-site models, polymer architectures (the stress test for MolPy's editing machinery), AmberTools parameterization — are in the Example Gallery and the task-oriented Guides.
Documentation
Full documentation, including executable notebooks: docs.molcrafts.org/molpy
- Getting Started — install and first example
- Example Gallery — short copy-paste workflows
- Guides — task-oriented notebooks
- Concepts — data model deep dives
- API Reference — full API
MolCrafts ecosystem
| Project | Role |
|---|---|
| molpy | Python toolkit — the shared molecular data model & workflow layer — this repo |
| molrs | Rust core — molecular data structures & compute kernels (native + WASM) |
| molpack | Packmol-grade molecular packing (Rust + Python) |
| molvis | WebGL molecular visualization & editing |
| molexp | Workflow & experiment-management platform |
| molnex | Molecular machine-learning framework |
| molq | Unified job queue — local / SLURM / PBS / LSF |
| molcfg | Layered configuration library |
| mollog | Structured logging, stdlib-compatible |
| molhub | Molecular dataset hub |
| molmcp | MCP server for the ecosystem |
| molrec | Atomistic record specification |
Contributing
Issues and pull requests are welcome — see Contributing.
License
BSD-3-Clause — see LICENSE.
Metadata
Release files for molcrafts-molpy-nightly 0.19.0.dev202610211431
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| molcrafts_molpy_nightly-0.19.0.dev202610211431.tar.gz | 127.7 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| molcrafts_molpy_nightly-0.19.0.dev202610211431-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 280.9 kB
Release files / molcrafts_molpy_nightly-0.19.0.dev202610211431.tar.gz
| Download URL | molcrafts_molpy_nightly-0.19.0.dev202610211431.tar.gz |
|---|---|
| Size | 127.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e7f4a38c0fb968e793b9d88a27370b045f85a29eb580425d428a945a34dc5cce
|
|
BLAKE2b-256 checksum How to use checksums |
6755e30a69b1e9e408c9bf1e9eaa61b5be82eba9018ac26ebff47622c741f873
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.
Transparency logRelease files / molcrafts_molpy_nightly-0.19.0.dev202610211431-py3-none-any.whl
| Download URL | molcrafts_molpy_nightly-0.19.0.dev202610211431-py3-none-any.whl |
|---|---|
| Size | 153.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b23fd0d7696fa070fbde9d87c99c8cb476c9e051daaf496d193cac408a71896c
|
|
BLAKE2b-256 checksum How to use checksums |
705e76bd1f76b760e60c6cb0617bd1d11588caadcb6142cea869139dd1dc01b7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.
Transparency logSecurity for molcrafts-molpy-nightly 0.19.0.dev202610211431
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for molcrafts_molpy_nightly-0.19.0.dev202610211431.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.