Source code for drugforge.data.schema.pairs

import logging
from typing import Any, ClassVar

from drugforge.data.schema.complex import Complex
from drugforge.data.schema.ligand import Ligand
from pydantic import BaseModel, Field

logger = logging.getLogger(__name__)


[docs] class PairBase(BaseModel): """ Base class for pairs. """ is_cacheable: ClassVar[bool] = True def __eq__(self, other: Any) -> bool: if not isinstance(other, PairBase): raise NotImplementedError # Check that both Complexes are the same and both Ligands are the same return (self.complex == other.complex) and (self.ligand == other.ligand) def __ne__(self, other: Any) -> bool: return not self.__eq__(other)
[docs] class CompoundStructurePair(PairBase): """ Schema for a CompoundStructurePair, containing both a Complex and Ligand This is designed to track a matched ligand and complex pair for investigation """ complex: Complex = Field(description="Target schema object") ligand: Ligand = Field(description="Ligand schema object") @property def unique_name(self): return f"{self.complex.unique_name}_{self.ligand.compound_name}-{self.ligand.fixed_inchikey}"