Menu

#26 Improve Annotation handling

2.3
accepted
None
5
2016-08-03
2016-07-13
No

Suggested by Chris Myers:

The getAnnotation method returns a list of Annotations even though there is only one Annotation on each object. This function is marked as deprecated, so I suspect that you know this, but I cannot find a replacement.
I assume addAnnotation should also be deprecated and setAnnotation should take a single item. It would also be nice to have some functions to help build and parse annotations. See getSEDBaseAnnotation in the attached as an example.

Discussion

  • Richard Adams

    Richard Adams - 2016-07-13

    Ticket moved from /p/jlibsedml/bugs/6/

     
  • Richard Adams

    Richard Adams - 2016-08-03

    I've committed in some improved methods to set Annotation, to add top-level elements and also an AnnotationValidator that will complain if you add > 1 top level element with same namespace, as per the SBML spec's recommendations. Please Can you add your attachment here in a comment so I can have a look and see what else you were looking to do?
    Thanks Richard

     
    • Chris Myers

      Chris Myers - 2016-08-04

      Here is the getSEDBaseAnnotation method I wrote.

      public static String getSEDBaseAnnotation(SEDBase sedBase, String name, String attribute, String defaultValue)
      {
          List<Annotation> annotations = sedBase.getAnnotation();
          for (int i = 0; i < annotations.size(); i++)
          {
              Annotation annotation = annotations.get(i);
              List<Element> elements = annotation.getAnnotationElementsList();
              for (Element element : elements) {
                  if (!element.getNamespaceURI().equals("http://www.async.ece.utah.edu/iBioSim")) continue;
                  if (element.getName().equals(name)) {
                      if (element.getAttributeValue(attribute)!=null) {
                          return element.getAttributeValue(attribute);
                      } else {
                          return defaultValue;
                      }
                  }
              }
          }
          return defaultValue;
      }
      

      On Aug 3, 2016, at 2:59 PM, Richard Adams otter606@users.sf.net wrote:

      I've committed in some improved methods to set Annotation, to add top-level elements and also an AnnotationValidator that will complain if you add > 1 top level element with same namespace, as per the SBML spec's recommendations. Please Can you add your attachment here in a comment so I can have a look and see what else you were looking to do?
      Thanks Richard

      [feature-requests:#26] Improve Annotation handling

      Status: open
      Group: 2.3
      Created: Wed Jul 13, 2016 08:50 PM UTC by Richard Adams
      Last Updated: Wed Jul 13, 2016 08:51 PM UTC
      Owner: nobody

      Suggested by Chris Myers:

      The getAnnotation method returns a list of Annotations even though there is only one Annotation on each object. This function is marked as deprecated, so I suspect that you know this, but I cannot find a replacement.
      I assume addAnnotation should also be deprecated and setAnnotation should take a single item. It would also be nice to have some functions to help build and parse annotations. See getSEDBaseAnnotation in the attached as an example.

      Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/jlibsedml/feature-requests/26/ https://sourceforge.net/p/jlibsedml/feature-requests/26/
      To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/ https://sourceforge.net/auth/subscriptions/

       
      • Chris Myers

        Chris Myers - 2016-08-04

        Here is the function modified with your changes;

        public static String getSEDBaseAnnotation(SEDBase sedBase, String name, String attribute, String defaultValue)
        {
            Annotation annotation = sedBase.getAnnotation();
            if (annotation!=null) {
                List<Element> elements = annotation.getAnnotationElementsList();
                for (Element element : elements) {
                    if (!element.getNamespaceURI().equals("http://www.async.ece.utah.edu/iBioSim")) continue;
                    if (element.getName().equals(name)) {
                        if (element.getAttributeValue(attribute)!=null) {
                            return element.getAttributeValue(attribute);
                        } else {
                            return defaultValue;
                        }
                    }
                }
            }
            return defaultValue;
        }
        

        I’m also still getting this warning, not sure why:

        17:04:23 [AWT-EventQueue-0] WARN org.jlibsedml.SEDMLReader - Unexpected [Element: <annotation [namespace:="" <a="" href="http://sed-ml.org/sed-ml/level1/version2">http://sed-ml.org/sed-ml/level1/version2]/>]</annotation>
        17:04:23 [AWT-EventQueue-0] WARN org.jlibsedml.SEDMLReader - Unexpected [Element: <annotation [namespace:="" <a="" href="http://sed-ml.org/sed-ml/level1/version2">http://sed-ml.org/sed-ml/level1/version2]/>]</annotation>

        On Aug 4, 2016, at 4:46 PM, Chris Myers ccmyers@users.sf.net wrote:

        Here is the getSEDBaseAnnotation method I wrote.
        public static String getSEDBaseAnnotation(SEDBase sedBase, String name, String attribute, String defaultValue)
        {
        List<annotation> annotations = sedBase.getAnnotation();
        for (int i = 0; i < annotations.size(); i++)
        {
        Annotation annotation = annotations.get(i);
        List<element> elements = annotation.getAnnotationElementsList();
        for (Element element : elements) {
        if (!element.getNamespaceURI().equals("http://www.async.ece.utah.edu/iBioSim")) continue;
        if (element.getName().equals(name)) {
        if (element.getAttributeValue(attribute)!=null) {
        return element.getAttributeValue(attribute);
        } else {
        return defaultValue;
        }
        }
        }
        }
        return defaultValue;
        }
        On Aug 3, 2016, at 2:59 PM, Richard Adams otter606@users.sf.net otter606@users.sf.net wrote:</element></annotation>

        I've committed in some improved methods to set Annotation, to add top-level elements and also an AnnotationValidator that will complain if you add > 1 top level element with same namespace, as per the SBML spec's recommendations. Please Can you add your attachment here in a comment so I can have a look and see what else you were looking to do?
        Thanks Richard

        [feature-requests:#26] Improve Annotation handling

        Status: open
        Group: 2.3
        Created: Wed Jul 13, 2016 08:50 PM UTC by Richard Adams
        Last Updated: Wed Jul 13, 2016 08:51 PM UTC
        Owner: nobody

        Suggested by Chris Myers:

        The getAnnotation method returns a list of Annotations even though there is only one Annotation on each object. This function is marked as deprecated, so I suspect that you know this, but I cannot find a replacement.
        I assume addAnnotation should also be deprecated and setAnnotation should take a single item. It would also be nice to have some functions to help build and parse annotations. See getSEDBaseAnnotation in the attached as an example.

        Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/jlibsedml/feature-requests/26/ https://sourceforge.net/p/jlibsedml/feature-requests/26/ https://sourceforge.net/p/jlibsedml/feature-requests/26/ https://sourceforge.net/p/jlibsedml/feature-requests/26/
        To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/ https://sourceforge.net/auth/subscriptions/ https://sourceforge.net/auth/subscriptions/ https://sourceforge.net/auth/subscriptions/
        [feature-requests:#26] Improve Annotation handling

        Status: accepted
        Group: 2.3
        Created: Wed Jul 13, 2016 08:50 PM UTC by Richard Adams
        Last Updated: Wed Aug 03, 2016 09:00 PM UTC
        Owner: Richard Adams

        Suggested by Chris Myers:

        The getAnnotation method returns a list of Annotations even though there is only one Annotation on each object. This function is marked as deprecated, so I suspect that you know this, but I cannot find a replacement.
        I assume addAnnotation should also be deprecated and setAnnotation should take a single item. It would also be nice to have some functions to help build and parse annotations. See getSEDBaseAnnotation in the attached as an example.

        Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/jlibsedml/feature-requests/26/ https://sourceforge.net/p/jlibsedml/feature-requests/26/
        To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/ https://sourceforge.net/auth/subscriptions/

         
  • Richard Adams

    Richard Adams - 2016-08-03
    • status: open --> accepted
    • assigned_to: Richard Adams
     
MongoDB Logo MongoDB