Skip to content

Commit

Permalink
🚚 Add unique constraints and fix gene_ref_is_symbol to label_ref_is_s…
Browse files Browse the repository at this point in the history
…ymbol
  • Loading branch information
falexwolf committed Oct 18, 2024
1 parent 9486e60 commit 721aca4
Show file tree
Hide file tree
Showing 2 changed files with 138 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Generated by Django 5.1.1 on 2024-10-18 14:12

from django.db import migrations


class Migration(migrations.Migration):
dependencies = [
("bionty", "0039_alter_cellline_source_alter_cellmarker_source_and_more"),
("lnschema_core", "0067_alter_featurevalue_unique_together_and_more"),
]

operations = [
migrations.RenameField(
model_name="artifactgene",
old_name="gene_ref_is_symbol",
new_name="label_ref_is_symbol",
),
migrations.AlterUniqueTogether(
name="artifactcellline",
unique_together={("artifact", "cellline", "feature")},
),
migrations.AlterUniqueTogether(
name="artifactcellmarker",
unique_together={("artifact", "cellmarker", "feature")},
),
migrations.AlterUniqueTogether(
name="artifactcelltype",
unique_together={("artifact", "celltype", "feature")},
),
migrations.AlterUniqueTogether(
name="artifactdevelopmentalstage",
unique_together={("artifact", "developmentalstage", "feature")},
),
migrations.AlterUniqueTogether(
name="artifactdisease",
unique_together={("artifact", "disease", "feature")},
),
migrations.AlterUniqueTogether(
name="artifactethnicity",
unique_together={("artifact", "ethnicity", "feature")},
),
migrations.AlterUniqueTogether(
name="artifactexperimentalfactor",
unique_together={("artifact", "experimentalfactor", "feature")},
),
migrations.AlterUniqueTogether(
name="artifactgene",
unique_together={("artifact", "gene", "feature")},
),
migrations.AlterUniqueTogether(
name="artifactorganism",
unique_together={("artifact", "organism", "feature")},
),
migrations.AlterUniqueTogether(
name="artifactpathway",
unique_together={("artifact", "pathway", "feature")},
),
migrations.AlterUniqueTogether(
name="artifactphenotype",
unique_together={("artifact", "phenotype", "feature")},
),
migrations.AlterUniqueTogether(
name="artifactprotein",
unique_together={("artifact", "protein", "feature")},
),
migrations.AlterUniqueTogether(
name="artifacttissue",
unique_together={("artifact", "tissue", "feature")},
),
migrations.AlterUniqueTogether(
name="featuresetcellmarker",
unique_together={("featureset", "cellmarker")},
),
migrations.AlterUniqueTogether(
name="featuresetgene",
unique_together={("featureset", "gene")},
),
migrations.AlterUniqueTogether(
name="featuresetpathway",
unique_together={("featureset", "pathway")},
),
migrations.AlterUniqueTogether(
name="featuresetprotein",
unique_together={("featureset", "protein")},
),
]
53 changes: 52 additions & 1 deletion bionty/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1479,6 +1479,9 @@ class FeatureSetGene(Record, LinkORM):
)
gene: Gene = models.ForeignKey("Gene", PROTECT, related_name="+")

class Meta:
unique_together = ("featureset", "gene")


class FeatureSetProtein(Record, LinkORM):
id: int = models.BigAutoField(primary_key=True)
Expand All @@ -1488,6 +1491,9 @@ class FeatureSetProtein(Record, LinkORM):
)
protein: Protein = models.ForeignKey("Protein", PROTECT, related_name="+")

class Meta:
unique_together = ("featureset", "protein")


class FeatureSetCellMarker(Record, LinkORM):
id: int = models.BigAutoField(primary_key=True)
Expand All @@ -1498,6 +1504,9 @@ class FeatureSetCellMarker(Record, LinkORM):
# follow the .lower() convention in link models
cellmarker: CellMarker = models.ForeignKey("CellMarker", PROTECT, related_name="+")

class Meta:
unique_together = ("featureset", "cellmarker")


class FeatureSetPathway(Record, LinkORM):
id: int = models.BigAutoField(primary_key=True)
Expand All @@ -1507,6 +1516,9 @@ class FeatureSetPathway(Record, LinkORM):
)
pathway: Pathway = models.ForeignKey("Pathway", PROTECT, related_name="+")

class Meta:
unique_together = ("featureset", "pathway")


class ArtifactOrganism(Record, LinkORM, TracksRun):
id: int = models.BigAutoField(primary_key=True)
Expand All @@ -1522,6 +1534,9 @@ class ArtifactOrganism(Record, LinkORM, TracksRun):
label_ref_is_name: bool | None = models.BooleanField(null=True, default=None)
feature_ref_is_name: bool | None = models.BooleanField(null=True, default=None)

class Meta:
unique_together = ("artifact", "organism", "feature")


class ArtifactGene(Record, LinkORM, TracksRun):
id: int = models.BigAutoField(primary_key=True)
Expand All @@ -1530,9 +1545,12 @@ class ArtifactGene(Record, LinkORM, TracksRun):
feature: Feature = models.ForeignKey(
Feature, PROTECT, null=True, default=None, related_name="links_artifactgene"
)
gene_ref_is_symbol: bool | None = models.BooleanField(null=True, default=None)
label_ref_is_symbol: bool | None = models.BooleanField(null=True, default=None)
feature_ref_is_symbol: bool | None = models.BooleanField(null=True, default=None)

class Meta:
unique_together = ("artifact", "gene", "feature")


class ArtifactProtein(Record, LinkORM, TracksRun):
id: int = models.BigAutoField(primary_key=True)
Expand All @@ -1548,6 +1566,9 @@ class ArtifactProtein(Record, LinkORM, TracksRun):
label_ref_is_name: bool | None = models.BooleanField(null=True, default=None)
feature_ref_is_name: bool | None = models.BooleanField(null=True, default=None)

class Meta:
unique_together = ("artifact", "protein", "feature")


class ArtifactCellMarker(Record, LinkORM, TracksRun):
id: int = models.BigAutoField(primary_key=True)
Expand All @@ -1568,6 +1589,9 @@ class ArtifactCellMarker(Record, LinkORM, TracksRun):
label_ref_is_name: bool | None = models.BooleanField(null=True, default=None)
feature_ref_is_name: bool | None = models.BooleanField(null=True, default=None)

class Meta:
unique_together = ("artifact", "cellmarker", "feature")


class ArtifactTissue(Record, LinkORM, TracksRun):
id: int = models.BigAutoField(primary_key=True)
Expand All @@ -1581,6 +1605,9 @@ class ArtifactTissue(Record, LinkORM, TracksRun):
label_ref_is_name: bool | None = models.BooleanField(null=True, default=None)
feature_ref_is_name: bool | None = models.BooleanField(null=True, default=None)

class Meta:
unique_together = ("artifact", "tissue", "feature")


class ArtifactCellType(Record, LinkORM, TracksRun):
id: int = models.BigAutoField(primary_key=True)
Expand All @@ -1597,6 +1624,9 @@ class ArtifactCellType(Record, LinkORM, TracksRun):
label_ref_is_name: bool | None = models.BooleanField(null=True, default=None)
feature_ref_is_name: bool | None = models.BooleanField(null=True, default=None)

class Meta:
unique_together = ("artifact", "celltype", "feature")


class ArtifactDisease(Record, LinkORM, TracksRun):
id: int = models.BigAutoField(primary_key=True)
Expand All @@ -1612,6 +1642,9 @@ class ArtifactDisease(Record, LinkORM, TracksRun):
label_ref_is_name: bool | None = models.BooleanField(null=True, default=None)
feature_ref_is_name: bool | None = models.BooleanField(null=True, default=None)

class Meta:
unique_together = ("artifact", "disease", "feature")


class ArtifactCellLine(Record, LinkORM, TracksRun):
id: int = models.BigAutoField(primary_key=True)
Expand All @@ -1628,6 +1661,9 @@ class ArtifactCellLine(Record, LinkORM, TracksRun):
label_ref_is_name: bool | None = models.BooleanField(null=True, default=None)
feature_ref_is_name: bool | None = models.BooleanField(null=True, default=None)

class Meta:
unique_together = ("artifact", "cellline", "feature")


class ArtifactPhenotype(Record, LinkORM, TracksRun):
id: int = models.BigAutoField(primary_key=True)
Expand All @@ -1647,6 +1683,9 @@ class ArtifactPhenotype(Record, LinkORM, TracksRun):
label_ref_is_name: bool | None = models.BooleanField(null=True, default=None)
feature_ref_is_name: bool | None = models.BooleanField(null=True, default=None)

class Meta:
unique_together = ("artifact", "phenotype", "feature")


class ArtifactPathway(Record, LinkORM, TracksRun):
id: int = models.BigAutoField(primary_key=True)
Expand All @@ -1662,6 +1701,9 @@ class ArtifactPathway(Record, LinkORM, TracksRun):
label_ref_is_name: bool | None = models.BooleanField(null=True, default=None)
feature_ref_is_name: bool | None = models.BooleanField(null=True, default=None)

class Meta:
unique_together = ("artifact", "pathway", "feature")


class ArtifactExperimentalFactor(Record, LinkORM, TracksRun):
id: int = models.BigAutoField(primary_key=True)
Expand All @@ -1681,6 +1723,9 @@ class ArtifactExperimentalFactor(Record, LinkORM, TracksRun):
label_ref_is_name: bool | None = models.BooleanField(null=True, default=None)
feature_ref_is_name: bool | None = models.BooleanField(null=True, default=None)

class Meta:
unique_together = ("artifact", "experimentalfactor", "feature")


class ArtifactDevelopmentalStage(Record, LinkORM, TracksRun):
id: int = models.BigAutoField(primary_key=True)
Expand All @@ -1701,6 +1746,9 @@ class ArtifactDevelopmentalStage(Record, LinkORM, TracksRun):
label_ref_is_name: bool | None = models.BooleanField(null=True, default=None)
feature_ref_is_name: bool | None = models.BooleanField(null=True, default=None)

class Meta:
unique_together = ("artifact", "developmentalstage", "feature")


class ArtifactEthnicity(Record, LinkORM, TracksRun):
id: int = models.BigAutoField(primary_key=True)
Expand All @@ -1720,6 +1768,9 @@ class ArtifactEthnicity(Record, LinkORM, TracksRun):
label_ref_is_name: bool | None = models.BooleanField(null=True, default=None)
feature_ref_is_name: bool | None = models.BooleanField(null=True, default=None)

class Meta:
unique_together = ("artifact", "ethnicity", "feature")


# backward compat
Species = Organism
Expand Down

0 comments on commit 721aca4

Please sign in to comment.