Skip to main content

hashrope-bio

Computational biology applications of hashrope — Exact byte comparison for gene-level change detection, genomic region comparison, mutation localization, drug resistance screening, and tandem repeat compression.

Exact comparison in 0.3.3

This release requires Hashrope 0.3.3 or later in the 0.3 series. Fingerprint values/defaults are unchanged; equality, mutation and conservation decisions now verify actual bytes. Report hash fields are metadata, and gene/exon reports carry separate verified change flags. Manually constructing these reports requires those flags rather than deriving them from hashes.

Exact verification can scan an entire independent region and uses a per-call comparison cache where needed. Shared ranges and periodic structure can be skipped after proof. Historical speedups and datasets below describe the earlier fingerprint experiments; they do not establish current exact-comparison performance or universal collision resistance. Historical result files have been preserved.

The exact-path optimization report reruns the full stored HIV comparison workload against archived preoptimization and optimized cores. It includes verification costs and construction exclusions; it does not revalidate the older chromosome-scale fingerprint speedups below.

Install

pip install "hashrope-bio==0.3.3"

For optional backends:

pip install -e ".[genomics]"   # pysam + biopython for FASTA I/O

Features

Gene-level change detection (genomics.gene_diff)

Compare gene bodies and exons exactly, with shortcuts for shared and repeated structure. Independent equal regions may require reading every byte.

from hashrope_bio.genomics import load_fasta_to_rope, load_gene_regions, diff_genes

ref_rope, h, _ = load_fasta_to_rope("reference.fa")
sample_rope, _, _ = load_fasta_to_rope("patient.fa", h=h)
genes = load_gene_regions("chr22_genes.tsv")
report = diff_genes(ref_rope, sample_rope, genes, h)
print(report.summary())
# Gene diff: 12/643 genes changed, 47/5127 exons changed
#   LARGE1 (650,315 bp): body changed, 3/14 exons differ
#   ...

Validated on GRCh38 chr22 with 643 real genes (UCSC refGene): 5,770/5,770 queries correct. Speedups: 25× for typical genes (10–50 Kbp), 411× for large genes (>500 Kbp).

Drug resistance screening (cheminformatics.resistance)

Check N known resistance mutation sites by comparing actual codon bytes.

from hashrope_bio.cheminformatics.resistance import check_resistance_panel, HIV_RT_NNRTI_PANEL

results = check_resistance_panel(ref_rope, sample_rope, HIV_RT_NNRTI_PANEL, h)
for r in results:
    if r.is_mutant:
        print(f"  {r.site.annotation}")

Validated on 100 real clinical HIV-1 sequences against Stanford HIVDB: 103/103 drug resistance mutations detected (100% sensitivity).

Region identity queries (genomics.region_query)

Exact byte comparison for arbitrary genomic regions; fingerprint queries remain available separately.

from hashrope_bio.genomics import region_hash, regions_identical

identical = regions_identical(ref_rope, sample_rope, start=10000, length=50000, h=h)

Mutation localization (genomics.mutation)

Exact prefix comparison localizes the first divergent byte. Matching fingerprints do not prune mutations.

Validated on 3,422 ClinVar pathogenic SNVs on chr22: 3,422/3,422 correct (100%).

Tandem repeat compression (genomics.repeats)

RepeatNode gives O(log q) hash computation for q-repeat motifs vs O(q·d) naive. 610× speedup at q=10,000 for clinical trinucleotide repeats (HTT, FMR1).

Project structure

src/hashrope_bio/
├── genomics/          # FASTA loading, region queries, mutation search, gene diff, repeats
├── proteomics/        # MD trajectory frame comparison (stub)
└── cheminformatics/   # Resistance panels, compound lookup with retained verification bytes
benchmarks/            # Experiment scripts
scripts/               # Dataset download helpers
data/                  # Downloaded datasets (gitignored)
tests/                 # Unit tests (28 passing)

Depends on

  • hashrope — core rope data structure
  • pysam / biopython (optional) — FASTA I/O

Citation

If you use hashrope-bio in published research, please cite:

License

MIT

Compound lookup compatibility

build_compound_index retains every candidate and its canonical encoding bytes. lookup_compound checks those bytes inside the matching hash bucket; collisions and duplicate input rows are retained. Legacy plain dictionaries containing only hashes/row IDs are rejected because they cannot verify identity; rebuild them from the source file. Canonicalization remains the caller's responsibility.

Run consumer tests from this directory with local Hashrope installed (or add ../../../packages/python and src to PYTHONPATH): python -m pytest tests.

Metadata

Release files for hashrope-bio 0.3.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 hashrope-bio 0.3.3
File Size Uploaded Provenance
hashrope_bio-0.3.3.tar.gz 21.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for hashrope-bio 0.3.3
File Interpreter ABI Platform
hashrope_bio-0.3.3-py3-none-any.whl Python 3 none any Details

Total release size: 41.2 kB

Release files / hashrope_bio-0.3.3.tar.gz

Download URL hashrope_bio-0.3.3.tar.gz
Size 21.2 kB
Tags Source
SHA-256 checksum
How to use checksums
028fb28a7f14207b05ed01f92856d174d425c95c3b8d85dcc2b58b69542640df
BLAKE2b-256 checksum
How to use checksums
dc7597b796da02c438caa8f12df24bf3601a97d4e1be10f64a2452e2560f8d32
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.2

Release files / hashrope_bio-0.3.3-py3-none-any.whl

Download URL hashrope_bio-0.3.3-py3-none-any.whl
Size 20.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a4d5574eba030260e74aaf78693013a3264b4655a22db018b91d0d5514a6055e
BLAKE2b-256 checksum
How to use checksums
bbfd8d655d5575dfafa65b4d57490093015cf73bf4233c00e865a0398bfad627
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.2

Security for hashrope-bio 0.3.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.

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