getReaction() public method

public getReaction ( long n ) : Reaction
n long
return Reaction
Beispiel #1
0
 /// <summary>
 ///     Imports all Reactions of the SBML Model.
 /// </summary>
 protected override void Import(Model model)
 {
     for (long i = 0; i < model.getNumReactions(); i++)
     {
         CreateReaction(model.getReaction(i), model);
     }
     AddToProject();
 }
 /// <summary>
 ///     Imports all Reactions of the SBML Model.
 /// </summary>
 protected override void Import(Model model)
 {
     _astHandler.FunctionDefinitions = _functionDefinitionImporter.FunctionDefinitions;
     _astHandler.SetUnitDefinitionImporter(_unitDefinitionImporter);
     _astHandler.UseConcentrations = _speciesImporter.UseConcentrations;
     for (long i = 0; i < model.getNumReactions(); i++)
     {
         CreateReaction(model.getReaction(i), model);
     }
     AddToProject();
 }
Beispiel #3
0
 private void SaveSpeciesReferences(Model sbmlModel)
 {
     SpeciesReferences = new List <SpeciesReference>();
     for (long i = 0; i < sbmlModel.getNumReactions(); i++)
     {
         for (long a = 0; a < sbmlModel.getReaction(i).getNumReactants(); a++)
         {
             var tmp = sbmlModel.getReaction(i).getReactant(a);
             if (!tmp.isSetStoichiometry() || tmp.isSetId())
             {
                 SpeciesReferences.Add(tmp);
             }
         }
         for (long a = 0; a < sbmlModel.getReaction(i).getNumProducts(); a++)
         {
             var tmp = sbmlModel.getReaction(i).getProduct(a);
             if (!tmp.isSetStoichiometry() || tmp.isSetId())
             {
                 SpeciesReferences.Add(tmp);
             }
         }
     }
 }
Beispiel #4
0
 public void test_ReadSBML_notes()
 {
     Reaction r;
       KineticLaw kl;
       string s = wrapSBML_L2v3("<listOfReactions>" +
     "<reaction name='J1'>" +
     "  <kineticLaw formula='k1*X0'>" +
     "    <notes>This is a test note.</notes>" +
     "    <listOfParameters>" +
     "      <parameter name='k1' value='0'/>" +
     "    </listOfParameters>" +
     "  </kineticLaw>" +
     "</reaction>" +
     "</listOfReactions>");
       D = libsbml.readSBMLFromString(s);
       M = D.getModel();
       r = M.getReaction(0);
       kl = r.getKineticLaw();
       assertTrue( kl.getNotes() != null );
       string notes = kl.getNotes().getChild(0).getCharacters();
       assertTrue( (  "This is a test note." != notes ) == false );
 }
Beispiel #5
0
 public void test_ReadSBML_metaid_Reaction()
 {
     SBase sb;
       Reaction r;
       string s = wrapSBML_L2v1("<listOfReactions>" +
     "  <reaction metaid='r'>" +
     "    <listOfReactants metaid='lor'>" +
     "      <speciesReference metaid='sr1'/>" +
     "    </listOfReactants>" +
     "    <listOfProducts metaid='lop'>" +
     "      <speciesReference metaid='sr2'/>" +
     "    </listOfProducts>" +
     "    <listOfModifiers metaid='lom'>" +
     "      <modifierSpeciesReference metaid='msr'/>" +
     "    </listOfModifiers>" +
     "    <kineticLaw metaid='kl'/>" +
     "  </reaction>" +
     "</listOfReactions>");
       D = libsbml.readSBMLFromString(s);
       M = D.getModel();
       assertTrue( M != null );
       r = M.getReaction(0);
       sb = r;
       assertEquals( true, sb.isSetMetaId() );
       assertTrue((  "r" == sb.getMetaId() ));
       sb = r.getListOfReactants();
       assertEquals( true, sb.isSetMetaId() );
       assertTrue((  "lor" == sb.getMetaId() ));
       sb = r.getReactant(0);
       assertEquals( true, sb.isSetMetaId() );
       assertTrue((  "sr1" == sb.getMetaId() ));
       sb = r.getListOfProducts();
       assertEquals( true, sb.isSetMetaId() );
       assertTrue((  "lop" == sb.getMetaId() ));
       sb = r.getProduct(0);
       assertEquals( true, sb.isSetMetaId() );
       assertTrue((  "sr2" == sb.getMetaId() ));
       sb = r.getListOfModifiers();
       assertEquals( true, sb.isSetMetaId() );
       assertTrue((  "lom" == sb.getMetaId() ));
       sb = r.getModifier(0);
       assertEquals( true, sb.isSetMetaId() );
       assertTrue((  "msr" == sb.getMetaId() ));
       sb = r.getKineticLaw();
       assertEquals( true, sb.isSetMetaId() );
       assertTrue((  "kl" == sb.getMetaId() ));
 }
Beispiel #6
0
 public void test_ReadSBML_metaid()
 {
     SBase sb;
       string s = wrapSBML_L2v1("<listOfFunctionDefinitions>" +
     "  <functionDefinition metaid='fd'/>" +
     "</listOfFunctionDefinitions>" +
     "<listOfUnitDefinitions>" +
     "  <unitDefinition metaid='ud'/>" +
     "</listOfUnitDefinitions>" +
     "<listOfCompartments>" +
     "  <compartment metaid='c'/>" +
     "</listOfCompartments>" +
     "<listOfSpecies>" +
     "  <species metaid='s'/>" +
     "</listOfSpecies>" +
     "<listOfParameters>" +
     "  <parameter metaid='p'/>" +
     "</listOfParameters>" +
     "<listOfRules>" +
     "  <rateRule metaid='rr'/>" +
     "</listOfRules>" +
     "<listOfReactions>" +
     "  <reaction metaid='rx'/>" +
     "</listOfReactions>" +
     "<listOfEvents>" +
     " <event metaid='e'/>" +
     "</listOfEvents>");
       D = libsbml.readSBMLFromString(s);
       M = D.getModel();
       assertTrue( M != null );
       sb = M.getFunctionDefinition(0);
       assertEquals( true, sb.isSetMetaId() );
       assertTrue((  "fd" == sb.getMetaId() ));
       sb = M.getUnitDefinition(0);
       assertEquals( true, sb.isSetMetaId() );
       assertTrue((  "ud" == sb.getMetaId() ));
       sb = M.getCompartment(0);
       assertEquals( true, sb.isSetMetaId() );
       assertTrue((  "c" == sb.getMetaId() ));
       sb = M.getSpecies(0);
       assertEquals( true, sb.isSetMetaId() );
       assertTrue((  "s" == sb.getMetaId() ));
       sb = M.getParameter(0);
       assertEquals( true, sb.isSetMetaId() );
       assertTrue((  "p" == sb.getMetaId() ));
       sb = M.getRule(0);
       assertEquals( true, sb.isSetMetaId() );
       assertTrue((  "rr" == sb.getMetaId() ));
       sb = M.getReaction(0);
       assertEquals( true, sb.isSetMetaId() );
       assertTrue((  "rx" == sb.getMetaId() ));
       sb = M.getEvent(0);
       assertEquals( true, sb.isSetMetaId() );
       assertTrue((  "e" == sb.getMetaId() ));
 }
Beispiel #7
0
        public void test_ReadSBML_line_col_numbers()
        {
            //setXMLParser();

              SBase sb;
              string s = "<?xml version='1.0' encoding='UTF-8'?>\n" +
            "<sbml xmlns='http://www.sbml.org/sbml/level2' level='2' version='1'>\n" +
            "  <model id='testModel' name='testModel'>\n" +
            "    <listOfReactions> <reaction/> </listOfReactions>\n" +
            "  </model>\n" +
            "</sbml>\n";
              D = libsbml.readSBMLFromString(s);
              M = D.getModel();
              assertTrue( M != null );
              sb = M;
              sb = M.getListOfReactions();
              sb = M.getReaction(0);
        }
Beispiel #8
0
        private void InitializeFromFbcV2(Model model, FbcModelPlugin plugin)
        {
            if (!plugin.getStrict())
              {
            Warnings.Add(
              "Encountered non-strict model, this software does not support any of the dynamic features of FBC V2, only the static features of the model are imported. ");
              }

              var numConstraints = plugin.getNumFluxBounds();
              for (int i = 0; i < numConstraints; i++)
              {
            var constraint = plugin.getFluxBound(i);
            Constraints.Add(new LPsolveConstraint(constraint.getReaction(), GetOperator(constraint.getOperation()),
              constraint.getValue()));
              }

              var activeObjective = plugin.getActiveObjective();
              if (activeObjective == null && plugin.getNumObjectives() > 0)
            activeObjective = plugin.getObjective(0);
              if (activeObjective == null) return;
              var numObjectives = (int)activeObjective.getNumFluxObjectives();
              for (int i = 0; i < numObjectives; i++)
              {
            var objective = activeObjective.getFluxObjective(i);
            Objectives.Add(new LPsolveObjective(objective.getReaction(), objective.getCoefficient()));
              }

              if (activeObjective.getType() == "minimize" || activeObjective.getType() == "minimise") Mode = FBA_Mode.minimize;
              else Mode = FBA_Mode.maximize;
              ActiveObjective = activeObjective.getId();

              for (int i = 0; i < model.getNumReactions(); i++)
              {
            var reaction = model.getReaction(i);
            ReversibilityMap[reaction.getId()] = reaction.getReversible();

            var rplug = (FbcReactionPlugin) reaction.getPlugin("fbc");
            if (rplug == null) continue;

            if (rplug.isSetLowerFluxBound())
            {
              var param = model.getParameter(rplug.getLowerFluxBound());
              if (param != null)
              {
            Constraints.Add(new LPsolveConstraint(reaction.getId(), lpsolve_constr_types.GE,
              param.getValue()));
              }
            }

            if (rplug.isSetUpperFluxBound())
            {
              var param = model.getParameter(rplug.getUpperFluxBound());
              if (param != null)
              {
            Constraints.Add(new LPsolveConstraint(reaction.getId(), lpsolve_constr_types.LE,
              param.getValue()));
              }
            }

            }
        }
 public void test_Reaction_parent_create()
 {
     Model m = new Model(2,4);
       Reaction r = m.createReaction();
       ListOf lo = m.getListOfReactions();
       assertTrue( lo == m.getReaction(0).getParentSBMLObject() );
       assertTrue( lo == r.getParentSBMLObject() );
       assertTrue( m == lo.getParentSBMLObject() );
 }
Beispiel #10
0
 public void test_ReadSBML_SpeciesReference_StoichiometryMath_2()
 {
     Reaction r;
       SpeciesReference sr;
       string s = wrapSBML_L2v1("<listOfReactions>" +
     "  <reaction name='r1'>" +
     "    <listOfReactants>" +
     "      <speciesReference species='X0'>" +
     "        <stoichiometryMath>" +
     "          <math> <cn type='rational'> 3 <sep/> 2 </cn> </math>" +
     "        </stoichiometryMath>" +
     "      </speciesReference>" +
     "    </listOfReactants>" +
     "  </reaction>" +
     "</listOfReactions>");
       D = libsbml.readSBMLFromString(s);
       M = D.getModel();
       assertTrue( M.getNumReactions() == 1 );
       r = M.getReaction(0);
       assertTrue( r != null );
       assertTrue( r.getNumReactants() == 1 );
       sr = r.getReactant(0);
       assertTrue( sr != null );
       assertEquals( false, sr.isSetStoichiometryMath() );
       assertTrue( sr.getStoichiometry() == 3 );
       assertTrue( sr.getDenominator() == 2 );
 }
Beispiel #11
0
 public void test_ReadSBML_SpeciesReference_StoichiometryMath_1()
 {
     Reaction r;
       SpeciesReference sr;
       StoichiometryMath math;
       string formula;
       string s = wrapSBML_L2v1("<listOfReactions>" +
     "  <reaction name='r1'>" +
     "    <listOfReactants>" +
     "      <speciesReference species='X0'>" +
     "        <stoichiometryMath>" +
     "          <math> <ci> x </ci> </math>" +
     "        </stoichiometryMath>" +
     "      </speciesReference>" +
     "    </listOfReactants>" +
     "  </reaction>" +
     "</listOfReactions>");
       D = libsbml.readSBMLFromString(s);
       M = D.getModel();
       assertTrue( M.getNumReactions() == 1 );
       r = M.getReaction(0);
       assertTrue( r != null );
       assertTrue( r.getNumReactants() == 1 );
       sr = r.getReactant(0);
       assertTrue( sr != null );
       assertEquals( true, sr.isSetStoichiometryMath() );
       math = sr.getStoichiometryMath();
       formula = libsbml.formulaToString(math.getMath());
       assertTrue( formula != null );
       assertTrue((  "x" == formula ));
 }
Beispiel #12
0
 public void test_ReadSBML_SpeciesReference_defaults()
 {
     Reaction r;
       SpeciesReference sr;
       string s = wrapSBML_L1v2("<listOfReactions>" +
     "  <reaction name='reaction_1' reversible='false'>" +
     "    <listOfReactants>" +
     "      <speciesReference species='X0'/>" +
     "    </listOfReactants>" +
     "  </reaction>" +
     "</listOfReactions>");
       D = libsbml.readSBMLFromString(s);
       M = D.getModel();
       assertTrue( M.getNumReactions() == 1 );
       r = M.getReaction(0);
       assertTrue((  "reaction_1" == r.getId() ));
       assertTrue( r.getReversible() == false );
       assertTrue( r.getNumReactants() == 1 );
       sr = r.getReactant(0);
       assertTrue((  "X0" == sr.getSpecies() ));
       assertTrue( sr.getStoichiometry() == 1 );
       assertTrue( sr.getDenominator() == 1 );
 }
Beispiel #13
0
 public void test_ReadSBML_Reaction_L2_defaults()
 {
     Reaction r;
       string s = wrapSBML_L2v1("<listOfReactions> <reaction id='r1'/> </listOfReactions>"
     );
       D = libsbml.readSBMLFromString(s);
       M = D.getModel();
       assertTrue( M.getNumReactions() == 1 );
       r = M.getReaction(0);
       assertEquals( true, r.isSetId() );
       assertEquals( false, r.isSetName() );
       assertEquals( false, r.isSetFast() );
       assertTrue((  "r1" == r.getId() ));
       assertTrue( r.getReversible() == true );
 }
Beispiel #14
0
 public void test_ReadSBML_Reaction_defaults()
 {
     Reaction r;
       string s = wrapSBML_L1v2("<listOfReactions>" +
     "  <reaction name='reaction_1'/>" +
     "</listOfReactions>");
       D = libsbml.readSBMLFromString(s);
       M = D.getModel();
       assertTrue( M.getNumReactions() == 1 );
       r = M.getReaction(0);
       assertTrue((  "reaction_1" == r.getId() ));
       assertTrue( r.getReversible() != false );
       assertTrue( r.getFast() == false );
 }
 public void test_Reaction_ancestor_add()
 {
     Reaction ia = new Reaction(2,4);
       Model m = new Model(2,4);
       ia.setId("k");
       m.addReaction(ia);
       ia = null;
       ListOf lo = m.getListOfReactions();
       Reaction obj = m.getReaction(0);
       assertTrue( obj.getAncestorOfType(libsbml.SBML_MODEL) == m );
       assertTrue( obj.getAncestorOfType(libsbml.SBML_LIST_OF) == lo );
       assertTrue( obj.getAncestorOfType(libsbml.SBML_DOCUMENT) == null );
       assertTrue( obj.getAncestorOfType(libsbml.SBML_EVENT) == null );
 }
Beispiel #16
0
 public void test_ReadSBML_KineticLaw()
 {
     Reaction r;
       KineticLaw kl;
       string s = wrapSBML_L1v2("<listOfReactions>" +
     "  <reaction name='J1'>" +
     "    <kineticLaw formula='k1*X0'/>" +
     "  </reaction>" +
     "</listOfReactions>");
       D = libsbml.readSBMLFromString(s);
       M = D.getModel();
       assertTrue( M.getNumReactions() == 1 );
       r = M.getReaction(0);
       kl = r.getKineticLaw();
       assertTrue((  "k1*X0" == kl.getFormula() ));
 }
 public void test_Reaction_ancestor_create()
 {
     Model m = new Model(2,4);
       Reaction r = m.createReaction();
       ListOf lo = m.getListOfReactions();
       assertTrue( r.getAncestorOfType(libsbml.SBML_MODEL) == m );
       assertTrue( r.getAncestorOfType(libsbml.SBML_LIST_OF) == lo );
       assertTrue( r.getAncestorOfType(libsbml.SBML_DOCUMENT) == null );
       assertTrue( r.getAncestorOfType(libsbml.SBML_EVENT) == null );
       Reaction obj = m.getReaction(0);
       assertTrue( obj.getAncestorOfType(libsbml.SBML_MODEL) == m );
       assertTrue( obj.getAncestorOfType(libsbml.SBML_LIST_OF) == lo );
       assertTrue( obj.getAncestorOfType(libsbml.SBML_DOCUMENT) == null );
       assertTrue( obj.getAncestorOfType(libsbml.SBML_EVENT) == null );
 }
Beispiel #18
0
 public void test_ReadSBML_KineticLaw_L2()
 {
     Reaction r;
       KineticLaw kl;
       ASTNode math;
       string formula;
       string s = wrapSBML_L2v1("<listOfReactions>" +
     "  <reaction id='J1'>" +
     "    <kineticLaw>" +
     "      <math>" +
     "        <apply>" +
     "          <times/>" +
     "          <ci> k  </ci>" +
     "          <ci> S2 </ci>" +
     "          <ci> X0 </ci>" +
     "        </apply>" +
     "      </math>" +
     "    </kineticLaw>" +
     "  </reaction>" +
     "</listOfReactions>");
       D = libsbml.readSBMLFromString(s);
       M = D.getModel();
       assertTrue( M.getNumReactions() == 1 );
       r = M.getReaction(0);
       assertTrue( r != null );
       kl = r.getKineticLaw();
       assertTrue( kl != null );
       assertEquals( true, kl.isSetMath() );
       math = kl.getMath();
       formula = kl.getFormula();
       assertTrue( formula != null );
       assertTrue((  "k * S2 * X0" == formula ));
 }
 public void test_Reaction_parent_add()
 {
     Reaction ia = new Reaction(2,4);
       Model m = new Model(2,4);
       ia.setId("k");
       m.addReaction(ia);
       ia = null;
       ListOf lo = m.getListOfReactions();
       assertTrue( lo == m.getReaction(0).getParentSBMLObject() );
       assertTrue( m == lo.getParentSBMLObject() );
 }
Beispiel #20
0
 public void test_ReadSBML_KineticLaw_Parameter()
 {
     Reaction r;
       KineticLaw kl;
       Parameter p;
       string s = wrapSBML_L1v2("<listOfReactions>" +
     "  <reaction name='J1'>" +
     "    <kineticLaw formula='k1*X0'>" +
     "      <listOfParameters>" +
     "        <parameter name='k1' value='0'/>" +
     "      </listOfParameters>" +
     "    </kineticLaw>" +
     "  </reaction>" +
     "</listOfReactions>");
       D = libsbml.readSBMLFromString(s);
       M = D.getModel();
       assertTrue( M.getNumReactions() == 1 );
       r = M.getReaction(0);
       kl = r.getKineticLaw();
       assertTrue((  "k1*X0" == kl.getFormula() ));
       assertTrue( kl.getNumParameters() == 1 );
       p = kl.getParameter(0);
       assertTrue((  "k1" == p.getId() ));
       assertTrue( p.getValue() == 0 );
 }
Beispiel #21
0
    private static void printMath(Model m)
    {
        int n;

        for (n = 0; n < m.getNumFunctionDefinitions(); ++n)
        {
            printFunctionDefinition(n + 1, m.getFunctionDefinition(n));
        }

        for (n = 0; n < m.getNumRules(); ++n)
        {
            printRuleMath(n + 1, m.getRule(n));
        }

        Console.WriteLine();

        for (n = 0; n < m.getNumReactions(); ++n)
        {
            printReactionMath(n + 1, m.getReaction(n));
        }

        Console.WriteLine();

        for (n = 0; n < m.getNumEvents(); ++n)
        {
            printEventMath(n + 1, m.getEvent(n));
        }
    }
Beispiel #22
0
        private void InitializeFromFbcV1(Model model, FbcModelPlugin plugin)
        {
            var numConstraints = plugin.getNumFluxBounds();
              for (int i = 0; i < numConstraints; i++)
              {
            var constraint = plugin.getFluxBound(i);
            Constraints.Add(new LPsolveConstraint(constraint.getReaction(), GetOperator(constraint.getOperation()),
              constraint.getValue()));
              }
              var activeObjective = plugin.getActiveObjective();
              if (activeObjective == null && plugin.getNumObjectives() > 0)
            activeObjective = plugin.getObjective(0);
              if (activeObjective == null) return;
              var numObjectives = (int)activeObjective.getNumFluxObjectives();
              for (int i = 0; i < numObjectives; i++)
              {
            var objective = activeObjective.getFluxObjective(i);
            Objectives.Add(new LPsolveObjective(objective.getReaction(), objective.getCoefficient()));
              }

              if (activeObjective.getType() == "minimize" || activeObjective.getType() == "minimise") Mode = FBA_Mode.minimize;
              else Mode = FBA_Mode.maximize;
              ActiveObjective = activeObjective.getId();

              for (int i = 0; i < model.getNumReactions(); i++)
              {
            var reaction = model.getReaction(i);
            ReversibilityMap[reaction.getId()] = reaction.getReversible();
              }
        }