Package org.sbml.jsbml

Examples of org.sbml.jsbml.Annotation


   
    // an AnnotationParser can only be used for the annotations of a SBML
    // component. If the contextObject is not
    // an Annotation instance, this parser doesn't process any elements.
    if (contextObject instanceof Annotation) {
      Annotation annotation = (Annotation) contextObject;
      StringBuilder builder = annotation.getAnnotationBuilder();

      // If the element is nested, we need to remove the default ending
      // tag of the element.
      if (isNested && annotation.getNonRDFannotation().endsWith(">")) {
        int builderLength = builder.length();
        builder.delete(builderLength - 3, builderLength);
      }

      // If the element is nested, we need to add a nested element ending
      // tag.
      if (isNested) {
        annotation.appendNoRDFAnnotation("/>");
      }
      // else, write a entire ending tag with the name of the element
      // (Store the prefix too into the String).
      else {
        if (!prefix.equals("")) {
          annotation.appendNoRDFAnnotation("</" + prefix + ":"
              + elementName + ">");
        } else {
          annotation.appendNoRDFAnnotation("</" + elementName
              + ">");
        }
      }
    } else {
      // There is a syntax error, the node can't be read?
View Full Code Here


    // If the element is an annotation and the contextObject is an
    // Annotation instance,
    // we need to add the namespace to the 'annotationNamespaces' HashMap of
    // annotation.
    if (contextObject instanceof Annotation) {
      Annotation annotation = (Annotation) contextObject;

      if (prefix.trim().length() == 0) {
        annotation.appendNoRDFAnnotation(" " + localName + "=\"" + URI + "\"");
      } else {
        annotation.appendNoRDFAnnotation(" " + prefix + ":" + localName + "=\"" + URI + "\"");
      }
      annotation.appendNoRDFAnnotation("");
     
     
      // If the attribute is the last attribute of its element, we need to
      // close the element tag.
      if (isLastNamespace && !hasAttributes) {
        annotation.appendNoRDFAnnotation(">");
      }
    }
    // If the namespaces are declared in the sbml node, we need to add the
    // namespace to
    // the 'SBMLDocumentNamespaces' map of the SBMLDocument instance.
View Full Code Here

    // an AnnotationParser can only be used for the annotations of a SBML
    // component. If the contextObject is not
    // an Annotation instance, this parser doesn't process any elements.
    if (contextObject instanceof Annotation) {

      Annotation annotation = (Annotation) contextObject;

      // If there is a prefix, the AnnotationParser will also store the
      // prefix within the key
      // and appends the element to the 'otherAnnotation' String of
      // annotation.
      if (!prefix.equals("")) {
        annotation.appendNoRDFAnnotation("<" + prefix + ":"
            + elementName);
      } else {
        annotation.appendNoRDFAnnotation("<" + elementName);
      }

      // If the element has no attributes and namespaces, we need to close
      // the element tag.
      if (!hasAttributes && !hasNamespaces) {
        annotation.appendNoRDFAnnotation(">");
      }
      return annotation;
    } else {
      // There is a syntax error, the node can't be read ?
      logger.error(String.format("Cannot read the element %s as the context object is not of the type Annotation", elementName));
View Full Code Here

            value);
      } catch (Throwable exc) {
        System.err.println(exc.getMessage());
      }
    } else if (contextObject instanceof Annotation) {
      Annotation annotation = (Annotation) contextObject;
      isAttributeRead = annotation.readAttribute(attributeName, prefix,
          value);
    }

    if (!isAttributeRead) {
      // TODO : throw new SBMLException ("The attribute " + attributeName
View Full Code Here

          SBase sbase = (SBase) contextObject;
          sbase.setNotes(new XMLNode(new XMLTriple("notes", null, null), new XMLAttributes()));
        } else if (elementName.equals("annotation")
            && contextObject instanceof SBase) {
          SBase sbase = (SBase) contextObject;
          Annotation annotation = (Annotation) newContextObject;
          sbase.setAnnotation(annotation);

          return annotation;
        } else if (contextObject instanceof SBMLDocument) {
          SBMLDocument sbmlDocument = (SBMLDocument) contextObject;
View Full Code Here

      Model m = doc.createModel("model1");
      Model m2 = new Model("model1", 2, 4);
     
      Species s1 = m.createSpecies("id1");
     
      Annotation annotation = new Annotation();
      CVTerm cvterm = new CVTerm();
      cvterm.addResource("urn.miriam.obo.go#GO%3A1234567");
      cvterm.setQualifierType(Type.BIOLOGICAL_QUALIFIER);
      cvterm.setBiologicalQualifierType(Qualifier.BQB_IS);
     
      annotation.addCVTerm(cvterm);
     
      System.out.println("The Annotation is still empty as there is no metaid defined on the species !!");
      System.out.println("@" + s1.getAnnotationString() + "@");
     
      s1.setMetaId("meta4");
      s1.setAnnotation(annotation);
     
      System.out.println("After adding a metaid on the species, the Annotation String get generated as it should.");
      System.out.println("@" + s1.getAnnotationString() + "@");
     


      String urn_id = "C00001";
     
      Species specie = m2.createSpecies();
      specie.setId("S2");
      specie.setName("S2");
      // specie.setCompartment(compartment);
      specie.setInitialAmount(1);

      annotation = new Annotation();
      CVTerm cvTerm = new CVTerm(Qualifier.BQB_IS);
      cvTerm.setQualifierType(Type.BIOLOGICAL_QUALIFIER);
     
      if(urn_id.startsWith("C"))
      {
      cvTerm.addResource("urn:miriam:kegg.compound:" + urn_id);
      annotation.addCVTerm(cvTerm);
      annotation.appendNoRDFAnnotation("http://www.genome.jp/dbget-bin/www_bget?cpd:"+urn_id);
      }
     
      if(urn_id.startsWith("G"))
      {
      cvTerm.addResource("urn:miriam:kegg.glycan:" + urn_id);
      annotation.addCVTerm(cvTerm);
      annotation.appendNoRDFAnnotation("<myApp:xxx>http://www.genome.jp/dbget-bin/www_bget?gl:"+urn_id + "</myApp:xxx>");
      }
     
      if (urn_id.contains("."))
      {
      cvTerm.addResource("urn:miriam:ec-code:" + urn_id);
      annotation.addCVTerm(cvTerm);
      annotation.appendNoRDFAnnotation("http://www.genome.jp/dbget-bin/www_bget?ec:"+urn_id);
      }

      System.out.println("The Annotation is still empty as there is no metaid defined on the species !!");
      System.out.println("@" + specie.getAnnotationString() + "@");
View Full Code Here

    // The namespace of this parser should be declared in a 'RDF' subnode of
    // annotation.
    // Adds the namespace to RDFAnnotationNamespaces HashMap of annotation.
    if (elementName.equals("RDF") && contextObject instanceof Annotation) {
      Annotation annotation = (Annotation) contextObject;

      annotation.addRDFAnnotationNamespace(localName, prefix, URI);
    }
  }
View Full Code Here

    // The namespace of this parser should be declared in the RDF subnode of
    // the annotation.
    // Adds the namespace to the RDFAnnotationNamespaces HashMap of
    // annotation.
    if (elementName.equals("RDF") && contextObject instanceof Annotation) {
      Annotation annotation = (Annotation) contextObject;

      annotation.addRDFAnnotationNamespace(localName, prefix, URI);
    }
  }
View Full Code Here

    // A BiologicalQualifierParser can only modify a contextObject which is
    // an instance of Annotation.
    // That will probably change in SBML level 3 with the Annotation package
    if (contextObject instanceof Annotation) {
      Annotation annotation = (Annotation) contextObject;

      // This parser can parse only biological Miriam qualifiers. This
      // element should not have attributes or namespace declarations.
      // Creates a new CVTerm and
      // sets the qualifierType and biologicalQualifierType of this
      // CVTerm. Then, adds the
      // initialized CVTerm to annotation.
      if (biologicalQualifierMap.containsKey(elementName)
          && !hasAttributes && !hasNamespaces) {
        CVTerm cvTerm = new CVTerm();
        cvTerm.setQualifierType(Type.BIOLOGICAL_QUALIFIER);
        cvTerm.setBiologicalQualifierType(biologicalQualifierMap
            .get(elementName));

        annotation.addCVTerm(cvTerm);
        return cvTerm;
      } else {
        // TODO : SBML syntax error, log an error
      }
    } else {
View Full Code Here

    // an AnnotationParser can only be used for the annotations of a SBML
    // component. If the contextObject is not
    // an Annotation instance, this parser doesn't process any XML
    // attributes.
    if (contextObject instanceof Annotation) {
      Annotation annotation = (Annotation) contextObject;

      // If there is a prefix, the AnnotationParser will also store the
      // prefix within the key
      // and appends the attribute to the 'otherAnnotation' String of
      // annotation.
      if (!prefix.equals("")) {
        annotation.appendNoRDFAnnotation(" " + prefix + ":"
            + attributeName + "=\"" + value + "\"");
      } else {
        annotation.appendNoRDFAnnotation(" " + attributeName + "=\""
            + value + "\"");
      }

      // If the attribute is the last attribute of its element, we need to
      // close the element tag.
      if (isLastAttribute) {
        annotation.appendNoRDFAnnotation(">");
      }
    } else {
      // There is a syntax error, the attribute can't be read?
      // TODO : log the problem
    }
View Full Code Here

TOP

Related Classes of org.sbml.jsbml.Annotation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.