Skip to main content

 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 (atoms, bonds, angles, dihedrals), Frame/Block columnar arrays, ForceField, Box
parser Grammar-based parsing — SMILES, SMARTS, BigSMILES, G-BigSMILES, CGSmiles
builder System assembly — linear / branched / cyclic polymers, polydispersity sampling (Schulz-Zimm, Poisson, Flory-Schulz), residue management
embed 3D coordinate generation for parsed or built topologies
op · reacter Structure editing — geometric transforms; template-based reactions with leaving-group selectors and LAMMPS fix bond/react templates
typifier Atom typing — OPLS-AA, GAFF / GAFF2, custom SMARTS / SMIRKS typifiers
potential · optimize Energy & force potentials with L-BFGS minimization
compute Analysis — RDF, MSD, clustering, shape & gyration, dielectric, neighbor lists, custom operators
pack Packmol-based packing with density targets
io Read and write — PDB, GRO, LAMMPS data, XYZ, JSON, HDF5, force fields, and trajectories
engine MD input generation & run management — LAMMPS, CP2K
wrapper · adapter External CLIs (Antechamber, Prepgen) and library bridges (RDKit, OpenBabel)

Install

pip install molcrafts-molpy

Core dependencies: NumPy, python-igraph, Lark, Pint, and molrs (the Rust numerical core). Optional: RDKit (3D geometry), 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/ -m "not external"

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.parser.parse_molecule("CCO")          # ethanol from SMILES
ff    = mp.io.read_xml_forcefield("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: molpy.molcrafts.org

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.

MolPy ports or adapts code, algorithms, and data from other projects (freud, foyer, OpenMM, moltemplate, RDKit, and others). All third-party attributions and their license terms are consolidated in Third-Party Attributions.


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

molcrafts_molpy-0.10.0.tar.gz (416.2 kB view details)

Uploaded Source

Built Distribution

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

molcrafts_molpy-0.10.0-py3-none-any.whl (505.5 kB view details)

Uploaded Python 3

File details

Details for the file molcrafts_molpy-0.10.0.tar.gz.

File metadata

  • Download URL: molcrafts_molpy-0.10.0.tar.gz
  • Upload date:
  • Size: 416.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for molcrafts_molpy-0.10.0.tar.gz
Algorithm Hash digest
SHA256 2d96e7e7e34baa0905eb0ab7e438bd67f1e236d8644512921bdefcbd0faa968e
MD5 ce4a91a13de32f6d17e5dfece57db9f2
BLAKE2b-256 06be793fcf17d6ae58abdfde81e9513b8c5282a5c74945b1596e5c5cfb36b5f7

See more details on using hashes here.

Provenance

The following attestation bundles were made for molcrafts_molpy-0.10.0.tar.gz:

Publisher: release.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-0.10.0-py3-none-any.whl.

File metadata

File hashes

Hashes for molcrafts_molpy-0.10.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8f4f3fc3433c4b6871dbd235ce47e3b32e384548fd9c1afe6f57a7876c22ae92
MD5 3e16046f67535fa45b647e030f121e53
BLAKE2b-256 a01addbfaac04651fc35aec6cab5427734235cf91d2298ba8c8d30aa643ba977

See more details on using hashes here.

Provenance

The following attestation bundles were made for molcrafts_molpy-0.10.0-py3-none-any.whl:

Publisher: release.yml on MolCrafts/molpy

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

Release history Release notifications | RSS feed

0.13.2

2 files

0.13.1

2 files

0.13.0

2 files

0.12.3

2 files

0.12.2

2 files

0.12.0

2 files

0.11.2

2 files

0.11.1

2 files

This release

0.10.0 This release

2 files

0.9.3

2 files

0.9.1

2 files

0.9.0

2 files

0.8.2

2 files

0.8.0

2 files

0.7.0

2 files

0.6.0

2 files

0.5.1

2 files

0.5.0

2 files

0.4.2

2 files

0.4.1

2 files

0.3.4

2 files

0.3.3

2 files

0.3.2

2 files

0.3.1

2 files

0.3.0

2 files

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