getKineticLaw() public method

public getKineticLaw ( ) : KineticLaw
return KineticLaw
Esempio n. 1
0
        /// <summary>
        ///     Creates the Local Parameters of the MoBi Reaction by the given local Parameters
        ///     of the SBML Reaction.
        /// </summary>
        private List <IParameter> CreateLocalParameters(Reaction sbmlReaction)
        {
            if (sbmlReaction.getKineticLaw() == null)
            {
                return(null);
            }
            if (sbmlReaction.getKineticLaw().getNumLocalParameters() <= 0)
            {
                return(null);
            }
            var parameter = new List <IParameter>();

            for (long i = 0; i < sbmlReaction.getKineticLaw().getNumLocalParameters(); i++)
            {
                var p       = sbmlReaction.getKineticLaw().getLocalParameter(i);
                var formula = ObjectBaseFactory.Create <ConstantFormula>()
                              .WithValue(p.getValue());
                var localParameter = ObjectBaseFactory.Create <IParameter>()
                                     .WithName(p.getId())
                                     .WithDescription(p.getNotesString())
                                     .WithFormula(formula);

                var dim = GetDimension(p);
                if (dim != null)
                {
                    localParameter.Dimension = dim;
                }

                if (localParameter != null)
                {
                    parameter.Add(localParameter);
                }
            }
            return(parameter);
        }
Esempio n. 2
0
        /// <summary>
        ///     Creates a "standard" MoBi reaction by a given one compartment reaction.
        /// </summary>
        private void CreateStandardReaction(Reaction sbmlReaction, Model model)
        {
            var reactionBuilder = ObjectBaseFactory.Create <IReactionBuilder>()
                                  .WithName(sbmlReaction.getId())
                                  .WithDescription(sbmlReaction.getNotesString());

            CreateModifiers(sbmlReaction, reactionBuilder, String.Empty, model);
            var parameters = CreateLocalParameters(sbmlReaction);

            if (parameters != null)
            {
                parameters.ForEach(reactionBuilder.AddParameter);
            }

            if (sbmlReaction.isSetKineticLaw())
            {
                CreateKineticLaw(sbmlReaction.getKineticLaw(), reactionBuilder, false);
            }
            CreateProducts(sbmlReaction, reactionBuilder, model);
            CreateEducts(sbmlReaction, reactionBuilder, model);

            if (reactionBuilder != null)
            {
                ReactionBuilderList.Add(reactionBuilder);
            }
        }
Esempio n. 3
0
        /// <summary>
        ///     Creates the Kinetic Formula for a passive Transport.
        /// </summary>
        private void CreateKinetic(Reaction sbmlReaction, ITransportBuilder passiveTransport)
        {
            _astHandler.NeedAbsolutePath = true;
            var formula = sbmlReaction.getKineticLaw() == null
             ? ObjectBaseFactory.Create <ExplicitFormula>().WithFormulaString(String.Empty)
             : _astHandler.Parse(sbmlReaction.getKineticLaw().getMath(), sbmlReaction.getId(), _sbmlProject, _sbmlInformation);

            if (formula == null)
            {
                passiveTransport.Formula = ObjectBaseFactory.Create <ExplicitFormula>()
                                           .WithFormulaString(String.Empty)
                                           .WithName(SBMLConstants.DEFAULT_FORMULA_NAME);
            }
            else
            {
                passiveTransport.Formula = formula;
                _passiveTransportBuildingBlock.FormulaCache.Add(formula);
            }
        }
Esempio n. 4
0
    private static void printReactionMath(int n, Reaction r)
    {
        string formula;
        KineticLaw kl;

        if (r.isSetKineticLaw())
        {
            kl = r.getKineticLaw();

            if (kl.isSetMath())
            {
                formula = libsbml.formulaToString(kl.getMath());
                Console.Write("Reaction " + n + ", formula: " + formula + Environment.NewLine);
            }
        }
    }
 public void test_KineticLaw_parent_add()
 {
     KineticLaw kl = new KineticLaw(2,4);
       Reaction r = new Reaction(2,4);
       r.setKineticLaw(kl);
       assertTrue( r == r.getKineticLaw().getParentSBMLObject() );
       r = null;
 }
Esempio n. 6
0
        /// <summary>
        ///     Creates for each compartment of the SBML Reaction one "Ghostreaction" to import multicompartment reactions.
        /// </summary>
        private void CreateGhostReactions(Reaction sbmlReaction, Dictionary <string, List <SpeciesReference> > eductCompartmentMoleculeDictionary, Dictionary <string, List <SpeciesReference> > productCompartmentMoleculeDictionary, Model model)
        {
            var usedProducts = new List <string>();

            foreach (var keyValuePair in eductCompartmentMoleculeDictionary)
            {
                var reactionBuilder = ObjectBaseFactory.Create <IReactionBuilder>()
                                      .WithName(sbmlReaction.getId() + "_" + keyValuePair.Key + "_ghostReaction")
                                      .WithDescription(sbmlReaction.getNotesString());

                CreateModifiers(sbmlReaction, reactionBuilder, keyValuePair.Key, model);
                var parameters = CreateLocalParameters(sbmlReaction);
                if (parameters != null)
                {
                    parameters.ForEach(reactionBuilder.AddParameter);
                }
                CreateKineticLaw(sbmlReaction.getKineticLaw(), reactionBuilder, true);

                var compartmentName = keyValuePair.Key;
                if (!_sbmlInformation.DummyNameContainerDictionary.ContainsValue(compartmentName))
                {
                    return;
                }
                var dummyMolecule = _sbmlInformation.DummyNameContainerDictionary.FirstOrDefault(x => x.Value == compartmentName).Key;

                reactionBuilder.AddModifier(dummyMolecule);

                foreach (var species in keyValuePair.Value)
                {
                    var reactionPartner = CreateReactionPartner(species, model);
                    if (reactionPartner != null)
                    {
                        reactionBuilder.AddEduct(reactionPartner);
                    }
                }

                if (productCompartmentMoleculeDictionary.ContainsKey(keyValuePair.Key))
                {
                    usedProducts.Add(keyValuePair.Key);
                    var productsInThisCompartment = productCompartmentMoleculeDictionary[keyValuePair.Key];
                    foreach (var product in productsInThisCompartment)
                    {
                        var reactionPartner = CreateReactionPartner(product, model);
                        if (reactionPartner != null)
                        {
                            reactionBuilder.AddProduct(reactionPartner);
                        }
                    }
                }
                ReactionBuilderList.Add(reactionBuilder);
            }


            foreach (var keyValuePair in productCompartmentMoleculeDictionary)
            {
                if (usedProducts.Contains(keyValuePair.Key))
                {
                    continue;
                }

                var reactionBuilder = ObjectBaseFactory.Create <IReactionBuilder>()
                                      .WithName(sbmlReaction.getId() + "_" + keyValuePair.Key + "_ghostReaction")
                                      .WithDescription(sbmlReaction.getNotesString());

                CreateModifiers(sbmlReaction, reactionBuilder, keyValuePair.Key, model);
                var parameters = CreateLocalParameters(sbmlReaction);
                if (parameters != null)
                {
                    parameters.ForEach(reactionBuilder.AddParameter);
                }
                CreateKineticLaw(sbmlReaction.getKineticLaw(), reactionBuilder, true);

                var compartmentName = keyValuePair.Key;
                if (!_sbmlInformation.DummyNameContainerDictionary.ContainsValue(compartmentName))
                {
                    return;
                }
                var dummyMolecule = _sbmlInformation.DummyNameContainerDictionary.FirstOrDefault(x => x.Value == compartmentName).Key;

                reactionBuilder.AddModifier(dummyMolecule);

                foreach (var species in keyValuePair.Value)
                {
                    var reactionPartner = CreateReactionPartner(species, model);
                    if (reactionPartner != null)
                    {
                        reactionBuilder.AddProduct(reactionPartner);
                    }
                }
                ReactionBuilderList.Add(reactionBuilder);
            }
        }
 public void test_KineticLaw_ancestor_create()
 {
     Reaction r = new Reaction(2,4);
       KineticLaw kl = r.createKineticLaw();
       assertTrue( kl.getAncestorOfType(libsbml.SBML_REACTION) == r );
       assertTrue( kl.getAncestorOfType(libsbml.SBML_DELAY) == null );
       assertTrue( kl.getAncestorOfType(libsbml.SBML_MODEL) == null );
       assertTrue( kl.getAncestorOfType(libsbml.SBML_DOCUMENT) == null );
       KineticLaw obj = r.getKineticLaw();
       assertTrue( obj.getAncestorOfType(libsbml.SBML_REACTION) == r );
       assertTrue( obj.getAncestorOfType(libsbml.SBML_MODEL) == null );
       assertTrue( obj.getAncestorOfType(libsbml.SBML_DELAY) == null );
       assertTrue( obj.getAncestorOfType(libsbml.SBML_DOCUMENT) == null );
       r = null;
 }
 public void test_KineticLaw_ancestor_add()
 {
     KineticLaw kl = new KineticLaw(2,4);
       Reaction r = new Reaction(2,4);
       r.setKineticLaw(kl);
       KineticLaw obj = r.getKineticLaw();
       assertTrue( obj.getAncestorOfType(libsbml.SBML_REACTION) == r );
       assertTrue( obj.getAncestorOfType(libsbml.SBML_MODEL) == null );
       assertTrue( obj.getAncestorOfType(libsbml.SBML_DOCUMENT) == null );
       r = null;
 }
 public void test_KineticLaw_parent_add()
 {
     KineticLaw kl = new KineticLaw(2,4);
       kl.setMath(libsbml.parseFormula("1"));
       Reaction r = new Reaction(2, 4);
       r.setKineticLaw(kl);
       assertTrue( r == r.getKineticLaw().getParentSBMLObject() );
       r = null;
 }
Esempio n. 10
0
 public void test_Reaction_copyConstructor()
 {
     Reaction o1 = new Reaction(2,4);
       o1.setId("c");
       assertTrue( o1.getId() ==  "c" );
       KineticLaw kl = new KineticLaw(2,4);
       kl.setMath(libsbml.parseFormula("1"));
       o1.setKineticLaw(kl);
       kl = null;
       assertTrue( o1.isSetKineticLaw() == true );
       assertNotEquals(o1.getKineticLaw(),null);
       Reaction o2 = new Reaction(o1);
       assertTrue( o2.getId() ==  "c" );
       assertTrue( o2.isSetKineticLaw() == true );
       assertNotEquals(o2.getKineticLaw(),null);
       assertTrue( o2.getParentSBMLObject() == o1.getParentSBMLObject() );
       o2 = null;
       o1 = null;
 }
 public void test_Reaction_clone()
 {
     Reaction o1 = new Reaction(2,4);
       o1.setId("c");
       assertTrue( o1.getId() ==  "c" );
       KineticLaw kl = new KineticLaw(2,4);
       o1.setKineticLaw(kl);
       kl = null;
       assertTrue( o1.isSetKineticLaw() == true );
       assertNotEquals(o1.getKineticLaw(),null);
       Reaction o2 = o1.clone();
       assertTrue( o2.getId() ==  "c" );
       assertTrue( o2.isSetKineticLaw() == true );
       assertNotEquals(o2.getKineticLaw(),null);
       assertTrue( o2.getParentSBMLObject() == o1.getParentSBMLObject() );
       o2 = null;
       o1 = null;
 }