LoLab-MSM / pysb

Python framework for Systems Biology modeling [Lopez Lab Mods]
BSD 2-Clause "Simplified" License
6 stars 8 forks source link

Problems with reversible synth/deg rules #10

Open lh64 opened 9 years ago

lh64 commented 9 years ago

The reversible synthesis/degradation rule

 Rule('synth_deg', A() <> None, k_deg, k_synth)

should produce the following pair of BNGL rules:

 synth_deg_forward:  A() -> __sink()    k_deg 
 synth_deg_reverse:  __source() -> A() + __source()    k_synth

However, it instead produces the single BNGL rule

 synth_deg:  A() <-> __sink()    k_deg, k_synth

This is obviously a problem since the synthesis rate erroneously depends on the concentration of the dummy species __sink().

Furthermore, reversing the order of the reactant and product in the rule, i.e.,

 Rule('synth_deg', None <> A(), k_synth, k_deg)

leads to the erroneous BNGL rule

 synth_deg:  A() <-> __sink()    k_synth, k_deg

where the reactant and product have been swapped but the rate constants have not.

These problems can be avoided by writing the synthesis and degradation rules as separate unidirectional rules or by using the macro 'synthesize_degrade_table([[A(), k_synth, k_deg]])'. Nevertheless, it makes sense to fix these problems. The best solution is probably to replace the source() and sink() species with BNG's null symbol '0'. This would avoid the need for any special handling in cases like this.

alubbock commented 6 years ago

@lh64 This has changed with pysb/pysb#317. Your synth/deg example above now gives the single BNGL rule:

  synth_deg:  A() <-> 0    k_deg, k_synth

If that's correct, we can close the ticket. One slight issue is that it doesn't get detected as a zero-order synthesis rule, so PySB needs an initial for A(), or it won't generate the network (assuming no other rules in the system). Is that something that needs changing?

lh64 commented 6 years ago

Is it a PySB issue or a BNG issue? What happens if you write it as two separate rules: 0 >> A() and A() >> 0? Do you need an initial on A() in that case? I think BNG will generate a network in that case but I’m not certain. If it does, I’m not sure why it doesn’t if the rule is reversible.

alubbock commented 6 years ago

It's a PySB issue. Rule.is_synth() and Rule.is_deg() weren't working properly for reversible rules. I've submitted a PR to fix it here: pysb/pysb#326