Package org.sbml.jsbml

Examples of org.sbml.jsbml.SBMLDocument


   * Tries to validate biomodels file with id 228.
   */
  @Test public void checkConsistency228() throws IOException, XMLStreamException {
    String fileName = DATA_FOLDER + "/l2v4/BIOMD0000000228.xml";
   
    SBMLDocument doc = new SBMLReader().readSBML(fileName);
    try {
      int nbErrors = doc.checkConsistency();

      System.out.println("Found " + nbErrors + " errors on Biomodels 228 with the unit checking turned off.");

    } catch (Exception e) {
      e.printStackTrace();
View Full Code Here


   * Tries to validate biomodels file with id 228.
   */
  @Test public void checkConsistency025() throws IOException, XMLStreamException {
    String fileName = DATA_FOLDER + "/l2v1/BIOMD0000000025.xml";
   
    SBMLDocument doc = new SBMLReader().readSBML(fileName);
    try {
      int nbErrors = doc.checkConsistency();

      System.out.println("Found " + nbErrors + " errors on Biomodels 025 with the unit checking turned off.");

    } catch (Exception e) {
      e.printStackTrace();
View Full Code Here

      System.exit(1);
    }

    String filename       = args[0];
    SBMLReader reader     = new SBMLReader();
    SBMLDocument document;
    long start, stop;

    start    = System.currentTimeMillis();
    document = reader.readSBML(filename);
    stop     = System.currentTimeMillis();

    if (document.getNumErrors() > 0)
    {
      print("Encountered the following errors while reading the SBML file:\n");
      document.printErrors();
      print("\nFurther consistency checking and validation aborted.\n");
      System.exit(1);
    }
    else
    {
      long errors = document.checkConsistency();
      long size   = new File(filename).length();

      println("            filename: " + filename);
      println("           file size: " + size);
      println("      read time (ms): " + (stop - start));
      println(" validation error(s): " + errors);

      if (errors > 0)
      {
        document.printErrors();
        System.exit(1);
      }
    }
  }
View Full Code Here

  @SuppressWarnings("unchecked")
  public ArrayList<Object> getListOfSBMLElementsToWrite(Object sbase) {
    ArrayList<Object> listOfElementsToWrite = null;
    if (sbase instanceof SBase) {
      if (sbase instanceof SBMLDocument) {
        SBMLDocument sbmlDocument = (SBMLDocument) sbase;
        if (sbmlDocument.isSetModel()) {
          listOfElementsToWrite = new ArrayList<Object>();
          listOfElementsToWrite.add(sbmlDocument.getModel());
        }
      } else if (sbase instanceof Model) {

        Model model = (Model) sbase;
        listOfElementsToWrite = new ArrayList<Object>();
View Full Code Here

  public void processNamespace(String elementName, String URI, String prefix,
      String localName, boolean hasAttributes, boolean isLastNamespace,
      Object contextObject) {

    if (contextObject instanceof SBMLDocument) {
      SBMLDocument sbmlDocument = (SBMLDocument) contextObject;
      if (!URI.equals(SBMLDocument.URI_NAMESPACE_L1)) {
        sbmlDocument.addNamespace(localName, prefix, URI);
      }
    }
  }
View Full Code Here

          Annotation annotation = (Annotation) newContextObject;
          sbase.setAnnotation(annotation);

          return annotation;
        } else if (contextObject instanceof SBMLDocument) {
          SBMLDocument sbmlDocument = (SBMLDocument) contextObject;
          if (elementName.equals("model")) {
            Model model = (Model) newContextObject;
            model.setParentSBML(sbmlDocument);
            sbmlDocument.setModel(model);

            return model;
          }
        } else if (contextObject instanceof Model) {
View Full Code Here

      Object sbmlElementToWrite) {
    if (sbmlElementToWrite instanceof SBase) {
      SBase sbase = (SBase) sbmlElementToWrite;

      if (sbase instanceof SBMLDocument) {
        SBMLDocument sbmlDocument = (SBMLDocument) sbmlElementToWrite;

        xmlObject.addAttributes(sbmlDocument
            .getSBMLDocumentNamespaces());
      }

      xmlObject.setPrefix("");
    }
View Full Code Here

  /**
   * @throws ParseException
   *
   */
  @Test public void checkHashCode() throws ParseException {
    SBMLDocument doc1 = new SBMLDocument(3, 1);
    Model model = doc1.createModel("test_model");
    Compartment c = model.createCompartment("c1");
    Species s = model.createSpecies("s1", c);
    s.addCVTerm(new CVTerm(CVTerm.Qualifier.BQB_IS, "urn:miriam:kegg.compound:C00001"));
    Rule r = model.createAlgebraicRule();
    r.setMath(ASTNode.parseFormula("sin(3) + 1"));
   
    SBMLDocument doc2 = doc1.clone();
    assertTrue(doc1.hashCode() == doc2.hashCode());
    assertTrue(model.hashCode() != doc2.hashCode());
    assertTrue(s.getCVTerm(0).equals(new CVTerm(CVTerm.Qualifier.BQB_IS, "urn:miriam:kegg.compound:C00001")));
    assertTrue(s.getCVTerm(0).hashCode() == (new CVTerm(CVTerm.Qualifier.BQB_IS, "urn:miriam:kegg.compound:C00001")).hashCode());
    assertTrue(doc1.equals(doc2));
    assertTrue(doc2.equals(doc1));
  }
View Full Code Here

   *
   */
  public MathMLTest() {
    int level = 3;
    int version = 1;
    SBMLDocument doc = new SBMLDocument(level, 1);
    Model m = doc.createModel("id");
    FunctionDefinition fd = m.createFunctionDefinition("fd");
    ASTNode math = new ASTNode(Type.LAMBDA, fd);
    math.addChild(new ASTNode("x", fd));
    ASTNode pieces = ASTNode.piecewise(new ASTNode(3, fd), ASTNode.lt("x",
        ASTNode.abs(Double.NEGATIVE_INFINITY, fd)), ASTNode.times(
View Full Code Here

   
    // TODO : transform this file into a proper junit test class that is included in the jsbml standard tests.
    // The junit test file would test the Annotation class methods. 
     
    // Setup : creating some simple objects
      SBMLDocument doc = new SBMLDocument(2,4);

      Model m = doc.createModel("model1");
      Model m2 = new Model("model1", 2, 4);
     
      Species s1 = m.createSpecies("id1");
     
      Annotation annotation = new Annotation();
View Full Code Here

TOP

Related Classes of org.sbml.jsbml.SBMLDocument

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.