Skip to content

Commit

Permalink
add a script to create an example and add enums for collection type
Browse files Browse the repository at this point in the history
  • Loading branch information
calmacx committed Feb 2, 2024
1 parent fe534c2 commit 2cda6ad
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 2 deletions.
14 changes: 14 additions & 0 deletions hdr_schemata/definitions/HDRUK/TissueCollectionTypeEnum.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from enum import Enum


class TissueCollectionTypeEnum(Enum):
CASE_CONTROL = "Case-control"
COHORT = "Cohort"
CROSS_SECTIONAL = "Cross-sectional"
LONGITUDINAL = "Longitudinal"
TWIN_STUDY = "Twin-study"
QUALITY_CONTROL = "Quality control"
POPULATION_BASED = "Population-based"
DISEASE_SPECIFIC = "Disease specific"
BIRTH_COHORT = "Birth cohort"
OTHER = "Other"
11 changes: 9 additions & 2 deletions hdr_schemata/models/HDRUK/v2_2_0/TissuesSampleCollection.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from .TissueSampleMetadata import TissueSampleMetadata
from hdr_schemata.definitions.HDRUK import (
TissueDataCategoriesEnum,
TissueCollectionTypeEnum,
MaterialTypeCategories,
)

Expand All @@ -11,17 +12,23 @@ class TissuesSampleCollection(BaseModel):
dataCategories: Optional[List[TissueDataCategoriesEnum]] = Field(
None,
title="Data Categories",
description="Data categories related to the tissue sample collection",
description="The type of data that is associated with the samples in the study. Can be several values MIABIS-2.0-13",
)

materialType: Optional[List[MaterialTypeCategories]] = Field(
None,
title="Material Type",
description="Material type of the tissue sample collection",
description="The biospecimen saved from a biological entity for propagation e.g. testing, diagnostics, treatment or research purposes. Can be several values MIABIS-2.0-14",
)

tissueSampleMetadata: Optional[TissueSampleMetadata] = Field(
None,
title="Tissue Sample Metadata",
description="Metadata related to the tissue sample",
)

collectionType: Optional[TissueCollectionTypeEnum] = Field(
None,
title="Collection Type",
description="The type of the sample collection. Can be several values [MIABIS-2.0-16](https://github.com/BBMRI-ERIC/miabis/blob/master/Structured-data-and-lists.md#collection-type)",
)
19 changes: 19 additions & 0 deletions hdr_schemata/utils/create_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import json

data = json.load(open("temp.json"))


def get_subItems(item):
return (
{subItem["name"]: get_subItems(subItem) for subItem in item["subItems"]}
if item.get("subItems")
else " | ".join(item["type"])
)


example = {item["name"]: get_subItems(item) for item in data}
print(json.dumps(example, indent=6))
with open("temp2.json", "w") as f:
json.dump(example, f, indent=6)

# print(json.dumps(data, indent=6))

0 comments on commit 2cda6ad

Please sign in to comment.