Skip to main content

mdatools

Generic MD analysis tools for protein-ligand simulations.

Installation

pip / uv

pip install mdatools
uv add mdatools

バージョン固定(推奨)

pip install "mdatools==0.2.1"
uv add "mdatools==0.2.1"

Optional extras

Extra 追加機能 インストール例
posebusters PoseBusters バッチ検証(NB06) pip install "mdatools[posebusters] @ git+..."
pocket ポケット環境プロファイル・比較(NB07–08) pip install "mdatools[pocket] @ git+..."

⚠️ posebusters extra を使う際は リガンドの SMILES または SDF が必須です。 詳細は docs/POSEBUSTERS_PREREQUISITES.md を参照。

開発用(リポジトリを clone して editable install)

git clone https://github.com/rkakamilan/md-analysis-tools-public.git
cd md-analysis-tools-public
uv sync --extra dev          # 開発依存も含めてインストール
uv sync --extra dev --extra notebook  # Notebook 用依存も追加

Quick start

各ノートブックの先頭 CONFIG セルだけ編集して実行します:

from pathlib import Path
from mdatools.config import AnalysisConfig, ResidueGroup

cfg = AnalysisConfig(
    ligand_resname = "LIG",
    dt_ns          = 2.0,
    # residue_groups: name any set of residues you want to prioritise in
    # template selection (NB03).  When the ligand contacts one of these
    # residues, `bonus` points are added to the total score on top of the
    # H-bond quality score (max ~100 pts) and stability score (max 15 pts).
    # A bonus of 20 corresponds to roughly one "good H-bond distance" worth
    # of score — enough to promote a snapshot that hits the target region
    # without completely overriding H-bond quality.
    # Examples:
    #   GPCR   — extracellular domain (ECD) residues contacted by peptide ligands
    #   Kinase — hinge residues that anchor ATP-competitive inhibitors
    #   Any    — allosteric pocket, key salt-bridge partner, etc.
    residue_groups = {
        # GPCR ECD example
        "ECD":    ResidueGroup(resids=[35, 36, 39], bonus=20),
        # Kinase hinge example
        # "Hinge": ResidueGroup(resids=[83, 85], bonus=20),
    },
)
REPLICA_ROOTS = [Path("../run01"), Path("../run02")]

Notebooks

Notebook 内容 依存 extra
01_rmsd.ipynb Backbone + ligand RMSD グリッド —
02_hbonds.ipynb H-bond 解析 + プロット —
03_template_selection.ipynb スコアリング + スナップショット抽出 —
04_validation.ipynb PyMOL コンフォメーションタイムライン —
05_dihedral.ipynb 回転可能結合の二面角解析 —
06_posebusters.ipynb PoseBusters バッチ検証 posebusters
07_pocket_profile.ipynb ポケット環境プロファイル(単一スナップショット) pocket
08_pocket_comparison.ipynb ポケット環境プロファイル複数比較 pocket

CLI

# H-bond バッチ解析
mdatools-batch-hbonds run01/ run02/ --ligand UNK --output-dir ./hbond_results

# RMSD バッチ解析
mdatools-batch-rmsd run01/ run02/ --output-dir ./results

# PoseBusters バッチ検証
mdatools-pb-validate \
  --topology run01/equilibrating_topology.pdb \
  --trajectory run01/trajectory.xtc \
  --protein protein_clean.pdb \
  --smiles "CC1=CC=CC=C1" \
  --output-dir ./pb_results

# Movie 生成
mdatools-movie --pse run01/traj.pse --output movie.mp4 --fps 15

API overview

Pocket environment (NB07–08)

from mdatools.pocket import PocketProfiler, PocketComparator
from mdatools.pocket.profiler import build_2d_mol
from mdatools.plotting.pocket_profile import make_snapshot_png
from mdatools.plotting.pocket_comparison import plot_pocket_comparison

# 単一スナップショット
profiler = PocketProfiler(ligand_resname="UNK")
metrics  = profiler.profile(Path("snapshot_clean.pdb"))

# 複数スナップショット比較
metrics_dict = profiler.profile_batch(pdb_paths, output_dir=Path("./results"))
comparator   = PocketComparator()
comparison   = comparator.run(metrics_dict)
print(comparator.auto_report(comparison))

# 可視化
mol, name2idx = build_2d_mol(Path("snapshot_clean.pdb"))
make_snapshot_png(mol, name2idx, metrics, out_path=Path("pocket.png"))
plot_pocket_comparison(mol, name2idx, comparison, output_path=Path("comparison.png"))

PoseBusters バッチ検証 (NB06)

from mdatools.posebusters import FrameExporter, PoseBustersValidator
from mdatools.config import AnalysisConfig
from mdatools.universe import load_and_align

cfg = AnalysisConfig(ligand_resname="UNK", output_dir=Path("./results"))
u   = load_and_align(Path("topology.pdb"), Path("trajectory.xtc"), cfg)

exporter  = FrameExporter(cfg)
pdb_files = exporter.export_from_universe(u, output_dir=Path("./pb_frames"), prefix="snap")

validator = PoseBustersValidator(cfg, ligand_smiles="CC1=CC=CC=C1")
result    = validator.run(pdb_dir=Path("./pb_frames"), protein_path=Path("protein_clean.pdb"))
print(f"Pass rate: {result.pass_rate:.1%}")
print(result.top_frames(10))

Tests

uv run pytest tests/

Project structure

src/mdatools/
├── config.py              # Pydantic v2 設定モデル
├── universe.py            # Universe ロード + アライメント
├── analysis/              # RMSD, H-bonds, contacts, dihedral
├── scoring/               # Template scorer + snapshot selector
├── posebusters/           # PoseBusters バッチ検証 (optional: posebusters extra)
│   ├── frame_exporter.py  #   軌跡フレーム → PDB 一括出力
│   └── batch_validator.py #   PoseBusters 全フレーム実行・集計
├── pocket/                # ポケット環境解析 (optional: pocket extra)
│   ├── profiler.py        #   d_min / hydrophob / n_NO / cone_dist 計算
│   └── comparator.py      #   複数スナップショット間の集計・考察
├── pymol_bridge/          # PML 生成, PyMOL subprocess, movie
├── io/                    # ファイル探索・CSV 入出力
├── plotting/              # Matplotlib / PIL 描画関数
│   ├── pocket_profile.py  #   2D 構造式 + d_min ハロー PNG
│   └── pocket_comparison.py # 2D 構造式 + メトリクステーブル PNG
└── cli/                   # CLI エントリポイント

Ensemble docking workflow

mdatools (MD analysis)            mdatools.docking (virtual screening)
─────────────────────────────     ──────────────────────────────────
MD trajectory analysis
  └─ representative conformation ──► receptor prep → docking execution
                                     pose filtering / clustering
                                     EF / ROC-AUC evaluation
MD validation of top hits ◄──────── top-ranked pose PDB
  └─ RMSD · H-bond · consensus
      final hit list

詳細は docs/ensemble_docking.md を参照。

Metadata

Release files for mdatools 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mdatools 0.3.1
File Size Uploaded Provenance Actions
mdatools-0.3.1.tar.gz 536.0 kB With provenance Details for mdatools-0.3.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mdatools 0.3.1
File Interpreter ABI Platform Actions
mdatools-0.3.1-py3-none-any.whl Python 3 none any Details for mdatools-0.3.1-py3-none-any.whl

Total release size: 747.5 kB

Release files / mdatools-0.3.1.tar.gz

Download URL mdatools-0.3.1.tar.gz
Size 536.0 kB
Tags Source
SHA-256 checksum
How to use checksums
838833dd39de4d4dc9166a7e10fe531f143cd0a1da33c6cdfb62bb5b1b61a154
BLAKE2b-256 checksum
How to use checksums
02427a778362a9f62efda1fd7abb869333308477a049d1d586b8bc85efe462fd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 May 15, 2026.

Transparency log

Release files / mdatools-0.3.1-py3-none-any.whl

Download URL mdatools-0.3.1-py3-none-any.whl
Size 211.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e244f9e981e2b02dc597de37434a10ab1c708ec0576eb3ee3ebdbb6f37ceac1f
BLAKE2b-256 checksum
How to use checksums
99c1a7f3765b9462358c4330d63cc21c646ff19c4ae53eb2d1935325798e55fd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 May 15, 2026.

Transparency log

Security for mdatools 0.3.1

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.

Select from 2 files

Attestation for mdatools-0.3.1.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 May 15, 2026.

Transparency log

A 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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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