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

State mapping in reaction rules? #501

Open
dweindl opened this issue May 11, 2020 · 8 comments
Open

State mapping in reaction rules? #501

dweindl opened this issue May 11, 2020 · 8 comments

Comments

@dweindl
Copy link
Contributor

dweindl commented May 11, 2020

Hi, BNGL supports state mapping using "%" in reaction rules, e.g. A(a%x) -> B(a%x), to indicate that the state of A is transferred to B. I was wondering if there exists anything comparable in pysb? I see that it is straightforward to generate all the rules programmatically, but it would be convenient if that could be avoided.

@FFroehlich
Copy link
Contributor

FFroehlich commented May 25, 2020

To the best of my knowlegde this features isn't currently supported in pysb. Would also be interesting for some of the applications I am looking at, so I will look into enabling this. Shouldn't. be too much hassle as long as its supported in BNGXML (which it should).

@dweindl
Copy link
Contributor Author

dweindl commented May 26, 2020

Great, thanks. Let me know if i can help.

@lh64
Copy link
Contributor

lh64 commented May 26, 2020

@dweindl The state-mapping rule you're showing is an old feature of BNGL that isn't really supported anymore (it's still in the software but it's not really considered part of "proper" BNGL). The “proper” way to use tags is to either tag a Molecule like A(b)%x or a Complex %x:A(b!+). Those tags can then get passed to Observables to perform local pattern matching and then onto Functions that can be used as ratelaws. We support those kinds of tags in PySB. Tags on a state of a component is something that was implemented in BNG a long time ago but doesn’t really fit into the more updated view of tags. So PySB doesn’t support it.

@lh64
Copy link
Contributor

lh64 commented May 26, 2020

A simple example model using the Tag class in PySB is https://github.com/pysb/pysb/blob/master/pysb/examples/localfunc.py

@FFroehlich
Copy link
Contributor

Was there a specific reason to deprecate this functionality in BNGL? I imagine that for any kind of study where molecules are in any way tagged and those tags can be transferred, the state mapping is a useful feature.

Even though they use the same syntax, molecule or complex tags really serve a different feature and don't permit the abstraction implemented in state mapping.

@dweindl
Copy link
Contributor Author

dweindl commented May 26, 2020

@lh64 Thanks for your explanation and the example. I stumbled across the %-notation in some older examples and found it pretty useful. As it still worked with BNGL, I wasn't aware that it is outdated.

@lh64
Copy link
Contributor

lh64 commented May 26, 2020

@FFroehlich The basic reason is that the syntax for molecule and complex tags isn't consistent with the syntax for component state tags, that's all. A tag is conceptually like a pointer to an object. They can be used to map reactants to products (needed for extracting base operations from the rules, e.g., bind, change state, etc.) and for defining the context for performing pattern matching in Observables. Observables produce numbers (the number of matches to a molecule or complex) but the tag itself is not a number.

In the state-mapping example, the tag in A(a%x) -> B(a%x) represents a number, which is the problem. We thought about modifying the syntax so the rule would look something like A(a~?%x) -> B(a~valueOf(x)), where %x would point to the state (as an object) of a and then a new builtin function (that we'd have to implement) valueOf would extract the value of the state from the tag x. But we never came to an agreement on exactly how to do this so it didn't happen. For example, should we tag the state, like I did above, or the component, as in something like A(a%x) -> B(a~x.getState())?

Anyway, we threw around ideas like this for a while but nothing ever came of it. So the original state-mapping syntax is still in there if it's useful but I'd be careful about using it because it could change at some point in a new BNG release.

@FFroehlich
Copy link
Contributor

@lh64 Thank you for the detailed explanation, that definitely makes sense.

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

No branches or pull requests

3 participants