torchcell.metabolism.flux_layer.gene_index_map

gene_index_map(model_gene_ids: list[str], gem_gene_ids: list[str]) → tuple[Tensor, Tensor][source]

Map GEM gene positions onto the model’s gene-token positions.

The transformer’s token index runs over the whole genome (6,607 ORFs); the GEM knows only its metabolic subset (1,161). Both directions are needed: the flux layer reads gene tokens at GEM positions, and a perturbation arrives as a token index that must be tested for GEM membership.

Returns:

(gem_to_model, model_to_gem). gem_to_model[k] is the token index of GEM gene k, or -1 if that gene is absent from the model’s universe. model_to_gem[t] is the GEM index of token t, or -1.