Skip to content

Conversation

@jgilis
Copy link
Contributor

@jgilis jgilis commented Aug 25, 2025

Merging this PR will update the ensemble.py function, more specifically, the _populate_features_base subroutine. This feature speeds up generating an ensemble from an existing list of GEMs considerably, e.g., for my personal project with a list of 150 GEMs, the runtime reduces from 1min30s to 2s. The speed gain can be largely attributed to pre-caching the model reaction attributes in dictionaries, thus avoiding repeated getattr calls.

rxn_vals[mid] = rxn_attrs[reaction]
else:
# Use default bounds if reaction missing from model
rxn_vals[mid] = {'lower_bound': 0, 'upper_bound': 0} # TODO remark: could use MISSING_ATTRIBUTE_DEFAULT instead
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jgilis I think it's fine to keep your implementation as-is; the global REACTION_ATTRIBUTES and MISSING_ATTRIBUTE_DEFAULT were intended for generalizability anticipating implementation of alternative GPRs for the same reaction across ensemble members. The rest of Medusa doesn't support that yet, so I'm OK with these changes focusing the current implementation more towards reaction presence+directionality. Adding support for alternative GPRs will require some other refactoring and addition of utility functions for simulation methods that use GPRs anyway.

@gregmedlock gregmedlock merged commit db55ef8 into opencobra:development Sep 2, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants