torchcell.datamodels.schema.GenePerturbation

class GenePerturbation(*, systematic_gene_name: str, perturbed_gene_name: str, gene_namespace: Literal['scerevisiae_s288c_sgd_systematic', 'scerevisiae_cenpk113_7d_locus_tag', 'scerevisiae_peter2018_pangenome_orf', 'ecoli_k12_mg1655_bnumber', 'ecoli_k12_bw25113_locus_tag', 'pputida_kt2440_locus_tag', 'ecoli_b_rel606_locus_tag', 'ecoli_k12_w3110_refseq_locus_tag'], identifier_mapping: DerivedIdentifierMapping | None = None, provenance: str = 'engineered')[source]

Bases: ModelStrict

Base perturbation of a single gene by systematic and common name.

gene_namespace names the HOST genome the record’s identifiers are written against (P1, ontology-unify 2026-10-15): the host is a fact of every record, and before this field it was expressible only by choosing a bacterial leaf class. It is REQUIRED on the base. A leaf whose name validator pins the S288C systematic form defaults it to SGD_S288C_NAMESPACE, because the stored name’s form already proves the namespace; a leaf whose validator is relaxed (an addition, a natural pangenome ORF, a released name, a variant site) carries no default, so the loader states the host. When the identifier has the form of some namespace it must be the declared one (_check_gene_namespace); when it has none, the leaf decides what is admissible.

identifier_mapping records how a stored identifier was DERIVED from the one the source released, when the two differ; None when the source released it as stored.

provenance records whether the difference from the reference was ENGINEERED in the lab or arose NATURALLY in an isolate. It defaults to "engineered" so the many engineered perturbation types need not repeat it; natural types set provenance="natural" as a class default.

classmethod validate_sys_gene_name(v: str) → str[source]

The identifier has the form of some host namespace (see the class doc).

classmethod validate_pert_gene_name(v: str) → str[source]

Normalize a trailing prime in the perturbed gene name to _prime.

classmethod validate_provenance(v: str) → str[source]

Provenance is one of the two allowed origins.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True}

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