Package org.sbml.jsbml

Examples of org.sbml.jsbml.Model


  public static void main(String args[]) {
    SBMLDocument doc = new SBMLDocument(2, 4);
    doc.setNotes("<body>Senseless test commentar</body>");

    Model m = doc.createModel("model");

    CVTerm term = new CVTerm();
    term.setQualifierType(Type.MODEL_QUALIFIER);
    term.setModelQualifierType(Qualifier.BQM_IS);
    term.addResource("urn:miriam:kegg.pathway:hsa00010");
    m.addCVTerm(term);

    History history = new History();
    Creator creator = new Creator();
    creator.setFamilyName("Dr\u00e4ger");
    creator.setGivenName("Andreas");
    creator.setEmail("andreas.draeger@uni-tuebingen.de");
    creator.setOrganization("Universit\u00e4t T\u00fcbingen");
    history.addCreator(creator);
    history.setCreatedDate(Calendar.getInstance().getTime());
    history.addModifiedDate(Calendar.getInstance().getTime());
    m.setHistory(history);

    m
        .setNotes("<body>A senseless test model with a senseless notes element.</body>");

    m.getUnitDefinition("substance").getUnit(0).setScale(-3);

    try {
      new SBMLWriter().write(doc, new BufferedOutputStream(System.out),
          "SBMLWriterTest", "");
    } catch (XMLStreamException e) {
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(
        new ASTNode(5.3, fd), ASTNode.log(new ASTNode(8, fd))));
    pieces = ASTNode.times(pieces, ASTNode.root(new ASTNode(2, fd),
        new ASTNode(16, fd)));
    math.addChild(pieces);
    fd.setMath(math);
    System.out.println(math.toMathML());
   
    Species species = m.createSpecies("spec");
    Reaction r = m.createReaction("r");
    r.addReactant(new SpeciesReference(species));
    KineticLaw kl = new KineticLaw(level, version);
    math = new ASTNode(fd, kl);
    math.addChild(new ASTNode(species, kl));
    math = ASTNode.times(math, new ASTNode(3.7, 8, kl));
View Full Code Here

    // 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();
      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);
View Full Code Here

  @Test public void read1() throws XMLStreamException, InvalidPropertiesFormatException, IOException, ClassNotFoundException {
    // URL fileUrl = this.getClass().getResource("./data/BIOMD0000000025.xml");
    String fileName = DATA_FOLDER + "/l2v1/BIOMD0000000025.xml";
   
    SBMLDocument doc = new SBMLReader().readSBMLFile(fileName);
    Model model = doc.getModel();
   
    assertTrue(doc.getLevel() == 2 && doc.getVersion() == 1);
   
    // TODO : assertTrue(model.getLevel() == 2 && model.getVersion() == 1);
   
    assertTrue(model.getId().equals("Smolen2002"));
    assertTrue(model.getName().equals("Smolen2002_CircClock"));
   
    /*
     * <dcterms:created rdf:parseType="Resource">
          <dcterms:W3CDTF>2005-06-29T11:01:49Z</dcterms:W3CDTF>
        </dcterms:created>
        <dcterms:modified rdf:parseType="Resource">
          <dcterms:W3CDTF>2008-08-21T11:47:14Z</dcterms:W3CDTF>
        </dcterms:modified>
     *
     */
    // System.out.println("Created on  : " + model.getHistory().getCreatedDate());
    // System.out.println("Modified on : " + model.getHistory().getModifiedDate());
   
    // asserTrue(model.getHistory().getCreatedDate());
   
    assertTrue(model.getUnitDefinition("substance").getName().equals("nanomole (new default)"));
   
    Species dClk = model.getSpecies("dClk");
   
    assertTrue(dClk.getCompartment().equals("CELL"));
    dClk.unsetCompartment();
    assertTrue(dClk.getCompartment().length() == 0);
   
    assertTrue(dClk != null);
   
    assertTrue(dClk.getName().length() == 0);
    assertTrue(dClk.getNumCVTerms() == 1);
   
    assertTrue(dClk.getInitialAmount() == Double.parseDouble("1e-16"));
   
    Species dClkF = model.getSpecies("dClkF");
   
    assertTrue(dClkF != null);
   
    assertTrue(dClkF.getName().equals("free dClk"));
   
    Reaction rdClk = model.getReaction("rdClk");
   
    assertTrue(rdClk != null);
   
    assertTrue(rdClk.getName().equals("dClk production"));
    assertTrue(rdClk.getMetaId().equals("metaid_0000012"));
    assertTrue(rdClk.getListOfReactants().size() == 1);
    assertTrue(rdClk.getListOfProducts().size() == 1);
    assertTrue(rdClk.getListOfModifiers().size() == 1);
   
    assertTrue(rdClk.getListOfReactants().get(0).getSpecies().equals("EmptySet"));
    assertTrue(rdClk.getListOfProducts().get(0).getSpecies().equals("dClk"));
    assertTrue(rdClk.getListOfModifiers().get(0).getSpecies().equals("dClkF"));
   
    KineticLaw rdClkKL = rdClk.getKineticLaw();
   
    assertTrue(rdClkKL.getListOfParameters().size() == 3);
    assertTrue(rdClkKL.getListOfParameters().get(2).getId().equals("parameter_0000009"));
    assertTrue(rdClkKL.getListOfParameters().get(2).getName().equals("tau2"));
    assertTrue(rdClkKL.getListOfParameters().get(2).getValue() == 10);
   
    Event event = model.getEvent(0);
   
    assertTrue(event.getMetaId().equals("metaid_0000015"));
    assertTrue(event.getNumEventAssignments() == 1);
    assertTrue(event.getEventAssignment(0).getVariable().equals("dClkF"));
   
View Full Code Here

   */
  @Test public void read3() throws XMLStreamException, InvalidPropertiesFormatException, IOException, ClassNotFoundException {
    String fileName = DATA_FOLDER + "/l2v4/BIOMD0000000228.xml"; // l2v4
   
    SBMLDocument doc = new SBMLReader().readSBMLFile(fileName);
    Model model = doc.getModel();
   
    assertTrue(doc.getLevel() == 2 && doc.getVersion() == 4);
   
    assertTrue(model.getId().equals(""));
    assertTrue(model.getName().equals("Swat2004_Mammalian_G1_S_Transition"));

    Compartment cell = model.getCompartment(0);
   
    assertTrue(cell.getSize() == 1);
   
    assertTrue(model.getListOfUnitDefinitions().size() == 3);   
    assertTrue(model.getListOfUnitDefinitions().get(1).getMetaId().equals("metaid_0000004"));
   
    Species pRBp = model.getSpecies("pRBp");
    pRBp.setHasOnlySubstanceUnits(false);
   
    assertTrue(pRBp != null);
    System.out.println("pRBp notes : " + pRBp.getNotesString()); // namespace lost, should probably here.

    // TODO : add more complex test for Notes !! assertTrue(pRBp.getNotesString().contains(JSBML.URI_XHTML_DEFINITION));

    System.out.println("pRBp annotation : " + pRBp.getAnnotation().getNonRDFannotation());
    System.out.println("pRBp annotation : " + pRBp.getCVTerm(0).toString());
   
    assertTrue(model.getListOfParameters().size() == 40);
   
    //org.sbml.libsbml.SBMLReader libSBMlReader = new org.sbml.libsbml.SBMLReader();
    //org.sbml.libsbml.SBMLDocument libsbmlDoc = libSBMlReader.readSBML(fileName);
    //org.sbml.jsbml.xml.libsbml.SBMLReader libSBMLAdapterReader = new  org.sbml.jsbml.xml.libsbml.LibSBMLReader();
   
    //Model libsbmlAdapterModel = libSBMLAdapterReader.readModel(libsbmlDoc.getModel());
   
    // System.out.println("nb global parameters = " + libsbmlDoc.getModel().getNumParameters());
   
    Parameter J18 = model.getParameter("J18");
   
    assertTrue(J18 != null);
    assertTrue(J18.getValue() == 0.6);
   
    Reaction pRB_synthesis = model.getReaction("pRB_synthesis");
   
    assertTrue(pRB_synthesis != null);
    System.out.println("pRB_synthesis additional annotation : " + pRB_synthesis.getAnnotation().getNonRDFannotation());

    assertTrue(pRB_synthesis.getAnnotation().getNonRDFannotation().trim().startsWith("<jigcell:ratelaw jigcell:name=\"Local\""));
View Full Code Here

  @SuppressWarnings("deprecation")
  @Test public void readL1V2Branch() throws XMLStreamException, InvalidPropertiesFormatException, IOException, ClassNotFoundException {
    String fileName = DATA_FOLDER + "/libsbml-test-data/l1v2-branch.xml";
   
    SBMLDocument doc = new SBMLReader().readSBMLFile(fileName);
    Model model = doc.getModel();
   
    assertTrue(doc.getLevel() == 1 && doc.getVersion() == 2);
   
    assertTrue(model.getLevel() == 1 && model.getVersion() == 2);
   
    // assertTrue(model.getId().equals("")); // TODO : document. Different behavior than libsbml, we set the id as the name for SBML level 1 models.
    assertTrue(model.getId().equals("Branch"));
    assertTrue(model.getName().equals("Branch"));
   
    Species s1 = model.getSpecies("S1");
   
    assertTrue(s1 != null);
   
    assertTrue(s1.getName().equals("S1"));
    assertTrue(s1.getId().equals("S1")); // changed, was assertTrue(s1.getId().equals("")); cf comment above.
    assertTrue(s1.getNumCVTerms() == 0);
   
    assertTrue(s1.getInitialAmount() == 0);
    assertTrue(s1.getBoundaryCondition() == false);
   
    Species x1 = model.getSpecies("X1");
   
    assertTrue(x1 != null);
   
    assertTrue(x1.getName().equals("X1"));
    assertTrue(x1.getInitialAmount() == 0);
    assertTrue(x1.getBoundaryCondition() == true);
   
   
    Reaction r1 = model.getReaction(0);
   
    assertTrue(r1 != null);
   
    assertTrue(r1.getName().equals("reaction_1"));
    assertTrue(r1.getListOfReactants().size() == 1);
View Full Code Here

    }
  }

  private SBMLDocument createDefaultDocument() {
    SBMLDocument doc = new SBMLDocument(2, 4);
    Model m = doc.createModel("untitled");
    m.createSpecies("s1");
    return doc;
  }
View Full Code Here

          listOfElementsToWrite = new ArrayList<Object>();
          listOfElementsToWrite.add(sbmlDocument.getModel());
        }
      } else if (sbase instanceof Model) {

        Model model = (Model) sbase;
        listOfElementsToWrite = new ArrayList<Object>();
        if (model.isSetListOfFunctionDefinitions()) {
          listOfElementsToWrite.add(model
              .getListOfFunctionDefinitions());
        }
        if (model.isSetListOfUnitDefinitions()) {
          listOfElementsToWrite.add(model.getListOfUnitDefinitions());
        }
        if (model.isSetListOfCompartmentTypes()) {
          listOfElementsToWrite
              .add(model.getListOfCompartmentTypes());
        }
        if (model.isSetListOfSpeciesTypes()) {
          listOfElementsToWrite.add(model.getListOfSpeciesTypes());
        }
        if (model.isSetListOfCompartments()) {
          listOfElementsToWrite.add(model.getListOfCompartments());
        }
        if (model.isSetListOfSpecies()) {
          listOfElementsToWrite.add(model.getListOfSpecies());
        }
        if (model.isSetListOfParameters()) {
          listOfElementsToWrite.add(model.getListOfParameters());
        }
        if (model.isSetListOfInitialAssignments()) {
          listOfElementsToWrite.add(model
              .getListOfInitialAssignments());
        }
        if (model.isSetListOfRules()) {
          listOfElementsToWrite.add(model.getListOfRules());
        }
        if (model.isSetListOfConstraints()) {
          listOfElementsToWrite.add(model.getListOfConstraints());
        }
        if (model.isSetListOfReactions()) {
          listOfElementsToWrite.add(model.getListOfReactions());
        }
        if (model.isSetListOfEvents()) {
          listOfElementsToWrite.add(model.getListOfEvents());
        }

        if (listOfElementsToWrite.isEmpty()) {
          listOfElementsToWrite = null;
        }
View Full Code Here

   *
   * @param doc
   */
  private void showGUI(SBMLDocument doc) {
    if (doc.isSetModel()) {
      Model m = doc.getModel();
      String title = "Content of model \"";
      if (m.isSetName()) {
        title += m.getName();
      } else if (m.isSetId()) {
        title += m.getId();
      } else {
        title += "undefined";
      }
      setTitle(title + "\"");
    } else {
View Full Code Here

TOP

Related Classes of org.sbml.jsbml.Model

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.