Skip to main content

Refnd

In datasets generated using a RGP (Relational Generative Process), such as datasets generated using evolution-like processes, the relational structure is important to consider for multiple tasks such as split without leakage, visualization, hypothesis generation / validation, etc. The relational structure of the dataset consists of knowing which pairs of elements are related (for example, which samples are evolutionary related). However, this structure is rarely known in advance, so we need to infer it.

Given a distance measurement, we can brute-force compute all pair distances to find related samples. Then, we can define a distance threshold under which samples are considered related. Linking those samples with an edge and the distance as weight yields a thresholded-proximity graph.

The problem with the brute force approach is that it has an $O(n^2)$ computational complexity, and does not scale well for large datasets. Fortunately, we defined a variant of the Hierarchical Navigable Small World (HNSW) algorithm to build this thresholded proximity graph in $O(nlog(n))$ instead.

Once the graph is obtained, operations on the dataset become easier, and more theoretically grounded. In fact, the distance in the graph between two samples can correlate with the likelihood of two samples being related if the distance measurement is well chosen. Hence, this helps visualize the data, split datasets without leakage, make discoveries, etc.

Furthermore, we can cluster the graph by finding communities or connected components. From these clusters, we can effectively split the dataset into train and test set without leakage with respect to the proximity threshold by splitting along clusters.

This library contains a toolkit of efficient functions and data structures to work with datasets generated from RGP. The core computations are implemented in Rust and multithreaded for maximum throughput! Everything is wrapped within an easy to use Python API. It currently supports:

  • Protein/dna sequences with Local and Global alignments.
  • Molecules with Real and Bit based Tanimoto similarities.
  • Protein, DNA and RNA structures with USAlign.
  • More coming!

To give an idea of what the library contains, we have these functions:

  • HNSW approximate proximity graph in $O(nlog(n))$
  • Find nearest neighbors using an exact algorithm ($O(n)$) or approximate using HNSW ($O(log(n))$)
  • Exact proximity graph in $O(n^2)$
  • Leiden clustering to find communities in the graph.
  • Find connected components within the graph.
  • Partition a dataset along clusters to prevent data leakage.
  • And more!

Installation – Python

pip install refnd

Build from source (latest version, potentially unstable)

pip install "git+https://github.com/anthol42/refnd.git#subdirectory=py"

Example

The following example shows how to split a protein dataset using 1 - global alignment as the distance function using the python API.

from refnd import KernelVariant, HNSWState, find_communities, find_components, partition
from refnd.utils import read_fasta

# Load the dataset
dataset = read_fasta("datasets/proteins.fasta")
sequences = [seq for header, seq in dataset]

# Initiate the HNSW index
hnsw = HNSWState(KernelVariant.AlignmentGlobal, sequences, proximity_threshold=0.3)

# Build it
hnsw.build()

# Get the proximity edges
edges = hnsw.edges()

# Load the graph
g = edges.graph()

# Get clusters
clusters = find_components(g) # Component based clustering – faster
clusters = find_communities(g) # Community based clustering - smaller clusters

# Partition into train and test
train_ids, test_ids = partition(clusters, g, post_filtering=True)
train = [dataset[i] for i in train_ids]
test = [dataset[i] for i in test_ids]

Documentation

See the documentation references here: https://anthol42.github.io/refnd/

Feedback

This project is currently in active development, and your feedback is greatly appreciated. If you find a bug, or would like a new feature, or give your thoughts on the API, please open an issue and we will be happy to help.

Metadata

Release files for refnd 0.0.3

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

Source distribution (sdist)

Source distribution for refnd 0.0.3
File Size Uploaded Provenance
refnd-0.0.3.tar.gz 232.0 kB Without provenance Details

Built distributions (wheels)

Table of built distributions (wheels) for refnd 0.0.3
File
refnd-0.0.3-cp314-cp314-win_amd64.whl CPython 3.14 CPython 3.14 Windows x86-64 Details
refnd-0.0.3-cp314-cp314-manylinux_2_28_x86_64.whl CPython 3.14 CPython 3.14 Linux glibc 2.28+ x86-64 Details
refnd-0.0.3-cp314-cp314-macosx_11_0_arm64.whl CPython 3.14 CPython 3.14 macOS 11.0+ ARM64 Details
refnd-0.0.3-cp314-cp314-macosx_10_15_x86_64.whl CPython 3.14 CPython 3.14 macOS 10.15+ x86-64 Details
refnd-0.0.3-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details
refnd-0.0.3-cp313-cp313-manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.28+ x86-64 Details
refnd-0.0.3-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details
refnd-0.0.3-cp313-cp313-macosx_10_14_x86_64.whl CPython 3.13 CPython 3.13 macOS 10.14+ x86-64 Details
refnd-0.0.3-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
refnd-0.0.3-cp312-cp312-manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.28+ x86-64 Details
refnd-0.0.3-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details
refnd-0.0.3-cp312-cp312-macosx_10_14_x86_64.whl CPython 3.12 CPython 3.12 macOS 10.14+ x86-64 Details
refnd-0.0.3-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
refnd-0.0.3-cp311-cp311-manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.28+ x86-64 Details
refnd-0.0.3-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details
refnd-0.0.3-cp311-cp311-macosx_10_14_x86_64.whl CPython 3.11 CPython 3.11 macOS 10.14+ x86-64 Details
refnd-0.0.3-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details
refnd-0.0.3-cp310-cp310-manylinux_2_28_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.28+ x86-64 Details
refnd-0.0.3-cp310-cp310-macosx_11_0_arm64.whl CPython 3.10 CPython 3.10 macOS 11.0+ ARM64 Details
refnd-0.0.3-cp310-cp310-macosx_10_14_x86_64.whl CPython 3.10 CPython 3.10 macOS 10.14+ x86-64 Details

Total release size: 69.1 MB

Release files / refnd-0.0.3.tar.gz

Download URL refnd-0.0.3.tar.gz
Size 232.0 kB
Tags Source
SHA-256 checksum
How to use checksums
8bf6678c758055dd1b21717a5a8be9d0c23afd90ef843334a312d813220e2b79
BLAKE2b-256 checksum
How to use checksums
77cc4ea3c9f2b3cbb0f2d9b46169fe8ba52655d5502ee3f65fc7bcdaefa714c5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / refnd-0.0.3-cp314-cp314-win_amd64.whl

Download URL refnd-0.0.3-cp314-cp314-win_amd64.whl
Size 3.7 MB
Tags CPython 3.14 Windows x86-64
SHA-256 checksum
How to use checksums
59266ede510c05f2371872320a2e26f9dfa5c0f781d5ea3b16e8c6186c0afa29
BLAKE2b-256 checksum
How to use checksums
601d3ec72d21ee5c69a11978186183c2688f75316a7993bf1da202851642ca66
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / refnd-0.0.3-cp314-cp314-manylinux_2_28_x86_64.whl

Download URL refnd-0.0.3-cp314-cp314-manylinux_2_28_x86_64.whl
Size 4.4 MB
Tags CPython 3.14 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
ee5a4149dd858118b7be20242b7adbf6c71d408f20206e3fc5aa441da81f68a8
BLAKE2b-256 checksum
How to use checksums
6577039a097d5594f1d42059fc4209e664b8976de4b05bd249ed18c3cc65a0fb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / refnd-0.0.3-cp314-cp314-macosx_11_0_arm64.whl

Download URL refnd-0.0.3-cp314-cp314-macosx_11_0_arm64.whl
Size 2.0 MB
Tags CPython 3.14 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
d48da0caed2c2b177d893b01081b965416364d80dfc5a4d7f1e2856094f3e53c
BLAKE2b-256 checksum
How to use checksums
8bf261bd137a685117c2058d784b9d2d1cc03f0f7765741ac079d83f5a44d40d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / refnd-0.0.3-cp314-cp314-macosx_10_15_x86_64.whl

Download URL refnd-0.0.3-cp314-cp314-macosx_10_15_x86_64.whl
Size 3.6 MB
Tags CPython 3.14 macOS 10.15+ x86-64
SHA-256 checksum
How to use checksums
d41755d58876e24ac6018eb59355a3150d0ab45735b67b7a98aeaf73dfc61295
BLAKE2b-256 checksum
How to use checksums
cbc3cc76e122c5f3c86f21e82935341210da41bb3960aa9c4a0ecf515a77a5e7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / refnd-0.0.3-cp313-cp313-win_amd64.whl

Download URL refnd-0.0.3-cp313-cp313-win_amd64.whl
Size 3.7 MB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
8f5d8d7ef5223bb0ed344de6fe9adde92ba7685651d28139bf7730cdab382bc0
BLAKE2b-256 checksum
How to use checksums
4db20cf1aa64c2a3e17dbcd7b1f8bfaedca7c46f61271a0d180acb3f7e5380ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / refnd-0.0.3-cp313-cp313-manylinux_2_28_x86_64.whl

Download URL refnd-0.0.3-cp313-cp313-manylinux_2_28_x86_64.whl
Size 4.4 MB
Tags CPython 3.13 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
d390ab867a009db8283288ad6fc05fffbeb41854be173c2126492a63bbe864c9
BLAKE2b-256 checksum
How to use checksums
d47f7e52d98cfad81f48bb6eda4db0e16b0db8ef24ae819c6e68a82df019f810
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / refnd-0.0.3-cp313-cp313-macosx_11_0_arm64.whl

Download URL refnd-0.0.3-cp313-cp313-macosx_11_0_arm64.whl
Size 2.0 MB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
0e43c41f45c4df9b3c6b7082cc9f8976f0ac892a179fa94f9c44a93ff8693282
BLAKE2b-256 checksum
How to use checksums
c27d8056ef460cfdd20dc1e1000e34c2275eca088cb8866736690174e2156dfe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / refnd-0.0.3-cp313-cp313-macosx_10_14_x86_64.whl

Download URL refnd-0.0.3-cp313-cp313-macosx_10_14_x86_64.whl
Size 3.6 MB
Tags CPython 3.13 macOS 10.14+ x86-64
SHA-256 checksum
How to use checksums
ab35ed41683ca3cc52e30ac747221b7bb7e0ea055deea6325de52f0503b8e408
BLAKE2b-256 checksum
How to use checksums
5797a5baeb3b8880106f25dfd86fa4698d618fa1096b14495865e9dc7fcf0fee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / refnd-0.0.3-cp312-cp312-win_amd64.whl

Download URL refnd-0.0.3-cp312-cp312-win_amd64.whl
Size 3.7 MB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
78aa8b53dae931f7acf55fbf9745265edeef1c60d09a96b3b053034f5453f9bf
BLAKE2b-256 checksum
How to use checksums
e2cd04664ccdc6bb378fd6b1e33fc245fd246d115ac10357a76a031450445368
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / refnd-0.0.3-cp312-cp312-manylinux_2_28_x86_64.whl

Download URL refnd-0.0.3-cp312-cp312-manylinux_2_28_x86_64.whl
Size 4.4 MB
Tags CPython 3.12 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
f3455e9c97aeac137dcd08fe411584332c03805721a8cd5b43a482b3e1d4738b
BLAKE2b-256 checksum
How to use checksums
850ca12613973c4359a36826f94b1fd0c8bed9e71387768aa1bf2ce89d29ee83
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / refnd-0.0.3-cp312-cp312-macosx_11_0_arm64.whl

Download URL refnd-0.0.3-cp312-cp312-macosx_11_0_arm64.whl
Size 2.0 MB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
e78e18d0a074f4c1c4b70907bd8419a4215b2c7f9fb6ab7d17563eae92d3039e
BLAKE2b-256 checksum
How to use checksums
4cf170d07e0ccff7d98b90574fc7ec307017f4fc4e21843c87858cafd5f84e6d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / refnd-0.0.3-cp312-cp312-macosx_10_14_x86_64.whl

Download URL refnd-0.0.3-cp312-cp312-macosx_10_14_x86_64.whl
Size 3.6 MB
Tags CPython 3.12 macOS 10.14+ x86-64
SHA-256 checksum
How to use checksums
efa2c2777e0472032300a887f0b6f1563843c0c7a6d791efe542f6d1493e8bd2
BLAKE2b-256 checksum
How to use checksums
b18ca3967ee5d50ef1580960b65368b7350b5232e73999a83c67b82d768dd66e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / refnd-0.0.3-cp311-cp311-win_amd64.whl

Download URL refnd-0.0.3-cp311-cp311-win_amd64.whl
Size 3.7 MB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
1cbb09987882f0b5daec44478d6ffb8e342306b9bc3b428eba42752e7b43418e
BLAKE2b-256 checksum
How to use checksums
6a664589920b729eb3ba3b695971d20df81bf362f503bfd99b1884e3529994e1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / refnd-0.0.3-cp311-cp311-manylinux_2_28_x86_64.whl

Download URL refnd-0.0.3-cp311-cp311-manylinux_2_28_x86_64.whl
Size 4.4 MB
Tags CPython 3.11 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
bb6078b4fc05c356bf97b67ba5897212e9a81c91e2a30516d3fc829541bcbbd4
BLAKE2b-256 checksum
How to use checksums
b086d9446f4d8f358472f44d270f6e8e3d624167c51c34201ce278d8b472af97
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / refnd-0.0.3-cp311-cp311-macosx_11_0_arm64.whl

Download URL refnd-0.0.3-cp311-cp311-macosx_11_0_arm64.whl
Size 2.0 MB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
36f4bae3942ad408f12fc71d90b516f5c8b6527fb8d394cd8369a7241ce5ba1f
BLAKE2b-256 checksum
How to use checksums
e4f54436bb01d240395230af27a7328c4bfa45a22070dc307c86ebe2b80bf762
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / refnd-0.0.3-cp311-cp311-macosx_10_14_x86_64.whl

Download URL refnd-0.0.3-cp311-cp311-macosx_10_14_x86_64.whl
Size 3.6 MB
Tags CPython 3.11 macOS 10.14+ x86-64
SHA-256 checksum
How to use checksums
06eb8401a52937d3b9a7ee5fbf1263f2fe2e74ba355cada9b3a8f5e7783968d3
BLAKE2b-256 checksum
How to use checksums
c596b5cf80df25666c3605b56813f728ef95ded30d34df99c31ca65d064d524f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / refnd-0.0.3-cp310-cp310-win_amd64.whl

Download URL refnd-0.0.3-cp310-cp310-win_amd64.whl
Size 3.7 MB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
093e77a8ee523dd9e4275e7bd548deab9fb2cb9e2d2fed7c6570d9feed72be0f
BLAKE2b-256 checksum
How to use checksums
0ff91cd3fac1f50af2411f116af558c9c7f5636ebe63c126b491a4f2e54b649a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / refnd-0.0.3-cp310-cp310-manylinux_2_28_x86_64.whl

Download URL refnd-0.0.3-cp310-cp310-manylinux_2_28_x86_64.whl
Size 4.4 MB
Tags CPython 3.10 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
c3bb587aebe538c28a1f67cf1b5dd4db5033fd539e3f469b71802ea85c7e2fe1
BLAKE2b-256 checksum
How to use checksums
21842662b7921ca7cabd5c3ad14613dc419293177b30b4ceb564fb633e87647d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / refnd-0.0.3-cp310-cp310-macosx_11_0_arm64.whl

Download URL refnd-0.0.3-cp310-cp310-macosx_11_0_arm64.whl
Size 2.0 MB
Tags CPython 3.10 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
995f44ff526231066d412a9ac2bac773f1a5ae982e10e4707844bdb49ddb015b
BLAKE2b-256 checksum
How to use checksums
da511eb0a4fcde2464180548317369d86ab588545f4f2fc42a6014cae9c26c1a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / refnd-0.0.3-cp310-cp310-macosx_10_14_x86_64.whl

Download URL refnd-0.0.3-cp310-cp310-macosx_10_14_x86_64.whl
Size 3.6 MB
Tags CPython 3.10 macOS 10.14+ x86-64
SHA-256 checksum
How to use checksums
06eea59547363caa2a6f32dd4628545c3bfd023353ace859120e6947cf81d13c
BLAKE2b-256 checksum
How to use checksums
304131934fa080088a114fa940ab5aa49b8df44a027b54eedb18b0c2519cebde
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Security for refnd 0.0.3

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.

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