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

Pattern matching is returning wrong results when comparing symmetric components #3

Closed jjtapia closed 8 years ago

jjtapia commented 9 years ago

The compare method in NFcore/templateMolecule.cpp is used to evaluate whether a given molecule is a match for a reaction template. If yes, it can return the corresponding mapping that corresponds to this match.

1) This compare method is returning wrong results for the example model in https://dl.dropboxusercontent.com/u/7096948/test_issue3.bngl

And setting seed species to R(s,s!1).L(s!1,s!2).R(s!2,s!3).L(s!3,s!4).R(s!4,s) 1

And reaction ProblemRule:%x:R(s!1).L(s!1,s!2).R(s!2,s)->R(s!1).L(s!1,s)+R(s,s) GE2(x)

Results in the following output All System Reactions: DORRxnClass: ProblemRule_sym1 ( baseRate=1, a=1, fired=0 times ) -(DOR) |1 mappings| R(s!2).L(s1!1,s!2).R(s1!1,s) (rateFactorSum=1). DORRxnClass: ProblemRule_sym2 ( baseRate=1, a=0, fired=0 times ) -(DOR) |0 mappings| R(s!2).L(s1!1,s!2).R(s2!1,s) (rateFactorSum=0). DORRxnClass: ProblemRule_sym3 ( baseRate=1, a=0, fired=0 times ) -(DOR) |0 mappings| R(s!2).L(s2!1,s!2).R(s1!1,s) (rateFactorSum=0). DORRxnClass: ProblemRule_sym4 ( baseRate=1, a=0, fired=0 times ) -(DOR) |0 mappings| R(s!2).L(s2!1,s!2).R(s2!1,s) (rateFactorSum=0).

When the correct mapping should be to map then once to sym1 and once to sym3

2) Similarly when the seed species is set to R(s,s!1).L(s!2,s!1).R(s!2,s!3).L(s!3,s!4).R(s!4,s) 1

We obtain the following mappings:

DORRxnClass: ProblemRule_sym1 ( baseRate=1, a=1, fired=0 times ) -(DOR) |0 mappings| R(s!2).L(s1!1,s!2).R(s1!1,s) (rateFactorSum=1). DORRxnClass: ProblemRule_sym2 ( baseRate=1, a=0, fired=0 times ) -(DOR) |0 mappings| R(s!2).L(s1!1,s!2).R(s2!1,s) (rateFactorSum=0). DORRxnClass: ProblemRule_sym3 ( baseRate=1, a=0, fired=0 times ) -(DOR) |2 mappings| R(s!2).L(s2!1,s!2).R(s1!1,s) (rateFactorSum=0). DORRxnClass: ProblemRule_sym4 ( baseRate=1, a=0, fired=0 times ) -(DOR) |0 mappings| R(s!2).L(s2!1,s!2).R(s2!1,s) (rateFactorSum=0).

When the correct mapping should be to map it once to sym3 and once to sym4

3) The species R(s!1,s).L(s!2,s!1).R(s!2,s!3).L(s!3,s!4).R(s!4,s) 1

Returns the correct mapping DORRxnClass: ProblemRule_sym1 ( baseRate=1, a=1, fired=0 times ) -(DOR) |0 mappings| R(s!2).L(s1!1,s!2).R(s1!1,s) (rateFactorSum=1). DORRxnClass: ProblemRule_sym2 ( baseRate=1, a=0, fired=0 times ) -(DOR) |0 mappings| R(s!2).L(s1!1,s!2).R(s2!1,s) (rateFactorSum=0). DORRxnClass: ProblemRule_sym3 ( baseRate=1, a=0, fired=0 times ) -(DOR) |2 mappings| R(s!2).L(s2!1,s!2).R(s1!1,s) (rateFactorSum=0). DORRxnClass: ProblemRule_sym4 ( baseRate=1, a=0, fired=0 times ) -(DOR) |0 mappings| R(s!2).L(s2!1,s!2).R(s2!1,s) (rateFactorSum=0).

These samples were obtained when using the binary NFsim found in the issue2 branch (4e516d82a492ba5d55c47491b06cec7914eca70d). Doing it using the binary from the main branch returns results that are even more pathological given the problems raised in issue #2.