phenopacket_mapper.mapping.phenopacket_building_block module

class phenopacket_mapper.mapping.phenopacket_building_block.PhenopacketBuildingBlock(phenopacket_element, **kwargs)[source]

Bases: object

map(instance: DataModelInstance)[source]

Creates the phenopacket element by the mapping specified in fields

>>> import phenopackets
>>> from phenopacket_mapper.data_standards import DataModelInstance, DataModel, DataField, DataFieldValue
>>> data_field = DataField("pseudonym", str)
>>> data_model = DataModel("Example data model", [data_field], [])
>>> inst = DataModelInstance(0, data_model, [DataFieldValue(0, data_field, "example_pseudonym")])
>>> individual = PhenopacketBuildingBlock(phenopackets.Individual, id=data_field).map(inst)
>>> individual.id
'example_pseudonym'
Parameters:

instance – the DataModelInstance from which to map to a Phenopacket schema element

Returns:

the resulting Phenopacket schema element

phenopacket_mapper.mapping.phenopacket_building_block.map_single(key, e, instance: DataModelInstance, kwargs)[source]