torchcell.metabolism.constraints.CatalyticUnits

class CatalyticUnits(*, unit_gene_index: Tensor, unit_reaction: Tensor, n_units: int, n_multigene_units: int, n_reactions_with_gpr: int, gene_ids: list[str])[source]

Bases: BaseModel

The GPR, flattened into AND-terms, as index arrays rather than strings.

A gene-protein-reaction rule is a disjunction of conjunctions: (a and b) or c means reaction j runs if the complex {a,b} is intact OR the isozyme c is present. Each conjunction is one catalytic unit. Complexes take a min over their genes (the scarcest subunit limits the complex); isozymes add (their capacities sum).

Stored as a flat (unit, gene) edge list plus a (unit -> reaction) map, which is the shape a scatter-based softmin / index_add consumes directly. Storing the parsed rule as a string and re-parsing per forward pass would be the same information at 10^4 times the cost.

model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].