data module

This module loads and manages all data required for pLAST, including models, metadata, cluster mappings, and GenBank features. It provides lazy loading for efficient resource usage.

class plast.data.PLASTData(config_dict=None)

Bases: object

Stores all data required for pLAST, including models, metadata, cluster mappings, and GenBank features. Provides lazy loading for efficient resource usage.

Parameters:

config_dict (dict or None) – Configuration dictionary with file paths and model info.

get_metadata_index_name(model_name=None)

Resolve the metadata index configured for a model.

Return type:

str

resolve_accession(accession, model_name=None, metadata_index=None, allow_fallbacks=True)

Resolve a model/browser accession to the row accession used in metadata.

Return type:

Optional[str]

accession_in_metadata_index(accession, model_name=None, metadata_index=None)

Return True only if the accession resolves in the requested metadata index.

Return type:

bool

filter_ids_for_metadata_index(plasmid_ids, model_name=None, metadata_index=None)

Keep only ids that belong to a model/browser metadata index.

Return type:

List[str]

candidate_accessions(accession, model_name=None, metadata_index=None)

Return likely accession aliases for metadata, gbfeatures, mappings and embeddings.

Return type:

List[str]

get_metadata_row(plasmid_id, model_name=None, metadata_index=None)

Return one metadata row resolved through the configured in-memory index.

Return type:

Series

get_metadata_for_ids(plasmid_ids, model_name=None, metadata_index=None)

Return metadata rows for ids without copying the full metadata table.

Return type:

DataFrame

get_search_index(model_name)

Return a cached, model-specific in-memory search index.

The index is filtered to the metadata scope configured for the model and stores NumPy matrices so each query can rank plasmids with vectorized operations instead of looping over all embeddings in Python.

Return type:

Dict[str, Any]

get_model_ids_and_umap_coords(model_name)

Return cached plasmid ids and UMAP coordinates for a model metadata scope.

Return type:

tuple

warm_search_indexes(model_names=None)

Preload metadata, embeddings and vectorized search indexes into RAM.

Return type:

None

get_cluster_mapping(model_name=None)

Return the MMseqs cluster mapping for a specific model.

Return type:

DataFrame

get_cluster_lookup(model_name=None)

Return a lightweight accession/protein -> cluster lookup for MMseqs results.

The lookup avoids pandas MultiIndex access in the request path, which removes lexsort warnings and reduces CPU/RAM overhead for repeated single-key lookups.

Return type:

Dict[str, Dict[str, str]]

get_mmseqs_db(model_name, padded=False)

Return the MMseqs database path configured for a model.

Return type:

str

get_model(model_name)

Get the model by name, loading it if necessary.

Parameters:

model_name (str) – Name of the model to retrieve.

Returns:

Loaded PLASTModel object.

Return type:

PLASTModel

Raises:

DataLoadingError – If model is not found in configuration.