Python bindings for watpocket
Project description
watpocket
watpocket is a C++ command-line tool that reads a molecular structure, selects residues by residue number, extracts their C-alpha (CA) atoms, and computes a 3D convex hull using CGAL.
Current Feature Set (v1)
- Single-frame structure input via Chemfiles (
.pdb,.cif,.mmciftested path) - Required residue selection with
--resnums - Convex hull generation via CGAL
convex_hull_3 - Optional draw output with
-d/--draw:.py: PyMOL script with hull edges as CGO lines.pdb: hull-only PDB (ANAatoms +CONECTedges)
- Trajectory mode (
<topology> <trajectory.nc>) with per-frame water-pocket analysis and CSV output
CLI
watpocket <structure> --resnums <selectors> [-d output.py|output.pdb]
watpocket <topology> <trajectory.nc> --resnums <selectors> -o output.csv [-d hull_models.pdb]
Input Rules
- With one positional input, it is treated as a structure file.
parm7/.prmtopis not supported in single-input mode (no coordinates); use trajectory mode instead.
- With two positional inputs, they are interpreted as
<topology> <trajectory>.<trajectory>currently supports NetCDF only (.nc).<topology>can be structure (.pdb/.cif/.mmcif) or Amber topology (.parm7/.prmtop).- In trajectory mode, topology is used to define atom/residue identity and must be atom-count compatible with the trajectory.
- If atom counts differ,
watpocketexits with an error.
Residue Selector Rules
--resnumstakes comma-separated selectors.- Supported selector forms:
12,15,18A:12,A:15,B:18
- If the input structure contains more than one chain, selectors must be chain-qualified (for example
A:12). - Every selected residue must contain exactly one atom named
CA. - For
parm7topologies:- residue IDs are 1-based residue order (
1..NRES); - chain-qualified selectors require
RESIDUE_CHAINIDin the topology; - if
RESIDUE_CHAINIDis missing, usingA:12-style selectors is an error.
- residue IDs are 1-based residue order (
Geometry Rules
The program raises an error if selected C-alpha points are:
- fewer than 4 points,
- collinear,
- coplanar.
--draw Output
When -d/--draw is provided, output format is chosen by mode and filename extension:
-
.py: writes a Python script for PyMOL that:- loads the input structure,
- creates a CGO object with hull edges (
LINESonly), - applies default styling for readability.
- requires input structure extension
.pdb,.cif, or.mmcif. - single-structure mode only.
-
.pdb: writes a hull-only PDB where:- each convex-hull vertex is an
ATOMrecord, - atom element is
C - residue name is
ANA, - convex-hull edges are encoded with
CONECTrecords, - if waters are found inside the hull, full water residues (all atoms) are appended as
ATOMrecords - single-structure mode: one hull in one PDB file
- trajectory mode: one hull per successful frame using
MODEL ... ENDMDL, with inside-hull waters included per model
- each convex-hull vertex is an
Trajectory mode accepts --draw only for .pdb paths. .py is rejected.
Trajectory CSV Output
When running in trajectory mode (<topology> <trajectory.nc>), watpocket computes results independently for each frame and writes CSV:
- Header:
frame,resnums,total_count frame: 1-based frame indexresnums: water residue numbers separated by one space (quoted CSV field, empty as"")total_count: number of water residues inside the hull for that frame
Output destination:
-o/--output <path>: required in trajectory mode; CSV is always written to this file
Optional trajectory draw output:
-d/--draw <path>.pdb: writes trajectory hulls as multi-model PDB (MODELrecords)
Frame handling:
- if one frame fails hull/water computation, that frame is skipped
- a warning is written to
stderr - remaining frames continue processing
After trajectory processing, watpocket prints summary statistics to stdout:
- min/max/mean/median waters per frame
- top 5 water
resnumsby presence in pocket, with fraction of frames present
Dependencies
- Vendored in repository (no per-build download for these):
external/cgalexternal/chemfiles
- CPM is still enabled for other dependencies (for example
CLI11).
Build
Use the existing CMake flow and presets from this repository:
cmake -S . -B build
cmake --build build -j
Example
watpocket protein.pdb --resnums A:12,A:15,A:18,A:26 -d hull.py
Then in PyMOL:
run hull.py
Trajectory mode example:
watpocket topology.pdb traj.nc --resnums 164,128,160,55,167,61,42,65,66 -o pocket_waters.csv
Trajectory mode with draw PDB example:
watpocket topology.parm7 traj.nc --resnums 164,128,160,55,167,61,42,65,66 -o pocket_waters.csv -d hull_models.pdb
parm7 topology example:
watpocket topology.parm7 traj.nc --resnums 164,128,160,55,167,61,42,65,66 -o pocket_waters.csv
Development
Compile, preferably with python bindings:
cmake -B./build --preset release -DWATPOCKET_ENABLE_PYTHON_BINDINGS=ON
cmake --build ./build --preset release
If you compiled with python bindings, install them in your current python environment and check that they are locatable:
cmake --install ./build --component pythoninstall
python -c "import watpocket; print(watpocket.__file__)"
Release a New Version
watpocket Python releases are wheel-only and versioned from the git tag at HEAD.
Install release tooling in your environment first:
uv venv
source .venv/bin/activate
uv -vv pip install -e ".[dev]" --no-progress -Cbuild.verbose=true
- Ensure your working tree is clean and choose the release version
X.Y.Z. - Create and push an annotated tag:
git tag -a X.Y.Z -m "Release X.Y.Z"
git push origin X.Y.Z
- Build wheels only (no upload):
scripts/pypi_release_wheels.sh --build-only
- Upload to TestPyPI (recommended first):
scripts/pypi_release_wheels.sh --testpypi
- Upload to PyPI:
scripts/pypi_release_wheels.sh
Notes:
- Accepted release tags are
X.Y.ZorvX.Y.Z. - The script uploads
dist/watpocket-<version>-*.whlonly (no source distribution). - Twine credentials can come from
~/.pypirc, keyring, orTWINE_USERNAME/TWINE_PASSWORD. - On Linux, wheels are repaired with
auditwheelbefore upload so PyPI acceptsmanylinuxtags (not plainlinux_x86_64). - If
ninjais not installed, the release script automatically falls back toCMAKE_GENERATOR="Unix Makefiles".
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 Distributions
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 watpocket-0.1.7-cp312-cp312-manylinux_2_39_x86_64.whl.
File metadata
- Download URL: watpocket-0.1.7-cp312-cp312-manylinux_2_39_x86_64.whl
- Upload date:
- Size: 1.4 MB
- Tags: CPython 3.12, manylinux: glibc 2.39+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
82c2e611074cae8fe5859a6171b2b4f8c5f138d79c9105ef6a351f8384e320ca
|
|
| MD5 |
ec797516b74be04ddd8f32de6134ea85
|
|
| BLAKE2b-256 |
9e021a59ab54fb3f587896e908ed1ef9a5f9be1774eae179aa5641e41a3293b8
|