Skip to content

Commit

Permalink
entitys
Browse files Browse the repository at this point in the history
  • Loading branch information
jhnnsrs committed Jul 31, 2024
1 parent b95074c commit da8a2e4
Show file tree
Hide file tree
Showing 33 changed files with 2,561 additions and 261 deletions.
5 changes: 3 additions & 2 deletions core/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ class HistoryAdmin(SimpleHistoryAdmin):
admin.site.register(models.Image, HistoryAdmin)
admin.site.register(models.Instrument)
admin.site.register(models.Dataset, HistoryAdmin)
admin.site.register(models.Antibody)
admin.site.register(models.Fluorophore)
admin.site.register(models.Entity)
admin.site.register(models.EntityGroup)
admin.site.register(models.EntityKind)
admin.site.register(models.Channel)
admin.site.register(models.Camera)
admin.site.register(models.ROI)
Expand Down
11 changes: 11 additions & 0 deletions core/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@ class TransformationKind(TextChoices):



class InstanceKind(TextChoices):

LOT = "LOT", "Lot"
BATCH = "BATCH", "Batch"
SINGLE = "SINGLE", "Single"
UNKNOWN = "UNKNOWN", "Unknown"





class ColorMapChoices(TextChoices):
VIRIDIS = "viridis"
PLASMA = "plasma"
Expand Down
100 changes: 71 additions & 29 deletions core/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,34 +103,6 @@ class CameraFilter:
provenance: ProvenanceFilter | None


@strawberry.django.filter(models.Fluorophore)
class FluorophoreFilter:
id: auto
emission_wavelength: Optional[FilterLookup[int]]
excitation_wavelength: Optional[FilterLookup[int]]
provenance: ProvenanceFilter | None
search: str | None
ids: list[strawberry.ID] | None

def filter_ids(self, queryset, info):
print(self.ids)
if self.ids is None:
return queryset
return queryset.filter(id__in=self.ids)

def filter_search(self, queryset, info):
print(self.search)
if self.search is None:
return queryset
return queryset.filter(name__icontains=self.search)


@strawberry.django.filter(models.Antibody)
class AntibodyFilter(IDFilterMixin, SearchFilterMixin):
id: auto
name: Optional[FilterLookup[str]]


@strawberry.django.filter(models.MultiWellPlate)
class MultiWellPlateFilter(IDFilterMixin, SearchFilterMixin):
id: auto
Expand Down Expand Up @@ -168,6 +140,17 @@ class OpticsViewFilter(ViewFilter):
camera: CameraFilter | None



@strawberry.django.filter(models.SpecimenView)
class SpecimenViewFilter(ViewFilter):
entity: strawberry.ID | None

def filter_entity(self, queryset, info):
if self.entity is None:
return queryset
return queryset.filter(entity_id=self.entity)


@strawberry.django.filter(models.WellPositionView)
class WellPositionViewFilter(ViewFilter):
well: MultiWellPlateFilter | None
Expand Down Expand Up @@ -233,4 +216,63 @@ class TableFilter:
def filter_ids(self, queryset, info):
if self.ids is None:
return queryset
return queryset.filter(id__in=self.ids)
return queryset.filter(id__in=self.ids)



@strawberry.django.filter(models.EntityKind)
class EntityKindFilter(IDFilterMixin, SearchFilterMixin):
id: auto
image: strawberry.ID | None = None

def filter_image(self, queryset, info):
if self.image is None:
return queryset
return queryset.filter(image_id=self.image)


@strawberry.django.filter(models.Entity)
class EntityFilter(IDFilterMixin, SearchFilterMixin):
id: auto
kind: strawberry.ID | None = None

def filter_kind(self, queryset, info):
if self.kind is None:
return queryset
return queryset.filter(kind_id=self.kind)



@strawberry.django.filter(models.EntityGroup)
class EntityGroupFilter(IDFilterMixin, SearchFilterMixin):
id: auto


@strawberry.django.filter(models.Ontology)
class OntologyFilter(IDFilterMixin, SearchFilterMixin):
id: auto


@strawberry.django.filter(models.Specimen)
class SpecimenFilter(IDFilterMixin, SearchFilterMixin):
id: auto

@strawberry.django.filter(models.Protocol)
class ProtocolFilter(IDFilterMixin, SearchFilterMixin):
id: auto

@strawberry.django.filter(models.Experiment)
class ExperimentFilter(IDFilterMixin, SearchFilterMixin):
id: auto



@strawberry.django.filter(models.ProtocolStep)
class ProtocolStepFilter(IDFilterMixin, SearchFilterMixin):
id: auto
protocol: strawberry.ID | None = None

def filter_protocol(self, queryset, info):
if self.protocol is None:
return queryset
return queryset.filter(protocol_id=self.protocol)
Empty file added core/management/__init__.py
Empty file.
Empty file.
40 changes: 40 additions & 0 deletions core/management/commands/ensure_onto.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
from django.core.management.base import BaseCommand
from django.conf import settings
from core import models, builders, base_models
import json
import omegaconf


class Command(BaseCommand):
help = "Creates all configured apps or overwrites them"

def handle(self, *args, **options):

default_ontology = models.Ontology.objects.update_or_create(
name="Internal",
description="An internal ontology for the core system",
)

ontology = models.Ontology.objects.update_or_create(
name="Gene Ontology",
public_url="https://www.ebi.ac.uk/ols4/ontologies/go",
description="The Gene Ontology (GO) provides a framework and set of concepts for describing the functions of gene products from all organisms.",
)

entity_kind = models.EntityKind.objects.update_or_create(
ontology=ontology,
name="Axon Initial Segment",
public_url="http://purl.obolibrary.org/obo/GO_0043194"
)












Loading

0 comments on commit da8a2e4

Please sign in to comment.