kazu.steps.linking.post_processing.xref_manager

Functions

request_with_retry(url, headers, json_data)

Classes

CrossReferenceManager

OxoCrossReferenceManager

A CrossReferenceManager that uses the EBI OXO service to identify cross- references.

class kazu.steps.linking.post_processing.xref_manager.CrossReferenceManager[source]

Bases: ABC

__init__(source_to_parser_metadata_lookup, path)[source]
Parameters:
  • source_to_parser_metadata_lookup (dict[str, str]) – when producing cross-referenced instances of Mapping, we need a reference in the MetadataDatabase to the target ontology, in order to look up the default label info etc. This lookup dict tells the cross reference manager what underlying parser it should use for a given source, since different parsers may hold sub sets or supersets of ids of each other. For example, a MedDRA hit might map to specific MONDO id. Since MONDO ids are held in both OpenTargetsDiseaseOntologyParser and MondoOntologyParser, we need to specify which one we want to use to generate the mapping

  • path (Path) – path to cross ref mapping resources required by this manager

abstract build_xref_cache(path)[source]

Build a XrefDatabase suitable for caching.

Parameters:

path (Path)

Returns:

Return type:

dict[str, dict[str, list[tuple[str, str]]]]

create_xref_mappings(mapping)[source]

Attempt to create additional xref mappings from a source mapping.

Parameters:

mapping (Mapping)

Returns:

Return type:

Iterable[Mapping]

xref_db: dict[str, dict[str, list[tuple[str, str]]]]
class kazu.steps.linking.post_processing.xref_manager.OxoCrossReferenceManager[source]

Bases: CrossReferenceManager

A CrossReferenceManager that uses the EBI OXO service to identify cross- references.

Downloads a set of cross-references directly from EBI, and caches locally

__init__(source_to_parser_metadata_lookup, path, oxo_kazu_name_mapping, uri_prefixes, oxo_query)[source]
Parameters:
  • source_to_parser_metadata_lookup (dict[str, str])

  • path (Path)

  • oxo_kazu_name_mapping (dict[str, str]) – mapping of OXO source names to Kazu names, to covert OXO format to Kazu. If not specified, the OXO version will be used

  • uri_prefixes (dict[str, str]) – mapping of KAZU sources to URI prefixes, to correctly reconstruct ids. If not specified, no prefix will be used

  • oxo_query (dict[str, list[str]]) – mapping of OXO source to target sources that will be used to construct the OXO API request

build_xref_cache(path)[source]

Build a XrefDatabase suitable for caching.

Parameters:

path (Path)

Returns:

Return type:

dict[str, dict[str, list[tuple[str, str]]]]

create_oxo_dump(path)[source]
Parameters:

path (Path)

Return type:

list[dict]

parse_oxo_dump(oxo_dump)[source]
Parameters:

oxo_dump (list[dict])

Return type:

dict[str, dict[str, list[tuple[str, str]]]]

headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}
oxo_url = 'https://www.ebi.ac.uk/spot/oxo/api/search'
kazu.steps.linking.post_processing.xref_manager.request_with_retry(url, headers, json_data)[source]
Parameters:
Return type:

Response