Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

 molpy

A programmable toolkit for molecular simulation workflows

CI PyPI Python License Ruff

Documentation  ·  Quick start  ·  Examples  ·  Ecosystem

MolPy is a Python toolkit for the full molecular-system workflow — parsing, building, editing, typing, analyzing, packing, and reading/writing simulation formats.

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

Each row is one src/molpy/ module — parse or build a structure, edit and type it, analyze or minimize it, then read and write it across formats.

Module Capability
core Explicit data model — editable Atomistic topology graph, Frame/Block columnar arrays, ForceField, Box
parser SMILES / SMARTS (via molrs types: SmilesIR, SmartsPattern); moltemplate .lt reader
builder System assembly — polymers, crosslinking, polydispersity, virtual sites, AmberTools facade
conformer 3D coordinate generation (molrs ETKDG + MMFF cleanup)
typifier Atom typing — OPLS-AA, CL&P, MMFF, GAFF via AmberTools
potential · optimize Energy & force potentials with L-BFGS minimization
compute Analysis modules under molpy.computerdf/msd/dielectric/spectra/order/voronoi/… (molrs kernels)
pack Packmol-based packing with density targets
io Read/write — PDB, GRO, LAMMPS data, XYZ, force fields, trajectories, …
engine MD input generation & run management — LAMMPS, CP2K, OpenMM
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 (molcrafts-molrs>=0.14.0,<0.15) plus the MolCrafts logging/config packages. Optional: RDKit (adapter example), AmberTools (GAFF charges).

Nightly builds. Bleeding-edge snapshots are published to the separate project molcrafts-molpy-nightly (versioned X.Y.Z.devN) on every push to the nightly branch. Install with pip install --pre molcrafts-molpy-nightly. It imports as molpy, so it cannot be installed alongside the stable molcrafts-molpy (same as tensorflow vs tf-nightly).

Install from source (development)
git clone https://github.com/MolCrafts/molpy.git
cd molpy
pip install -e ".[dev]"   # includes tox (gate driver)
prek install
# optional manual gates (same as prek/CI):
#   uv run --extra dev tox -e lint
#   uv run --extra dev tox -e py
pytest tests/

pip install -e ".[dev]" pulls the published molcrafts-molrs wheel from PyPI. To develop molpy against a local molrs checkout (e.g. when changing the Rust core), build molrs editable first — molrs ships its Python bindings as a maturin project that needs the Rust toolchain via rustup:

git clone https://github.com/MolCrafts/molrs.git
cd molrs
pip install maturin
maturin develop -m molrs-python/Cargo.toml --release   # installs `molrs` editable
cd ../molpy
pip install -e ".[dev]"                                # resolves molrs from the local build

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

mol   = mp.Atomistic.from_smiles("CCO")          # ethanol from SMILES
ff    = mp.io.read_xml_forcefield(mp.data.get_forcefield_path("oplsaa.xml"))  # bundled OPLS-AA
typed = mp.typifier.OplsAtomisticTypifier(ff).typify(mol)

mp.io.write_lammps_system("output/", typed.to_frame(), ff)
# → output/system.data  output/system.in

More workflows — packed solvent boxes, virtual-site models, polymer chains and networks (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

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.


Crafted with 💚 by MolCrafts

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file molcrafts_molpy_nightly-0.14.0.dev202608281318.tar.gz.

File metadata

File hashes

Hashes for molcrafts_molpy_nightly-0.14.0.dev202608281318.tar.gz
Algorithm Hash digest
SHA256 d9fd679871995e3cd12912afad38fece3794629571d44796faf92808baf9cd78
MD5 16c01e75d69d34bca663df1194b4f0f5
BLAKE2b-256 a5644faedfdedd731a79380d7e8bcaeb833f72b15b8be7f5898950d3c8eb8020

See more details on using hashes here.

Provenance

The following attestation bundles were made for molcrafts_molpy_nightly-0.14.0.dev202608281318.tar.gz:

Publisher: nightly.yml on MolCrafts/molpy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file molcrafts_molpy_nightly-0.14.0.dev202608281318-py3-none-any.whl.

File metadata

File hashes

Hashes for molcrafts_molpy_nightly-0.14.0.dev202608281318-py3-none-any.whl
Algorithm Hash digest
SHA256 5383510e5a55fdad65c194ccff2151dec50ccf09adb08bf4f87569c1e16565b0
MD5 279d5b39459d7e7bdbbe6b8dca452042
BLAKE2b-256 6ecdef93d8bb710d6a074cf75adcfc3054fd2f25325481167126e115ca459377

See more details on using hashes here.

Provenance

The following attestation bundles were made for molcrafts_molpy_nightly-0.14.0.dev202608281318-py3-none-any.whl:

Publisher: nightly.yml on MolCrafts/molpy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page