pyconfind
A modern Python implementation of ConFind — the rotamer-based protein side-chain contact-degree analysis introduced in Zheng et al 2015 and Zheng et al 2017.
The Python output is byte-for-byte identical to the upstream C++ binary on 248 of 253 real structures tested (100 single-chain PDB + 100 AlphaFold DB + 50 multi-chain + 3 high-resolution; see docs/stress_test_results.md), plus a further 100 RCSB entries cross-checked as both PDB and mmCIF. The 5 exceptions are insertion-code structures where the C++ ordering relies on undefined behavior (documented). The test suite runs against real PDB/mmCIF structures with committed C++-reference contact maps.
pyconfind is also faster than the C++ binary, with two interchangeable contact-degree backends (both byte-identical to the reference):
- a pure NumPy/SciPy reference, which on its own already beats the C++ binary;
- an optional Numba JIT/multi-threaded backend (
pip install pyconfind[fast]) that is ~3× faster again.
With the Numba backend and the rotamer library pre-loaded, per-structure
analysis is ~7-11× faster than the C++ binary in full mode (median ~10×
over the benchmark set). native_only=True runs another ~26× faster
again — under 0.36 s for everything in the benchmark set (largest 555
residues), and ~0.07 s for small ones.
Left: full analysis (every position considers all 18 substitutable AAs).
Right: native_only=True — only the native AA is placed at each position
(see native-only mode). The
rotamer library is loaded once before measurement and excluded from every
timing, so the numbers reflect per-structure analysis only. See
docs/benchmark.md for the structure set and the harness.
Install
pip install pyconfind # pure-Python reference backend
pip install "pyconfind[fast]" # + Numba JIT/multi-threaded backend
From source (for development):
pip install -e ".[dev]" # editable install with test/lint tooling
Example notebook
examples/pyconfind_demo.ipynb is a runnable
walkthrough (install → fetch a PDB → analyze via the library API → visualize a
contact map, per-residue scores, and a 3D structure colored by contact degree).
Click the badge to run it on a free Colab CPU runtime.
Quick start
The rotamer library is optional — if you don't pass one, pyconfind downloads
the Dunbrack 2010 library once (~6 MB) and caches it per-user (via
platformdirs), so the simplest invocation is just:
pyconfind --p input.pdb --o out.cont # library auto-downloaded + cached
CLI (matches the original confind flag names, so existing pipelines drop in;
pass --rLib to use your own library):
# Inputs may be PDB or mmCIF (format auto-detected via gemmi):
pyconfind --p input.cif --o out.cont
# Modern structured output:
pyconfind --p input.pdb --json --o out.json
# Only consider the native AA at each position (no AA substitution):
pyconfind --p input.pdb --native-only --o out.cont
# Restrict the computed/output residues (MSL selection language):
pyconfind --p input.pdb --sel "chain A AND resi 20-60" --o out.cont
# Pre-select part of the structure before anything runs:
pyconfind --p input.pdb --psel "NAME CA WITHIN 25 OF CHAIN A" --o out.cont
# Use your own library:
pyconfind --p input.pdb --rLib path/to/rotlibs --o out.cont
Library API:
from pyconfind import analyze
result = analyze("input.pdb") # library auto-downloaded + cached
positions = result.positions_dataframe() # one row per residue
contacts = result.contacts_dataframe() # one row per residue-residue contact
contacts.nlargest(10, "degree")
analyze() takes an assembly= argument too — by default it picks the first
biological assembly, which is what you want for crystal structures whose
asymmetric unit contains multiple independent copies of the complex
(e.g. antibody/antigen structures like 5TRU). Pass assembly=None to keep
the asymmetric unit as-is.
Rotamer libraries
Out of the box, pyconfind supports the Dunbrack 2010 MSL-format library that
ships with the upstream confind source (EBL.out + BEBL.out); leave
--rLib unset to auto-download it. Point --rLib at your own directory
containing both files to use a different library. Only backbone-dependent
libraries are supported.
Modern Dunbrack and Richardson-style libraries are next on the roadmap.
Native-only mode (extension over the C++ binary)
The original C++ confind substitutes in all 18 non-Gly/Pro amino acids at
every position and computes contact degree across the full rotamer space.
pyconfind adds --native-only: at each position, only place rotamers of the
native amino acid (but still consider every rotamer of that AA).
Validation
The C++ reference binary is built from the upstream tarball by:
scripts/build-reference.sh
The byte-identity tests then compare pyconfind's output against the C++ output on every example PDB. To run them yourself:
pytest tests/
References
-
"Sequence statistics of tertiary structural motifs reflect protein stability", F. Zheng, G. Grigoryan, PLoS ONE, 12(5): e0178272, 2017.
-
"Tertiary Structural Propensities Reveal Fundamental Sequence/Structure Relationships", F. Zheng, J. Zhang, G. Grigoryan, Structure, 23(5): 961-971, 2015.
Metadata
Release files for pyconfind 0.6.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyconfind-0.6.0.tar.gz | 6.9 MB | With provenance | Details for pyconfind-0.6.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pyconfind-0.6.0-py3-none-any.whl | Python 3 | none | any | Details for pyconfind-0.6.0-py3-none-any.whl |
Total release size: 7.0 MB
Release files / pyconfind-0.6.0.tar.gz
| Download URL | pyconfind-0.6.0.tar.gz |
|---|---|
| Size | 6.9 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c6871b399ca63052931dc0dc7ce541804c531b8c5328cc9fa4d8c9613f7dc056
|
|
BLAKE2b-256 checksum How to use checksums |
c8d2260bd0faf94c7df2c4b58ee1773b7072d655ef9b7160c05adeec3183c84a
|
| 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 Jun 4, 2026.
Transparency logRelease files / pyconfind-0.6.0-py3-none-any.whl
| Download URL | pyconfind-0.6.0-py3-none-any.whl |
|---|---|
| Size | 73.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ebbecf9c18bbef4ffd6290a20d03c2b7eb0eec8b8022b1d904ab74af92ffde4c
|
|
BLAKE2b-256 checksum How to use checksums |
eb1560b0ee430e1ba48f953de12201beea28b22b1adba1c8f5e2bf18b70423bf
|
| 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 Jun 4, 2026.
Transparency logSecurity for pyconfind 0.6.0
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.
Attestation for pyconfind-0.6.0.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 Jun 4, 2026.
Transparency logA 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.