Skip to content

Commit

Permalink
Use species ID as name if needed
Browse files Browse the repository at this point in the history
  • Loading branch information
bgyori committed Oct 4, 2024
1 parent 5335739 commit 7e973ff
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions mira/sources/sbml/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,9 +564,10 @@ def variables_from_ast(ast_node):


def _extract_concept(species, units=None, model_id=None):
# Generally, species have an ID and a name
species_id = species.getId()
species_name = species.getName()
display_name = species_name if species_name else species_id
# If the name is missing, we revert to the ID as the name
species_name = species.getName() or species_id
if "(" in species_name or not species_name:
species_name = species_id

Expand All @@ -576,7 +577,7 @@ def _extract_concept(species, units=None, model_id=None):
mapped_ids, mapped_context = grounding_map[(model_id, species_name)]
concept = Concept(
name=species_name,
display_name=display_name,
display_name=species_name,
identifiers=copy.deepcopy(mapped_ids),
context=copy.deepcopy(mapped_context),
units=units,
Expand All @@ -597,7 +598,7 @@ def _extract_concept(species, units=None, model_id=None):
logger.debug(f"[{model_id} species:{species_id}] had no annotations")
concept = Concept(
name=species_name,
display_name=display_name,
display_name=species_name,
identifiers={},
context={},
units=units,
Expand Down Expand Up @@ -709,7 +710,7 @@ def _extract_concept(species, units=None, model_id=None):
identifiers["biomodels.species"] = f"{model_id}:{species_id}"
concept = Concept(
name=species_name or species_id,
display_name=display_name,
display_name=species_name,
identifiers=identifiers,
# TODO how to handle multiple properties? can we extend context to allow lists?
context=context,
Expand Down

0 comments on commit 7e973ff

Please sign in to comment.