Skip to content

Commit

Permalink
added initial version of bia shared datamodels (#111)
Browse files Browse the repository at this point in the history
* added initial version of bia shared datamodels

* switched to pydantic model only

* added dataset class as parent of annotation and image study components

* created process class and subclasses to cover annotation, post-processing, and imaging techniques

* added api models

* added class diagram

* updated semantic models and class diagram but not api models

* added models to indicate UUID connections
  • Loading branch information
sherwoodf authored Jun 26, 2024
1 parent 702d908 commit 3c6e535
Show file tree
Hide file tree
Showing 8 changed files with 803 additions and 0 deletions.
11 changes: 11 additions & 0 deletions bia-shared-datamodels/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"python.testing.pytestArgs": [
"."
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.formatOnSave": true
}
}
9 changes: 9 additions & 0 deletions bia-shared-datamodels/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
### First time setup
Package containing the shared BIA models in link-ml yaml format, and the generate pydantic and readmes.

Below shows the class diagram for the Shared BIA Models.

<img src="./src/bia_models/Datamodel-class_diagram.svg">

To edit the diagram, see: https://docs.google.com/drawings/d/1l0Yjy5bGBDlu6qoNfE7Mta7XdBmydRNCQTciY-KeztQ/edit

26 changes: 26 additions & 0 deletions bia-shared-datamodels/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[tool.poetry]
name = "bia-shared-datamodels"
version = "0.1.0"
description = "Schemas and models for working with the BioImage Archive's (Metadata, Incentives, Formats and Accessibility) metadata implementation"
authors = ["Francois Sherwood <[email protected]>"]
license = "Apache Software License 2.0"
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.9"
pydantic = {version = "^2", extras = ["email"]}
pydantic-2-mermaid = "^0.7"
pytest = "^7"

[tool.poetry-dynamic-versioning]
enable = true
vcs = "git"
style = "pep440"

# [tool.poetry.group.dev.dependencies]

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

[tool.poetry.extras]
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
135 changes: 135 additions & 0 deletions bia-shared-datamodels/src/bia_models/bia_data_model.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
from __future__ import annotations

import semantic_models
from pydantic import BaseModel, Field, AnyUrl
from typing import List, Optional, Union
from uuid import UUID

from pydantic_core import Url


class DocumentMixin(BaseModel):
uuid: UUID = Field(
description="""Unique ID (across the BIA database) used to refer to and identify a document."""
)


class UserIdentifiedObject(BaseModel):
title_id: str = Field(
description="""User provided title, which is unqiue within a submission, used to identify a part of a submission."""
)


class Study(
semantic_models.Study,
DocumentMixin,
):
experimental_imaging_component: List[UUID] = Field()
annotation_component: List[UUID] = Field()


class FileReference(
semantic_models.FileReference,
DocumentMixin,
):
submission_dataset: UUID = Field()


class ImageRepresentation(
semantic_models.ImageRepresentation,
DocumentMixin,
):
original_file_reference: Optional[List[UUID]] = Field()


class ExperimentalImagingDataset(
semantic_models.ExperimentalImagingDataset,
DocumentMixin,
UserIdentifiedObject,
):
image: List[UUID] = Field()
file: List[UUID] = Field()
submitted_in_study: UUID = Field()
specimen_preparation_method: List[UUID] = Field()
acquisition_method: List[UUID] = Field()
biological_entity: List[UUID] = Field()
# we include image analysis and correlation


class Specimen(semantic_models.Specimen):
preparation_method: List[UUID] = Field()
sample_of: List[UUID] = Field()


class ExperimentallyCapturedImage(
semantic_models.ExperimentallyCapturedImage,
DocumentMixin,
):
acquisition_process: List[UUID] = Field()
representation: List[UUID] = Field()
submission_dataset: UUID = Field()
subject: Specimen = Field()
# note Specimen is included in image document, but needs to be overriden to link to protocol & biosample via uuid.


class ImageAcquisition(
semantic_models.ImageAcquisition,
DocumentMixin,
UserIdentifiedObject,
):
pass


class SpecimenPrepartionProtocol(
semantic_models.SpecimenPrepartionProtocol,
DocumentMixin,
UserIdentifiedObject,
):
pass


class BioSample(
semantic_models.BioSample,
DocumentMixin,
UserIdentifiedObject,
):
pass


class ImageAnnotationDataset(
semantic_models.ImageAnnotationDataset,
DocumentMixin,
UserIdentifiedObject,
):
image: List[UUID] = Field()
file: List[UUID] = Field()
annotation_file: List[UUID] = Field()
submitted_in_study: UUID = Field()
annotation_method: UUID = Field()


class AnnotationFileReference(
semantic_models.AnnotationFileReference,
DocumentMixin,
):
source_image: List[UUID] = Field()
submission_dataset: UUID = Field()
creation_process: UUID = Field()


class DerivedImage(
semantic_models.DerivedImage,
DocumentMixin,
):
source_image: List[UUID] = Field()
submission_dataset: UUID = Field()
creation_process: UUID = Field()
representation: List[UUID] = Field()


class AnnotationMethod(
semantic_models.AnnotationMethod,
DocumentMixin,
UserIdentifiedObject,
):
source_dataset: List[Union[UUID, AnyUrl]]
Loading

0 comments on commit 3c6e535

Please sign in to comment.