Skip to content

Commit

Permalink
Merge pull request #124 from monarch-initiative/update-mim-titles-parser
Browse files Browse the repository at this point in the history
Update mimTitles parsing
  • Loading branch information
joeflack4 authored Aug 30, 2024
2 parents bf1053e + 75233b7 commit dc3c79a
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions omim2obo/parsers/omim_txt_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,17 @@ def parse_omim_id(omim_id, log_success_case_warnings=False):
return None


def parse_mim_titles(lines):
def parse_mim_titles(lines) -> Tuple[Dict[str, Tuple[OmimType, str, str, str]], Dict[str, List[str]]]:
"""
Parse the omim titles
:param lines:
:return: omim_type and omim_replaced, dicts that captures the type of the omim_id and if they've been replaced
:return:
omim_type_and_titles: Dict[str, Tuple[OmimType, str, str, str]]: Lookup of MIM's type, as well as it's preferred
labels, alternative labels, and 'included' labels.
omim_replaced: Dict[str, List[str]]: Lookup of obsolete MIMs and a list of any different MIMs that it has been
replaced with / moved to.
"""
omim_type = {}
omim_type_and_titles = {}
omim_replaced = {}
declared_to_type = {
'Caret': OmimType.OBSOLETE, # 'HP:0031859', # obsolete
Expand All @@ -190,15 +194,15 @@ def parse_mim_titles(lines):
if not declared and not omim_id and not pref_label and not alt_label and not inc_label:
continue
if declared in declared_to_type:
omim_type[omim_id] = (declared_to_type[declared], pref_label, alt_label, inc_label)
omim_type_and_titles[omim_id] = (declared_to_type[declared], pref_label, alt_label, inc_label)
else:
LOG.error('Unknown OMIM type line %s', line)
if declared == 'Caret': # moved|removed|split -> moved twice
omim_replaced[omim_id] = []
if pref_label.startswith('MOVED TO '):
replaced = [parse_omim_id(rep) for rep in pref_label[9:].split() if rep != 'AND']
omim_replaced[omim_id] = list(filter(None, replaced))
return omim_type, omim_replaced
return omim_type_and_titles, omim_replaced


def parse_phenotypic_series_titles(lines) -> Dict[str, List]:
Expand Down

0 comments on commit dc3c79a

Please sign in to comment.