phenopacket_mapper.mapping package

This module facilitates the mapping from a local data model to the phenopacket schema

phenopacket_mapper.mapping.map_single(key, e, instance: DataModelInstance, kwargs)[source]
class phenopacket_mapper.mapping.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

class phenopacket_mapper.mapping.PhenopacketMapper(data_model: DataModel, **kwargs)[source]

Bases: object

check_data_fields_in_model(element)[source]
map(data: DataSet) List[Phenopacket][source]

Map data from the DataModel to Phenopackets

The mapping is based on the definition of the DataModel and the parameters passed to the constructor.

If successful, a list of Phenopackets will be returned

Parameters:

data – List of DataModelInstances created from the data using the DataModel

Returns:

List of Phenopackets

Submodules