# torchcell/adapters/baryshnikova2010_adapter.py
# [[torchcell.adapters.baryshnikova2010_adapter]]
# https://github.com/Mjvolk3/torchcell/tree/main/torchcell/adapters/baryshnikova2010_adapter.py
# Test file: tests/torchcell/adapters/test_baryshnikova2010_adapter.py
"""BioCypher adapter exposing the Baryshnikova 2010 single-mutant fitness catalog.
Each record is one SGA strain (a kanMX deletion, a DAmP hypomorph or a temperature-
sensitive allele) measured on the SGA final-selection plate, so the node and edge method
lists are the Costanzo 2016 SMF lists verbatim: the same ``genotype``/``perturbation``
leaves, the same ``media``/``temperature``/``environment`` triple and the same ``fitness
phenotype``. No new graph class and no new ``CellAdapter`` method is introduced. The one
shape difference from Costanzo is invisible to the adapter: the environment comes in two
temperatures (30 C for deletions and DAmP, 26 C for TS alleles), which the chunked
environment and temperature methods already handle as two nodes.
"""
import os.path as osp
import yaml
from omegaconf import OmegaConf
from torchcell.adapters.cell_adapter import CellAdapter
from torchcell.datasets.scerevisiae.baryshnikova2010 import SmfBaryshnikova2010Dataset
[docs]
class SmfBaryshnikova2010Adapter(CellAdapter):
"""Cell adapter that serves the Baryshnikova 2010 SMF dataset to BioCypher."""
def __init__(
self,
dataset: SmfBaryshnikova2010Dataset,
process_workers: int,
io_workers: int,
chunk_size: int = int(1e4),
loader_batch_size: int = int(1e3),
):
"""Load the adapter conf enable-list and initialize the base CellAdapter."""
current_dir = osp.dirname(osp.abspath(__file__))
config_path = osp.join(current_dir, "conf", "smf_baryshnikova2010_adapter.yaml")
if not osp.exists(config_path):
raise FileNotFoundError(f"Config file not found: {config_path}")
with open(config_path) as file:
yaml_config = yaml.safe_load(file)
config = OmegaConf.create(yaml_config)
super().__init__(
config, dataset, process_workers, io_workers, chunk_size, loader_batch_size
)
self.dataset = dataset
self.process_workers = process_workers
self.io_workers = io_workers
self.chunk_size = chunk_size
self.loader_batch_size = loader_batch_size