hklarner / pyboolnet

PyBoolNet is a Python package for the generation, modification and analysis of Boolean networks.
42 stars 21 forks source link

Error in loading BNet file #92

Closed yzongy closed 2 years ago

yzongy commented 2 years ago

Hi Hannes,

I am loading a model and converting it to primes with bent2primes. But it seems like there was a formatting issue with the input file: ERROR failed to run bnet2primes: cmd=/Users/yzongy/.pyenv/versions/3.9.7/lib/python3.9/site-packages/pyboolnet/binaries/BNetToPrime/BNetToPrime_mac64, return_code=1, out=b''

How can I get further information on this error and locate the problem in my input file?

Model: processed_output_boolNet_wildtype_fbcBased.txt

Best,

Bill

carissableker commented 2 years ago

This is not a bnet file -- see here for the documentation: https://pyboolnet.readthedocs.io/en/master/quickstart.html?highlight=bnet#boolean-networks

And for examples of the correct format: https://github.com/hklarner/pyboolnet/tree/master/pyboolnet/repository

carissableker commented 2 years ago

Btw, you also have multiple functions per node, e.g.:

s_1004__91__e__93___fc

occurs twice as the target.

yzongy commented 2 years ago

Thanks!

I was using pystablemotifs which will convert my input to a bnet file then call bnet2primes.

How did you detect the duplicated target nodes and other formatting issues in such a big file?

hklarner commented 2 years ago

thanks @carissableker for responding!

I agree, processed_output_boolNet_wildtype_fbcBased.txt, is not a bnet file. Looks like it lists conjunctive conditions that are sufficient for activating components - this also explains, why the same targets appear repeatedly.

@yzongy you should ask the pystablemotifs maintainers how to obtain a valid bnet file.

yzongy commented 2 years ago

Thanks for your hints! I have validated the bnet file already, so bnet2Prime is running properly now. But the issue is it takes so long to convert a model with about 3000 nodes to primes:

Screen Shot 2022-02-22 at 11 21 17 PM

Is there any tips to speed it up?

hklarner commented 2 years ago

I think the BnetToPrime is pretty competitive in terms of cpu time. The task is linear for the number of components (3000 in your case) and exponential in the number of inputs of each components.

Primes are just a Python dict, so save and load them using the built in json library.

Btw 3000 nodes is a very large model. I've worked with models of about 100 nodes.

yzongy commented 2 years ago

Thanks for the hints!

I tried to split long rules and make the number of components of each rule under 5 by adding new intermediate nodes.

It took significantly less time to run bnet2primes.

Thanks again!