Skip to content

Commit

Permalink
Checks if synonym val exists before access
Browse files Browse the repository at this point in the history
The current obographs serialiser creates

```
{
      "id" : "http://purl.obolibrary.org/obo/OBA_2050220",
      "lbl" : "vascular cell adhesion protein 1 amount",
      "type" : "CLASS",
      "meta" : {
        "definition" : {
          "val" : "The amount of a vascular cell adhesion protein 1 when measured in anatomical entity.",
          "xrefs" : [ "AUTO:patterns/patterns/entity_attribute_location" ]
        },
        "synonyms" : [ {
          "pred" : "hasExactSynonym"
        }]
      }
    }
```

So we need to check if the value exists before accessing it to not fail hard.

This is not tested.
  • Loading branch information
matentzn committed Nov 20, 2024
1 parent 74d9ec4 commit ccdcbb3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion kgx/source/obograph_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ def parse_meta(self, node: str, meta: Dict) -> Dict:

if "synonyms" in meta:
# parse 'synonyms' as 'synonym'
synonyms = [s["val"] for s in meta["synonyms"]]
synonyms = [s["val"] for s in meta["synonyms"] if "val" in s]
properties["synonym"] = synonyms

if "xrefs" in meta:
Expand Down

0 comments on commit ccdcbb3

Please sign in to comment.