phenopacket_mapper.preprocessing package

Methods for preprocessing data before mapping to Phenopackets.

phenopacket_mapper.preprocessing.preprocess_dict(value: Any, mapping_dict: Dict) Any[source]

Takes a value and uses a mapping dictionary to preprocess it.

If the value is in the mapping dictionary, the corresponding value is returned. If the value is not in the mapping dictionary, the original value is returned.

Parameters:
  • value – The value to preprocess.

  • mapping_dict – A dictionary containing the mapping rules.

Returns:

The preprocessed value.

phenopacket_mapper.preprocessing.preprocess_method(value: Any, method: Callable, **kwargs) Any[source]

Takes a value and uses a method to preprocess it.

The method is called with the value as an argument. If the method raises an exception, the original value is returned.

If the method requires additional arguments, they can be passed as keyword arguments in kwargs.

Please write the method such that it is callable as method(value, **kwargs).

Parameters:
  • value – The value to preprocess.

  • method – The method to use for preprocessing.

  • kwargs – Additional arguments for the method.

Returns:

The preprocessed value.

phenopacket_mapper.preprocessing.preprocess(value: Any, mapping: Dict | Callable, **kwargs) Any[source]

Preprocess a value before mapping to a Phenopacket.

Relies on preprocess_dict and preprocess_method to preprocess using a dictionary or method, respectively. Please consult the documentation for these functions for more information.

Submodules