phenopacket_mapper.utils.parsing.parse_coding module
- phenopacket_mapper.utils.parsing.parse_coding.parse_coding(coding_str: str, resources: List[CodeSystem], compliance: Literal['lenient', 'strict'] = 'lenient') Coding [source]
Parsed a string representing a coding to a Coding object
Expected format: <namespace_prefix>:<code>
E.g.: >>> parse_coding(“SNOMED:404684003”, [code_system_module.SNOMED_CT]) Coding(system=CodeSystem(name=SNOMED CT, name space prefix=SNOMED, version=0.0.0), code=’404684003’, display=’’, text=’’)
Intended to be called with a list of all resources used.
Can only recognize the name space prefixes that belong to code systems provided in the resources list. If a name space is not found in the resources, it will return a Coding object with the system as the name space prefix and the code as the code.
E.g.: >>> parse_coding(“SNOMED:404684003”, []) Warning: Code system with namespace prefix ‘SNOMED’ not found in resources. Warning: Returning Coding object with system as namespace prefix and code as ‘404684003’ Coding(system=’SNOMED’, code=’404684003’, display=’’, text=’’)
- Parameters:
coding_str – a string representing a coding
resources – a list of all resources used
compliance – whether to throw a ValueError or just a warning if a name space prefix is not found in the
resources :return: a Coding object as specified in the coding string