phenopacket_mapper.utils.parsing.parse_data_type module

phenopacket_mapper.utils.parsing.parse_data_type.parse_data_type(type_str: str, resources: List[CodeSystem], compliance: Literal['lenient', 'strict'] = 'lenient') List[Any | CodeSystem | type | str][source]

Parses a string representing of one or multiple data types or code systems to a list of type in Python

The purpose of this method is to parse entries in a Data Model tabular file for DataField.data_type. In the tabular file, the user can list typical primitive data types such as string, int, etc., or date as a data type. Further is it possible to list the name space prefix (e.g., “SCT” for SNOMED CT) of a specific resource (given its inclusion in the list passed as the resources parameter) to indicate that codes or terms from that resource are permittable.

When compliance is set to ‘lenient’ (default), this method only issues warnings if a data type is unrecognized and adds a literal to the list of allowed data types. When compliance is set to ‘strict’, it throws a ValueError in the case described above.

E.g. >>> parse_data_type(“integer, str, Boolean”, []) [<class ‘int’>, <class ‘str’>, <class ‘bool’>]

Parameters:
  • type_str

  • resources

  • compliance

Returns:

phenopacket_mapper.utils.parsing.parse_data_type.parse_single_data_type(type_str: str, resources: List[CodeSystem], compliance: Literal['lenient', 'strict'] = 'lenient') Any | CodeSystem | type | str[source]

Parses a string representing a data type to the type in Python

E.g.: >>> parse_single_data_type(‘date’, []) <class ‘phenopacket_mapper.data_standards.date.Date’>

Parameters:
  • type_str

  • resources

  • compliance

Returns: