Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Model writing omits keywords in reaction rules #55

Open
jrfaeder opened this issue Feb 8, 2024 · 3 comments
Open

Model writing omits keywords in reaction rules #55

jrfaeder opened this issue Feb 8, 2024 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@jrfaeder
Copy link
Contributor

jrfaeder commented Feb 8, 2024

The keywords used as rule modifiers, such as DeleteMolecules and TotalRate are not being output to strings. The result is these keywords are deleted upon output by PyBNG, which creates a model with rules missing the keywords that is not equivalent to the model initially read by PyBNG. An example is provided in the attached bngl and python files. The bngl file has a rule with the DeleteMolecules keyword. When the model is read by PyBNG, the output of the rule does not contain the keyword.

test_deleteMolecules.bngl

begin model
begin parameters
  kdl 0.03 #CBL degrades ZAP/SYK
end parameters
begin molecule types
  A(State~UZAP~PZAP~SHP~uSYK~pSYK,CBL)
  Zeta(receptor,ITAM1~U~PP,ITAM2~U~PP,ITAM3~U~PP,ITAM4~U~PP,ITAM5~U~PP,ITAM6~U~PP)
  CBL(site)
  dead()
end molecule types
begin seed species
  A(State~UZAP,CBL) 1
  Zeta(receptor,ITAM1~U,ITAM2~U,ITAM3~U,ITAM4~U,ITAM5~U,ITAM6~U) 1
  CBL(site) 1
end seed species
begin reaction rules
  CBL_degrade_ITAM1:	Zeta(ITAM1!1).A(State!1,CBL!3).CBL(site!3) -> dead()	kdl DeleteMolecules
end reaction rules
end model
writeModel({suffix=>"changed",evaluate_expressions=>1,overwrite=>1})

run_pybng.py

mname="test_deleteMolecules"
model= bionetgen.bngmodel(mname+".bngl")
print(model.rules)
@jrfaeder
Copy link
Contributor Author

jrfaeder commented Feb 8, 2024

The output of running the above python code is

begin reaction rules
  CBL_degrade_ITAM1: Zeta(ITAM1!1).A(State!1,CBL!2).CBL(site!2) -> dead() kdl 
end reaction rules

@jrfaeder jrfaeder added the bug Something isn't working label Feb 8, 2024
@jrfaeder
Copy link
Contributor Author

jrfaeder commented Feb 8, 2024

It turns out that because of differences between BNGL and its translation to XML (which is what PyBNG uses to create objects), the assignment of keywords to rules can be tricky. The omission of the DeleteMolecules keyword above occurs because of the specific logic of the code that parses the xml version of the model (starting at bionetgen/modelapi/xmlparsers.py line 701) requires that only one instance of the Delete operation occur in the rule. If there are multiple instances, as in the example above, the keyword is not assigned to the rule. This is clearly incorrect, because the DeleteMolecules attribute is set in BNGL at the rule level, so all Delete operations in the rule inherit this attribute. Therefore, if there are multiple Delete operations, as above, each of them will have the DeleteMolecules keyword. However, the test at line 705,

if not isinstance(del_op, list):

only allows the keyword to be set if there is only one Delete operation present.
This points to a clear locus in the code to fix, but we are still working at present to make sure we get the logic of the new code correct.

A concrete example is provided by the following rule:

 dZeta:	Zeta() -> dead()	kdl DeleteMolecules

For this rule the rule operations include only one Delete, and the DeleteMolecules keyword is correctly associated with the rule.

@jrfaeder
Copy link
Contributor Author

Commit 49625c2 fixes the issue described above but I'm going to leave this issue open because I am not convinced the current code will handle rules that use multiple keywords.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant