NCBI / README.md
anindya64's picture
Add normalized Parquet train/test NCBI shard index
c964bc2 verified
metadata
pretty_name: NCBI RefSeq Protein Shard Index
license: other
tags:
  - biology
  - proteins
  - sequences
  - fasta
  - ncbi
  - refseq
  - parquet
configs:
  - config_name: default
    data_files:
      - split: train
        path: data/train-*.parquet
      - split: test
        path: data/test-*.parquet

NCBI RefSeq Protein Shard Index

This dataset contains the original NCBI RefSeq protein FASTA shards plus a viewer-friendly file/shard index. The full sequence data is stored as 1,725 .fasta.zst shards and the per-record metadata JSONL files are very large, so the default Dataset Viewer table indexes repository files instead of expanding all 459,415,871 protein records.

Use the original sequences/.../shard-*.fasta.zst files for complete FASTA records. Use the default Parquet table for Dataset Viewer previews, source discovery, file sizes, record counts, and download patterns.

Splits

The split is deterministic by file ID: sha256(file_id) % 10. Bucket 0 is test; buckets 1 through 9 are train.

Split Rows
train 4,676
test 502
total 5,178

Source Statistics

Field Value
Source FASTA files 1,725
RefSeq protein records 459,415,871
Residues 179,203,453,293
Sequence shards 1,725
Compressed sequence shard bytes 78,108,688,857
Metadata JSONL bytes 158,533,041,909

Usage

pip install datasets

Load the shard index:

from datasets import load_dataset

ds = load_dataset("LiteFold/NCBI")
print(ds)
print(ds["train"][0])

Load one split:

from datasets import load_dataset

train = load_dataset("LiteFold/NCBI", split="train")
test = load_dataset("LiteFold/NCBI", split="test")

List sequence shards:

from datasets import load_dataset

index = load_dataset("LiteFold/NCBI", split="train")
shards = index.filter(lambda row: row["is_sequence_shard"])
print(shards[0]["path"])

Find a source FASTA and its files:

from datasets import load_dataset

index = load_dataset("LiteFold/NCBI", split="train")
rows = index.filter(lambda row: row["source_file"] == "sequence/ncbi_refseq/release_complete/complete.1486.protein.faa.gz")
for row in rows:
    print(row["role"], row["path"], row["size_bytes"])

Download all sequence shards:

hf download LiteFold/NCBI --repo-type dataset \
  --include 'sequences/*/shard-*.fasta.zst' \
  --local-dir ./ncbi_refseq_protein

Download one source shard:

hf download LiteFold/NCBI --repo-type dataset \
  --include 'sequences/sequence_ncbi_refseq_release_complete_complete.1486.protein.faa.gz/shard-*.fasta.zst' \
  --local-dir ./ncbi_refseq_protein

Stream a downloaded shard with Python:

from pathlib import Path
import zstandard as zstd

shard = next(Path("./ncbi_refseq_protein").rglob("shard-*.fasta.zst"))
dctx = zstd.ZstdDecompressor()
with shard.open("rb") as f, dctx.stream_reader(f) as reader:
    print(reader.read(1024).decode("utf-8", errors="replace"))

Columns

Column Description
file_id Stable row ID, equal to the repository path.
repo_id Hugging Face dataset repository.
source_sha Source repository commit used to build the index.
dataset_id Source dataset identifier from the manifest.
source_slug Source slug from the original pipeline manifest.
source_file Original source FASTA file path.
path File path in the repository.
role File role, such as sequence_shard, metadata_records, or source_manifest.
shard_index Numeric shard index for sequence shards.
size_bytes File size in bytes.
compression Compression format, when applicable.
records_in_source Protein record count for the source FASTA file.
residues_in_source Residue count for the source FASTA file.
shards_in_source Shard count for the source FASTA file.
records_total Total protein record count from the aggregate manifest.
residues_total Total residue count from the aggregate manifest.
total_shards Total sequence shard count.
is_sequence_shard Whether the row points to a FASTA shard.
is_metadata_records Whether the row points to a per-record metadata JSONL.
download_pattern Recommended path or glob for downloading.
access_note Note describing the index scope.
split_bucket Deterministic split bucket from sha256(file_id) % 10.

Preparation

The normalization script used to create the Parquet files is included at scripts/prepare_ncbi_dataset.py.