afdb-msa-index / README.md
sokrypton's picture
Upload README.md with huggingface_hub
431e68b verified
|
Raw
History Blame Contribute Delete
4.07 kB
---
license: cc-by-4.0
tags:
- protein
- alphafold
- msa
- sequence-search
pretty_name: AlphaFold DB minimizer index
size_categories:
- 100M<n<1B
---
# AlphaFold DB minimizer index
A static sequence-search index over **239,602,633 AlphaFold DB v6 entries**
(99.4% of the database), designed to be queried directly from a browser with
HTTP Range requests. No server, no search engine, no MMseqs2.
It exists to answer one question quickly: *which AFDB entry is ≥90% identical to
my sequence?* — so that entry's precomputed MSA can be borrowed and re-indexed
onto the query instead of computing a new alignment.
Used by [AFDB MSA](https://github.com/sokrypton/afdb-msa).
## Cost of a query
```
~45 ranged requests, ~50 KB, ~1 ms — independent of index size
```
Twelve minimizer seeds per query; each costs an 8-byte read of `buckets.u32`
(a prefix-sum array, so slots `b` and `b+1` arrive together) and one read of its
posting list.
## Layout
| file | size | contents |
|---|---|---|
| `meta.json` | 2 KB | entry count, k, target seeds, bucket bits, file table |
| `buckets.u32` | 134 MB | `2^25+1` prefix offsets: a seed's high bits give its posting range |
| `post-000..009.bin` | 14.2 GB | 5 bytes per posting: 1-byte key residual + 4-byte entry id |
| `acc.bin` | 2.88 GB | fixed 12-byte accessions, so an entry id **is** its byte offset |
Seeds are 31-bit. The top 25 bits address a bucket; the stored 1-byte residual is
the seed's low 8 bits, overlapping the bucket by 2 — a harmless redundancy that
still pins down the 6 low bits the bucket does not carry. Residual collisions are
filtered by the alignment that follows, since shared-seed count is a prefilter.
## Parameters
```
k = 10 10-mers; survive 90% identity with p = 0.9^10 = 0.35
target = 12 seeds per sequence, so P(share >=1) = 1 - 0.65^12 = 99.2%
w adaptive window = len/12, clamped to [4,128]
```
The window adapts to length rather than being fixed: a fixed window undersamples
short proteins — at k=12 w=16 a 142-residue globin got 8 seeds and shared none
with a real 90% relative on two of three tries.
## Measured against BLAST
16 AFDB sequences with 5% of positions mutated, versus BLAST on full UniProtKB:
| | index | BLAST |
|---|---|---|
| hits at ≥90% identity | **100%** | 81% |
| median identity | 95% | 95% |
| time | **1 ms** | 287 s |
The index also wins outright on some queries (94% vs 41% on one). That is the
corpus, not cleverness: **63% of AFDB entries have been deleted from current
UniProtKB**, so BLAST cannot return them and settles for a distant relative.
AFDB is its own authority here.
## Limits
- **Sensitivity fades below ~70% identity.** Exact-k-mer seeding is reliable
above ~90% and degrades below. That is deliberate — the target is close
relatives worth borrowing an MSA from.
- **Repetitive and low-complexity sequence yields few distinct seeds** (a
homopolymer collapses to one), so such queries retrieve weakly. A thin
candidate list is not evidence that nothing similar exists.
- **Entries only, not sequences.** The index maps seeds to AFDB accessions; the
residues come from AlphaFold DB's own API. Note that most AFDB accessions no
longer resolve in current UniProtKB.
## Building
From `sequences.fasta` (118 GB) with
[the tools in the repo](https://github.com/sokrypton/afdb-msa):
```sh
for i in $(seq 0 23); do
node tools/afdb-shard.mjs part_$(printf '%02d' $i).fa shards/ $i &
done; wait
node --max-old-space-size=120000 tools/afdb-merge.mjs shards/ index/
```
About 5 minutes of sharding on 24 cores, 2.5 minutes to merge.
## Attribution
Derived from the [AlphaFold Protein Structure Database](https://alphafold.ebi.ac.uk/)
(EMBL-EBI / Google DeepMind), release v6, which is distributed under
[CC-BY-4.0](https://creativecommons.org/licenses/by/4.0/). This index inherits
that licence.
> Varadi et al. *AlphaFold Protein Structure Database: massively expanding the
> structural coverage of protein-sequence space with high-accuracy models.*
> Nucleic Acids Research (2022).