Knowledge-Graph-Hub / universalizer

The KG-Hub Universalizer provides functions for knowledge graph cleanup and identifier normalization.
BSD 3-Clause "New" or "Revised" License
3 stars 2 forks source link

IndexError on checking for STY category #19

Closed caufieldjh closed 1 year ago

caufieldjh commented 1 year ago

In make_cat_maps, parsing an edgefile containing a biolink:related_to can lead to this error (in this case, from Bioportal-to-KGX):

Normalizing graph...
Found these graph files:['transformed/ontologies/RETO/RETO_8_edges.tsv', 'transformed/ontologies/RETO/RETO_8_nodes.tsv']
Retrieving entity names in transformed/ontologies/RETO/RETO_8_nodes.tsv...
Found 133441 unexpected identifiers.
Will normalize 82399 identifiers.
Wrote IRI maps to transformed/ontologies/RETO/update_id_maps.tsv.
Retrieving categories in transformed/ontologies/RETO/RETO_8_nodes.tsv...
Traceback (most recent call last):
  File "/home/harry/BioPortal-to-KGX/run.py", line 138, in <module>
    run()
  File "/home/harry/.cache/pypoetry/virtualenvs/bioportal-to-kgx-BG6p1jeu-py3.9/lib/python3.9/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/home/harry/.cache/pypoetry/virtualenvs/bioportal-to-kgx-BG6p1jeu-py3.9/lib/python3.9/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/home/harry/.cache/pypoetry/virtualenvs/bioportal-to-kgx-BG6p1jeu-py3.9/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/harry/.cache/pypoetry/virtualenvs/bioportal-to-kgx-BG6p1jeu-py3.9/lib/python3.9/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/home/harry/BioPortal-to-KGX/run.py", line 113, in run
    transform_status = do_transforms(
  File "/home/harry/BioPortal-to-KGX/bioportal_to_kgx/functions.py", line 339, in do_transforms
    if not clean_and_normalize_graph(filepath=outdir,
  File "/home/harry/.cache/pypoetry/virtualenvs/bioportal-to-kgx-BG6p1jeu-py3.9/lib/python3.9/site-packages/universalizer/norm.py", line 90, in clean_and_normalize_graph
    remap_these_categories, remove_these_edges = make_cat_maps(
  File "/home/harry/.cache/pypoetry/virtualenvs/bioportal-to-kgx-BG6p1jeu-py3.9/lib/python3.9/site-packages/universalizer/norm.py", line 322, in make_cat_maps
    or (obj_node_id.split("/"))[-2] == "STY"
IndexError: list index out of range

This predicate is used frequently and often with object IDs which aren't the STY IRIs being checked for here, or even IRIs at all, so they fail. Try a try.