RuleWorld / bionetgen

Rule-based modeling framework
https://bionetgen.org/
MIT License
59 stars 25 forks source link

Can't call method "mapF" on an undefined value #198

Closed jczech closed 6 years ago

jczech commented 6 years ago

A previously working model produces the following error in the latest version of BioNetGen:

ABORT: Can't call method "mapF" on an undefined value at /home/jczech/bionetgen/bng2/Perl2/RxnRule.pm line 3930.

Based on a git bisect, this seems to have orginated with commit 6743c167a31b03fd11d3cba630e072aeaf6ca901.

Here's a stripped down version of that model that produces the same error:

begin model
begin parameters
  ifnar_n      1e+4
  tak1_n       1e+5
  ikk_n        2e+5
  NFkB_n       1e+5
  tbk1_n       1e+5
  irf3_n       1e+5
  traf3_n      1e+5
  mavs_n       5e+5
  B_rig_mavs        1e-7    
  U_rig_mavs        1e-3    
  B_polyIC          1e-8    
  U_polyIC          1e-3    
  B_mavs_traf       1e-7    
  U_mavs_traf       1e-3    
end parameters 
begin molecule types
  PolyIC(RIG)           
  RIG(MAVS,PolyIC)      
  MAVS(RIG,TRAF3,TBK1)  
  TRAF3(MAVS)           
  IFNAR(IFNb,Socs1)     
  TAK1(st~i~a)                        
  IKK(st~n~a~i~ii)                    
  IkBa(NFkB,loc~nuc~cyt,Ser32_36~0~p) 
  NFkB(IkBa,loc~nuc~cyt)              
  TBK1(Ser172~0~p,MAVS)               
  IRF3(IRF3,loc~nuc~cyt,Ser396~0~p)   
  IFNb(IFNAR,loc~ext~cyt)             
  STAT1(STAT2,loc~nuc~cyt,Tyr701~0~p) 
  STAT2(STAT1,loc~nuc~cyt,Tyr690~0~p) 
end molecule types
begin seed species 
  PolyIC(RIG)           0
  RIG(MAVS,PolyIC)      0
  TRAF3(MAVS)           traf3_n
  MAVS(RIG,TRAF3,TBK1)  mavs_n
  IFNAR(IFNb,Socs1)     ifnar_n
  NFkB(loc~cyt,IkBa!0).IkBa(loc~cyt,Ser32_36~0,NFkB!0)  NFkB_n
  TAK1(st~i)            tak1_n
  IKK(st~n)             ikk_n
  TBK1(Ser172~0,MAVS)                    tbk1_n
  IRF3(IRF3,loc~cyt,Ser396~0)            irf3_n
  STAT2(STAT1,loc~cyt,Tyr690~0)      30000
end seed species
begin reaction rules 
  RIG(MAVS,PolyIC) + MAVS(RIG,TRAF3,TBK1)   <->\
  RIG(MAVS!1,PolyIC).MAVS(RIG!1,TRAF3,TBK1) B_rig_mavs, U_rig_mavs
  PolyIC(RIG) + RIG(MAVS!1,PolyIC).MAVS(RIG!1,TRAF3,TBK1) <->\
  PolyIC(RIG!2).RIG(MAVS!1,PolyIC!2).MAVS(RIG!1,TRAF3,TBK1)  B_polyIC, U_polyIC
  PolyIC(RIG!1).RIG(MAVS!3,PolyIC!1).MAVS(RIG!3,TRAF3,TBK1) + TRAF3(MAVS)    <->\
  PolyIC(RIG!1).RIG(MAVS!3,PolyIC!1).MAVS(RIG!3,TRAF3!2,TBK1).TRAF3(MAVS!2)  B_mavs_traf, U_mavs_traf
  PolyIC(RIG!1).RIG(MAVS!3,PolyIC!1).MAVS(RIG!3,TRAF3!2,TBK1).TRAF3(MAVS!2)  ->\
  PolyIC(RIG) + RIG(MAVS!3,PolyIC).MAVS(RIG!3,TRAF3,TBK1)  +  TRAF3(MAVS)    U_polyIC 
end reaction rules
end model
begin actions
generate_network({overwrite=>1}); 
writeSBML({}); 
writeMfile({}); 
simulate_ssa({suffix=>"ssa__equil_34d",t_end=>2913600,n_steps=>1000}); 
end actions
jrfaeder commented 6 years ago

Here's an even shorter version of the file that demonstrates the issue seems to be having three product patterns in the rule.

begin molecule types
  A(b)           
  B(a,c)      
  C(b)  
end molecule types
begin seed species 
  A(b!1).B(a!1,c!2).C(b!2) 1
end seed species
begin observables
  Molecules Afree A(b)
end observables
begin reaction rules 
  A(b!1).B(a!1,c!2).C(b!2) -> \
  A(b) + B(a,c) + C(b) 1
end reaction rules

generate_network({overwrite=>1}); 
simulate({method=>"ode",t_end=>10,n_steps=>10})
jrfaeder commented 6 years ago

Upon further inspection with the streamlined code, the problem commit seems to be febb4a1f2dc2daa208c72a3ec20daf94589682b7.

jrfaeder commented 6 years ago

Well, the one right before that runs correctly, but the commit Jacob identified above also seems to have problems!

jrfaeder commented 6 years ago

I found the bug here:

RxnRule.pm:3922          #jjt: only iterate over reactants
                                     foreach my $ref ( @$edel[0..2] )

Changing [0..2] to [0..1] disappears the bug. This also explains the erratic behavior I think. The bug was otherwise harmless because deleteEdge would ignore the third argument.