Fix KeyError when accessing lineage dictionary in OBO parser#233
Fix KeyError when accessing lineage dictionary in OBO parser#233manvikri22 wants to merge 1 commit intoalthonos:masterfrom
Conversation
- Added a check to ensure the superentity exists in the lineage dictionary before attempting to access it. - Added a warning message for better debugging when a superentity is missing.
|
Hi @manvikri22 , do you have an example where such an error happens? My impression is that the |
|
Hi @althonos, Thank you for the feedback! You're right that the KeyError could occur when a superentity is referenced but not declared (a dangling entity). In the case I encountered, I was working with an OBO file where certain is_a relationships pointed to terms that were either missing or improperly defined. Here's a minimal example that triggers the error:
In this case, the term BFO:0000040 is referenced as a superclass but is not declared in the file, leading to the KeyError when the symmetrize_lineage() function tries to access it. The fix I proposed ensures that the missing entity is handled gracefully by logging a warning, but you're right that this might need a broader resolution to support dangling entities in a more global way. If you'd like, I can update the pull request or work on a more comprehensive fix based on your guidance. Let me know what you think! |
Description
This pull request addresses an issue where accessing the lineage dictionary resulted in a KeyError if the superentity was not found.
Changes Made
Motivation
This change enhances error handling in the OBO parser, making it more resilient to inconsistencies in the ontology files and providing clearer feedback to users during debugging.