PDB/mmCIF file parsing using pandas DataFrames
Project description
MolScene
Molecular structures as pandas DataFrames.
MolScene reads molecular structures (PDB, mmCIF) into pandas DataFrames and writes them back out (PDB, mmCIF, GRO). Every Scene is a DataFrame so the full pandas toolbox (filtering, grouping, plotting, to_csv, etc.) works out of the box. MolScene adds a layer on top for molecular structural data operations: atom selection, rigid-body transformations and alignment, residue morphing, multi-frame trajectories, and distance maps.
from molscene import Scene
s = Scene.from_pdb("1jge.pdb") # load a structure into a DataFrame
ca = s.select("chain A and name CA") # VMD-style atom selection
ca = ca - ca.get_center() # center it on the origin (operator math)
ca.write_pdb("ca_centered.pdb") # write it back out
Why use MolScene?
- Just a DataFrame.
Scenesubclassespandas.DataFrame, so columns likechain,resid,resname,name,x,y,zare all there to slice, group, and analyze with common data analysis tools. - Atom selection. Use a familiar VMD-style string (
"protein and within 5 of resname HEM") via the optionalmolselectengine, or plain keyword filters (s.select(chain=["A"], name=["CA"])) with no extra dependencies. - Geometry reads like math.
+,-,*,/translate, scale, and reflect coordinates;scene1 + scene2concatenates two structures. - Built-in structural alignment Pair atoms by order, by columns, or by sequence (Needleman–Wunsch), then
superpose, computermsd, or get aTransformation(rotation + translation). - Smooth morphing and trajectories. Interpolate between conformations with screw-linear (dual-quaternion) or slerp motion, and carry multiple coordinate frames per scene.
- Metadata travels with the data. Attach arbitrary metadata to a scene, like bonds, angles or dihedrals, that depend on atom indices; it is preserved through selections and transformations.
Installation
pip install molscene
String atom selection (Scene.select("chain A and resid 1 to 100")) is powered by the optional molselect package. Install it with the extra:
pip install "molscene[selection]"
The keyword form Scene.select(chain=["A"]) works without it.
Conda: a conda-forge recipe lives in
recipe/;conda installsupport will follow once the package is published to conda-forge.
Quickstart
import numpy as np
from molscene import Scene
# Load from a file (format auto-detected by from_file, or use from_pdb/from_cif/from_gro)
s = Scene.from_pdb("1jge.pdb")
# It's a DataFrame — use pandas directly
print(s["resname"].value_counts())
print(len(s), "atoms")
# Select atoms (string needs molscene[selection]; kwargs always work)
backbone = s.select("name CA C N O")
chain_a = s.select(chain=["A"])
# Geometry with operators
centered = s - s.get_center()
shifted = s + np.array([10, 0, 0])
scaled = s * 2.0
# Align one structure onto another and measure RMSD
mobile = Scene.from_pdb("model.pdb")
ref = Scene.from_pdb("native.pdb")
aligned = mobile.superpose(ref, match="sequence")
print(aligned.rmsd(ref, match="sequence"))
# Write back out (format from extension)
centered.write_pdb("centered.pdb")
See the full documentation for the User Guide (with API reference) and Developer Guide.
Documentation
- Getting Started: installation and first steps
- User Guide: full API reference
- Examples
- Developer Guide
Build the docs locally with:
pip install "molscene[docs]"
sphinx-build -b html docs docs/_build/html
Contributing
Contributions are welcome — see .github/CONTRIBUTING.md
and the Code of Conduct. Run the test suite with:
pip install "molscene[test,selection]"
pytest molscene/tests/
License
MIT — see LICENSE.
Copyright
Copyright (c) 2025-2026, Carlos Bueno
Acknowledgements
Project skeleton based on the Computational Molecular Science Python Cookiecutter version 1.10.
Project details
Release history Release notifications | RSS feed
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file molscene-0.2.0.tar.gz.
File metadata
- Download URL: molscene-0.2.0.tar.gz
- Upload date:
- Size: 63.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
97ea0ff185ef6ef465b480b0e73d333c6c9a04a6bf40a3a81f28f584bcdf3b72
|
|
| MD5 |
22882d5c64c5e884954c255aaa8ced9c
|
|
| BLAKE2b-256 |
c62caade98277e8b16b1c74841e9f11e506baf20acd2788fb308806f84b570d6
|
Provenance
The following attestation bundles were made for molscene-0.2.0.tar.gz:
Publisher:
publish.yaml on cabb99/molscene
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
molscene-0.2.0.tar.gz -
Subject digest:
97ea0ff185ef6ef465b480b0e73d333c6c9a04a6bf40a3a81f28f584bcdf3b72 - Sigstore transparency entry: 1707019009
- Sigstore integration time:
-
Permalink:
cabb99/molscene@e229b371ca731fffb6b9006a147c9a84f873a828 -
Branch / Tag:
refs/tags/0.2.0 - Owner: https://github.com/cabb99
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@e229b371ca731fffb6b9006a147c9a84f873a828 -
Trigger Event:
release
-
Statement type:
File details
Details for the file molscene-0.2.0-py3-none-any.whl.
File metadata
- Download URL: molscene-0.2.0-py3-none-any.whl
- Upload date:
- Size: 65.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
312206930b1bc365953ad56444dc9b4439e2ed6afa67df31bc6290533c604740
|
|
| MD5 |
286623b3d71daa6afa277c142e8f24d2
|
|
| BLAKE2b-256 |
43b42b566663670b5cf00be4ada0a159a407b3204d41d9ba28e1feeda9333d01
|
Provenance
The following attestation bundles were made for molscene-0.2.0-py3-none-any.whl:
Publisher:
publish.yaml on cabb99/molscene
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
molscene-0.2.0-py3-none-any.whl -
Subject digest:
312206930b1bc365953ad56444dc9b4439e2ed6afa67df31bc6290533c604740 - Sigstore transparency entry: 1707019034
- Sigstore integration time:
-
Permalink:
cabb99/molscene@e229b371ca731fffb6b9006a147c9a84f873a828 -
Branch / Tag:
refs/tags/0.2.0 - Owner: https://github.com/cabb99
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@e229b371ca731fffb6b9006a147c9a84f873a828 -
Trigger Event:
release
-
Statement type: