It is not possible to set a ModelHistory without created and modified timestamps. Nowhere in the SBML specification does it state that the modfied and created date are required on a model history. It should be possible to create a ModelHistory only with creator information or only with timestamps, but it should not be required that all the information is always there.
I attached a python example which shows the problem. When setting a ModelHistory with timestamps everything works, without timestamps the following SBML error code is returned.
ERROR:root:Error encountered trying to <set model history on <Parameter p2>>.
ERROR:root:LibSBML returned error code -5: The object passed as an argument to the method is not of a type that is valid for the operation or kind of object involved. For example, handing an invalidly-constructed ASTNode to a method expecting an ASTNode will result in this error.
The complete python example is attached as file
def set_model_history(sbase, creators, set_timestamps=True):
"""Set a model history with given creators."""
h = libsbml.ModelHistory() # type: libsbml.ModelHistory
# add creators
for creator in creators:
c = libsbml.ModelCreator()
if creator.familyName:
c.setFamilyName(creator.familyName)
if creator.givenName:
c.setGivenName(creator.givenName)
if creator.email:
c.setEmail(creator.email)
if creator.organization:
c.setOrganization(creator.organization)
check(h.addCreator(c), 'add creator')
# set timestamp
if set_timestamps:
date = date_now()
check(h.setCreatedDate(date), 'set creation date')
check(h.setModifiedDate(date), 'set modified date')
check(sbase.setModelHistory(h), f'set model history on {sbase}')
```
I want to write a model history, but do not want any timestamps, because these create issues in tracking SBML models in git repositories (i.e., every model creation creates changes in the timestamps and the model even if the model did not change).
See example attached:
diff --git a/docs/models/pancreas/pancreaswb.xml b/docs/models/pancreas/pancreaswb.xml
index 69791da..930c6ba 100644
--- a/docs/models/pancreas/pancreaswb.xml
+++ b/docs/models/pancreas/pancreaswb.xml
@@ -56,10 +56,10 @@
<dcterms:created rdf:parsetype="Resource">
- <dcterms:w3cdtf>2020-04-22T11:18:08Z</dcterms:w3cdtf>
+ <dcterms:w3cdtf>2020-04-23T21:02:10Z</dcterms:w3cdtf>
</dcterms:created>
<dcterms:modified rdf:parsetype="Resource">
- <dcterms:w3cdtf>2020-04-22T11:18:08Z</dcterms:w3cdtf>
+ <dcterms:w3cdtf>2020-04-23T21:02:10Z</dcterms:w3cdtf>
</dcterms:modified>
```
Workarounds for now are:
- to not write ModelHistory (but looses the creator information I want)
- set a fixed created and modified date which is not the real creation/modification date (i.e. all my models were created and modfied on 1900-01-01T00:00:00 (but this is just incorrect information in the model)
In my opinion it must be either:
- stated in the specifcation that a modelhistory always requires certain elements like created and modified
- or one should be able to create ModelHistory elements with subsets of the information
Best Matthias
I'd be fine to lift the limitations on the format. Many times i would like to save the model history, without having author information for example (timestamps are easy to generate at the timepoint, but figuring out who is using the software is harder). So I would support lifting limitations to sub elements.
We should discuss this with the rest of the team though.
@Frank exactly my other use case where it makes sense to allow only subsets
of the ModelHistory. I don't want to write the creators on every single
SBase, but only on Model and SBMLDocument. So for all other elements like
Parameters and Species I would just use the created and modified date.
On Thu, Apr 23, 2020 at 10:29 PM Frank Bergmann fbergmann@users.sourceforge.net wrote:
--
Matthias König, PhD.
Junior Group Leader LiSyM - Systems Medicine of the Liver
Humboldt Universität zu Berlin, Institute of Biology, Institute for
Theoretical Biology
https://livermetabolism.com
konigmatt@googlemail.com
https://twitter.com/konigmatt
https://github.com/matthiaskoenig
Tel: +49 30 2093 98435
Related
libSBML: #477