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

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.2
File Size Uploaded Provenance
refnd-0.0.2.tar.gz 233.6 kB Without provenance Details

Built distributions (wheels)

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

Total release size: 63.7 MB

Release files / refnd-0.0.2.tar.gz

Download URL refnd-0.0.2.tar.gz
Size 233.6 kB
Tags Source
SHA-256 checksum
How to use checksums
bf3954da03f669b46263597d74f6277b9d34fad543f99c509089aeadd541cb16
BLAKE2b-256 checksum
How to use checksums
aebb82d9225987f04689cfbf533e8ec4caee64f1a61d7da9afce14c586df1482
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

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

Download URL refnd-0.0.2-cp314-cp314-win_amd64.whl
Size 3.4 MB
Tags CPython 3.14 Windows x86-64
SHA-256 checksum
How to use checksums
cae8727070c9523d3eda4b783294cfab0d8484732c5ff9a0735e2e10fe63b0b5
BLAKE2b-256 checksum
How to use checksums
55872f502c46caaa6d0865d618c18074a9a7161aee71abc4b60bfb5eb3a4fe25
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

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

Download URL refnd-0.0.2-cp314-cp314-manylinux_2_28_x86_64.whl
Size 4.2 MB
Tags CPython 3.14 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
42fbaea0c3e2219c523a979e408114c84697190adb74bd5782a527408f0ad093
BLAKE2b-256 checksum
How to use checksums
5eff169e9e374b98efbde5d7eafedfe6c015ae48b45f30ea9ce5ff2199e198d5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

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

Download URL refnd-0.0.2-cp314-cp314-macosx_11_0_arm64.whl
Size 1.7 MB
Tags CPython 3.14 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
0fee2d0ead1aeb4d3d4840e1a975b410accbd003f7daad5ed921fa18bae72443
BLAKE2b-256 checksum
How to use checksums
935c3286c6e04977d937b9fb8f894501be27f2000cb06c670511fbf09d318a2d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

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

Download URL refnd-0.0.2-cp314-cp314-macosx_10_15_x86_64.whl
Size 3.4 MB
Tags CPython 3.14 macOS 10.15+ x86-64
SHA-256 checksum
How to use checksums
06d289ac0f5010ac3f0c0388f810bdd9785b95e74d813ce071501e0aba86a4b3
BLAKE2b-256 checksum
How to use checksums
abc2e9bebafb2dcd3091647857f8978a001597bc9cdc76ea8286fe462cee582b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

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

Download URL refnd-0.0.2-cp313-cp313-win_amd64.whl
Size 3.4 MB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
08a7326c47ae815b6456ebf77e25e49f551ad2eb3ecc993fb15f4e627f82b1c2
BLAKE2b-256 checksum
How to use checksums
29c37fb05b4d62c7f8d14b9dd67a0bbd5477a1f0462aac7cec59a19d2949361e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

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

Download URL refnd-0.0.2-cp313-cp313-manylinux_2_28_x86_64.whl
Size 4.2 MB
Tags CPython 3.13 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
cbd945bfe899bc6b8d10354f10cbc03f84c2fdff2d6a325957b08b898a9d00bc
BLAKE2b-256 checksum
How to use checksums
ea0ce2fda90e885d61d83f30ce1612e645c660a7efd77b1615e69ec50fa80d49
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

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

Download URL refnd-0.0.2-cp313-cp313-macosx_11_0_arm64.whl
Size 1.7 MB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
c1dd18e8c7797ae461581809e9413d817c3efad16a3116d0b30dc70f2dbd417e
BLAKE2b-256 checksum
How to use checksums
b61b46922cad9205da1330d9618df5d9dd052e981ab4c94b91e8c5937e6e67b7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

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

Download URL refnd-0.0.2-cp313-cp313-macosx_10_14_x86_64.whl
Size 3.4 MB
Tags CPython 3.13 macOS 10.14+ x86-64
SHA-256 checksum
How to use checksums
fc2d7cf33da897c7b126511a350e914d176148683b4e42d72da9d0a0567bd2a4
BLAKE2b-256 checksum
How to use checksums
b07d5519d76ff9261e6b948d9fff69bc87738bc862f14d8d4285a825ef6795e1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

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

Download URL refnd-0.0.2-cp312-cp312-win_amd64.whl
Size 3.4 MB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
d378c44ee1ba78473bda7f06e5269d58af2eadc43f59b08f0f6122ac98d5c406
BLAKE2b-256 checksum
How to use checksums
7210b8fbde80f2548b75204453d9f1b46c5beba65320c14062903ebef280aedc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

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

Download URL refnd-0.0.2-cp312-cp312-manylinux_2_28_x86_64.whl
Size 4.2 MB
Tags CPython 3.12 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
988b13fc38692be82b5d3032381873e45c6806d1ae02a763df34faaf8a8ed04b
BLAKE2b-256 checksum
How to use checksums
cf54582168a4c497c07138852000fb39bb43e4e93705280ebfdaede3da3c9074
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

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

Download URL refnd-0.0.2-cp312-cp312-macosx_11_0_arm64.whl
Size 1.7 MB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
45971290b052087934e042ad8b4dc362caacca19a8dcfce6424f3daaf61f145c
BLAKE2b-256 checksum
How to use checksums
b8525bfc584e9f9be3743be6dfb1fdee847f1a97c59b132c44b95d7739ebe229
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

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

Download URL refnd-0.0.2-cp312-cp312-macosx_10_14_x86_64.whl
Size 3.4 MB
Tags CPython 3.12 macOS 10.14+ x86-64
SHA-256 checksum
How to use checksums
74ddd82284f0d3cddce58876b5563a90b3ec5b6184d6f2749a15100dbf9a8ad8
BLAKE2b-256 checksum
How to use checksums
8da752ad1701e58c935804c5ef91da3a79883e1c73487f41d8bfa38030df769a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

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

Download URL refnd-0.0.2-cp311-cp311-win_amd64.whl
Size 3.4 MB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
1e93fcfbc314804ae57f2416e7b3a9f4428354b14a1304852984f56fac659ae2
BLAKE2b-256 checksum
How to use checksums
eafd223bf24fffa8ddc8a5346c70815014e59045e4c606632273f39c40634501
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

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

Download URL refnd-0.0.2-cp311-cp311-manylinux_2_28_x86_64.whl
Size 4.2 MB
Tags CPython 3.11 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
a502bdd787fe4a632c9212479b28bc5f9d6351775a833b237cf5eccb835cc656
BLAKE2b-256 checksum
How to use checksums
0da917f00ecfb0a2e664107255079d178414558e30a781337f4c1dc3a8d49b0f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

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

Download URL refnd-0.0.2-cp311-cp311-macosx_11_0_arm64.whl
Size 1.7 MB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
0a007d11164bce68e12dfa2e2e027fb51a4e4b21da9d91c422e6d095b0d5f57e
BLAKE2b-256 checksum
How to use checksums
bb8fb806d09208a4a161774e6cb75938b664ca96cae829ad384bff9beed88b7d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

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

Download URL refnd-0.0.2-cp311-cp311-macosx_10_14_x86_64.whl
Size 3.4 MB
Tags CPython 3.11 macOS 10.14+ x86-64
SHA-256 checksum
How to use checksums
065b2341bbe02b3ca8c0bd33e6f9c1517dc00418e5c980effc8520a9cd87e08d
BLAKE2b-256 checksum
How to use checksums
2d24609864feee14daaad8e8a0befcb521957466555e57445e8657d2aec64d37
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

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

Download URL refnd-0.0.2-cp310-cp310-win_amd64.whl
Size 3.4 MB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
d812cec1a054a564dc5df2531648cad9583bff5a37fe4badfcd5be47a9911a9d
BLAKE2b-256 checksum
How to use checksums
553964f720435e1f4ca8cb57b883f843e2c17ef3a02f8d6b04c93fc3fadb121e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

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

Download URL refnd-0.0.2-cp310-cp310-manylinux_2_28_x86_64.whl
Size 4.2 MB
Tags CPython 3.10 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
3b2f629e1cfd33cffdba3e92366776764abf89440a985e5a480b2aa8e7827eb2
BLAKE2b-256 checksum
How to use checksums
5cd4b15d4ecd55c5cf7ef26093e76c9a7ffe8ef493a6a9f947413980bb5694fa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

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

Download URL refnd-0.0.2-cp310-cp310-macosx_11_0_arm64.whl
Size 1.7 MB
Tags CPython 3.10 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
34a21698af7b163012447d81789609ca7b554f166d77afd28c74cb1fffd6810a
BLAKE2b-256 checksum
How to use checksums
dcc31df9c7a14128c069e7392ac4da6687ad96cedddb0f0030024129622a6976
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

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

Download URL refnd-0.0.2-cp310-cp310-macosx_10_14_x86_64.whl
Size 3.4 MB
Tags CPython 3.10 macOS 10.14+ x86-64
SHA-256 checksum
How to use checksums
d0ed2e5bc1d26213491595f3c3a62b7f1518922a90340b20a02d174deda81a1d
BLAKE2b-256 checksum
How to use checksums
c8b9aa3f7151bc2328a8cd6c62bb3d242f1a2296fc8c24a5d4ec76bac7963287
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Security for refnd 0.0.2

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