Package org.sbml.jsbml

Examples of org.sbml.jsbml.Reaction


              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


              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

              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

    model = doc.createModel("test_model");
    model.setMetaId("M1");
    compartment = model.createCompartment("cytoplasm");
    compartment.setMetaId("M2");
    compartment2 = model.createCompartment("periplasm");
    Reaction reaction = model.createReaction("R1");
    k = reaction.createKineticLaw();
    k.setMetaId("M3");
    LocalParameter param1 = k.createLocalParameter("LP1");
    param1.setMetaId("M4");
  }
View Full Code Here

  @Test
  public void testRemoveFromParentKineticLaw() {

    assertTrue(k.removeFromParent());

    Reaction reaction = model.getReaction(0);
   
    assertTrue(reaction.isSetKineticLaw() == false);
    assertTrue(doc.findSBase("M1") != null);
    assertTrue(doc.findSBase("M3") == null);
    assertTrue(doc.findSBase("M4") == null);
   
    k = reaction.createKineticLaw();
    k.setMetaId("M4");
    k.createLocalParameter("LP1");
   
  }
View Full Code Here

        }

        // if the reaction is set
        if (rGlyph.isSetReaction()) {
          String reactionId = rGlyph.getReaction();
          Reaction reaction = model.getReaction(reactionId);
          if (reaction == null) {
            System.err.println("reactionId in in ReactionGlyph is not in SBML model: " + reactionId);
            continue;
          }
          for (SpeciesReferenceGlyph sRefGlyph : rGlyph.getListOfSpeciesReferenceGlyphs()) {
View Full Code Here

 
  private Reaction R;

  @Before public void setUp() throws Exception
  {
    R = new  Reaction(2,4);
    if (R == null);
    {
    }
  }
View Full Code Here

  // The junit test file would test uniqueness of metaids and ids in the model. 
   
  // Setup : creating some simple objects
    SBMLDocument doc=new SBMLDocument(2,4);
    Model m=doc.createModel("model1");
    Reaction r = m.createReaction("id1");
    SpeciesReference s = new SpeciesReference();
    s.setMetaId("meta2");
    r.addReactant(s);
    r.setMetaId("meta");

    System.out.println("Reaction parent and model                    : " + r.getParent() + " " + r.getModel() + "\n");

    Reaction clonedReaction = r.clone();
   
    // Here everything is fine, the cloned reaction get created with all
    // the appropriate fields but the parent that is set to null for all cloned JSBML objects
    // (any objects that inherit from AbstracTreeNode)
    // That is why the getParent() and getModel() are returning null as they should
    System.out.println("Cloned reaction metaid and id                : " + clonedReaction.getMetaId() + " " + clonedReaction.getId());
    System.out.println("Cloned reaction metaid of the first reactant : " + clonedReaction.getReactant(0).getMetaId());
    System.out.println("Cloned reaction parent and model             : " + clonedReaction.getParent() + " " + clonedReaction.getModel() + "\n");
   
    System.out.println("Trying to add the cloned reaction to the model, which should not be possible");
    // Trying to add the
    boolean operationSuccessful = m.addReaction(clonedReaction);

    if (operationSuccessful != false) {
      throw new SBMLException("It should not be possible to add two elements with the same id in a ListOf class !!");
    }
    // Here the parent is still null as it should as the cloned reaction
    // was not added to the model as her id is the same as the reaction 'r'
    System.out.println("Cloned reaction parent and model still null  : " + clonedReaction.getParent() + " " + clonedReaction.getModel() + "\n");

    // setting a new unit id the the cloned reaction
    clonedReaction.setId("id2");
   
    System.out.println("Trying to add the cloned reaction to the model, with a new unique id. It is still not possible as the metaids are not unique.");
    try {
      m.addReaction(clonedReaction);
      throw new SBMLException("It should not be possible to add two elements with the same metaid in a SBML document !!");
    } catch (IllegalArgumentException e) {
      // success, the exception should be thrown there
    }

    // setting a new unique metaid to the reaction but not it's sub-elements
    clonedReaction.setMetaId("meta3");  
   
    System.out.println("Trying to add the cloned reaction to the model, with a new unique id and metaid. It is still not possible as the metaids are not unique.");
    try {
      operationSuccessful = m.addReaction(clonedReaction);
      throw new SBMLException("It should not be possible to add a reaction that has any sub-elements with a non unique metaid !!");
    } catch (IllegalArgumentException e) {
      // success, the exception should be thrown there
    }

    System.out.println("Trying to add the cloned reaction to the model, with a new unique id and metaid for all sub-elements.");
    // setting a new unique metaid to the reaction and all it's sub-elements
    clonedReaction.getReactant(0).setMetaId("meta4");

    // At the moment (rev 768), the reaction cannot be added to the model as the metaid 'meta3' as
    // been added in the list of metaids in the previous call to addReaction() where only the speciesReference id
    // was invalid
    try {
      operationSuccessful = m.addReaction(clonedReaction);

      if (operationSuccessful != true) {
        throw new SBMLException("It should be possible to add a reaction with an unique ids and metaids to a model !!");
      }
    } catch (IllegalArgumentException e) {
      // bug here
      System.out.println("Bug detected : there is a problem in the recursive adding of metaids !!!");
      System.out.println("The reaction was not added to the model where it should have been");
    }

    System.out.println("Cloned reaction parent and model should be set  : " + clonedReaction.getParent() + " " + clonedReaction.getModel());
    System.out.println("Model.getReaction(0) id                         : " + m.getReaction(0).getId());
    System.out.println("Model.getReaction(1)                            : " + m.getReaction(1));
    // System.out.println("Model.getReaction(1) parent                     : " + m.getReaction(1).getParent());

   
View Full Code Here

    k2.setId("k2");
    k1.setValue(3.14);
    k2.setValue(2.72);
    M.addParameter(k1);
    M.addParameter(k2);
    Reaction r1 = new Reaction(2, 4);
    r1.setId("reaction_1");
    KineticLaw kl = new KineticLaw(2, 4);
    kl.setFormula("k1 * X0");
    LocalParameter k3 = new LocalParameter(2, 4);
    LocalParameter k4 = new LocalParameter(2, 4);
    k3.setId("k1");
    k4.setId("k2");
    k3.setValue(2.72);
    k4.setValue(3.14);
    kl.addParameter(k3);
    kl.addParameter(k4);
    r1.setKineticLaw(kl);
    M.addReaction(r1);
    KineticLaw kl1 = M.getReaction(0).getKineticLaw();
    // assertTrue(!kl1.getParameter("k1").equals(k3)); // TODO : compare Parameter and LocalParameter
    // assertTrue(!kl1.getParameter("k1").equals(k1)); // We are not doinga clone of the object and even it will return true
    // assertTrue(!kl1.getParameter("k2").equals(k4)); // TODO : compare Parameter and LocalParameter
View Full Code Here

    assertTrue(M.getNumParameters() == 1);
  }

  @Test
  public void test_Model_addReaction() {
    Reaction r = new Reaction(2, 4);
    r.setId("r");
    M.addReaction(r);
    assertTrue(M.getNumReactions() == 1);
  }
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.