Skip to main content

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

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

Built distributions (wheels)

Table of built distributions (wheels) for phrank-py 0.2.18
File
phrank_py-0.2.18-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details
phrank_py-0.2.18-cp313-cp313-manylinux_2_34_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.34+ x86-64 Details
phrank_py-0.2.18-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details
phrank_py-0.2.18-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
phrank_py-0.2.18-cp312-cp312-manylinux_2_34_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.34+ x86-64 Details
phrank_py-0.2.18-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details
phrank_py-0.2.18-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
phrank_py-0.2.18-cp311-cp311-manylinux_2_34_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.34+ x86-64 Details
phrank_py-0.2.18-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details
phrank_py-0.2.18-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details
phrank_py-0.2.18-cp310-cp310-manylinux_2_34_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.34+ x86-64 Details
phrank_py-0.2.18-cp310-cp310-macosx_11_0_arm64.whl CPython 3.10 CPython 3.10 macOS 11.0+ ARM64 Details

Total release size: 11.4 MB

Release files / phrank_py-0.2.18-cp313-cp313-win_amd64.whl

Download URL phrank_py-0.2.18-cp313-cp313-win_amd64.whl
Size 838.7 kB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
8d81815eceeeaf77fbbd9b4ff2928231a7609fbd33b01c6b6d64aa7f5ba92a66
BLAKE2b-256 checksum
How to use checksums
9490b80abcd2e346088d287969c79972b0a2e6c30d7d09da8c10a5101d1ba384
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.18-cp313-cp313-manylinux_2_34_x86_64.whl

Download URL phrank_py-0.2.18-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
40df842dfb2f37f1751a73f8c420f8a1712e3f535cbcc0311969803be9359ab5
BLAKE2b-256 checksum
How to use checksums
d971e614f3066d407b54cd6be3cbc28c8f5964ac65a3b5601ccd5c4086f30f36
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.18-cp313-cp313-macosx_11_0_arm64.whl

Download URL phrank_py-0.2.18-cp313-cp313-macosx_11_0_arm64.whl
Size 949.5 kB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
9d461a6d5950a4ae1ab393c6d9dba4553a2c040b1ef4243c36ae16173d06e377
BLAKE2b-256 checksum
How to use checksums
de9cdf24b0d5a73bf49e55e7a41ce8122e7dd9076a8b7ddb4847ff7605bbcda7
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.18-cp312-cp312-win_amd64.whl

Download URL phrank_py-0.2.18-cp312-cp312-win_amd64.whl
Size 838.7 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
1e0bb40e1f3175cd1dbcc787251c2c3bf9ff7e90b6be6682c07e81ce2599e683
BLAKE2b-256 checksum
How to use checksums
7d59cdda1844b9c34f8f6c4d0e2db5f5378d2c61148e5ebf0fb6564f7ee3c5e4
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.18-cp312-cp312-manylinux_2_34_x86_64.whl

Download URL phrank_py-0.2.18-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
063ea1931db6d40c50320d1eef81584c264136fa962197e6856df4e70c7417c6
BLAKE2b-256 checksum
How to use checksums
b5f2960b9b184121788f94ecf8696de13c774e643811a63a11d80fd0dba53b85
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.18-cp312-cp312-macosx_11_0_arm64.whl

Download URL phrank_py-0.2.18-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
a0a3452b8fa3276734fcb230bc52631551a1c09aab29f255ca0f9ca938652f83
BLAKE2b-256 checksum
How to use checksums
8f100033f7c359c4d7b1504b19a150055fbe492dd0d2696cab4a963c6b86f771
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.18-cp311-cp311-win_amd64.whl

Download URL phrank_py-0.2.18-cp311-cp311-win_amd64.whl
Size 839.2 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
349ec30481f017283a07165d3b72c2deb1ea17c39707a25b5fd5933e9706e835
BLAKE2b-256 checksum
How to use checksums
6c5b73dc0835f0601a99afca2b7a57e8b842321c04a8ecce5772612ea6ca5812
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.18-cp311-cp311-manylinux_2_34_x86_64.whl

Download URL phrank_py-0.2.18-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
3fabcada615a4e4b0fbf3e3d83c2e79002d2cfbfd2180b665ae68369e37d3b04
BLAKE2b-256 checksum
How to use checksums
dcf799af9e943ee0b00a7b38c9f745767f51a01ada7f3cb2631fc798a9315801
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.18-cp311-cp311-macosx_11_0_arm64.whl

Download URL phrank_py-0.2.18-cp311-cp311-macosx_11_0_arm64.whl
Size 949.3 kB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
f3deb7663bd6ce3757904d651a7f19091e471ed5e60d8337343e584a33238f83
BLAKE2b-256 checksum
How to use checksums
7b15db74e78814d21b47863661b7e879d625059f96898dc6ae89469de6c74827
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.18-cp310-cp310-win_amd64.whl

Download URL phrank_py-0.2.18-cp310-cp310-win_amd64.whl
Size 839.2 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
49d30c0dfb54033fa9b6cbba4ad9cc1833dd6d679c0e05700fbb9552a8a33ff5
BLAKE2b-256 checksum
How to use checksums
4845f71ec5c5a4a19be065331e26978d2612e59063bd47f54e1b1d05f2c09636
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.18-cp310-cp310-manylinux_2_34_x86_64.whl

Download URL phrank_py-0.2.18-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
df5284d6123e6405a0c7c5ffe3a6d4f6c63f1d9a27656dc32b4a8f0f8d5b9857
BLAKE2b-256 checksum
How to use checksums
59a7042b0852bc1ee67e32ba05952bf3b7d54cc1af738307c48ae95636ad8805
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.18-cp310-cp310-macosx_11_0_arm64.whl

Download URL phrank_py-0.2.18-cp310-cp310-macosx_11_0_arm64.whl
Size 949.5 kB
Tags CPython 3.10 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
a42d94a0f906f116df7c1ba4dca7f1fb19efd5e037c534bdeb963b3be7b47fd5
BLAKE2b-256 checksum
How to use checksums
b8c3011d799677e56b573aa00e2abbbe50cdb8fcd7dd26efbc3a84c6baf21648
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.18

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.

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