Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚚 Rename PlateWell to Well #33

Merged
merged 2 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lnschema_lamin1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
Techsample
Treatment
TreatmentTarget
PlateWell
Well

"""

Expand All @@ -30,8 +30,8 @@
Biosample,
Experiment,
ExperimentType,
PlateWell,
Techsample,
Treatment,
TreatmentTarget,
Well,
)
61 changes: 61 additions & 0 deletions lnschema_lamin1/migrations/0010_rename_platewell_well.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Generated by Django 4.2.1 on 2023-09-18 15:46

import lnschema_core.ids
from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("lnschema_core", "0019_dataset_reference_dataset_reference_type_and_more"),
("lnschema_lamin1", "0009_alter_platewell_id"),
]

operations = [
migrations.RenameModel(
old_name="PlateWell",
new_name="Well",
),
migrations.AlterUniqueTogether(
name="well",
unique_together={("row", "column")},
),
migrations.AddField(
model_name="well",
name="name",
field=models.CharField(db_index=True, default=None, max_length=32, null=True, unique=True),
),
migrations.RemoveField(
model_name="well",
name="plate",
),
migrations.AlterField(
model_name="well",
name="id",
field=models.CharField(
default=lnschema_core.ids.base62_4,
max_length=4,
primary_key=True,
serialize=False,
),
),
migrations.AddField(
model_name="biosample",
name="datasets",
field=models.ManyToManyField(related_name="biosamples", to="lnschema_core.dataset"),
),
migrations.AddField(
model_name="experiment",
name="datasets",
field=models.ManyToManyField(related_name="experiments", to="lnschema_core.dataset"),
),
migrations.AddField(
model_name="treatment",
name="datasets",
field=models.ManyToManyField(related_name="treatments", to="lnschema_core.dataset"),
),
migrations.AddField(
model_name="well",
name="datasets",
field=models.ManyToManyField(related_name="wells", to="lnschema_core.dataset"),
),
]
19 changes: 13 additions & 6 deletions lnschema_lamin1/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from django.db.models import PROTECT
from lnschema_bionty.models import CellLine, CellType, Disease, Species, Tissue
from lnschema_core import ids
from lnschema_core.models import File, Registry, User
from lnschema_core.models import Dataset, File, Registry, User
from lnschema_core.types import ChoicesMixin
from lnschema_core.users import current_user_id

Expand Down Expand Up @@ -55,7 +55,9 @@ class Experiment(Registry):
experiment_type = models.ForeignKey(ExperimentType, PROTECT, null=True, related_name="experiments")
"""Type of the experiment."""
files = models.ManyToManyField(File, related_name="experiments")
"""Date on which the experiment is performed."""
"""Files linked to the experiment."""
datasets = models.ManyToManyField(Dataset, related_name="experiments")
"""Datasets linked to the experiment."""
created_at = models.DateTimeField(auto_now_add=True, db_index=True)
"""Time of creation of record."""
updated_at = models.DateTimeField(auto_now=True, db_index=True)
Expand All @@ -64,17 +66,18 @@ class Experiment(Registry):
"""Creator of record, a :class:`~lamindb.User`."""


class PlateWell(Registry):
class Well(Registry):
"""Wells in a experimental plate."""

id = models.CharField(max_length=8, default=ids.base62_8, primary_key=True)
plate = models.IntegerField()
id = models.CharField(max_length=4, default=ids.base62_4, primary_key=True)
name = models.CharField(max_length=32, default=None, null=True, unique=True, db_index=True)
row = models.CharField(max_length=4, default=None)
column = models.IntegerField()
files = models.ManyToManyField(File, related_name="wells")
datasets = models.ManyToManyField(Dataset, related_name="wells")

class Meta:
unique_together = (("plate", "row", "column"),)
unique_together = (("row", "column"),)


class TreatmentTarget(Registry):
Expand Down Expand Up @@ -128,6 +131,8 @@ class Treatment(Registry):
"""Pubchem ID of the chemical treatment."""
files = models.ManyToManyField(File, related_name="treatments")
"""Files linked to the treatment."""
datasets = models.ManyToManyField(Dataset, related_name="treatments")
"""Datasets linked to the treatment."""
created_at = models.DateTimeField(auto_now_add=True, db_index=True)
"""Time of creation of record."""
updated_at = models.DateTimeField(auto_now=True, db_index=True)
Expand Down Expand Up @@ -158,6 +163,8 @@ class Biosample(Registry):
"""Diseases linked to the biosample."""
files = models.ManyToManyField(File, related_name="biosamples")
"""Files linked to the biosample."""
datasets = models.ManyToManyField(Dataset, related_name="biosamples")
"""Datasets linked to the biosample."""
created_at = models.DateTimeField(auto_now_add=True, db_index=True)
"""Time of creation of record."""
updated_at = models.DateTimeField(auto_now=True, db_index=True)
Expand Down
Loading