RuleWorld / nfsim

A general-purpose, stochastic, biochemical reaction simulator for large reaction networks
http://michaelsneddon.net/nfsim/
MIT License
14 stars 9 forks source link

Operations order bug #22

Open jrfaeder opened 6 years ago

jrfaeder commented 6 years ago

This issue was reported by Pedro Mendes. The following reaction can cause NFsim to fail: E1(a!1,b!2).A(e1!1).B(e1!2) <-> E1(a!1,b!2).P(e1!1,e2).Q(e1!2) k131, k132 DeleteMolecules NFsim tries to create a bond between the newly created P molecule and E1 before it deletes A, causing the following error:

Your universal traversal limit was probably set too low, so some updates were not correct!

Trying to bond E1_2054(a) & P_6(e1) to sites that are already occupied! Check rxn rules!!

++ Molecule instance of type: E1 (uId=2054, tId=2, cId=181, degree=0) components: a=NO_STATE bond=A_181(e1) b=NO_STATE bond=B_1443(e1) ++ Molecule instance of type: P (uId=6, tId=3, cId=6, degree=0) components: e1=NO_STATE bond=empty e2=NO_STATE bond=empty

The UTL issue is probably not relevant here. This problem occurs in both 1.11 and 1.12. RandomBiBi.bngl.txt

ASinanSaglam commented 2 years ago

The following is likely related to this issue

This was reported by: Freundliche Grüße, I'm just adding it as an issue on GH.

This reaction fails to run in NFsim

A1(a!1).B(b!1) + A2(a) <-> A1(a) + A2(a!1).B(b!1) 1,1

with the error:

Trying to bond A1_0(a2) & B_4(b)                                     
to sites that are already occupied!  Check rxn rules!! 

Furthermore, restating this rule with

A1(a!1).B(b!1) + A2(a) -> A1(a) + A2(a!1).B(b!1) 1
A1(a) + A2(a!1).B(b!1) ->  A1(a!1).B(b!1) + A2(a) 1

also fails with the same error but switching the order of the reactant and products actually runs without errors:

A1(a!1).B(b!1) + A2(a) -> A1(a) + A2(a!1).B(b!1) 1
A2(a!1).B(b!1) + A1(a) -> A2(a) + A1(a!1).B(b!1) 1

The resulting BNG-XMLs are exactly what's expected from them, likely pointing to an issue somewhere in NFsim.

Below is a sample BNGL for this issue., again written by Freundliche Grüße

begin model
begin molecule types
    A1(a,a,a)
    A2(a,a)
    B(b)
end molecule types
begin reaction rules
    # Not working
    # A1(a!1).B(b!1) + A2(a) <-> A1(a) + A2(a!1).B(b!1) 1,1
    # Not Working either
    # A1(a!1).B(b!1) + A2(a) -> A1(a) + A2(a!1).B(b!1) 1
    # A1(a) + A2(a!1).B(b!1) ->  A1(a!1).B(b!1) + A2(a) 1
    # Working
    A1(a!1).B(b!1) + A2(a) -> A1(a) + A2(a!1).B(b!1) 1
    A2(a!1).B(b!1) + A1(a) -> A2(a) + A1(a!1).B(b!1) 1
end reaction rules
begin seed species
    A1(a!1,a!2,a!3).B(b!1).B(b!2).B(b!3) 1
    A2(a,a) 1
end seed species
end model
# Simulation Commands
writeXML()
simulate_nf({gml=>100000000,suffix=>"stage_1",get_final_state=>1,seed=>1,t_end=>2,n_steps=>2,complex=>1,print_functions=>1,utl=>500})