Package org.sbml.jsbml

Examples of org.sbml.jsbml.Reaction


  /**
   *
   */
  @Test public void testRegister7() {
   
    Reaction r2 = model.createReaction("R2");
   
    r2.createReactant("SR3");
   
    r2.createKineticLaw().createLocalParameter("LP1");
   
    Reaction clonedR2 = r2.clone();

    assertTrue(clonedR2.getKineticLaw().getLocalParameterCount() == 1);

    try {
      clonedR2.getKineticLaw().createLocalParameter("LP1");
     
      fail("We should not be able to register twice the same id.");
    } catch (IllegalArgumentException e) {
      assertTrue(true);
      // success
    }

    try {
      clonedR2.getKineticLaw().createLocalParameter("LP2");
      assertTrue(true);
      // success     
    } catch (IllegalArgumentException e) {
      fail("We should be able to register a new local parameter on a cloned reaction.");
    }
   
    assertTrue(clonedR2.getKineticLaw().getLocalParameterCount() == 2);
  }
View Full Code Here


  /**
   *
   */
  @Test public void testRegister8() {
   
    Reaction r2 = model.createReaction("R2");
   
    KineticLaw kl = r2.createKineticLaw();

    ListOf<LocalParameter> listOfLP = new ListOf<LocalParameter>(2, 4);
    listOfLP.add(new LocalParameter("LP1"));
    listOfLP.add(new LocalParameter("LP2"));
    listOfLP.add(new LocalParameter("LP3"));
View Full Code Here

   *
   */
  @Test public void testUnRegister() {
   
   
    Reaction r1 = model.removeReaction("R1");
   
    assertTrue(model.getReaction("R1") == null);   
    assertTrue(model.getReaction(0) == null);
    assertTrue(model.findNamedSBase("SP1") == null);
    assertTrue(model.findNamedSBase("SP2") == null);
    // assertTrue(model.findNamedSBase("LP1") == null);
    assertTrue(doc.findSBase("SP1") == null);
    assertTrue(doc.findSBase("R1") == null);
    assertTrue(doc.findSBase("LP1") == null);
   
    Species s3 = new Species();
   
    // Setting the same id as a removed SpeciesReference
    s3.setId("SP1");

    // Setting the same metaid as a removed LocalParameter
    try {
      s3.setMetaId("LP1");
      assertTrue(true);
    } catch (IdentifierException e) {
      fail("We should be able to put any metaId to a Species not linked to a model.");
    }

    try {
      model.addSpecies(s3);
      assertTrue(true);
    } catch (IllegalArgumentException e) {
      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

  /**
   *
   */
  @Test public void testUnRegister2() {
   
    Reaction r1 = model.removeReaction("R1");

    assertTrue(r1.getReactant("SP1") != null);

    assertTrue(model.findNamedSBase("LP1") == null);
   
    // creating a product with the same id as a species
    r1.createProduct("S1");
  }
View Full Code Here

    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);
    assertTrue(r1.getListOfProducts().size() == 1);
    assertTrue(r1.getNumModifiers() == 0);
    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"));
   
View Full Code Here

    SBMLDocument doc = new SBMLDocument(1, 2);
    Model m = doc.createModel();
    Compartment c = m.createCompartment("c1");
    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

        if (unitDefinition.isSetListOfUnits()) {
          listOfElementsToWrite = new ArrayList<Object>();
          listOfElementsToWrite.add(unitDefinition.getListOfUnits());
        }
      } else if (sbase instanceof Reaction) {
        Reaction reaction = (Reaction) sbase;
        listOfElementsToWrite = new ArrayList<Object>();

        if (reaction.isSetListOfReactants()) {
          listOfElementsToWrite.add(reaction.getListOfReactants());
        }
        if (reaction.isSetListOfProducts()) {
          listOfElementsToWrite.add(reaction.getListOfProducts());
        }
        if (reaction.isSetKineticLaw()) {
          listOfElementsToWrite.add(reaction.getKineticLaw());
        }

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

          setInitialAssignmentSymbol(initialAssignment, model);
        }
      }
      if (model.isSetListOfReactions()) {
        for (int i = 0; i < model.getReactionCount(); i++) {
          Reaction reaction = model.getReaction(i);

          setReactionCompartment(reaction, model);

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

              setSpeciesReferenceSpecies(speciesReference, model);
            }
          }
          if (reaction.isSetListOfProducts()) {
            for (int j = 0; j < reaction.getProductCount(); j++) {
              SpeciesReference speciesReference = reaction
                  .getProduct(j);

              setSpeciesReferenceSpecies(speciesReference, model);
            }
          }
          if (reaction.isSetListOfModifiers()) {
            for (int j = 0; j < reaction.getModifierCount(); j++) {
              ModifierSpeciesReference modifierSpeciesReference = reaction
                  .getModifier(j);

              setSpeciesReferenceSpecies(
                  modifierSpeciesReference, model);
            }
          }
          if (reaction.isSetKineticLaw()) {
            KineticLaw kineticLaw = reaction.getKineticLaw();
            if (kineticLaw.isSetListOfLocalParameters()) {
              for (int j = 0; j < kineticLaw.getLocalParameterCount(); j++) {
                LocalParameter parameter = kineticLaw
                    .getLocalParameter(j);
                setParameterUnits(parameter, model);
View Full Code Here

              return rule;
            } else if (elementName.equals("reaction")
                && list.getSBaseListType().equals(
                    ListOf.Type.listOfReactions)) {
              Reaction reaction = (Reaction) newContextObject;
              model.addReaction(reaction);

              return reaction;
            } else {
              // TODO: SBML syntax error, throw an exception?
            }
          } else if (list.getParentSBMLObject() instanceof UnitDefinition) {
            UnitDefinition unitDefinition = (UnitDefinition) list
                .getParentSBMLObject();

            if (elementName.equals("unit")
                && list.getSBaseListType().equals(
                    ListOf.Type.listOfUnits)) {
              Unit unit = (Unit) newContextObject;
              unitDefinition.addUnit(unit);

              return unit;
            } else {
              // TODO: SBML syntax error, throw an exception?
            }
          } else if (list.getParentSBMLObject() instanceof Reaction) {
            Reaction reaction = (Reaction) list
                .getParentSBMLObject();

            if (elementName.equals("specieReference")) {
              SpeciesReference speciesReference = (SpeciesReference) newContextObject;

              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 {
                // TODO: SBML syntax error, throw an exception?
              }
            } 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.addLocalParameter(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?
          }
View Full Code Here

              int i = 0;
              SpeciesReference sr = null;

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

                if (reaction != null) {
                  sr = reaction.getReactant(variableID);
                  if (sr == null) {
                    sr = reaction.getProduct(variableID);
                  }
                }
              }

              speciesReference = sr;
View Full Code Here

TOP

Related Classes of org.sbml.jsbml.Reaction

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.