BIH-CEI / phenopacket_mapper

A Python library to map from any bespoke tabular data format to the GA4GH Phenopacket schema.
https://bih-cei.github.io/phenopacket_mapper/latest/
MIT License
0 stars 0 forks source link

fix loading of orgroups #181

Open frehburg opened 3 weeks ago

frehburg commented 3 weeks ago

@ielis i noticed that there are or groups in the phenopacket schema. E.g.: GenomicInterpretation.call. I am unsure of how to resolve them in a DataModel when loading data from a file.

Do you have any ideas?

ielis commented 3 weeks ago

Hi @frehburg the oneof Protobuf field represents a field where one of several values may be stored. A TimeElement is a nice example of this in the context of Phenopacket Schema.

In Python, a oneof field where, e.g. str and pathlib.Path are the possible values is probably best represented as typing.Union[str, pathlib.Path].

Regarding ideas - using Unions as input argument type provides convenience. However, union as a return type is a bit annoying because the user code is forced to do instance check before doing anything useful.

Perhaps we may have a Union node in our data model hierarchy, and have the node implement the node requirements?