Hi Lucian,
it would be very good to support the XMLChanges in phrasedml. You already have some proposed syntax in the tutorial. With the XMLChanges we would support the full L1V2 specification with the phrasedml, antimony, tellurium stack.
see also https://github.com/sys-bio/tellurium/issues/115
I already have some use cases where I need the XMLChanges:
- changing the species boundaryCondition from True to False and const from True to False (to test how model behaves if I let the species go)
- replacing a const=true parameter with const=false and adding rule for calculation of the parameter to the model
Like mentioned in
https://github.com/sys-bio/tellurium/issues/114#issuecomment-197400001
it would be very nice to have some helper functions in libsbml for this kind of manipulation. This would make handling these things reproducible and easy for the user.
getElement(s)ByXPath(xpath) # gets Element(s) from xpath addXML(xpath, xml) # adds xml to the element specified by xpath changeXML(xpath, xml) # changes xml removeXML(xpath) # remove xml at xpath
I will implement the tellurium part of the XMLChanges in mid/end of April.
Matthias
As a workaround, I would suggest doing this with modular Antimony:
model one()
const species S1=3
end
model two()
A: one()
var species S1
A.S1 is S1
end
model one()
x=3
end
model two()
A: one()
A.x is x
x := time+2
end
As a bonus, this will end up being much more exchangeable, since few tools implement XMLChange support, I think.
Hi Lucian,
this works great for the given example.
I tried a bit more complex case and got into trouble. I mainly want to modify an existing SBML model, so I do the following
- load SBML
- convert to antimony
- define antimony change model (bitsandpieces)
- combine the two antimony strings
- load the combined antimony model
- strangly the changes are not applied to the model (do I have to define a master model or something? what does the
*
in front of the model id mean? is this an indicator for that?)I looked some time for obvious errors, but not sure why the following is not working.
The created antimony and sbml via antimony are attached below. The antimony string contains the changes, the SBML does not have the changed Km_A ?
How do I load an SBML model and modify it?
As you suspected, the issue is with the asterisk, which means 'Use this model as the default model in this file.' If you load an Antimony string and then ask it for 'the SBML model' (i.e. give it an argument of 'NULL', which tellurium does behind the scenes), it will give you the default model.
If no model is marked with an asterisk, it will give you the '__main" model if there is such a thing (i.e. the model not wrapped in 'model foo() ... end'), and otherwise will give you the model you defined last.
Fortunately in this case, if you define two different models with an asterisk, it will use the last one defined in the input as the default. This lets us change your script to the following, which works:
Perfect.
So in my opinion we should drop XMLChange support in tellurium/phrasedml completely than.
We have the alternative method of providing derived models and using them directly in the SEDML. This provides a mean to encode all of the "useful" model changes, i.e. changes which create another useful/working model afterwards. This is so much cleaner and error-free than any of the XMLChanges directly in SEDML which will never guarantee that a useful/valid model comes out of it. In addition it does not require manipulation of the XML Dom.
I will create a handful of standard model changes/deletions/insertions people would want to perform. I think with the derived model syntax most (all?) use cases can be handled.
We should recommend this approach to any manipulations via XMLChanges/Removals/Additions.
That certainly works for me!
A further argument in favor of not trying to support this is that there is no parallel standard simulator command they correspond to: you can say r.S1=3 and change the value of S1, but nobody even thinks about the possibility of having 'r.insert("S1:=time+2")'. Those sorts of manipulations are carried out at the modeling level
Closing this as 'wontfix', since we're encouraging people to use alternate methods of accomplishing the same thing.