使用 PyMOL (pymol-open-source) 将 mmCIF 转换为 PDB 的简易 API。
This project exposes a lightweight API using PyMOL (pymol-open-source) to convert mmCIF files into PDB format.
本项目使用 uv 管理依赖。若尚未安装,请参照 uv 官方说明完成安装。
Dependencies are managed with uv. Install uv first following its official guide.
uv sync上述指令会创建虚拟环境并安装 pyproject.toml 中列出的所有依赖。
The command above creates a virtual environment and pulls all dependencies declared in pyproject.toml.
# 启动 FastAPI 服务(默认监听 8000 端口)
# Start the FastAPI service (default: port 8000)
uv run uvicorn app.main:app --reload启动后可发送 POST 请求到 http://127.0.0.1:8000/convert:
After the server is up, send a POST request to http://127.0.0.1:8000/convert:
curl -X POST \
-F "file=@example.cif" \
http://127.0.0.1:8000/convert \
-o output.pdb若需确认服务状态,可访问 http://127.0.0.1:8000/health。
Check http://127.0.0.1:8000/health for a basic health probe.
import requests
url = "http://127.0.0.1:8000/convert"
with open("input_model_0.cif", "rb") as handle:
files = {"file": ("input_model_0.cif", handle, "application/mmcif")}
response = requests.post(url, files=files, timeout=120)
response.raise_for_status()
with open("output_model_0.pdb", "wb") as writer:
writer.write(response.content)将本地 input_model_0.cif 上传转换,并保存为 output_model_0.pdb。
The snippet uploads input_model_0.cif, receives the converted payload, and writes it to output_model_0.pdb.
uv run pytest使用 uv run pytest 运行所有单元测试。
Execute uv run pytest to run the full test suite.