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

Encoding of the "or" when converting from SBMLqual to bnet #25

Open
nanls opened this issue Aug 11, 2021 · 4 comments
Open

Encoding of the "or" when converting from SBMLqual to bnet #25

nanls opened this issue Aug 11, 2021 · 4 comments

Comments

@nanls
Copy link

nanls commented Aug 11, 2021

Hi,

I am using BioLQM to convert an SBMLqual file to bnet.

The input SBMLqual file describes a system of 3 nodes sA, sB, sX, and the only transition is sX = sA | sB. Here is the content of the math tag of the SBML describing this transition :

            <math xmlns="http://www.w3.org/1998/Math/MathML">
              <apply><or/>
                <apply><eq/>
                  <ci>sA</ci>
                  <cn type="integer">1</cn>
                </apply>
                <apply><eq/>
                  <ci>sB</ci>
                  <cn type="integer">1</cn>
                </apply>
              </apply>
            </math>

In the resulting bnet file, I obtained sX, !sB&sA | sB.

I know that (!B&A) | B is equivalent to A | B, but I am wondering why I don't obtain the exact equivalent of what is wrote in the SBMLqual. Is there any reason to have picked this form, or is it a weird bug ?

@aurelien-naldi
Copy link
Contributor

Hi,

It's not a bug but a limitation of the implementation: bioLQM stores the logical rules as decision diagrams which are optimized for evaluating the rules but often differ from their original representation. It would be nicer for model conversion to keep track of the original function and to use it directly when possible, but it would require large changes to the data structures.

@pauleve
Copy link
Contributor

pauleve commented Aug 24, 2021

To workaround this issue, you can use the colomoto.minibn Python module (part of colomoto_jupyter Python package), either to simplify a bnet file:

from colomoto import minibn
bn = minibn.BooleanNetwork.load("file.bnet")
bn = bn.simplify()
with open("file-simplified.bnet", "w") as fp:
     fp.write(bn.source())

or through biolqm:

import biolqm
m = biolqm.load("myfile.sbml")
bn = biolqm.to_minibn(m) # simplify by default
with open("file-simplified.bnet", "w") as fp:
     fp.write(bn.source())

@aurelien-naldi
Copy link
Contributor

That's a good way to get nicer looking functions in the bnet output, but the functions may still be transformed compared to the original file (you may recover the same functions in some cases, but it is not guaranteed)

@nanls
Copy link
Author

nanls commented Sep 1, 2021

Thanks for these explanations and snippets. I will try! :)

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