Menu

#477 Not possible to set ModelHistory without timestamps

libSBML-5.18.0
open
nobody
None
2020-04-23
2020-04-23
No

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

1 Attachments

Related

libSBML: #477

Discussion

  • Frank Bergmann

    Frank Bergmann - 2020-04-23

    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.

     
    • Matthias König

      Matthias König - 2020-04-24

      @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:

      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.

      Status: open
      Version: libSBML-5.18.0
      Priority:
      Created: Thu Apr 23, 2020 07:51 PM UTC by Matthias König
      Last Updated: Thu Apr 23, 2020 07:52 PM UTC
      Owner: nobody
      Attachments:

      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.</set>

      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

      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/sbml/libsbml/477/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

      --
      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


Log in to post a comment.

MongoDB Logo MongoDB