iggytop.adapters.base_adapter.BaseAdapter#
- class iggytop.adapters.base_adapter.BaseAdapter(bc, cache_dir=None, receptors_to_include=('TCR', 'BCR'), test=False)#
Base class for all adapters.
This class is responsible for the basic structure and function for Iggytop adapters. It initializes any adapter by calling the corresponding function for downloading and reading the data from the source. It also provides methods for generating BioCypher nodes and edges from the data.
- Variables:
- Parameters:
- __init__(bc, cache_dir=None, receptors_to_include=('TCR', 'BCR'), test=False)#
Initializes the BaseAdapter instance.
- Parameters:
Methods
__init__(bc[, cache_dir, ...])Initializes the BaseAdapter instance.
Creates an Anndata object from the AIRR cell data and saves it to a file in the cache directory.
Abstract method to generate BioCypher edges from the data.
Abstract method to get the latest release of the data.
Abstract method to generate BioCypher nodes from the data.
read_table(bc, table_path, receptors[, test])Abstract method to read and harmonize the data table from the source.
set_metadata([version, source_url, ...])Sets the metadata for the adapter.
Attributes
Property to get the list of AIRR cells.
Property to get the cache directory.
Property to get the database name.
Property to get the adapter metadata.
Property to get the available receptor types.
Property to get the data table.
- _get_ontoweaver_kg()#
Generates BioCypher nodes and edges from the harmonized table via OntoWeaver.
Runs the shared per-hub mappings in
_ONTOWEAVER_MAPPINGS(driven purely by REGISTRY_KEYS column names, so they apply unmodified to any adapter’s table) against a copy of the table augmented with a few precomputed columns (thecompleteflags, which need boolean combinations no single-column mapping can express, and the source database’s identity, which lives inself.metadatarather than as a table column). The passes are reconciled together afterwards, so nodes/edges produced by more than one pass (e.g. a chain_2 node, created as a target by the receptor_complex mapping and as the subject of the chain_2 mapping) are merged into one.
- create_anndata()#
Creates an Anndata object from the AIRR cell data and saves it to a file in the cache directory.
- Return type:
- abstractmethod get_edges()#
Abstract method to generate BioCypher edges from the data.
Adapters are expected to implement this via
_get_ontoweaver_kg.- Yields:
tuple – A BioCypher edge (id, source, target, type, properties).
- abstractmethod get_latest_release(bc)#
Abstract method to get the latest release of the data.
- abstractmethod get_nodes()#
Abstract method to generate BioCypher nodes from the data.
Adapters are expected to implement this via
_get_ontoweaver_kg.- Yields:
tuple – A BioCypher node (id, type, properties).
- abstractmethod read_table(bc, table_path, receptors, test=False)#
Abstract method to read and harmonize the data table from the source.
- Parameters:
- Return type:
DataFrame- Returns:
The data table.
- set_metadata(version=None, source_url=None, previous_version=None, previous_checksum=None)#
Sets the metadata for the adapter.
- Parameters:
version (
str) – The version of the database. Defaults to None.source_url (
str) – The URL of the source. Defaults to None.previous_version (
str) – The version of the database in the previous release. Defaults to None.previous_checksum (
str|list|None) – The checksum(s) of the source file(s) in the previous release. Defaults to None.
- _abc_impl = <_abc._abc_data object>#
- property airr_cells: list[AirrCell] | None#
Property to get the list of AIRR cells.
- Returns:
The list of AIRR cells.
- property metadata: dict[str, Any]#
Property to get the adapter metadata.
- Returns:
The metadata dictionary.
- property receptors: list[str]#
Property to get the available receptor types.
- Returns:
List of receptor types.
- property table: DataFrame#
Property to get the data table. Reads the table if not already read.
- Returns:
The data table.