Adapter

An adapter is the entry point for bringing external data into Bioverse. It knows how to fetch or generate raw files from a repository (AlphaFold, ProteinShake, PDB, etc.), optionally runs a Processor to parse structure files, and returns the three objects every downstream component expects: a stream of Batch shards, a Split with train/validation/test partitions, and Assets for auxiliary lookup tables (vocabularies, embeddings, metadata maps).

Adapters are typically invoked once when building or refreshing a Dataset. See Adapters for available sources.

class bioverse.adapter.Adapter[source]

Bases: ABC

Download raw data from an external source into Bioverse.

Adapters are the entry point of the data pipeline. A concrete adapter fetches or generates files under raw_path, optionally parses them with a Processor, and returns the three objects required to build a Dataset:

  • an iterator of Batch shards,

  • a Split with partition assignments, and

  • Assets for shared lookup tables.

Implement download() and register the class in a dataset config (D_*.yaml) or call it from release().

Examples

Minimal adapter that wraps a local PDB directory:

from bioverse.adapter import Adapter
from bioverse.data import Assets, Batch, Split
from bioverse.processors.pdb import PdbProcessor
from bioverse.utilities.io import rebatch

class MyAdapter(Adapter):
    def download(self, path="my_structures"):
        records = PdbProcessor.process(path)
        batches = rebatch(records)
        split = Split({"scene_split": ["train"] * len(batches)})
        assets = Assets()
        return batches, split, assets
abstract download(*args, **kwargs) Tuple[Iterator[Batch], Split, Assets][source]

Download raw data and return batches, split, and assets.

Returns:

  • batches – Iterator yielding Batch shards.

  • split – Train/validation/test partition assignments.

  • assets – Auxiliary lookup tables shared across batches.