Source code for app.model.orm.perturbation
from typing import Optional
import sqlalchemy as sql
from sqlalchemy.orm import (
Mapped,
mapped_column,
relationship,
)
from sqlalchemy.ext.hybrid import hybrid_property
from app.model.orm.orm_base import OrmBase
[docs]
class Perturbation(OrmBase):
"""
The description of a change over time in a particular experiment's environment.
A perturbation is described by the addition or removal of a ``Compartment``
to the experiment or by the change from one ``Community`` to another.
This may be changed in the future as we collect more studies with perturbations.
"""
[docs]
experimentId: Mapped[str] = mapped_column(sql.ForeignKey('Experiments.publicId'), nullable=False)
[docs]
removedCompartment: Mapped[Optional['Compartment']] = relationship(foreign_keys=[removedCompartmentId])
[docs]
addedCompartment: Mapped[Optional['Compartment']] = relationship(foreign_keys=[addedCompartmentId])
@hybrid_property
@hybrid_property