Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

179 read hierarchical data #183

Merged
merged 71 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
5b723d2
wrote signature of load hierarchical data
frehburg Oct 16, 2024
e66e32f
added test case for reading list of jsons
frehburg Oct 16, 2024
ccba224
implemented reading lists
frehburg Oct 16, 2024
e41b76d
wrote test case for reading list of xmls
frehburg Oct 16, 2024
26ef833
updated tests to also test upper and lowercase file extensions
frehburg Oct 16, 2024
2dd5235
removed prints from read xml
frehburg Oct 16, 2024
fce3170
added check to datareader to only allow json and xml when reading mul…
frehburg Oct 16, 2024
44c6400
retrieving values from dict
frehburg Oct 16, 2024
c9d8b2e
implemented default value in recursive dict get
frehburg Oct 16, 2024
3e5384d
moved datafield value in class
frehburg Oct 16, 2024
fd7cd14
added datasection isntance dataclass
frehburg Oct 16, 2024
4af2370
wrote test for is_hierarchical of d\tamodel
frehburg Oct 16, 2024
6dba07f
wrote more test cases for is hierarchical
frehburg Oct 16, 2024
3c3454f
added is hierarchical property to data model
frehburg Oct 16, 2024
15b0d25
typos
frehburg Oct 16, 2024
0f479c8
added getattr to datasection and updated return type for datamodel
frehburg Oct 16, 2024
7171057
added getattr for orgroup
frehburg Oct 16, 2024
f6e9857
split loading into hierarchical and tabular
frehburg Oct 16, 2024
4af3dc9
renamed path to file
frehburg Oct 16, 2024
978b8a5
renamed path to file
frehburg Oct 16, 2024
d4d1cfa
removed static methods
frehburg Oct 16, 2024
502209b
fixed
frehburg Oct 16, 2024
3649018
import and removed old
frehburg Oct 16, 2024
6aa301f
fix
frehburg Oct 16, 2024
c982917
remove old todo comments
frehburg Oct 16, 2024
d5ae849
removed old
frehburg Oct 16, 2024
31aae1e
added test input file
frehburg Oct 16, 2024
279cf64
renamed dr to data_reader
frehburg Oct 16, 2024
e8e4997
created structure of load hierarchical
frehburg Oct 16, 2024
c10d12f
added class desc and tmp code to remove warning
frehburg Oct 16, 2024
e16bf0f
implemented loading of datasection instances
frehburg Oct 16, 2024
6565ed0
typo
frehburg Oct 16, 2024
33db169
removed data models
frehburg Oct 16, 2024
7a87400
added mapping param instead of kwargs
frehburg Oct 16, 2024
ce97575
implemented filling datafieldvalue when loading hierarchical
frehburg Oct 16, 2024
404884c
fixed identifiers
frehburg Oct 16, 2024
73ed4f3
moved recursive dict call from nb to utils
frehburg Oct 17, 2024
ffbfe4c
wrote hierarchical data loading
frehburg Oct 17, 2024
eeaf909
changed todo
frehburg Oct 17, 2024
4cfef5a
fixed typing in data model
frehburg Oct 17, 2024
411a72e
removed methods for hierarchical data loading
frehburg Oct 17, 2024
5b9e89e
added load hierarchical data to init
frehburg Oct 17, 2024
29b5ab0
changed elements in value set to tuple instead of list
frehburg Oct 17, 2024
360bf85
had to fix some tests
frehburg Oct 17, 2024
e285e8a
made all data classes frozen for them to be hashable
frehburg Oct 17, 2024
d0c549b
using resources passed to method
frehburg Oct 17, 2024
098bf3a
resources now tuple not list
frehburg Oct 17, 2024
270f24f
renamed datamodel.datamodelname to name
frehburg Oct 17, 2024
6715be7
renamed dtamodel name
frehburg Oct 17, 2024
a4deaba
renamed name
frehburg Oct 17, 2024
215fa83
tuple not list
frehburg Oct 17, 2024
d10722e
typo
frehburg Oct 17, 2024
867ebca
updated cardinality constructor and added examples 0,1 1,1 0,n 1,n
frehburg Oct 17, 2024
291d2a3
had to redo it again because frozen
frehburg Oct 17, 2024
166c4ed
renamed row_no to id
frehburg Oct 17, 2024
fe6b783
wrong import
frehburg Oct 17, 2024
e87deae
identifier for tabular instances now includes row: before row number
frehburg Oct 17, 2024
1f50ed5
removed unnecessary main
frehburg Oct 17, 2024
a4c6354
renamed method
frehburg Oct 17, 2024
deefb8c
created new method to load single data
frehburg Oct 17, 2024
bb4a1ec
changed id of instances
frehburg Oct 17, 2024
2adf8df
removed unnecessary file type
frehburg Oct 17, 2024
de6589c
added load hier dataset to init
frehburg Oct 17, 2024
ac18541
added method comment
frehburg Oct 17, 2024
f7e5f65
renamed datafieldvalue row_no to id
frehburg Oct 17, 2024
2d45665
removed unnecessary prints
frehburg Oct 17, 2024
f1edd73
finally able to load data
frehburg Oct 17, 2024
463baec
set todos and tests for loading hierarchical data
frehburg Oct 17, 2024
d1d7718
rerun notebook
frehburg Oct 17, 2024
1478c03
removed doctest
frehburg Oct 17, 2024
716159a
removed doctest
frehburg Oct 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
380 changes: 326 additions & 54 deletions notebooks/hierarchical_data_model.ipynb

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions src/phenopacket_mapper/data_standards/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@
from .code_system import CodeSystem, SNOMED_CT, HPO, MONDO, OMIM, ORDO, LOINC
from .code import Coding, CodeableConcept
from .data_model import DataModel, DataField, DataModelInstance, DataFieldValue, DataSet, DataSection, OrGroup
from . import data_models
from .value_set import ValueSet

__all__ = [
"Cardinality",
"Coding", "CodeableConcept",
"DataModel", "DataField", "DataModelInstance", "DataFieldValue", "DataSet", "DataSection", "OrGroup",
"data_models",
"CodeSystem",
"SNOMED_CT", "HPO", "MONDO", "OMIM", "ORDO", "LOINC",
"Date",
Expand Down
34 changes: 33 additions & 1 deletion src/phenopacket_mapper/data_standards/cardinality.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,36 @@ def __post_init__(self):
raise ValueError(f"Parameter max must be a positive integer. (Not: {self.min})")

def __str__(self):
return f"{self.min}..{self.max}"
return f"{self.min}..{self.max}"

# Singleton instances
_instances = {}

@classmethod
@property
def ZERO_TO_ONE(cls) -> 'Cardinality':
if 'ZERO_TO_ONE' not in cls._instances:
cls._instances['ZERO_TO_ONE'] = cls(0, 1)
return cls._instances['ZERO_TO_ONE']

@classmethod
@property
def ZERO_TO_N(cls) -> 'Cardinality':
if 'ZERO_TO_N' not in cls._instances:
cls._instances['ZERO_TO_N'] = cls(0, 'n')
return cls._instances['ZERO_TO_N']

@classmethod
@property
def ONE(cls) -> 'Cardinality':
if 'OPTIONAL' not in cls._instances:
cls._instances['ONE'] = cls(1, 1)
return cls._instances['ONE']

@classmethod
@property
def ONE_TO_N(cls) -> 'Cardinality':
if 'ONE_TO_N' not in cls._instances:
cls._instances['ONE_TO_N'] = cls(1, 'n')
return cls._instances['ONE_TO_N']

Loading
Loading