torchcell.datamodels

The pydantic schema of a torchcell experiment. A record is a typed genotype x environment -> phenotype experiment: Genotype holds a list of gene perturbations (for example SgaKanMxDeletionPerturbation), Environment holds the medium, an optional temperature and any environment perturbations, and each phenotype family (fitness, gene interaction, CalMorph morphology, microarray, RNA-seq and pseudobulk expression, metabolite, protein abundance, visual score, environment response and others) has its own phenotype, experiment and experiment-reference classes in schema. The classes derive from the strict bases in pydant (ModelStrict and ModelStrictArbitrary). Dataset loaders emit these objects, and the converter modules map one experiment type onto another (for example gene essentiality onto fitness). The package namespace re-exports a subset (torchcell.datamodels.__all__); every class below is listed under the module that defines it.

compound_identity

Shared, pure, offline compound-identity resolver (UI-2).

Classes

compound_identity.CompoundResolutionStatus

Typed outcome of a resolution attempt, ordered from usable to terminal.

compound_identity.CompoundIdentityRecord

One row of the pinned name->structure table (JSON round-trips this natively).

compound_identity.CompoundIdentityResolution

What a caller splats into Compound (only the identity-carrying fields).

Functions

compound_identity.normalize_compound_name

Lowercase + strip + conservative synonym canonicalization (documented).

compound_identity.resolve_compound_identity

Resolve a compound identity from the pinned table -- pure, offline.

compound_identity.inchikey_from_smiles

Derive a standard InChIKey from a SMILES with RDKit, or None if it will not parse.

compound_identity.resolve_compound_identity_from_smiles

Resolve by name, falling back to the caller's SMILES ONLY when no row exists.

compound_identity.resolved_compound

Build a Compound fill-or-gap through the resolver (the loader entrypoint).

compound_identity_curate

Reproducible curator for the pinned compound-identity table (UI-2, serve-50).

Classes

compound_identity_curate.CurationDirective

One parsed input line: a loader label plus how to resolve it.

compound_identity_curate.PubChemProperty

One row of a PUG REST PropertyTable.

compound_identity_curate.PubChemClient

Rate-limited PUG REST client with an on-disk response cache.

compound_identity_curate.CuratedRow

One assembled table row, before it is serialized to JSON.

Functions

compound_identity_curate.parse_line

Parse LABEL [| key=value]... into a typed directive.

compound_identity_curate.read_name_list

Parse an input list of labels (comments and blank lines skipped).

compound_identity_curate.read_cid_list

Parse an input list of bare PubChem CIDs (one per line).

compound_identity_curate.name_property_url

The canonical single-name GET endpoint (also the row's recorded source_url).

compound_identity_curate.cid_property_url

The canonical single-CID GET endpoint that reproduces one batched row.

compound_identity_curate.synonyms_url

The canonical single-CID synonyms endpoint (the ChEBI source).

compound_identity_curate.assemble

Collapse directives + PubChem answers into deduplicated, canonical rows.

compound_identity_curate.serialize

Deterministic table bytes (sorted keys, stable indent, trailing newline).

compound_identity_curate.curate

Read the input lists, query PubChem, and assemble the rows.

conversion

Convert raw Neo4j experiment records into typed experiments stored in LMDB.

Classes

conversion.ConversionEntry

One input/output type pair plus its conversion functions.

conversion.ConversionMap

Collection of conversion entries defining how to map experiment types.

conversion.Converter

Abstract base that converts queried records and caches them in LMDB.

fitness_composite_conversion

Converter that maps gene essentiality and synthetic lethality data into fitness.

Classes

fitness_composite_conversion.CompositeFitnessConverter

Converter combining gene essentiality and synthetic lethality to fitness.

gene_essentiality_to_fitness_conversion

Convert gene-essentiality experiments into equivalent fitness experiments.

Classes

gene_essentiality_to_fitness_conversion.GeneEssentialityToFitnessConverter

Converter turning gene-essentiality records into fitness records.

Functions

gene_essentiality_to_fitness_conversion.gene_essentiality_to_fitness_experiment

Map an essential gene to a zero-fitness experiment, else drop it.

gene_essentiality_to_fitness_conversion.gene_essentiality_to_fitness_reference

Build the wild-type (fitness 1.0) reference for the fitness dataset.

identity

Composition-based identity for the environment-side entities of the graph.

Functions

identity.compound_identity_key

The join key for a compound, as "<field>:<value>".

identity.media_identity

Project a medium onto its composition: state, synthetic flag, base, contents.

identity.temperature_identity

Project a temperature onto its value and typed unit (no unit conversion).

identity.environment_perturbation_identity

Project an environment perturbation onto its typed slots.

identity.environment_identity

Project an environment onto medium, temperature, edits, oxygen, duration and rate.

identity.strain_background_identity

Project a strain background onto its genome content, dropping who stated it.

identity.identity_sha256

Hash an identity projection: sha256 over its canonical JSON encoding.

interned_constant

Content-addressed sub-objects of an Experiment record in the knowledge graph.

Functions

interned_constant.constant_id

The node id of an interned constant: sha256 over label, kind and exact payload.

interned_constant.split_experiment_dump

Return (pointered dump, constants) for one experiment.model_dump().

interned_constant.collect_pointers

Add every $ref id reachable in obj to out.

interned_constant.resolve_pointers

Splice constants back: a dict carrying $ref becomes constants[ref].

interned_constant.verified_constant

Parse a fetched payload after checking that (kind, payload) hashes to its id.

media

Reusable, provenance-first definitions of the common growth media.

Functions

media.dropout

base with the named compounds moved from components into dropouts.

media.restated

base with a dataset paper's own medium statements appended to its provenance.

ontology_checks

Programmatic coherence checks over the torchcell ontology.

Classes

ontology_checks.AdapterNodeSite

One BioCypherNode(...) construction in cell_adapter.py.

ontology_checks.PropertyMismatch

A node class whose emitted properties differ from its declared properties.

ontology_checks.OptionalTraversal

An adapter attribute chain that walks THROUGH a field the schema may null.

ontology_checks.PhenotypeLabelMap

Bijection between concrete phenotype classes and phenotype node classes.

ontology_checks.CompoundIdentityIssue

A Compound that is neither identified nor honestly gapped.

ontology_checks.MediaBaseIssue

A Media.base_medium that names nothing in MEDIA_LIBRARY.

ontology_checks.MediaDerivationIssue

A derived medium that dropped a base component without declaring a dropout.

ontology_checks.EnvironmentCompoundCollision

One compound encoded twice in an environment: as a component AND as an edit.

ontology_checks.JoinKeyCensus

How many records of a built dataset are joinable on each identity key.

Functions

ontology_checks.schema_models

Every pydantic model DEFINED in schema.py (not merely imported).

ontology_checks.schema_enums

Every enum DEFINED in schema.py.

ontology_checks.composition_targets

Schema models this model COMPOSES (holds in one of its fields).

ontology_checks.experiment_closure

Models reachable from Experiment / ExperimentReference.

ontology_checks.orphan_models

Schema models no experiment record can ever reach, sorted by name.

ontology_checks.lane_membership

The three record lanes, each closed under inheritance AND composition.

ontology_checks.lane_back_edges

Composition edges pointing UP from a lane into the experiment lane.

ontology_checks.sourced_value_fields

Model.field -> rendered annotation for every field carrying SourcedValue.

ontology_checks.enum_value_collisions

Schema enums whose members share a value (a silent Python alias).

ontology_checks.graph_schema

The committed BioCypher graph schema, parsed into per-class entries.

ontology_checks.cell_adapter_source

The CellAdapter module source (read as text; never imported for this).

ontology_checks.isolated_graph_node_classes

Node classes no edge class connects (invisible to any traversal query).

ontology_checks.phenotype_label_map

Match each phenotype node class to its concrete pydantic phenotype class.

ontology_checks.adapter_node_sites

Every BioCypherNode(...) the adapter constructs, with what it emits.

ontology_checks.adapter_property_mismatches

Node classes where emitted properties != declared properties, either way.

ontology_checks.adapter_optional_traversals

Adapter chains that dereference THROUGH a schema field that may be None.

ontology_checks.compound_has_identity

True when the compound carries at least one structure identifier.

ontology_checks.compound_has_identity_gap

True when an identifier's absence is declared as a typed ProvenanceGap.

ontology_checks.media_library_compound_issues

Shared-library compounds that are neither identified nor honestly gapped.

ontology_checks.media_base_issues

Library media whose base_medium names no member of MEDIA_LIBRARY.

ontology_checks.media_derivation_issues

Derived media that silently lost a base component.

ontology_checks.environment_compound_collisions

Compounds encoded twice in one environment: as a component AND as an edit.

ontology_checks.join_key_audit

Census of the identity keys a built dataset actually carries.

pydant

Strict Pydantic base models used across torchcell data schemas.

Classes

pydant.ModelStrict

Base model that forbids extra fields and is immutable.

pydant.ModelStrictArbitrary

Strict immutable model that also permits arbitrary field types.

schema

Pydantic data models for torchcell genotypes, environments, and phenotypes.

Classes

schema.ProvenanceGapMixin

Mixin giving a model a provenance_gaps list of typed field-absences.

schema.HashableProvenanceGapMixin

ProvenanceGapMixin for a model that must stay hashable.

schema.MatingType

Mating-type locus state.

schema.Zygosity

How many of a background's chromosome copies carry an allele.

schema.AlleleEdit

How a background allele's sequence differs from the R64 locus.

schema.GenomicSpan

A 1-based, end-inclusive interval on one replicon of a deposited assembly set.

schema.BackgroundAllele

One allele a strain background carries, as an edit against its reference genome.

schema.StrainBackground

The genome content a strain carries beyond its reference genome.

schema.ReferenceGenome

The deposited reference a record's identifiers and background edits are written against.

schema.StrainReferenceGenome

A ReferenceGenome that states its typed strain background (#507).

schema.SOTerm

A Sequence Ontology term: a SO:NNNNNNN id paired with its name.

schema.GenePerturbation

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

schema.PresenceAbsencePerturbation

AXIS 1 -- a gene is PRESENT or ABSENT relative to the reference.

schema.SequencePerturbation

AXIS 3 -- a sequence-level allelic change (SNP/indel/substitution allele).

schema.ExpressionRangeMultiplier

Min/max multiplier bounds on a gene's expression level.

schema.CrisprConstruct

The engineered CRISPR machinery introduced to perturb a gene -- a first-class MATERIAL ENTITY (the guide RNA + Cas effector we actually put in the cell).

schema.StrainConstruction

Where one physical deletion strain came from in its collection.

schema.OrfHistoryRelation

How the ORF a strain was built against relates to the current R64 gene.

schema.ConstructedOrf

The ORF annotation a deletion strain was BUILT against, when not the current gene.

schema.DeletionPerturbation

Gene deletion via KanMX or NatMX gene replacement (engineered absence).

schema.KanMxDeletionPerturbation

Gene deletion via KanMX gene replacement.

schema.BarcodedKanMxDeletionPerturbation

A KanMX deletion strain that carries the molecular barcode it was screened by.

schema.HeterozygousDeletionPerturbation

One allele of a diploid replaced by a deletion cassette (HIP / het collection).

schema.NatMxDeletionPerturbation

Gene deletion via NatMX gene replacement.

schema.SgaKanMxDeletionPerturbation

KanMX deletion perturbation specific to SGA experiments.

schema.SgaNatMxDeletionPerturbation

NatMX deletion perturbation specific to SGA experiments.

schema.DampPerturbation

Decreased-abundance-by-mRNA-perturbation (DAmP) allele perturbation.

schema.SgaDampPerturbation

DAmP perturbation specific to SGA experiments.

schema.TsAllelePerturbation

Temperature-sensitive allele perturbation via amino acid substitution.

schema.AllelePerturbation

Generic allele perturbation via amino acid substitution.

schema.SuppressorAllelePerturbation

Suppressor allele that raises fitness in the presence of a perturbation.

schema.SgaSuppressorAllelePerturbation

Suppressor allele perturbation specific to SGA experiments.

schema.SgaTsAllelePerturbation

Temperature-sensitive allele perturbation specific to SGA experiments.

schema.SgaAllelePerturbation

Generic allele perturbation specific to SGA experiments.

schema.ConditionalAlleleClass

How a conditional allele of an essential gene reduces its function.

schema.ConditionalAllelePerturbation

A conditional (hypomorphic) allele of an essential gene, class possibly unknown.

schema.MeanDeletionPerturbation

Deletion perturbation aggregating duplicate experiments by their mean.

schema.MarkerDeletionPerturbation

Gene deletion via a selectable/auxotrophic marker other than KanMX or NatMX.

schema.CrisprDeletionPerturbation

Gene deletion via an ACTIVE Cas nuclease cut repaired from a homology donor.

schema.GeneAdditionPerturbation

Gain-of-function: a gene ADDED to the strain (heterologous expression or an extra native copy), carried on a plasmid or integrated at a chromosomal locus.

schema.NaturalGeneAbsencePerturbation

A reference (core) gene ABSENT in a natural isolate (Caudal core-loss).

schema.NaturalGenePresencePerturbation

A non-reference (accessory) gene PRESENT in a natural isolate (Caudal accessory).

schema.SequenceVariantPerturbation

SNP/indel-level allelic variation: a native gene whose sequence in this strain differs from the S288C reference, captured via an off-graph pointer.

schema.CopyNumberVariantPerturbation

Copy-number variation (CNV) of a PRESENT pangenome ORF relative to S288C.

schema.EngineeredCopyNumberPerturbation

An ENGINEERED copy-number/dosage change of a PRESENT native gene.

schema.ExpressionModulationPerturbation

AXIS 4 (ABC) -- engineered expression modulation of a present gene.

schema.CrisprActivationPerturbation

CRISPRa -- guide-directed dead-Cas activator INCREASES a present gene's expression.

schema.CrisprInterferencePerturbation

CRISPRi -- guide-directed dead-Cas repressor DECREASES a present gene's expression.

schema.Genotype

Collection of gene perturbations defining a strain's genotype.

schema.TemperatureUnit

UO-aligned temperature units (typed, not a free string) -- G2 unit typing.

schema.Temperature

Temperature value with a typed unit (defaults to Celsius).

schema.ConcentrationUnit

UO-aligned units for a dose / physical-factor magnitude (G2 unit typing).

schema.DoseBasis

How a dose was SET when the molar value is not released (dose PROVENANCE, not a phenotypic consequence): a target-inhibition endpoint or an explicit fixed dose.

schema.PhysicalFactor

A neutral, scalar physical/physiological environment variable.

schema.Compound

Chemical identity of a small molecule, keyed by a canonical InChIKey.

schema.Concentration

A dose of an environmental agent: a numeric value+unit and/or a target-basis.

schema.Solvent

The vehicle a compound was dissolved in and its final fraction in the medium.

schema.MediaComponentRole

Functional role of a medium component (never a phenotypic consequence).

schema.ComponentDefinition

Identity/composition completeness of a component (the 'what is it' axis).

schema.MediaComponent

One ingredient of a medium: a (possibly undefined) compound at a dose.

schema.Media

Growth medium resolved to typed COMPONENTS (provenance-first).

schema.EnvironmentPerturbation

Base: a defined change to the growth environment vs the base medium.

schema.SmallMoleculePerturbation

An added chemical SPECIES (drug, acid, alcohol, salt, oxidant, ...).

schema.EnvironmentPhysicalPerturbation

A neutral, scalar physical/physiological environment FACTOR (pH, osmolarity, ...).

schema.BiologicAgentClass

Material class of a proteinaceous / biologic agent added to the medium.

schema.BiologicPerturbation

An added BIOLOGIC agent (peptide / protein / antibody / toxin).

schema.EndpointRule

When a culture was read out (the endpoint is part of what was measured).

schema.CultureFormat

The physical culture a measurement was grown in.

schema.PreCultureSource

What the screened culture was inoculated FROM.

schema.PreCulture

The culture step BEFORE treatment, which sets the cells' state at time zero.

schema.Environment

Experimental environment: base medium + temperature + optional perturbations.

schema.CultureEnvironment

An Environment that also states its culture protocol (#507 point 8).

schema.Phenotype

Base phenotype describing an observed label and its graph level.

schema.UncertaintyType

What a reported uncertainty number IS, so it converts to an SE correctly.

schema.SampleUnit

What one sample in n_samples physically is.

schema.FitnessPhenotype

Fitness phenotype with fitness value and uncertainty statistics.

schema.GeneEssentialityPhenotype

Phenotype indicating whether a gene knockout is lethal.

schema.SyntheticLethalityPhenotype

Phenotype indicating synthetic lethality between perturbed genes.

schema.SyntheticRescuePhenotype

Phenotype indicating one perturbation rescues another's deleterious effect.

schema.GeneInteractionPhenotype

Phenotype holding a gene interaction score, its p-value and its replicate design.

schema.CalMorphPhenotype

Phenotype holding CalMorph morphological measurements and CV statistics.

schema.Publication

The source document a record's values come from.

schema.ExperimentReference

Reference (wildtype/control) context for an experiment.

schema.Experiment

Base experiment pairing a genotype and environment with a phenotype.

schema.FitnessExperimentReference

Reference context for a fitness experiment.

schema.FitnessExperiment

Experiment measuring a fitness phenotype.

schema.GeneInteractionExperimentReference

Reference context for a gene interaction experiment.

schema.GeneInteractionExperiment

Experiment measuring a gene interaction phenotype.

schema.GeneEssentialityExperimentReference

Reference context for a gene essentiality experiment.

schema.GeneEssentialityExperiment

Experiment measuring a gene essentiality phenotype.

schema.SyntheticLethalityExperimentReference

Reference context for a synthetic lethality experiment.

schema.SyntheticLethalityExperiment

Experiment measuring a synthetic lethality phenotype.

schema.SyntheticRescueExperimentReference

Reference context for a synthetic rescue experiment.

schema.SyntheticRescueExperiment

Experiment measuring a synthetic rescue phenotype.

schema.CalMorphExperimentReference

Reference context for a CalMorph experiment.

schema.CalMorphExperiment

Experiment measuring a CalMorph phenotype.

schema.MicroarrayExpressionPhenotype

Microarray expression phenotype with canonical log2 ratio convention.

schema.MicroarrayExpressionExperimentReference

Reference context for a microarray expression experiment.

schema.MicroarrayExpressionExperiment

Experiment measuring a microarray expression phenotype.

schema.RNASeqExpressionPhenotype

NGS (RNA-seq) expression phenotype: ABSOLUTE per-gene expression, not a ratio.

schema.RNASeqExpressionExperimentReference

Reference context for an RNA-seq expression experiment.

schema.RNASeqExpressionExperiment

Experiment measuring an RNA-seq (absolute TPM) expression phenotype.

schema.PseudobulkExpressionPhenotype

Pseudobulk single-cell RNA-seq expression: per-gene log2 fold-change vs WT, plus the per-genotype single-cell summary scalars that a bulk assay cannot provide.

schema.PseudobulkExpressionExperimentReference

Reference context for a pseudobulk single-cell expression experiment.

schema.PseudobulkExpressionExperiment

Experiment measuring a pseudobulk single-cell (Perturb-seq) expression phenotype.

schema.VisualScorePhenotype

Ordinal visual-inspection score as a proxy for a metabolite/product level.

schema.VisualScoreExperimentReference

Reference (control colony) context for a visual-score experiment.

schema.VisualScoreExperiment

Experiment measuring a visual-score phenotype.

schema.MetabolitePhenotype

Quantitative metabolite/product level(s), keyed by metabolite id.

schema.MetaboliteExperimentReference

Reference (control) context for a metabolite experiment.

schema.MetaboliteExperiment

Experiment measuring a metabolite phenotype.

schema.ProteinAbundancePhenotype

Quantitative protein-abundance profile keyed by protein (systematic ORF).

schema.ProteinAbundanceExperimentReference

Reference (control) context for a protein-abundance experiment.

schema.ProteinAbundanceExperiment

Experiment measuring a protein-abundance phenotype.

schema.AssayType

HOW an environment-response readout was physically measured (experimental design).

schema.MeasurementType

What an environment-response readout number IS, so heterogeneous chemogenomic scores are never silently compared.

schema.ResponseCategory

The controlled vocabulary a qualitative environment-response call resolves to.

schema.EnvironmentResponsePhenotype

A strain's fitness/growth RESPONSE to an environmental perturbation.

schema.EnvironmentResponseExperimentReference

Reference (control) context for an environment-response experiment.

schema.EnvironmentResponseExperiment

Experiment measuring a strain's response to an environmental perturbation.

schema.StrainEnvironmentResponseExperimentReference

Reference for a strain-resolved environment response (typed background).

schema.StrainEnvironmentResponseExperiment

A strain's response to an environmental perturbation, with a typed background.

schema.HaplotypeBlock

One run of consecutive markers called to the same parent on one chromosome.

schema.SegregantParent

One parent of a biparental cross, pinned to a sha256-anchored assembly.

schema.SegregantGenotype

Strain-level haplotype mosaic of one haploid segregant from a two-parent cross.

schema.SegregantGrowthExperimentReference

Reference (control) context for a segregant growth experiment.

schema.SegregantGrowthExperiment

Growth of a haploid segregant (haplotype-mosaic genotype) in one environment.

Functions

schema.heterozygous_deletion_functional_copies

Functional copies left at the deleted locus, respecting the background.

schema.derive_se

Derive the standard error of the mean from a reported uncertainty + its kind.

strain_background

Shared constructors for typed strain backgrounds (issue #507).

Classes

strain_background.AlleleSpec

The locus and edit kind a standard allele designation denotes.

strain_background.ByGenotype

A standard BY strain as mating type, ploidy and allele -> zygosity.

Functions

strain_background.pending_source_review

A deferred_pending_source_review gap on field naming its resolver.

strain_background.standard_allele

A BackgroundAllele for a STANDARD_ALLELES designation.

strain_background.standard_background

A EukaryoticStrainBackground for BY4741 / BY4742 / BY4743.

synthetic_lethality_to_fitness_conversion

Convert synthetic-lethality experiments into equivalent fitness experiments.

Classes

synthetic_lethality_to_fitness_conversion.SyntheticLethalityToFitnessConverter

Converter turning synthetic-lethality records into fitness records.

Functions

synthetic_lethality_to_fitness_conversion.synthetic_lethality_to_fitness_experiment

Map a synthetic-lethal experiment to a fitness-0 experiment, else drop it.

synthetic_lethality_to_fitness_conversion.synthetic_lethality_to_fitness_reference

Map a synthetic-lethality reference to a fitness-1 reference experiment.