jcrozum / pystablemotifs

Python library for attractor identification and control in Boolean networks
MIT License
28 stars 7 forks source link

Error to run boolean net to primes #80

Closed priyambial123 closed 2 years ago

priyambial123 commented 2 years ago

Hello

I am getting an error when I tried the below command:

import pystablemotifs as sm

relative_path_to_model = "/scicore/home/cichon/thirun0000/attractors/attractors.txt"
primes = sm.format.import_primes(relative_path_to_model)

print("RULES")
sm.format.pretty_print_prime_rules(primes)
print()

ar = sm.AttractorRepertoire.from_primes(primes)
ar.summary()

This is my attractors.txt file

DCAF5*= not(miR124 or miR335 or miR4507 or miR653 or miR3154 or miR5191 or miR98 or miR101 or miR198 or miR149 or miR744 or miR3157 or miR3941) and (BCL6 or MYC or KDM5A or TCF4 or KDM2B)
miR124*= miR124
miR335*= BCL6 or MYC or KDM5A
miR4507*= BCL6 or TCF4
miR653*= MYC or KDM5A
miR3154*= MYC or KDM5A
miR5191*= TCF4 or MYC or KDM5A
miR98*= KDM2B
miR101*= KDM2B
miR198*= KDM2B
miR149*= KDM2B
miR744*= KDM2B
miR3157*= KDM2B
miR3941*= KDM2B
BCL6*= not (miR124 or miR335)
MYC*= not miR335
KDM5A*= not miR335
TCF4*= TCF4 
KDM2B*= KDM2B

I get the error:

ERROR failed to run bnet2primes: cmd=/scicore/home/cichon/thirun0000/lib/python3.6/site-packages/pyboolnet/binaries/BNetToPrime/BNetToPrime_linux64, return_code=1, out=b'{"BCL6":[[{"miR335":1,\x08 \x08},{"miR124":1,\x08 \x08},\x08 \x08],[{"miR124":0,"miR335":0,\x08 \x08},\x08 \x08]],'
RULES
Traceback (most recent call last):
  File "attractors.py", line 10, in <module>
    ar = sm.AttractorRepertoire.from_primes(primes)
  File "/scicore/home/cichon/thirun0000/lib/python3.6/site-packages/pystablemotifs/AttractorRepertoire.py", line 98, in from_primes
    x.analyze_system(primes,max_simulate_size=max_simulate_size,max_simulate_size_vc=max_simulate_size_vc,max_stable_motifs=max_stable_motifs,max_in_degree=max_in_degree,MPBN_update=MPBN_update)
  File "/scicore/home/cichon/thirun0000/lib/python3.6/site-packages/pystablemotifs/AttractorRepertoire.py", line 196, in analyze_system
    self.succession_diagram = sm_succession.build_succession_diagram(primes,max_simulate_size=max_simulate_size,max_simulate_size_vc=max_simulate_size_vc,max_stable_motifs=max_stable_motifs,max_in_degree=max_in_degree,MPBN_update=MPBN_update)
  File "/scicore/home/cichon/thirun0000/lib/python3.6/site-packages/pystablemotifs/succession.py", line 515, in build_succession_diagram
    myMotifReduction=sm_reduction.MotifReduction(motif_history,fixed.copy(),primes,max_simulate_size=max_simulate_size,max_simulate_size_vc=max_simulate_size_vc,prioritize_source_motifs=prioritize_source_motifs,max_stable_motifs=max_stable_motifs,MPBN_update=MPBN_update)
  File "/scicore/home/cichon/thirun0000/lib/python3.6/site-packages/pystablemotifs/reduction.py", line 412, in __init__
    self.reduced_primes = reduced_primes.copy()
AttributeError: 'NoneType' object has no attribute 'copy'

Is there any error in the rules input file?

Thanks

kyuhyongpark commented 2 years ago

Hello,

You're missing a space after the 'not' in the rule for DCAF5. Even with that fix, it may take too long for the rules to be imported. I recommend you reduce the number of regulators per node.

1. For example, DCAF5*= not(miR124 or miR335 or miR4507 or miR653 or miR3154 or miR5191 or miR98 or miR101 or miR198 or miR149 or miR744 or miR3157 or miR3941) and (BCL6 or MYC or KDM5A or TCF4 or KDM2B)

Can be changed to DCAF5= not X1 and X2 X1 = miR124 or miR335 or miR4507 or miR653 or miR3154 or miR5191 or miR98 or miR101 or miR198 or miR149 or miR744 or miR3157 or miR3941 X2* = BCL6 or MYC or KDM5A or TCF4 or KDM2B

X1 and X2 are dummy nodes. The model behavior will be mostly equivalent.

2. Another way is to reduce the nodes that have same regulators and regulates the same nodes in a same way. For example miR89, miR101, miR198, ... seem to do the exact same thing. Reducing them to a node will not change the model behavior.

priyambial123 commented 2 years ago

Hello

Thank you for the suggestions and for finding the mistake in the rules file. How to reduce the nodes that have same regulators? Can you give an example?

Thanks

priyambial123 commented 2 years ago

I have reduced the network as follows:

DCAF5*= X1 and X2
X1*= BCL6 or MYC or KDM5A or TCF4 or KDM2B
X2*= not(miR124 or miR335 or miR4507 or miR653 or X4 or X3)
miR124*= miR124
miR335*= BCL6 or MYC or KDM5A
miR4507*= BCL6 or TCF4
X4*= MYC or KDM5A
miR5191*= TCF4 or MYC or KDM5A
X3*= KDM2B
BCL6*= not(miR124 or miR335)
MYC*= not miR335
KDM5A*= not miR335
TCF4*= TCF4 
KDM2B*= KDM2B

I get the below error:

Traceback (most recent call last):
  File "attractors.py", line 10, in <module>
    ar = sm.AttractorRepertoire.from_primes(primes)
  File "/scicore/home/cichon/thirun0000/lib/python3.6/site-packages/pystablemotifs/AttractorRepertoire.py", line 98, in from_primes
    x.analyze_system(primes,max_simulate_size=max_simulate_size,max_simulate_size_vc=max_simulate_size_vc,max_stable_motifs=max_stable_motifs,max_in_degree=max_in_degree,MPBN_update=MPBN_update)
  File "/scicore/home/cichon/thirun0000/lib/python3.6/site-packages/pystablemotifs/AttractorRepertoire.py", line 196, in analyze_system
    self.succession_diagram = sm_succession.build_succession_diagram(primes,max_simulate_size=max_simulate_size,max_simulate_size_vc=max_simulate_size_vc,max_stable_motifs=max_stable_motifs,max_in_degree=max_in_degree,MPBN_update=MPBN_update)
  File "/scicore/home/cichon/thirun0000/lib/python3.6/site-packages/pystablemotifs/succession.py", line 515, in build_succession_diagram
    myMotifReduction=sm_reduction.MotifReduction(motif_history,fixed.copy(),primes,max_simulate_size=max_simulate_size,max_simulate_size_vc=max_simulate_size_vc,prioritize_source_motifs=prioritize_source_motifs,max_stable_motifs=max_stable_motifs,MPBN_update=MPBN_update)
  File "/scicore/home/cichon/thirun0000/lib/python3.6/site-packages/pystablemotifs/reduction.py", line 412, in __init__
    self.reduced_primes = reduced_primes.copy()
AttributeError: 'NoneType' object has no attribute 'copy'
kyuhyongpark commented 2 years ago

Hi,

The error is due to the missing space between not and (. Fixing them in the rules for X2 and BCL6 will be all you need to do. I just ran the code on the fixed rules and it was fine.

kyuhyongpark commented 2 years ago

I think your changed rule is not equivalent to the original. This is because DCAF5 is no longer regulated by miR5191.

I'd change the rule as following:

DCAF5= X1 and X2 X1 = BCL6 or MYC or KDM5A or TCF4 or KDM2B X2 = not (miR124 or miR335 or miR4507 or miR653 or miR5191 or miR98) miR124= miR124 miR335= BCL6 or MYC or KDM5A miR4507= BCL6 or TCF4 miR653= MYC or KDM5A miR5191= TCF4 or MYC or KDM5A miR98= KDM2B BCL6= not (miR124 or miR335) MYC= not miR335 KDM5A= not miR335 TCF4= TCF4 KDM2B= KDM2B

Note1: miR3154 is reduced since it is equivalent to miR653. Note2: miR101, miR198, miR149, miR744, miR3157, miR3941 are reduced since they are equivalent to miR98.

I just ran it and got 8 attractors.

priyambial123 commented 2 years ago

This is the output file that was generated

  RULES
BCL6* = !miR124 & !miR335
DCAF5* = X1 & X2
KDM2B* = KDM2B
KDM5A* = !miR335
MYC* = !miR335
TCF4* = TCF4
X1* = TCF4 | MYC | KDM5A | KDM2B | BCL6
X2* = !miR124 & !miR335 & !miR4507 & !miR5191 & !miR653 & !miR98
miR124* = miR124
miR335* = MYC | KDM5A | BCL6
miR4507* = TCF4 | BCL6
miR5191* = TCF4 | MYC | KDM5A
miR653* = MYC | KDM5A
miR98* = KDM2B

ERROR %% created on 13. Jun. 2022 using pyboolnet
% pyboolnet is available at https://github.com/hklarner/pyboolnet

% encoding of prime implicants as hyper-arcs that consist of a unique "target" and (possibly) several "sources".
% "target" and "source" are triplets that consist of a variable name, an activity and a unique arc-identifier. 

target("BCL6",0,a1). source("miR335",1,a1).
target("BCL6",0,a2). source("miR124",1,a2).
target("BCL6",1,a3). source("miR124",0,a3). source("miR335",0,a3).
target("DCAF5",0,a4). source("X2",0,a4).
target("DCAF5",0,a5). source("X1",0,a5).
target("DCAF5",1,a6). source("X1",1,a6). source("X2",1,a6).
target("KDM2B",0,a7). source("KDM2B",0,a7).
target("KDM2B",1,a8). source("KDM2B",1,a8).
target("KDM5A",0,a9). source("miR335",1,a9).
target("KDM5A",1,a10). source("miR335",0,a10).
target("MYC",0,a11). source("miR335",1,a11).
target("MYC",1,a12). source("miR335",0,a12).
target("TCF4",0,a13). source("TCF4",0,a13).
target("TCF4",1,a14). source("TCF4",1,a14).
target("X1",0,a15). source("BCL6",0,a15). source("KDM2B",0,a15). source("KDM5A",0,a15). source("MYC",0,a15). source("TCF4",0,a15).
target("X1",1,a16). source("TCF4",1,a16).
target("X1",1,a17). source("MYC",1,a17).
target("X1",1,a18). source("KDM5A",1,a18).
target("X1",1,a19). source("KDM2B",1,a19).
target("X1",1,a20). source("BCL6",1,a20).
target("X2",0,a21). source("miR98",1,a21).
target("X2",0,a22). source("miR653",1,a22).
target("X2",0,a23). source("miR5191",1,a23).
target("X2",0,a24). source("miR4507",1,a24).
target("X2",0,a25). source("miR335",1,a25).
target("X2",0,a26). source("miR124",1,a26).
target("X2",1,a27). source("miR124",0,a27). source("miR335",0,a27). source("miR4507",0,a27). source("miR5191",0,a27). source("miR653",0,a27). source("miR98",0,a27).
target("miR124",0,a28). source("miR124",0,a28).
target("miR124",1,a29). source("miR124",1,a29).
target("miR335",0,a30). source("BCL6",0,a30). source("KDM5A",0,a30). source("MYC",0,a30).
target("miR335",1,a31). source("MYC",1,a31).
target("miR335",1,a32). source("KDM5A",1,a32).
target("miR335",1,a33). source("BCL6",1,a33).
target("miR4507",0,a34). source("BCL6",0,a34). source("TCF4",0,a34).
target("miR4507",1,a35). source("TCF4",1,a35).
target("miR4507",1,a36). source("BCL6",1,a36).
target("miR5191",0,a37). source("KDM5A",0,a37). source("MYC",0,a37). source("TCF4",0,a37).
target("miR5191",1,a38). source("TCF4",1,a38).
target("miR5191",1,a39). source("MYC",1,a39).
target("miR5191",1,a40). source("KDM5A",1,a40).
target("miR653",0,a41). source("KDM5A",0,a41). source("MYC",0,a41).
target("miR653",1,a42). source("MYC",1,a42).
target("miR653",1,a43). source("KDM5A",1,a43).
target("miR98",0,a44). source("KDM2B",0,a44).
target("miR98",1,a45). source("KDM2B",1,a45).

% generator: "in_set(ID)" specifies which arcs are chosen for a trap set (ID is unique for target(_,_,_)).
{in_set(ID) : target(V,S,ID)}.

% consistency constraint
:- in_set(ID1), in_set(ID2), target(V,1,ID1), target(V,0,ID2).

% stability constraint
:- in_set(ID1), source(V,S,ID1), not in_set(ID2) : target(V,S,ID2).

% bijection constraint (between asp solutions and trap spaces)
% to avoid the repetition of equivalent solutions we add all prime implicants
% that agree with the current solution.
in_set(ID) :- target(V,S,ID), hit(V,S), hit(V1,S1) : source(V1,S1,ID).

% "hit" captures the stable variables and their activities.
hit(V,S) :- in_set(ID), target(V,S,ID).

%% cardinality constraint (enforced by "Bounds=(1, 14)")
:- {hit(V,S)} 0.
:- 15 {hit(V,S)}.

% show fixed nodes
#show hit/2.
**ERROR [Errno 2] No such file or directory: 'gringo': 'gringo'
ERROR call to gringo and / or clasp failed.**

What is error at the end of the file. Is this expected?

kyuhyongpark commented 2 years ago

It seems some of the packages are not properly installed.

If you installed pystablemotifs from PyPI, you will need to install pyboolnet separately (instructions at https://github.com/hklarner/pyboolnet). This is because PyPI (apparently) does not support dependencies that are not also on PyPI.

priyambial123 commented 2 years ago

I have installed the packages in conda environment. pystable motifs was installed in different folder inside the environment. When I gave the path of this folder, the code ran without any errors and in the output file, I got 8 attractors

Thanks

jcrozum commented 2 years ago

It looks like this issue has been resolved, so I will close it now.