Phrank Python Bindings (phrank_py)
phrank_py provides Python bindings for the Phrank similarity engine. It is a high-performance, phenotype-driven similarity engine that calculates the structural similarity between patient cohorts using Information Content (IC) derived from an underlying ontology.
By wrapping the core Rust implementation, phrank_py delivers the performance of Rust's parallelization combined with zero-copy memory transfers directly into Python's SciPy ecosystem.
🚀 Key Features
High Performance: Leverages Rust's multithreading to compute pairwise similarity matrices rapidly.
Zero-Copy SciPy Integration: Returns the similarity matrix directly as a scipy.sparse.csr_matrix without duplicating large arrays in memory.
Phenopacket Compatible: Easily parses standard Phenopacket JSON files to build feature dictionaries.
🛠 Getting Started
Prerequisites You will need the scipy package installed to handle the sparse matrix output. If you are parsing Phenopackets, ensure you have the appropriate protobuf/JSON parsers installed.
Example Usage The following example demonstrates how to load an ontology, parse a directory of Phenopacket JSON files, and compute a similarity matrix for the entire cohort.
import os
from pathlib import Path
from google.protobuf.json_format import Parse
from phenopackets import Phenopacket
from phrank_py import PyPhrank, CohortEntity, Ontology
# 1. Initialize the Phrank Engine with your ontology JSON
phrank = PyPhrank(Ontology.Json("./hp.json"), cache_size=1500)
# 2. Load your patient cohort (e.g., from a directory of Phenopackets)
pp_dir = Path(os.path.expanduser("./phenopackets"))
cohort: list[Phenopacket] = [
Parse(json_file.read_text(encoding="utf-8"), Phenopacket())
for json_file in pp_dir.glob("*.json")
]
# 3. Map Patient IDs to a list of their phenotypic feature IDs
cohort_entities = [
CohortEntity(pp.id, pt.type.id)
for pp in cohort
for pt in pp.phenotypic_features
]
# 4. Calculate the similarity matrix
# Returns a SciPy CSR matrix and a mapping of matrix indices to Patient IDs
matrix, mapping = phrank.calculate_similarity(cohort_entities)
print(f"Generated sparse matrix of shape: {matrix.shape}")
Credit
Original Publication by Karthik A. Jagadeesh et al. here
Metadata
Release files for phrank-py 0.2.17
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
Total release size: 11.4 MB
Release files / phrank_py-0.2.17-cp313-cp313-win_amd64.whl
| Download URL | phrank_py-0.2.17-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 838.8 kB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
0aebdd82aad3497189f2501b353c8972fe6f531ff7c70b6a05417a4cf7113a18
|
|
BLAKE2b-256 checksum How to use checksums |
c506fd103ee259ac31d423031aa93c10a32341251915aba37a36cf354cc2212a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / phrank_py-0.2.17-cp313-cp313-manylinux_2_34_x86_64.whl
| Download URL | phrank_py-0.2.17-cp313-cp313-manylinux_2_34_x86_64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.13 Linux glibc 2.34+ x86-64 |
|
SHA-256 checksum How to use checksums |
d8cbe4366b7c386dd4f67fd1f2edbc108adbc0ebe31ffcf215735dda92bd4c83
|
|
BLAKE2b-256 checksum How to use checksums |
2046d4850c0251aab05dbcce02f46e87a86b02e69f43350b5d37b1142b041fa5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / phrank_py-0.2.17-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | phrank_py-0.2.17-cp313-cp313-macosx_11_0_arm64.whl |
|---|---|
| Size | 949.4 kB |
| Tags | CPython 3.13 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
e52058348317b7318985ca564c3c16c8fa53d3b6c2111b750b56cb4e355928eb
|
|
BLAKE2b-256 checksum How to use checksums |
56bf3e13963768756c2b120739114c66070f8636888dd9a295abad35a4214d69
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / phrank_py-0.2.17-cp312-cp312-win_amd64.whl
| Download URL | phrank_py-0.2.17-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 838.7 kB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
c0121bad3ceff9aad388df30b7142aa7a01c168541e0327a76abe3c6611ae4ca
|
|
BLAKE2b-256 checksum How to use checksums |
3cbbf1134ec3173724eb57cb7e0acb50ba0052905cc5a67a9627bcfba2ed9a37
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / phrank_py-0.2.17-cp312-cp312-manylinux_2_34_x86_64.whl
| Download URL | phrank_py-0.2.17-cp312-cp312-manylinux_2_34_x86_64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.12 Linux glibc 2.34+ x86-64 |
|
SHA-256 checksum How to use checksums |
584e228ff0b4974b6aabc3559b94fb08130f0c2911d2e8314ee610581318c7dd
|
|
BLAKE2b-256 checksum How to use checksums |
f616c8cd0fc2383c432ba483f66e50e82d2d84b0cf967a4be365e580caa57975
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / phrank_py-0.2.17-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | phrank_py-0.2.17-cp312-cp312-macosx_11_0_arm64.whl |
|---|---|
| Size | 949.2 kB |
| Tags | CPython 3.12 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
9bd4abf2d0b550f9b2beef7a03146e39bcc21c82761b2aa147c8904e3d08e0a6
|
|
BLAKE2b-256 checksum How to use checksums |
fe3442d9a67cbfc7e225f22c108401ade3aa73c888095ae9d4e5b4bf5ddc1096
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / phrank_py-0.2.17-cp311-cp311-win_amd64.whl
| Download URL | phrank_py-0.2.17-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 839.6 kB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
c29950c60fbaf1c37c2ad28cabcda606909921986101eecc5387e1355285fab4
|
|
BLAKE2b-256 checksum How to use checksums |
c8f28954b0e7cbb5bf3a4d2add160d65288f4a588188c0b9e1106f82f38e6977
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / phrank_py-0.2.17-cp311-cp311-manylinux_2_34_x86_64.whl
| Download URL | phrank_py-0.2.17-cp311-cp311-manylinux_2_34_x86_64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.11 Linux glibc 2.34+ x86-64 |
|
SHA-256 checksum How to use checksums |
b29b931adb364ecdbd5eea440740f6977ce5af4f5694cf302a97bedfe0f0675f
|
|
BLAKE2b-256 checksum How to use checksums |
947fd1f144982d311bbb0c07826e9832169a07a4f4b76c03cb124ec3f1358e00
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / phrank_py-0.2.17-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | phrank_py-0.2.17-cp311-cp311-macosx_11_0_arm64.whl |
|---|---|
| Size | 949.5 kB |
| Tags | CPython 3.11 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
2bc0d44de48ee76d6ec8852d082dbc8a4caa72723a63651b43024d06219b51fb
|
|
BLAKE2b-256 checksum How to use checksums |
67b6fb4c8dad5339655459ae0e78af961b2e868d51fd7d0729e4b1b229c491b8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / phrank_py-0.2.17-cp310-cp310-win_amd64.whl
| Download URL | phrank_py-0.2.17-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 839.6 kB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
10fdd2668cee857bca8e432e8cd80e6a4936c8b8097dcf0718ea7cde5b0bf44a
|
|
BLAKE2b-256 checksum How to use checksums |
1316dd2b15767fc86c86c62672f4857e5ca00c3ae8db6f756aa456eb0dbb35e2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / phrank_py-0.2.17-cp310-cp310-manylinux_2_34_x86_64.whl
| Download URL | phrank_py-0.2.17-cp310-cp310-manylinux_2_34_x86_64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.10 Linux glibc 2.34+ x86-64 |
|
SHA-256 checksum How to use checksums |
b0f23e41121b2ac6f79580303f2521a76a8f259d7d8141b642b8dcbd19288937
|
|
BLAKE2b-256 checksum How to use checksums |
327a82f6017e35f5abdf1d10a4d96f1f4f76700367805449f84537eaa19ca1a0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / phrank_py-0.2.17-cp310-cp310-macosx_11_0_arm64.whl
| Download URL | phrank_py-0.2.17-cp310-cp310-macosx_11_0_arm64.whl |
|---|---|
| Size | 949.7 kB |
| Tags | CPython 3.10 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
dbcf57c11df3456fd97b7303cf04421923e23593a3aba5f31bd294388cd15bfc
|
|
BLAKE2b-256 checksum How to use checksums |
b0fa45b81c67abaaea74b7b1cd722a6a1a45b51ff4bc99fe888a1efd05fc006d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Security for phrank-py 0.2.17
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.