From 2142a00aec56ee128825c7d54896208f4a674591 Mon Sep 17 00:00:00 2001 From: Sunny Sun <38218185+sunnyosun@users.noreply.github.com> Date: Mon, 18 Sep 2023 17:53:37 +0200 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=9A=9A=20Rename=20PlateWell=20to=20We?= =?UTF-8?q?ll?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lnschema_lamin1/__init__.py | 4 +- .../migrations/0010_rename_platewell_well.py | 41 +++++++++++++++++++ lnschema_lamin1/models.py | 8 ++-- 3 files changed, 47 insertions(+), 6 deletions(-) create mode 100644 lnschema_lamin1/migrations/0010_rename_platewell_well.py diff --git a/lnschema_lamin1/__init__.py b/lnschema_lamin1/__init__.py index cf0464a..3c2914c 100644 --- a/lnschema_lamin1/__init__.py +++ b/lnschema_lamin1/__init__.py @@ -15,7 +15,7 @@ Techsample Treatment TreatmentTarget - PlateWell + Well """ @@ -30,8 +30,8 @@ Biosample, Experiment, ExperimentType, - PlateWell, Techsample, Treatment, TreatmentTarget, + Well, ) diff --git a/lnschema_lamin1/migrations/0010_rename_platewell_well.py b/lnschema_lamin1/migrations/0010_rename_platewell_well.py new file mode 100644 index 0000000..05768af --- /dev/null +++ b/lnschema_lamin1/migrations/0010_rename_platewell_well.py @@ -0,0 +1,41 @@ +# 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, + ), + ), + ] diff --git a/lnschema_lamin1/models.py b/lnschema_lamin1/models.py index 8ed6cd2..46665ef 100644 --- a/lnschema_lamin1/models.py +++ b/lnschema_lamin1/models.py @@ -64,17 +64,17 @@ 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") class Meta: - unique_together = (("plate", "row", "column"),) + unique_together = (("row", "column"),) class TreatmentTarget(Registry): From 0a51ecbe0b2c9f256627011fe738e6a7b2984a03 Mon Sep 17 00:00:00 2001 From: Sunny Sun <38218185+sunnyosun@users.noreply.github.com> Date: Mon, 18 Sep 2023 17:58:35 +0200 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=8E=A8=20Added=20datasets=20back=20li?= =?UTF-8?q?nks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../migrations/0010_rename_platewell_well.py | 20 +++++++++++++++++++ lnschema_lamin1/models.py | 11 ++++++++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/lnschema_lamin1/migrations/0010_rename_platewell_well.py b/lnschema_lamin1/migrations/0010_rename_platewell_well.py index 05768af..baffda6 100644 --- a/lnschema_lamin1/migrations/0010_rename_platewell_well.py +++ b/lnschema_lamin1/migrations/0010_rename_platewell_well.py @@ -38,4 +38,24 @@ class Migration(migrations.Migration): 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"), + ), ] diff --git a/lnschema_lamin1/models.py b/lnschema_lamin1/models.py index 46665ef..917da30 100644 --- a/lnschema_lamin1/models.py +++ b/lnschema_lamin1/models.py @@ -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 @@ -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) @@ -72,6 +74,7 @@ class Well(Registry): 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 = (("row", "column"),) @@ -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) @@ -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)