Esempio n. 1
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. 2
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);
            }
        }