Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid reaction id collisions in SplitReversibleReactionsTransform #144

Open
artgoldberg opened this issue Nov 25, 2020 · 2 comments
Open
Labels

Comments

@artgoldberg
Copy link
Contributor

SplitReversibleReactionsTransform does

for submodel in model.submodels:
    for rxn in list(submodel.reactions):
        if rxn.reversible:
            # remove reversible reaction
            model.reactions.remove(rxn)
            submodel.reactions.remove(rxn)

            # create separate forward and reverse reactions
            rxn_for = submodel.reactions.create(
                model=model,
                id='{}_forward'.format(rxn.id),
                ...

The id of rxn_for could collide with the id of an existing reaction.
This problem can be avoided by

  1. check whether id '{}_forward'.format(rxn.id) is already used by a reaction.
  2. if not, use it.
  3. if yes, create another id that does not collide. E.g., when copying file 'x' MacOS creates 'x copy', 'x copy 1', 'x copy 2', and so forth. It appears to use the first 'x copy n' available.
@johnsekar
Copy link

johnsekar commented Nov 25, 2020 via email

@jonrkarr
Copy link
Member

The approach John outlined (prefix or suffix) is commonly used in our field for issues like this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants