Ejemplo n.º 1
0
        /// <summary>
        ///     A passive Transport is created when two Species with the same name are reacting with
        ///     each other.
        /// </summary>
        private bool IsPassiveTransport(Reaction sbmlReaction, Model model)
        {
            var educt   = sbmlReaction.getReactant(0).getSpecies();
            var product = sbmlReaction.getProduct(0).getSpecies();

            var eductSpecies   = GetSpeciesById(educt, model);
            var productSpecies = GetSpeciesById(product, model);

            if (eductSpecies.getName() != productSpecies.getName())
            {
                return(false);
            }

            var molinfoEduct   = _sbmlInformation.MoleculeInformation.FirstOrDefault(info => info.SpeciesIds.Any(s => s == educt));
            var molinfoProduct = _sbmlInformation.MoleculeInformation.FirstOrDefault(info => info.SpeciesIds.Any(s => s == product));

            if (molinfoEduct == null)
            {
                return(false);
            }
            if (molinfoProduct == null)
            {
                return(false);
            }

            var reactantMolecule = molinfoEduct.GetMoleculeBuilder();
            var productMolecule  = molinfoProduct.GetMoleculeBuilder();

            return(reactantMolecule == productMolecule);
        }
Ejemplo n.º 2
0
 public void setUp()
 {
     R = new  Reaction(2,4);
       if (R == null);
       {
       }
 }
Ejemplo n.º 3
0
        /// <summary>
        ///     Saves products of a SBML reaction into a dictionary, containing their compartment and SpeciesReference.
        /// </summary>
        private Dictionary <string, List <SpeciesReference> > ComputeProducts(Reaction sbmlReaction, Model model)
        {
            var productCompartmentMoleculeDictionary = new Dictionary <string, List <SpeciesReference> >();

            for (long i = 0; i < sbmlReaction.getNumProducts(); i++)
            {
                var product        = sbmlReaction.getProduct(i);
                var productSpecies = GetSpeciesById(product.getSpecies(), model);
                var compartment    = productSpecies.getCompartment();
                if (_sbmlInformation.MoleculeInformation.All(info => info.SpeciesIds.TrueForAll(s => s != productSpecies.getId())))
                {
                    continue;
                }

                if (!productCompartmentMoleculeDictionary.ContainsKey(compartment))
                {
                    productCompartmentMoleculeDictionary[compartment] = new List <SpeciesReference> {
                        product
                    }
                }
                ;
                else
                {
                    productCompartmentMoleculeDictionary[compartment].Add(product);
                }
            }
            return(productCompartmentMoleculeDictionary);
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
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);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        ///     Creates a Ghostreaction to import a SBML multicompartment reaction.
        /// </summary>
        private void CreateGhostReaction(Reaction sbmlReaction, Model model)
        {
            var eductCompartmentMoleculeDictionary   = ComputeEducts(sbmlReaction, model);
            var productCompartmentMoleculeDictionary = ComputeProducts(sbmlReaction, model);

            CreateGhostReactions(sbmlReaction, eductCompartmentMoleculeDictionary, productCompartmentMoleculeDictionary, model);
        }
Ejemplo n.º 7
0
 public void test_KineticLaw_getParameterById()
 {
     Parameter k1 = new  Parameter(2,4);
       Parameter k2 = new  Parameter(2,4);
       k1.setId( "k1");
       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");
       Parameter k3 = new  Parameter(2,4);
       Parameter k4 = new  Parameter(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();
       assertNotEquals(kl1.getParameter( "k1" ),k3);
       assertNotEquals(kl1.getParameter( "k1" ),k1);
       assertNotEquals(kl1.getParameter( "k2" ),k4);
       assertEquals(kl1.getParameter( "k3" ),null);
 }
Ejemplo n.º 8
0
 /// <summary>
 ///     Creates the Educts of the MoBi reaction.
 /// </summary>
 private void CreateEducts(Reaction sbmlReaction, IReactionBuilder reactionBuilder, Model model)
 {
     for (long i = 0; i < sbmlReaction.getNumReactants(); i++)
     {
         var educt = CreateReactionPartner(sbmlReaction.getReactant(i), model);
         if (educt != null)
         {
             reactionBuilder.AddEduct(educt);
         }
     }
 }
Ejemplo n.º 9
0
 /// <summary>
 ///     Creates the Products of the MoBi reaction.
 /// </summary>
 private void CreateProducts(Reaction sbmlReaction, IReactionBuilder reactionBuilder, Model model)
 {
     for (long i = 0; i < sbmlReaction.getNumProducts(); i++)
     {
         var product = CreateReactionPartner(sbmlReaction.getProduct(i), model);
         if (product != null)
         {
             reactionBuilder.AddProduct(product);
         }
     }
 }
Ejemplo n.º 10
0
 /// <summary>
 ///     Creates a multicompartment reaction.
 /// </summary>
 private void CreateMulticompartmentReaction(Reaction sbmlReaction, Model model)
 {
     if ((sbmlReaction.getNumReactants() + sbmlReaction.getNumProducts() == 2) && (IsPassiveTransport(sbmlReaction, model)))
     {
         CreatePassiveTransport(sbmlReaction, model);
     }
     else
     {
         CreateGhostReaction(sbmlReaction, model);
     }
 }
Ejemplo n.º 11
0
 /// <summary>
 ///     Creates a MoBi reaction by a given SBML Reaction.
 /// </summary>
 internal void CreateReaction(Reaction sbmlReaction, Model model)
 {
     if (IsMultiCompartmentReaction(sbmlReaction, model))
     {
         CreateMulticompartmentReaction(sbmlReaction, model);
     }
     else
     {
         CreateStandardReaction(sbmlReaction, model);
     }
 }
 public void test_Reaction_addProduct2()
 {
     Reaction m = new  Reaction(2,2);
       SpeciesReference p = new  SpeciesReference(2,1);
       p.setSpecies( "k");
       int i = m.addProduct(p);
       assertTrue( i == libsbml.LIBSBML_VERSION_MISMATCH );
       assertTrue( m.getNumProducts() == 0 );
       p = null;
       m = null;
 }
Ejemplo n.º 13
0
        protected override void Context()
        {
            base.Context();
            _sbmlModel       = new Model(3, 1);
            _sbmlInformation = new SBMLInformation();

            //one compartment reaction
            _reaction = _sbmlModel.createReaction();
            _reaction.setId("r1");

            //reaction partner
            var s1 = _sbmlModel.createSpecies();

            s1.setId("s1");
            s1.setCompartment("default");

            var s2 = _sbmlModel.createSpecies();

            s2.setId("s2");
            s2.setCompartment("default");

            var m  = new MoleculeInformation(s1);
            var m2 = new MoleculeInformation(s2);

            _sbmlInformation.MoleculeInformation.Add(m);
            _sbmlInformation.MoleculeInformation.Add(m2);

            //SRef
            var s1Ref = _reaction.createReactant();

            s1Ref.setSpecies("s1");
            s1Ref.setStoichiometry(1);

            var s2Ref = _reaction.createProduct();

            s2Ref.setSpecies("s2");
            s2Ref.setStoichiometry(2);
            _reaction.addProduct(s2Ref);

            //Modifier
            var mod = _reaction.createModifier();

            mod.setId("mod");
            mod.setName("mod");
            mod.setSpecies("s1");

            //Kinetic Law
            var kl = _reaction.createKineticLaw();

            kl.setId("kl");
            kl.setMath(libsbml.parseFormula("2*3"));
        }
Ejemplo n.º 14
0
        /// <summary>
        ///     Imports the SBML Modifiers to MoBi Modifiers.
        /// </summary>
        private void CreateModifiers(Reaction sbmlReaction, IReactionBuilder reactionBuilder, string reactionCompartment, Model model)
        {
            for (long i = 0; i < sbmlReaction.getNumModifiers(); i++)
            {
                var modifier = sbmlReaction.getModifier(i);
                if (ModifierInDifferentCompartment(reactionCompartment, modifier, model))
                {
                    continue;
                }

                var modifierMolecule = _sbmlInformation.GetMoleculeBySBMLId(modifier.getSpecies());
                if (modifierMolecule != null)
                {
                    reactionBuilder.AddModifier(modifierMolecule.Name);
                }
            }
        }
Ejemplo n.º 15
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);
            }
        }
 public void test_Reaction_addProduct1()
 {
     Reaction m = new  Reaction(2,2);
       SpeciesReference p = new  SpeciesReference(2,2);
       SpeciesReference p1 = new  SpeciesReference(2,2);
       p1.setSpecies( "k");
       p1.setId( "k1");
       int i = m.addProduct(p);
       assertTrue( i == libsbml.LIBSBML_INVALID_OBJECT );
       p.setSpecies( "k");
       p.setId( "k1");
       i = m.addProduct(p);
       assertTrue( i == libsbml.LIBSBML_OPERATION_SUCCESS );
       assertTrue( m.getNumProducts() == 1 );
       i = m.addProduct(p1);
       assertTrue( i == libsbml.LIBSBML_DUPLICATE_OBJECT_ID );
       assertTrue( m.getNumProducts() == 1 );
       p = null;
       p1 = null;
       m = null;
 }
Ejemplo n.º 17
0
        /// <summary>
        ///     Checks if all reaction partners are in the same compartment.
        /// </summary>
        private bool IsMultiCompartmentReaction(Reaction sbmlReaction, Model model)
        {
            var compartment = String.Empty;

            for (long i = 0; i < sbmlReaction.getNumReactants(); i++)
            {
                var x = sbmlReaction.getReactant(i).getSpecies();

                var species = GetSpeciesById(x, model);
                if (compartment == String.Empty)
                {
                    compartment = species.getCompartment();
                }
                else
                {
                    if (compartment != species.getCompartment())
                    {
                        return(true);
                    }
                }
            }

            for (long i = 0; i < sbmlReaction.getNumProducts(); i++)
            {
                var x       = sbmlReaction.getProduct(i).getSpecies();
                var species = GetSpeciesById(x, model);
                if (compartment == String.Empty)
                {
                    compartment = species.getCompartment();
                }
                else
                {
                    if (compartment != species.getCompartment())
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
 public void test_SpeciesReference_Reactant_parent_create()
 {
     Reaction r = new Reaction(2,4);
       SpeciesReference sr = r.createReactant();
       ListOf lo = r.getListOfReactants();
       assertTrue( lo == r.getReactant(0).getParentSBMLObject() );
       assertTrue( lo == sr.getParentSBMLObject() );
       assertTrue( r == lo.getParentSBMLObject() );
 }
 public void test_SpeciesReference_Reactant_parent_add()
 {
     SpeciesReference sr = new SpeciesReference(2,4);
       Reaction r = new Reaction(2,4);
       sr.setSpecies("s");
       r.addReactant(sr);
       sr = null;
       ListOf lo = r.getListOfReactants();
       assertTrue( lo == r.getReactant(0).getParentSBMLObject() );
       assertTrue( r == lo.getParentSBMLObject() );
 }
 public void test_SpeciesReference_Modifier_parent_create()
 {
     Reaction r = new Reaction(2,4);
       ModifierSpeciesReference sr = r.createModifier();
       ListOf lo = r.getListOfModifiers();
       assertTrue( lo == sr.getParentSBMLObject() );
       assertTrue( lo == r.getModifier(0).getParentSBMLObject() );
       assertTrue( r == lo.getParentSBMLObject() );
 }
Ejemplo n.º 21
0
        /// <summary>
        ///     Imports a SBML Reaction by creating a passive Transport.
        /// </summary>
        private void CreatePassiveTransport(Reaction sbmlReaction, Model model)
        {
            var reactant        = sbmlReaction.getReactant(0).getSpecies();
            var product         = sbmlReaction.getProduct(0).getSpecies();
            var reactantSpecies = GetSpeciesById(reactant, model);
            var productSpecies  = GetSpeciesById(product, model);

            if (_sbmlInformation.MoleculeInformation.All(info => info.SpeciesIds.TrueForAll(s => s != reactant)))
            {
                return;
            }
            if (_sbmlInformation.MoleculeInformation.All(info => info.SpeciesIds.TrueForAll(s => s != product)))
            {
                return;
            }
            var molInfoReactant = _sbmlInformation.MoleculeInformation.FirstOrDefault(info => info.SpeciesIds.Contains(reactant));
            var molInfoProduct  = _sbmlInformation.MoleculeInformation.FirstOrDefault(info => info.SpeciesIds.Contains(product));

            if (molInfoProduct == null)
            {
                return;
            }
            if (molInfoReactant == null)
            {
                return;
            }

            //must be the same Molecule
            if (molInfoReactant.GetMoleculeBuilder() != molInfoProduct.GetMoleculeBuilder())
            {
                CreateErrorMessage();
            }

            var passiveTransport = ObjectBaseFactory.Create <ITransportBuilder>().WithName(sbmlReaction.getId());

            passiveTransport.ForAll = false;
            if (molInfoReactant.GetMoleculeBuilderName() == null)
            {
                return;
            }
            passiveTransport.MoleculeList.AddMoleculeName(molInfoReactant.GetMoleculeBuilderName());

            var reactantCompartment = GetContainerFromCompartment_(molInfoReactant.GetCompartment(reactantSpecies));
            var productCompartment  = GetContainerFromCompartment_(molInfoProduct.GetCompartment(productSpecies));

            if (reactantCompartment != null && productCompartment != null)
            {
                var reactantMatchTag = new MatchTagCondition(reactantCompartment.Name);
                var productMatchTag  = new MatchTagCondition(productCompartment.Name);
                passiveTransport.SourceCriteria.Add(reactantMatchTag);
                passiveTransport.TargetCriteria.Add(productMatchTag);
            }

            var parameters = CreateLocalParameters(sbmlReaction);

            if (parameters != null)
            {
                parameters.ForEach(passiveTransport.AddParameter);
            }
            CreateKinetic(sbmlReaction, passiveTransport);
            AddNeighbourhood(reactantCompartment, productCompartment, model);

            _passiveTransportBuildingBlock.Add(passiveTransport);
        }
 public void test_Reaction_setName3()
 {
     Reaction p = new  Reaction(2,2);
       int i = p.setName("");
       assertTrue( i == libsbml.LIBSBML_OPERATION_SUCCESS );
       assertEquals( false, p.isSetName() );
       p = null;
 }
 public void test_Reaction_createReactant()
 {
     Reaction m = new  Reaction(2,2);
       SpeciesReference p = m.createReactant();
       assertTrue( m.getNumReactants() == 1 );
       assertTrue( (p).getLevel() == 2 );
       assertTrue( (p).getVersion() == 2 );
       m = null;
 }
 public void test_Reaction_addReactant4()
 {
     Reaction m = new  Reaction(2,2);
       SpeciesReference p = null;
       int i = m.addReactant(p);
       assertTrue( i == libsbml.LIBSBML_OPERATION_FAILED );
       assertTrue( m.getNumReactants() == 0 );
       m = null;
 }
 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;
 }
Ejemplo n.º 26
0
 public void test_SpeciesReference_Reactant_ancestor_add()
 {
     SpeciesReference sr = new SpeciesReference(2,4);
       Reaction r = new Reaction(2,4);
       sr.setSpecies("s");
       r.addReactant(sr);
       sr = null;
       ListOf lo = r.getListOfReactants();
       SpeciesReference obj = r.getReactant(0);
       assertTrue( obj.getAncestorOfType(libsbml.SBML_REACTION) == r );
       assertTrue( obj.getAncestorOfType(libsbml.SBML_LIST_OF) == lo );
       assertTrue( obj.getAncestorOfType(libsbml.SBML_DOCUMENT) == null );
       assertTrue( obj.getAncestorOfType(libsbml.SBML_COMPARTMENT) == null );
 }
Ejemplo n.º 27
0
 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 );
 }
Ejemplo n.º 28
0
 public void test_Reaction_createWithNS()
 {
     XMLNamespaces xmlns = new  XMLNamespaces();
       xmlns.add( "http://www.sbml.org", "testsbml");
       SBMLNamespaces sbmlns = new  SBMLNamespaces(2,1);
       sbmlns.addNamespaces(xmlns);
       Reaction object1 = new  Reaction(sbmlns);
       assertTrue( object1.getTypeCode() == libsbml.SBML_REACTION );
       assertTrue( object1.getMetaId() == "" );
       assertTrue( object1.getNotes() == null );
       assertTrue( object1.getAnnotation() == null );
       assertTrue( object1.getLevel() == 2 );
       assertTrue( object1.getVersion() == 1 );
       assertTrue( object1.getNamespaces() != null );
       assertTrue( object1.getNamespaces().getLength() == 2 );
       object1 = null;
 }
Ejemplo n.º 29
0
 public void test_SpeciesReference_Reactant_ancestor_create()
 {
     Reaction r = new Reaction(2,4);
       SpeciesReference sr = r.createReactant();
       ListOf lo = r.getListOfReactants();
       assertTrue( sr.getAncestorOfType(libsbml.SBML_REACTION) == r );
       assertTrue( sr.getAncestorOfType(libsbml.SBML_LIST_OF) == lo );
       assertTrue( sr.getAncestorOfType(libsbml.SBML_DOCUMENT) == null );
       assertTrue( sr.getAncestorOfType(libsbml.SBML_COMPARTMENT) == null );
       SpeciesReference obj = r.getReactant(0);
       assertTrue( obj.getAncestorOfType(libsbml.SBML_REACTION) == r );
       assertTrue( obj.getAncestorOfType(libsbml.SBML_LIST_OF) == lo );
       assertTrue( obj.getAncestorOfType(libsbml.SBML_DOCUMENT) == null );
       assertTrue( obj.getAncestorOfType(libsbml.SBML_COMPARTMENT) == null );
 }
Ejemplo n.º 30
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);
            }
        }
Ejemplo n.º 31
0
 public void test_SpeciesReference_Modifier_ancestor_add()
 {
     ModifierSpeciesReference sr = new ModifierSpeciesReference(2,4);
       sr.setSpecies("s");
       Reaction r = new Reaction(2,4);
       r.addModifier(sr);
       sr = null;
       ListOf lo = r.getListOfModifiers();
       ModifierSpeciesReference obj = r.getModifier(0);
       assertTrue( obj.getAncestorOfType(libsbml.SBML_REACTION) == r );
       assertTrue( obj.getAncestorOfType(libsbml.SBML_LIST_OF) == lo );
       assertTrue( obj.getAncestorOfType(libsbml.SBML_DOCUMENT) == null );
       assertTrue( obj.getAncestorOfType(libsbml.SBML_COMPARTMENT) == null );
 }
 public void test_Reaction_addReactant3()
 {
     Reaction m = new  Reaction(2,2);
       SpeciesReference p = new  SpeciesReference(1,2);
       p.setSpecies( "k");
       int i = m.addReactant(p);
       assertTrue( i == libsbml.LIBSBML_LEVEL_MISMATCH );
       assertTrue( m.getNumReactants() == 0 );
       p = null;
       m = null;
 }
 public void test_KineticLaw_parent_create()
 {
     Reaction r = new Reaction(2,4);
       KineticLaw kl = r.createKineticLaw();
       assertTrue( r == kl.getParentSBMLObject() );
       r = null;
 }
 public void test_Reaction_createKineticLaw()
 {
     Reaction r = new  Reaction(2,2);
       KineticLaw kl = r.createKineticLaw();
       assertTrue( r.isSetKineticLaw() == true );
       assertTrue( (kl).getLevel() == 2 );
       assertTrue( (kl).getVersion() == 2 );
       r = null;
 }
 public void test_KineticLaw_parent_NULL()
 {
     Reaction r = new Reaction(2,4);
       KineticLaw kl = r.createKineticLaw();
       Parameter p = kl.createParameter();
       assertTrue( r == kl.getParentSBMLObject() );
       assertTrue( r == p.getAncestorOfType(libsbml.SBML_REACTION) );
       assertTrue( kl == p.getAncestorOfType(libsbml.SBML_KINETIC_LAW) );
       KineticLaw kl1 = kl.clone();
       assertTrue( kl1.getParentSBMLObject() == null );
       assertTrue( kl1.getParameter(0).getAncestorOfType(libsbml.SBML_REACTION) == null );
       assertTrue( kl1 == kl1.getParameter(0).getAncestorOfType(libsbml.SBML_KINETIC_LAW) );
       r = null;
 }
 public void test_Reaction_setFast2()
 {
     Reaction R1 = new  Reaction(2,4);
       int i = R1.unsetFast();
       assertTrue( i == libsbml.LIBSBML_OPERATION_SUCCESS );
       assertTrue( R1.getFast() == false );
       assertEquals( false, R1.isSetFast() );
 }
 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() );
 }
Ejemplo n.º 38
0
 public void tearDown()
 {
     R = null;
 }
 public void test_SpeciesReference_Modifier_parent_add()
 {
     ModifierSpeciesReference sr = new ModifierSpeciesReference(2,4);
       sr.setSpecies("s");
       Reaction r = new Reaction(2,4);
       r.addModifier(sr);
       sr = null;
       ListOf lo = r.getListOfModifiers();
       assertTrue( lo == r.getModifier(0).getParentSBMLObject() );
       assertTrue( r == lo.getParentSBMLObject() );
 }
 public void test_Reaction()
 {
     Reaction r = new Reaction(2,4);
       assertEquals( true, r.hasRequiredElements() );
       r = null;
 }
Ejemplo n.º 41
0
 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;
 }
Ejemplo n.º 42
0
 /**
    * Adds a copy of the given Reaction object to this Model.
    *
    * @param r the Reaction object to add
    *
    *
  * @return integer value indicating success/failure of the
  * function.  @if clike The value is drawn from the
  * enumeration #OperationReturnValues_t. @endif The possible values
  * returned by this function are:
  * @li @link libsbml#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS@endlink
    * @li @link libsbml#LIBSBML_LEVEL_MISMATCH LIBSBML_LEVEL_MISMATCH@endlink
    * @li @link libsbml#LIBSBML_VERSION_MISMATCH LIBSBML_VERSION_MISMATCH@endlink
    * @li @link libsbml#LIBSBML_DUPLICATE_OBJECT_ID LIBSBML_DUPLICATE_OBJECT_ID@endlink
    * @li @link libsbml#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT@endlink
    * @li @link libsbml#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED@endlink
    *
    *
  * @note This method should be used with some caution.  The fact that this
  * method @em copies the object passed to it means that the caller will be
  * left holding a physically different object instance than the one contained
  * inside this object.  Changes made to the original object instance (such as
  * resetting attribute values) will <em>not affect the instance in this
  * object</em>.  In addition, the caller should make sure to free the
  * original object if it is no longer being used, or else a memory leak will
  * result.  Please see other methods on this class (particularly a
  * corresponding method whose name begins with the word <code>create</code>)
  * for alternatives that do not lead to these issues.
  *
  *
    *
    * @see createReaction()
    */
 public int addReaction(Reaction r)
 {
     int ret = libsbmlPINVOKE.Model_addReaction(swigCPtr, Reaction.getCPtr(r));
     return ret;
 }
Ejemplo n.º 43
0
 public void test_L3_Reaction_hasRequiredAttributes()
 {
     Reaction r = new  Reaction(3,1);
       assertEquals( false, r.hasRequiredAttributes() );
       r.setId( "id");
       assertEquals( false, r.hasRequiredAttributes() );
       r.setFast(false);
       assertEquals( false, r.hasRequiredAttributes() );
       r.setReversible(false);
       assertEquals( true, r.hasRequiredAttributes() );
       r = null;
 }
        public void test_Reaction_constructor()
        {
            SBase s;

              try
              {
            s = new Reaction(1,1);
            s = new Reaction(1,2);
            s = new Reaction(2,1);
            s = new Reaction(2,2);
            s = new Reaction(2,3);
            s = new Reaction(2,4);
            s = new Reaction(3,1);
            s = new Reaction(SN11);
            s = new Reaction(SN12);
            s = new Reaction(SN21);
            s = new Reaction(SN22);
            s = new Reaction(SN23);
            s = new Reaction(SN24);
            s = new Reaction(SN31);
              }
              catch (SBMLConstructorException e)
              {
             s = null;
              }
              assertTrue(s != null);

              string msg = "";

              try
              {
            s = new Reaction(9,9);
              }
              catch (SBMLConstructorException e)
              {
             msg = e.Message;
              }
              assertTrue(msg == ErrMsg);

              msg = "";

              try
              {
            s = new Reaction(SN99);
              }
              catch (SBMLConstructorException e)
              {
             msg = e.Message;
              }
              assertTrue(msg == ErrMsg);
        }
Ejemplo n.º 45
0
 public void test_L3_Reaction_createWithNS()
 {
     XMLNamespaces xmlns = new  XMLNamespaces();
       xmlns.add( "http://www.sbml.org", "testsbml");
       SBMLNamespaces sbmlns = new  SBMLNamespaces(3,1);
       sbmlns.addNamespaces(xmlns);
       Reaction r = new  Reaction(sbmlns);
       assertTrue( r.getTypeCode() == libsbml.SBML_REACTION );
       assertTrue( r.getMetaId() == "" );
       assertTrue( r.getNotes() == null );
       assertTrue( r.getAnnotation() == null );
       assertTrue( r.getLevel() == 3 );
       assertTrue( r.getVersion() == 1 );
       assertTrue( r.getNamespaces() != null );
       assertTrue( r.getNamespaces().getLength() == 2 );
       assertTrue( r.getId() == "" );
       assertTrue( r.getName() == "" );
       assertTrue( r.getCompartment() == "" );
       assertTrue( r.getFast() == false );
       assertTrue( r.getReversible() == true );
       assertEquals( false, r.isSetId() );
       assertEquals( false, r.isSetName() );
       assertEquals( false, r.isSetCompartment() );
       assertEquals( false, r.isSetFast() );
       assertEquals( false, r.isSetReversible() );
       r = null;
 }