Package org.sbml.jsbml

Examples of org.sbml.jsbml.SpeciesReference


  }

  @Test
  public void test_Model_createProduct() {
    Reaction r;
    SpeciesReference sr;
    M.createReaction();
    M.createReaction();
    sr = M.createProduct();
    assertTrue(sr != null);
    assertTrue(M.getReactionCount() == 2);
View Full Code Here


  }

  @Test
  public void test_Model_createReactant() {
    Reaction r;
    SpeciesReference sr;
    M.createReaction();
    M.createReaction();
    sr = M.createReactant();
    assertTrue(sr != null);
    assertTrue(M.getReactionCount() == 2);
View Full Code Here

    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));
    kl.setMath(math);
View Full Code Here

    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.getCompartmentCount() == 1);
    c = m.getCompartment(0);
    assertTrue(c.getName().equals("compartmentOne"));
    assertTrue(c.getVolume() == 1);
    ud = c.getDerivedUnitDefinition();
    assertTrue(ud.getUnitCount() == 1);

    // assertTrue(ud.getUnit(0).getKind() == Unit.Kind.LITRE); // getDerivedUnitDefinition not working properly
    assertTrue(m.getSpeciesCount() == 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.getUnitCount() == 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.getReactionCount() == 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.getUnitCount() == 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.getReactantCount() == 1);
    assertTrue(r.getProductCount() == 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.getLocalParameterCount() == 1);
    p = kl.getParameter(0);
    assertTrue(p.getName().equals("k1"));
    assertTrue(p.getValue() == 0);
    r = m.getReaction(1);
    assertTrue(r.getReactantCount() == 1);
    assertTrue(r.getProductCount() == 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.getLocalParameterCount() == 1);
    p = kl.getParameter(0);
    assertTrue(p.getName().equals("k2"));
    assertTrue(p.getValue() == 0);
    r = m.getReaction(2);
    assertTrue(r.getReactantCount() == 1);
    assertTrue(r.getProductCount() == 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.getLocalParameterCount() == 1);
    p = kl.getParameter(0);
    assertTrue(p.getName().equals("k3"));
View Full Code Here

    /*
     * Reactions
     */
    logger.debug("==== Reactions ====");
    Reaction r2 = new Reaction(level, version);
    SpeciesReference sr1 = r2.createReactant(s1);
    sr1.setId("sr1");
    r2.createModifier(p1);
    r2.setId("r2");
    model.addReaction(r2);
   
    /*
 
View Full Code Here

            log4jLogger.warn("No Compartment matches the compartmentID of reaction.");
          }

          if (reaction.isSetListOfReactants()) {
            for (int j = 0; j < reaction.getReactantCount(); j++) {
              SpeciesReference speciesReference = reaction
                  .getReactant(j);

              if (speciesReference.isSetSpecies()
                  && !speciesReference.isSetSpeciesInstance()) {
                log4jLogger.warn(String.format("No Species matches the speciesID '%s' of %s.",
                    speciesReference.getId(), speciesReference.getElementName()));
              }
            }
          }
          if (reaction.isSetListOfProducts()) {
            for (int j = 0; j < reaction.getProductCount(); j++) {
              SpeciesReference speciesReference = reaction
                  .getProduct(j);

              if (speciesReference.isSetSpecies()
                  && !speciesReference.isSetSpeciesInstance()) {
                log4jLogger.warn(String.format("No Species matches the speciesID '%s' of %s.",
                    speciesReference.getId(), speciesReference.getElementName()));
              }
            }
          }
          if (reaction.isSetListOfModifiers()) {
            for (int j = 0; j < reaction.getModifierCount(); j++) {
View Full Code Here

            if (elementName.equals("speciesReference")
                && (reaction.getLevel() > 1 || (reaction
                    .getLevel() == 1 && reaction
                    .getVersion() == 2))) {
              SpeciesReference speciesReference = (SpeciesReference) newContextObject;
              speciesReference.initDefaults();

              if (list.getSBaseListType().equals(
                  ListOf.Type.listOfReactants)) {
                reaction.addReactant(speciesReference);

                return speciesReference;
              } else if (list.getSBaseListType().equals(
                  ListOf.Type.listOfProducts)) {
                reaction.addProduct(speciesReference);

                return speciesReference;
              } else {
                log4jLogger.warn("The element " + elementName + " is not recognized");
              }
            } else if (elementName.equals("specieReference")
                && reaction.getLevel() == 1) {
              SpeciesReference speciesReference = (SpeciesReference) newContextObject;
              speciesReference.initDefaults();

              if (list.getSBaseListType().equals(
                  ListOf.Type.listOfReactants)) {
                reaction.addReactant(speciesReference);

                return speciesReference;
              } else if (list.getSBaseListType().equals(
                  ListOf.Type.listOfProducts)) {
                reaction.addProduct(speciesReference);

                return speciesReference;
              } else {
                log4jLogger.warn("The element " + elementName + " is not recognized");
              }
            } else if (elementName
                .equals("modifierSpeciesReference")
                && list.getSBaseListType().equals(
                    ListOf.Type.listOfModifiers)
                && reaction.getLevel() > 1) {
              ModifierSpeciesReference modifierSpeciesReference = (ModifierSpeciesReference) newContextObject;
              reaction.addModifier(modifierSpeciesReference);

              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.addLocalParameter(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.addLocalParameter(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");
          }
View Full Code Here

    s2.setMetaId("S2");
   
    Reaction r1 = model.createReaction("R1");
    r1.setMetaId("R1");
   
    SpeciesReference reactant = model.createReactant("SP1");
    reactant.setMetaId("SP1");
    reactant.setSpecies(s1);
   
    SpeciesReference product = model.createProduct("SP2");
    product.setMetaId("SP2");
    product.setSpecies(s2);
   
    LocalParameter lp1 = r1.createKineticLaw().createLocalParameter("LP1");
    lp1.setMetaId("LP1");
   
  }
View Full Code Here

      fail("We should be able to register an id or metaid from a removed element.");
      // success
    }
   
    try {
      SpeciesReference reactant = r1.createReactant("S1");
      reactant.setMetaId("S1");
    } catch (IllegalArgumentException e) {
      fail("We should be able to put any id to an element removed from a model.");
    } catch (IdentifierException e) {
      fail("We should be able to put any id to an element removed from a model.");
    }
View Full Code Here

    if (eventAssignment.isSetVariable()) {
      String variableID = eventAssignment.getVariable();

      Compartment compartment = model.getCompartment(variableID);
      Species species = null;
      SpeciesReference speciesReference = null;
      Parameter parameter = null;

      if (compartment == null) {
        species = model.getSpecies(variableID);

        if (species == null) {
          parameter = model.getParameter(variableID);

          if (parameter == null) {
            if (model.isSetListOfReactions()) {

              int i = 0;
              SpeciesReference sr = null;

              while (i <= model.getReactionCount() - 1
                  && sr == null) {
                Reaction reaction = model.getReaction(i);
View Full Code Here

TOP

Related Classes of org.sbml.jsbml.SpeciesReference

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.