Package org.sbml.jsbml

Examples of org.sbml.jsbml.KineticLaw


    assertTrue(r1.getReversible() == false);
   
    assertTrue(r1.getListOfReactants().get(0).getSpecies().equals("X0"));
    assertTrue(r1.getListOfProducts().get(0).getSpecies().equals("S1"));
   
    KineticLaw rdClkKL = r1.getKineticLaw();

    assertTrue(rdClkKL != null);
    assertTrue(rdClkKL.getListOfLocalParameters().size() == 1);
    assertTrue(rdClkKL.getListOfLocalParameters().get(0).getName().equals("k1"));
   
    System.out.println("L1V2 formula = " + rdClkKL.getFormula());
  }
View Full Code Here


        if (listOfElementsToWrite.isEmpty()) {
          listOfElementsToWrite = null;
        }
      } else if (sbase instanceof KineticLaw) {
        KineticLaw kineticLaw = (KineticLaw) sbase;

        if (kineticLaw.isSetListOfParameters()) {
          listOfElementsToWrite = new ArrayList<Object>();
          listOfElementsToWrite.add(kineticLaw.getListOfParameters());
        }
      }
    }
    return listOfElementsToWrite;
  }
View Full Code Here

              setSpeciesReferenceSpecies(
                  modifierSpeciesReference, model);
            }
          }
          if (reaction.isSetKineticLaw()) {
            KineticLaw kineticLaw = reaction.getKineticLaw();
            if (kineticLaw.isSetListOfParameters()) {
              for (int j = 0; j < kineticLaw.getNumParameters(); j++) {
                LocalParameter parameter = kineticLaw
                    .getParameter(j);

                setParameterUnits(parameter, model);
              }
            }
View Full Code Here

              }
            } else {
              // TODO : SBML syntax error, throw an exception?
            }
          } else if (list.getParentSBMLObject() instanceof KineticLaw) {
            KineticLaw kineticLaw = (KineticLaw) list
                .getParentSBMLObject();

            if (elementName.equals("parameter")
                && list.getSBaseListType().equals(
                    ListOf.Type.listOfParameters)) {
              LocalParameter localParameter = (LocalParameter) newContextObject;
              kineticLaw.addParameter(localParameter);

              return localParameter;
            } else {
              // TODO : SBML syntax error, throw an exception?
            }
          } else {
            // TODO : SBML syntax error, throw an exception?
          }
        } else if (contextObject instanceof UnitDefinition) {
          UnitDefinition unitDefinition = (UnitDefinition) contextObject;

          if (elementName.equals("listOfUnits")) {
            ListOf<Unit> listOfUnits = (ListOf<Unit>) newContextObject;
            unitDefinition.setListOfUnits(listOfUnits);

            return listOfUnits;
          }
        } else if (contextObject instanceof Reaction) {
          Reaction reaction = (Reaction) contextObject;

          if (elementName.equals("listOfReactants")) {
            ListOf listOfReactants = (ListOf) newContextObject;
            reaction.setListOfReactants(listOfReactants);
            listOfReactants
                .setSBaseListType(ListOf.Type.listOfReactants);

            return listOfReactants;
          } else if (elementName.equals("listOfProducts")) {
            ListOf listOfProducts = (ListOf) newContextObject;
            reaction.setListOfProducts(listOfProducts);
            listOfProducts
                .setSBaseListType(ListOf.Type.listOfProducts);

            return listOfProducts;
          } else if (elementName.equals("kineticLaw")) {
            KineticLaw kineticLaw = (KineticLaw) newContextObject;
            reaction.setKineticLaw(kineticLaw);

            return kineticLaw;
          } else {
            // TODO : SBML syntax error, throw an exception?
          }
        } else if (contextObject instanceof KineticLaw) {
          KineticLaw kineticLaw = (KineticLaw) contextObject;

          if (elementName.equals("listOfParameters")) {
            ListOf listOfLocalParameters = (ListOf) newContextObject;
            kineticLaw
                .setListOfLocalParameters(listOfLocalParameters);
            listOfLocalParameters
                .setSBaseListType(ListOf.Type.listOfParameters);

            return listOfLocalParameters;
View Full Code Here

    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));
    kl.setMath(math);
    r.setKineticLaw(kl);
   
    System.out.println(math.toMathML());

    try {
View Full Code Here

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

              return modifierSpeciesReference;
            } else {
              log4jLogger.warn("The element " + elementName + " is not recognized");
            }
          } else if (list.getParentSBMLObject() instanceof KineticLaw) {
            KineticLaw kineticLaw = (KineticLaw) list
                .getParentSBMLObject();
            // Level 3 : parameter and listOfParameters =>
            // localParameter and listOfLocalParameter
            if (elementName.equals("localParameter")
                && list.getSBaseListType().equals(
                    ListOf.Type.listOfLocalParameters)
                && kineticLaw.getLevel() >= 3) {
              LocalParameter localParameter = (LocalParameter) newContextObject;
              kineticLaw.addParameter(localParameter);

              return localParameter;
            } else if (elementName.equals("parameter")
                && list.getSBaseListType().equals(
                    ListOf.Type.listOfLocalParameters)
                && kineticLaw.isSetLevel()
                && kineticLaw.getLevel() < 3) {
              LocalParameter localParameter = new LocalParameter(
                  (Parameter) newContextObject);
              kineticLaw.addParameter(localParameter);

              return localParameter;
            } else {
              log4jLogger.warn("The element " + elementName + " is not recognized");
            }
          } else if (list.getParentSBMLObject() instanceof Event) {
            Event event = (Event) list.getParentSBMLObject();

            if (elementName.equals("eventAssignment")
                && list.getSBaseListType().equals(
                    ListOf.Type.listOfEventAssignments)
                && event.getLevel() > 1) {
              EventAssignment eventAssignment = (EventAssignment) newContextObject;
              event.addEventAssignment(eventAssignment);

              return eventAssignment;
            } else {
              log4jLogger.warn("The element " + elementName + " is not recognized");
            }
          } else {
            log4jLogger.warn("The element " + elementName + " is not recognized");
          }
        } else if (contextObject instanceof UnitDefinition) {
          UnitDefinition unitDefinition = (UnitDefinition) contextObject;

          if (elementName.equals("listOfUnits")) {
            ListOf<Unit> listOfUnits = (ListOf<Unit>) newContextObject;
            unitDefinition.setListOfUnits(listOfUnits);

            return listOfUnits;
          }
        } else if (contextObject instanceof Event) {
          Event event = (Event) contextObject;

          if (elementName.equals("listOfEventAssignments")) {
            ListOf<EventAssignment> listOfEventAssignments = (ListOf<EventAssignment>) newContextObject;
            event.setListOfEventAssignments(listOfEventAssignments);

            return listOfEventAssignments;
          } else if (elementName.equals("trigger")) {
            Trigger trigger = (Trigger) newContextObject;
            event.setTrigger(trigger);

            return trigger;
          } else if (elementName.equals("delay")) {
            Delay delay = (Delay) newContextObject;
            event.setDelay(delay);

            return delay;
          } else if (elementName.equals("priority")) {
            Priority priority = (Priority) newContextObject;
            event.setPriority(priority);

            return priority;
          } else {
            log4jLogger.warn("The element " + elementName + " is not recognized");
          }
        } else if (contextObject instanceof Reaction) {
          Reaction reaction = (Reaction) contextObject;
          if (elementName.equals("listOfReactants")) {
            ListOf<SpeciesReference> listOfReactants = (ListOf<SpeciesReference>) newContextObject;
            reaction.setListOfReactants(listOfReactants);

            return listOfReactants;
          } else if (elementName.equals("listOfProducts")) {
            ListOf<SpeciesReference> listOfProducts = (ListOf<SpeciesReference>) newContextObject;
            reaction.setListOfProducts(listOfProducts);

            return listOfProducts;
          } else if (elementName.equals("listOfModifiers")
              && reaction.getLevel() > 1) {
            ListOf<ModifierSpeciesReference> listOfModifiers = (ListOf<ModifierSpeciesReference>) newContextObject;
            reaction.setListOfModifiers(listOfModifiers);

            return listOfModifiers;
          } else if (elementName.equals("kineticLaw")) {
            KineticLaw kineticLaw = (KineticLaw) newContextObject;
            reaction.setKineticLaw(kineticLaw);

            return kineticLaw;
          } else {
            log4jLogger.warn("The element " + elementName + " is not recognized");
          }
        } else if (contextObject instanceof SpeciesReference) {
          SpeciesReference speciesReference = (SpeciesReference) contextObject;

          if (elementName.equals("stoichiometryMath")) {
            StoichiometryMath stoichiometryMath = (StoichiometryMath) newContextObject;
            speciesReference.setStoichiometryMath(stoichiometryMath);

            return stoichiometryMath;
          } else {
            log4jLogger.warn("The element " + elementName + " is not recognized");
          }
        } else if (contextObject instanceof KineticLaw) {
          KineticLaw kineticLaw = (KineticLaw) contextObject;

          if (elementName.equals("listOfLocalParameters")
              && kineticLaw.getLevel() >= 3) {
            ListOf<LocalParameter> listOfLocalParameters = (ListOf<LocalParameter>) newContextObject;
            kineticLaw.setListOfLocalParameters(listOfLocalParameters);
            listOfLocalParameters.setSBaseListType(ListOf.Type.listOfLocalParameters);

            return listOfLocalParameters;
          } else if (elementName.equals("listOfParameters")
              && kineticLaw.isSetLevel() && kineticLaw.getLevel() < 3) {
            ListOf<LocalParameter> listOfLocalParameters = (ListOf<LocalParameter>) newContextObject;
            kineticLaw.setListOfLocalParameters(listOfLocalParameters);
            listOfLocalParameters.setSBaseListType(ListOf.Type.listOfLocalParameters);

            return listOfLocalParameters;
          } else {
            log4jLogger.warn("The element " + elementName + " is not recognized");
View Full Code Here

    assertTrue(r1.getReversible() == false);
   
    assertTrue(r1.getListOfReactants().get(0).getSpecies().equals("X0"));
    assertTrue(r1.getListOfProducts().get(0).getSpecies().equals("S1"));
   
    KineticLaw rdClkKL = r1.getKineticLaw();

    assertTrue(rdClkKL != null);
    assertTrue(rdClkKL.getListOfLocalParameters().size() == 1);
    assertTrue(rdClkKL.getListOfLocalParameters().get(0).getName().equals("k1"));
   
    System.out.println("L1V2 formula = " + rdClkKL.getFormula());
  }
View Full Code Here

  @Test
  public void test_read_l1v1_branch() throws XMLStreamException, InvalidPropertiesFormatException, IOException, ClassNotFoundException {
    SBMLDocument d;
    Model m;
    Compartment c;
    KineticLaw kl;
    LocalParameter p;
    Reaction r;
    Species s;
    SpeciesReference sr;
    UnitDefinition ud;
    String filename = DATA_FOLDER + "/libsbml-test-data/l1v1-branch.xml";
    d = new SBMLReader().readSBML(filename);
    if (d == null)
      ;
    {
    }
    assertTrue(d.getLevel() == 1);
    assertTrue(d.getVersion() == 1);
    m = d.getModel();
    assertTrue(m.getName().equals("Branch"));
    assertTrue(m.getNumCompartments() == 1);
    c = m.getCompartment(0);
    assertTrue(c.getName().equals("compartmentOne"));
    assertTrue(c.getVolume() == 1);
    ud = c.getDerivedUnitDefinition();
    assertTrue(ud.getNumUnits() == 1);

    // assertTrue(ud.getUnit(0).getKind() == Unit.Kind.LITRE); // getDerivedUnitDefinition not working properly
    assertTrue(m.getNumSpecies() == 4);
    s = m.getSpecies(0);
    assertTrue(s.getName().equals("S1"));
    assertTrue(s.getCompartment().equals("compartmentOne"));
    assertTrue(s.getInitialAmount() == 0);
    assertTrue(s.getBoundaryCondition() == false);

    //    ud = s.getDerivedUnitDefinition(); // getDerivedUnitDefinition not working properly
//    assertTrue(ud.getNumUnits() == 2);
//    assertTrue(ud.getUnit(0).getKind() == Unit.Kind.MOLE);
//    assertTrue(ud.getUnit(0).getExponent() == 1);
//    assertTrue(ud.getUnit(1).getKind() == Unit.Kind.LITRE);
//    assertTrue(ud.getUnit(1).getExponent() == -1);
   
    s = m.getSpecies(1);
    assertTrue(s.getName().equals("X0"));
    assertTrue(s.getCompartment().equals("compartmentOne"));
    assertTrue(s.getInitialAmount() == 0);
    assertTrue(s.getBoundaryCondition() == true);
    s = m.getSpecies(2);
    assertTrue(s.getName().equals("X1"));
    assertTrue(s.getCompartment().equals("compartmentOne"));
    assertTrue(s.getInitialAmount() == 0);
    assertTrue(s.getBoundaryCondition() == true);
    s = m.getSpecies(3);
    assertTrue(s.getName().equals("X2"));
    assertTrue(s.getCompartment().equals("compartmentOne"));
    assertTrue(s.getInitialAmount() == 0);
    assertTrue(s.getBoundaryCondition() == true);
    assertTrue(m.getNumReactions() == 3);
    r = m.getReaction(0);
    assertTrue(r.getName().equals("reaction_1"));
    assertTrue(r.getReversible() == false);
    assertTrue(r.getFast() == false);
    ud = r.getKineticLaw().getDerivedUnitDefinition();

    //    assertTrue(ud.getNumUnits() == 2);
//    assertTrue(ud.getUnit(0).getKind() == Unit.Kind.MOLE);
//    assertTrue(ud.getUnit(0).getExponent() == 1);
//    assertTrue(ud.getUnit(1).getKind() == Unit.Kind.LITRE);
//    assertTrue(ud.getUnit(1).getExponent() == -1);
   
    assertTrue(r.getKineticLaw().containsUndeclaredUnits() == true);
    r = m.getReaction(1);
    assertTrue(r.getName().equals("reaction_2"));
    assertTrue(r.getReversible() == false);
    assertTrue(r.getFast() == false);
    r = m.getReaction(2);
    assertTrue(r.getName().equals("reaction_3"));
    assertTrue(r.getReversible() == false);
    assertTrue(r.getFast() == false);
    r = m.getReaction(0);
    assertTrue(r.getNumReactants() == 1);
    assertTrue(r.getNumProducts() == 1);
    sr = r.getReactant(0);
    assertTrue(sr.getSpecies().equals("X0"));
    assertTrue(sr.getStoichiometry() == 1);
    assertTrue(sr.getDenominator() == 1);
    sr = r.getProduct(0);
    assertTrue(sr.getSpecies().equals("S1"));
    assertTrue(sr.getStoichiometry() == 1);
    assertTrue(sr.getDenominator() == 1);
    kl = r.getKineticLaw();
    assertTrue(kl.getFormula().equals("k1*X0")); // We are not putting the same space in the formula
    assertTrue(kl.getNumParameters() == 1);
    p = kl.getParameter(0);
    assertTrue(p.getName().equals("k1"));
    assertTrue(p.getValue() == 0);
    r = m.getReaction(1);
    assertTrue(r.getNumReactants() == 1);
    assertTrue(r.getNumProducts() == 1);
    sr = r.getReactant(0);
    assertTrue(sr.getSpecies().equals("S1"));
    assertTrue(sr.getStoichiometry() == 1);
    assertTrue(sr.getDenominator() == 1);
    sr = r.getProduct(0);
    assertTrue(sr.getSpecies().equals("X1"));
    assertTrue(sr.getStoichiometry() == 1);
    assertTrue(sr.getDenominator() == 1);
    kl = r.getKineticLaw();
    assertTrue(kl.getFormula().equals("k2*S1")); // equals("k2 * S1")
    assertTrue(kl.getNumParameters() == 1);
    p = kl.getParameter(0);
    assertTrue(p.getName().equals("k2"));
    assertTrue(p.getValue() == 0);
    r = m.getReaction(2);
    assertTrue(r.getNumReactants() == 1);
    assertTrue(r.getNumProducts() == 1);
    sr = r.getReactant(0);
    assertTrue(sr.getSpecies().equals("S1"));
    assertTrue(sr.getStoichiometry() == 1);
    assertTrue(sr.getDenominator() == 1);
    sr = r.getProduct(0);
    assertTrue(sr.getSpecies().equals("X2"));
    assertTrue(sr.getStoichiometry() == 1);
    assertTrue(sr.getDenominator() == 1);
    kl = r.getKineticLaw();
    assertTrue(kl.getFormula().equals("k3*S1")); // equals("k3 * S1")
    assertTrue(kl.getNumParameters() == 1);
    p = kl.getParameter(0);
    assertTrue(p.getName().equals("k3"));
    assertTrue(p.getValue() == 0);
    d = null;
  }
View Full Code Here

    Species s1 = m.createSpecies("s1", c);
    Species s2 = m.createSpecies("s2", c);
    Reaction r = m.createReaction("r1");
    r.createReactant(null, s1);
    r.createProduct(null, s2);
    KineticLaw kl = r.createKineticLaw();
    kl.setFormula("s1 * 3");
    SBMLWriter.write(doc, System.out, ' ', (short) 2);
  }
View Full Code Here

TOP

Related Classes of org.sbml.jsbml.KineticLaw

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.