상속: SBase
예제 #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);
            }
        }
예제 #2
0
 public void setUp()
 {
     string filename = "../../sbml/annotation/test/test-data/annotationL3.xml";
       d = libsbml.readSBML(filename);
       m = d.getModel();
       c = m.getCompartment(0);
 }
예제 #3
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);
        }
예제 #4
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);
        }
예제 #5
0
            protected override void Because()
            {
                var model = new Model(3, 1);

                model.setName("TestModel");
                model.setNotes("TestNotes");
                model.setMetaId("TestMetaId");
                sut.CreateEventsTopContainer();
                sut.CreateTopContainer(model);
                var compartment = new Compartment(3, 1);

                compartment.setName("Compartment");
                compartment.setId("c1");
                compartment.setSpatialDimensions(1);
                compartment.setSize(5);

                var compartment2 = new Compartment(3, 1);

                compartment2.setName("Compartment");
                compartment2.setId("c2");
                compartment2.setSpatialDimensions(2);
                compartment2.setSize(5);

                var compartment3 = new Compartment(3, 1);

                compartment3.setName("Compartment");
                compartment3.setId("c3");
                compartment3.setSpatialDimensions(3);
                compartment3.setSize(5);

                _container  = sut.CreateContainerFromCompartment(compartment);
                _container2 = sut.CreateContainerFromCompartment(compartment2);
                _container3 = sut.CreateContainerFromCompartment(compartment3);
                sut.CreateSpatialStructureFromModel(sut._topContainer, model);
            }
예제 #6
0
 public void setUp()
 {
     M = new  Model(3,1);
       if (M == null);
       {
       }
 }
예제 #7
0
        /// <summary>
        ///     Sets all the autogenerated Molecule Start Values to the right values and updates their
        ///     "IsPresent" property.
        /// </summary>
        private void SetMoleculeStartValues(Model model)
        {
            foreach (var molInfo in _sbmlInformation.MoleculeInformation)
            {
                foreach (var msv in _moleculeStartValuesBuildingBlock)
                {
                    if (msv.Name != molInfo.GetMoleculeBuilderName())
                    {
                        continue;
                    }
                    if (molInfo.GetContainer().Any(x => x.Name == msv.ContainerPath.LastOrDefault()))
                    {
                        msv.IsPresent = true;
                        var sbmlSpecies = molInfo.GetSpeciesIfOne();
                        if (sbmlSpecies == null)
                        {
                            return;
                        }
                        var amountDimension = GetDimension(sbmlSpecies, model);

                        //unit is set by the Unit of SubstanceUnit
                        if (sbmlSpecies.isSetInitialAmount())
                        {
                            msv.StartValue = sbmlSpecies.getInitialAmount();
                            if (amountDimension != null)
                            {
                                msv.Dimension = amountDimension;
                                molInfo.SetDimension(amountDimension);
                            }
                        }
                        if (!sbmlSpecies.isSetInitialConcentration())
                        {
                            continue;
                        }

                        //unit is {unit of amount}/{unit of size}
                        msv.StartValue = sbmlSpecies.getInitialConcentration();

                        var sizeDimension = GetSizeDimensionFromCompartment(sbmlSpecies, model);
                        if (amountDimension == null)
                        {
                            continue;
                        }
                        if (sizeDimension == null)
                        {
                            continue;
                        }

                        var newDim = CreateNewDimension(amountDimension, sizeDimension);
                        msv.Dimension = newDim;
                        molInfo.SetDimension(newDim);
                    }
                    else
                    {
                        msv.IsPresent  = false;
                        msv.StartValue = 0;
                    }
                }
            }
        }
예제 #8
0
        private void ImportInitialAssignment(InitialAssignment initialAssignment, Model model)
        {
            var symbol = initialAssignment.getSymbol();

            if (IsParameter(symbol))
            {
                var parameter = GetParameter(symbol);
                SetPSV(initialAssignment.getMath(), parameter, String.Empty);
                return;
            }

            if (IsContainerSizeParameter(symbol))
            {
                var sizeParameter = GetContainerSizeParameter(symbol);
                SetPSV(initialAssignment.getMath(), sizeParameter, symbol);
                return;
            }

            if (IsSpeciesAssignment(symbol))
            {
                DoSpeciesAssignment(symbol, initialAssignment.getMath(), isInitialAssignment: true);
            }

            CheckSpeciesReferences(initialAssignment.getId(), symbol, model);
        }
예제 #9
0
        protected override void Because()
        {
            var sbmlModel = new Model(3, 1);

            //Event
            var sbmlEvent = sbmlModel.createEvent();

            sbmlEvent.setId("e1");
            sbmlEvent.setName("e1_name");
            sbmlEvent.setNotes("eventNotes");

            //Trigger
            var trigger = sbmlModel.createTrigger();

            trigger.setMath(libsbml.parseFormula("1 > 0 "));
            sbmlEvent.setTrigger(trigger);
            //Event Assignment
            var assign = new EventAssignment(3, 1);

            assign.setId("ea1");
            assign.setName("ea1_name");
            assign.setVariable("x1");
            assign.setMath(libsbml.parseFormula("1+2"));
            sbmlEvent.addEventAssignment(assign);

            sbmlModel.addEvent(sbmlEvent);

            sut.DoImport(sbmlModel, new MoBiProject(), A.Fake <SBMLInformation>(), new MoBiMacroCommand());
        }
예제 #10
0
        /// <summary>
        ///     Sets all the autogenerated Molecule Start Values to the right values and updates their
        ///     "IsPresent" property.
        /// </summary>
        private void SetMoleculeStartValues(Model model)
        {
            foreach (var molInfo in _sbmlInformation.MoleculeInformation)
            {
                foreach (var msv in _moleculeStartValuesBuildingBlock)
                {
                    if (msv.Name != molInfo.GetMoleculeBuilderName())
                    {
                        continue;
                    }
                    if (molInfo.GetContainer().Any(x => x.Name == msv.ContainerPath.LastOrDefault()))
                    {
                        msv.IsPresent             = true;
                        msv.NegativeValuesAllowed = true;
                        var sbmlSpecies = molInfo.GetSpeciesIfOne();
                        if (sbmlSpecies == null)
                        {
                            return;
                        }
                        var sbmlUnit        = GetUnit(sbmlSpecies, model);
                        var amountDimension = _unitDefinitionImporter.DimensionFor(sbmlUnit);

                        //unit is set by the Unit of SubstanceUnit
                        if (sbmlSpecies.isSetInitialAmount())
                        {
                            msv.StartValue = sbmlSpecies.getInitialAmount();
                            if (amountDimension != null)
                            {
                                msv.Dimension = amountDimension;
                                molInfo.SetDimension(amountDimension);
                            }
                        }
                        if (!sbmlSpecies.isSetInitialConcentration())
                        {
                            continue;
                        }

                        //unit is {unit of amount}/{unit of size}
                        var baseValue = _unitDefinitionImporter.ToMobiBaseUnit(sbmlUnit, sbmlSpecies.getInitialConcentration());
                        msv.StartValue = baseValue.value;
                        msv.Formula    = _context.Create <ExplicitFormula>($"{msv.Name}_0").WithName($"{msv.Name}_0").WithDimension(amountDimension).WithFormulaString($"{baseValue.value} * {Constants.VOLUME_ALIAS}");
                        msv.Formula.AddObjectPath(
                            ObjectPathFactory.CreateFormulaUsablePathFrom(ObjectPath.PARENT_CONTAINER, Constants.Parameters.VOLUME)
                            .WithAlias(Constants.VOLUME_ALIAS)
                            .WithDimension(_moBiDimensionFactory.Dimension(Constants.Dimension.VOLUME))
                            );
                        _moleculeStartValuesBuildingBlock.AddFormula(msv.Formula);
                        msv.Dimension = amountDimension;
                        molInfo.SetDimension(amountDimension);
                        UseConcentrations = true;
                    }
                    else
                    {
                        msv.IsPresent  = false;
                        msv.StartValue = 0;
                    }
                }
            }
        }
예제 #11
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();
 }
예제 #12
0
 protected override void Import(Model model)
 {
     for (long i = 0; i < model.getNumInitialAssignments(); i++)
     {
         ImportInitialAssignment(model.getInitialAssignment(i), model);
     }
     AddToProject();
 }
예제 #13
0
 private void CreateMoleculeStartValueBuildingBlock(Model model)
 {
     _moleculeStartValuesBuildingBlock = _moleculeStartValuesCreator.CreateFrom(GetMainSpatialStructure(model),
                                                                                MoleculeBuildingBlock)
                                         .WithId(SBMLConstants.SBML_MOLECULESTARTVALUES_BB)
                                         .WithName(SBMLConstants.SBML_MOLECULESTARTVALUES_BB)
                                         .WithDescription(SBMLConstants.SBML_MOLECULESTARTVALUES_DESCRIPTION);
 }
예제 #14
0
 protected override void Import(Model model)
 {
     for (long i = 0; i < model.getNumFunctionDefinitions(); i++)
     {
         _functionDefinitions.Add(model.getFunctionDefinition(i));
     }
     _astHandler.FunctionDefinitions = _functionDefinitions;
 }
예제 #15
0
 /// <summary>
 ///     Creates the TopContainer of the Spatial Structure.
 /// </summary>
 internal void CreateTopContainer(Model model)
 {
     _topContainer = _objectBaseFactory.Create <IContainer>()
                     .WithId(SBMLConstants.SBML_TOP_CONTAINER)
                     .WithName("TOPCONTAINER" + SBMLConstants.SBML + model.getName())
                     .WithMode(ContainerMode.Logical)
                     .WithContainerType(ContainerType.Compartment);
 }
예제 #16
0
        /// <summary>
        ///     The creation of Algrebraic Rules is not supported.
        /// </summary>
        private void CreateAlgebraicRule(Model model)
        {
            var msg = new NotificationMessage(GetMainSpatialStructure(model), MessageOrigin.All, null, NotificationType.Warning)
            {
                Message = SBMLConstants.SBML_FEATURE_NOT_SUPPORTED + ": SBML Algebraic Rule was not imported."
            };

            _sbmlInformation.NotificationMessages.Add(msg);
        }
 public void test_CompartmentType_parent_create()
 {
     Model m = new Model(2,4);
       CompartmentType ct = m.createCompartmentType();
       ListOf lo = m.getListOfCompartmentTypes();
       assertTrue( lo == m.getCompartmentType(0).getParentSBMLObject() );
       assertTrue( lo == ct.getParentSBMLObject() );
       assertTrue( m == lo.getParentSBMLObject() );
 }
 public void test_AssignmentRule_parent_create()
 {
     Model m = new Model(2,4);
       AssignmentRule r = m.createAssignmentRule();
       ListOf lo = m.getListOfRules();
       assertTrue( lo == m.getRule(0).getParentSBMLObject() );
       assertTrue( lo == r.getParentSBMLObject() );
       assertTrue( m == lo.getParentSBMLObject() );
 }
예제 #19
0
        protected override void Import(Model model)
        {
            if (model == null) return;
            if (_sbmlProject == null) return;

            for (long i = 0; i < model.getNumUnitDefinitions(); i++)
            {
               ConvertUnit(model.getUnitDefinition(i));
            }
        }
예제 #20
0
        /// <summary>
        ///     Creates the Spatial Structure of the SBML Model with the TopContainer.
        /// </summary>
        internal void CreateSpatialStructureFromModel(IContainer topContainer, Model model)
        {
            SpatialStructure = _spatialStructureFactory.Create().DowncastTo <IMoBiSpatialStructure>()
                               .WithName(SBMLConstants.SBML_MODEL + model.getName())
                               .WithTopContainer(topContainer)
                               .WithDescription(SBMLConstants.SBML_NOTES + model.getNotesString() + SBMLConstants.SPACE +
                                                SBMLConstants.SBML_METAID + model.getMetaId());

            SpatialStructure.AddTopContainer(_eventsTopContainer);
        }
예제 #21
0
 public void test_Model_addCompartment2()
 {
     Model m = new  Model(2,2);
       Compartment c = new  Compartment(2,1);
       c.setId( "c");
       int i = m.addCompartment(c);
       assertTrue( i == libsbml.LIBSBML_VERSION_MISMATCH );
       assertTrue( m.getNumCompartments() == 0 );
       c = null;
       m = null;
 }
예제 #22
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_SBMLDocument_setLevelAndVersion()
 {
     SBMLDocument d = new  SBMLDocument(2,2);
       Model m1 = new  Model(2,2);
       d.setModel(m1);
       assertTrue( d.setLevelAndVersion(2,3,false) == true );
       assertTrue( d.setLevelAndVersion(2,1,false) == true );
       assertTrue( d.setLevelAndVersion(1,2,false) == true );
       assertTrue( d.setLevelAndVersion(1,1,false) == false );
       d = null;
 }
예제 #24
0
 /// <summary>
 ///     Gets a SBML species by it's Id.
 /// </summary>
 private Species GetSpeciesById(string speciesId, Model model)
 {
     for (long i = 0; i < model.getNumSpecies(); i++)
     {
         if (model.getSpecies(i).getId() == speciesId)
         {
             return(model.getSpecies(i));
         }
     }
     return(null);
 }
 public void test_CompartmentType_parent_add()
 {
     CompartmentType ct = new CompartmentType(2,4);
       Model m = new Model(2,4);
       ct.setId("ct");
       m.addCompartmentType(ct);
       ct = null;
       ListOf lo = m.getListOfCompartmentTypes();
       assertTrue( lo == m.getCompartmentType(0).getParentSBMLObject() );
       assertTrue( m == lo.getParentSBMLObject() );
 }
 /// <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();
 }
예제 #27
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);
     }
 }
예제 #28
0
 private void reportConstraints(IMoBiProject project, Model model)
 {
     if (model.getNumConstraints() != 0)
     {
         var msg = new NotificationMessage(project, MessageOrigin.All, null, NotificationType.Warning)
         {
             Message = ("SBML Constraints are not supported.")
         };
         SBMLInformation.NotificationMessages.Add(msg);
     }
 }
예제 #29
0
        /// <summary>
        ///    Imports all Events of the SBML Model.
        /// </summary>
        protected override void Import(Model model)
        {
            _astHandler.NeedAbsolutePath = true;
            CreateEGBandEGBB();

            for (long i = 0; i < model.getNumEvents(); i++)
            {
                CreateEvent(model.getEvent(i));
            }
            _astHandler.NeedAbsolutePath = false;
            AddToProject();
        }
예제 #30
0
        protected override void Import(Model sbmlModel)
        {
            CreateTopContainer(sbmlModel);
            CreateEventsTopContainer();

            for (long i = 0; i < sbmlModel.getNumCompartments(); i++)
            {
                _topContainer.Add(CreateContainerFromCompartment(sbmlModel.getCompartment(i)));
            }
            CreateSpatialStructureFromModel(_topContainer, sbmlModel.getModel());
            AddToProject();
        }
예제 #31
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"));
        }
예제 #32
0
 public void test_Model_addCompartment1()
 {
     Model m = new  Model(2,2);
       Compartment c = new  Compartment(2,2);
       int i = m.addCompartment(c);
       assertTrue( i == libsbml.LIBSBML_INVALID_OBJECT );
       c.setId( "c");
       i = m.addCompartment(c);
       assertTrue( i == libsbml.LIBSBML_OPERATION_SUCCESS );
       assertTrue( m.getNumCompartments() == 1 );
       c = null;
       m = null;
 }
예제 #33
0
        private string getProjectName(Model model)
        {
            var name = String.Empty;

            if (model.isSetId())
            {
                name += model.getId() + SBMLConstants.SPACE;
            }
            if (model.isSetName())
            {
                name += model.getName();
            }
            return(name != string.Empty ? name : SBMLConstants.DEFAULT_PROJECT_NAME);
        }
예제 #34
0
 protected override void Import(Model model)
 {
     CreateMoleculeBuildingBlock();
     for (long i = 0; i < model.getNumSpecies(); i++)
     {
         CreateMoleculeFromSpecies(model.getSpecies(i));
     }
     CheckMoleculeNameContainer();
     CreateDummySpecies();
     CreateMoleculeStartValueBuildingBlock(model);
     SetMoleculeStartValues(model);
     SetDummyMSVs();
     AddToProject();
 }
예제 #35
0
 public void test_CompartmentType_ancestor_add()
 {
     CompartmentType ct = new CompartmentType(2,4);
       Model m = new Model(2,4);
       ct.setId("ct");
       m.addCompartmentType(ct);
       ct = null;
       ListOf lo = m.getListOfCompartmentTypes();
       CompartmentType obj = m.getCompartmentType(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 );
 }
예제 #36
0
 public void test_AssignmentRule_ancestor_create()
 {
     Model m = new Model(2,4);
       AssignmentRule r = m.createAssignmentRule();
       ListOf lo = m.getListOfRules();
       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 );
       Rule obj = m.getRule(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 );
 }
예제 #37
0
        public void Initialize(Model sbmlModel, SBMLDocument sbmlDoc)
        {
            Level   = (int)sbmlDoc.getLevel();
            Version = (int)sbmlDoc.getVersion();
            SaveSpeciesReferences(sbmlModel);

            if (sbmlModel.isSetConversionFactor())
            {
                ConversionFactor = sbmlModel.getConversionFactor();
            }
            if (sbmlModel.isSetSBOTerm())
            {
                SboTerm = sbmlModel.getSBOTerm();
            }
        }
예제 #38
0
 public void test_ListOf_append()
 {
     Model m = new  Model(2,4);
       m.createCompartment();
       ListOf loc = m.getListOfCompartments();
       assertTrue( loc.size() == 1 );
       SBase c = new  Compartment(2,4);
       int i = loc.append(c);
       assertTrue( i == libsbml.LIBSBML_OPERATION_SUCCESS );
       assertTrue( loc.size() == 2 );
       SBase sp = new  Species(2,4);
       i = loc.append(sp);
       assertTrue( i == libsbml.LIBSBML_INVALID_OBJECT );
       assertTrue( loc.size() == 2 );
       m = null;
       sp = null;
 }
        /// <summary>
        ///     Checks if the given Initial Assignment wants to assign a stoichiometry (species Reference).
        ///     This is not supported and causes a Notification.
        /// </summary>
        public void CheckSpeciesReferences(string assignmentId, string paramName, Model model)
        {
            foreach (var sp in _sbmlInformation.SpeciesReferences)
            {
                if (sp.getId() != paramName)
                {
                    continue;
                }

                var msg = new NotificationMessage(GetMainSpatialStructure(model), MessageOrigin.All, null,
                                                  NotificationType.Warning)
                {
                    Message = SBMLConstants.SBML_FEATURE_NOT_SUPPORTED + ": Stoichiometry of " + assignmentId +
                              " was set to default value: " + SBMLConstants.SBML_STOICHIOMETRY_DEFAULT
                };
                _sbmlInformation.NotificationMessages.Add(msg);
            }
        }
예제 #40
0
 public void test_SBMLDocument_setLevelAndVersion_Error()
 {
     SBMLDocument d = new  SBMLDocument();
       d.setLevelAndVersion(2,1,true);
       Model m1 = new  Model(2,1);
       Unit u = new  Unit(2,1);
       u.setKind(libsbml.UnitKind_forName("mole"));
       u.setOffset(3.2);
       UnitDefinition ud = new  UnitDefinition(2,1);
       ud.setId( "ud");
       ud.addUnit(u);
       m1.addUnitDefinition(ud);
       d.setModel(m1);
       assertTrue( d.setLevelAndVersion(2,2,true) == false );
       assertTrue( d.setLevelAndVersion(2,3,true) == false );
       assertTrue( d.setLevelAndVersion(1,2,true) == false );
       assertTrue( d.setLevelAndVersion(1,1,true) == false );
       d = null;
 }
예제 #41
0
 protected override void Import(Model model)
 {
     for (long i = 0; i < model.getNumRules(); i++)
     {
         var rule = model.getRule(i);
         if (rule.isAssignment())
         {
             CreateAssignmentRule(rule, model);
         }
         if (rule.isRate())
         {
             CreateRateRule(rule, model);
         }
         if (rule.isAlgebraic())
         {
             CreateAlgebraicRule(model);
         }
     }
     AddToProject();
 }
예제 #42
0
        /// <summary>
        ///     Gets the dimension of a species. It is set by it's one substanceUnits attribute
        ///     or by the substanceUnits definition of the Model.
        /// </summary>
        private IDimension GetDimension(Species s, Model model)
        {
            var        substanceUnits  = s.isSetSubstanceUnits() ? s.getSubstanceUnits() : model.getSubstanceUnits();
            IDimension amountDimension = null;

            if (_sbmlInformation.MobiDimension.ContainsKey(substanceUnits))
            {
                amountDimension = _sbmlInformation.MobiDimension[substanceUnits];
            }

            if (amountDimension == null)
            {
                return(null);
            }
            if (_moBiDimensionFactory.Dimensions.All(dim => dim.Name != amountDimension.Name))
            {
                _moBiDimensionFactory.AddDimension(amountDimension);
            }

            return(amountDimension);
        }
 public void test_Model_L1V2()
 {
     Model m = new Model(1,2);
       assertEquals( false, (m.hasRequiredElements()) );
       m.createCompartment();
       assertEquals( true, m.hasRequiredElements() );
       m = null;
 }
 public void test_Model_L1V1()
 {
     Model m = new Model(1,1);
       assertEquals( false, (m.hasRequiredElements()) );
       m.createCompartment();
       assertEquals( false, (m.hasRequiredElements()) );
       m.createSpecies();
       assertEquals( false, (m.hasRequiredElements()) );
       m.createReaction();
       assertEquals( true, m.hasRequiredElements() );
       m = null;
 }
 public void test_Model()
 {
     Model m = new Model(2,4);
       assertEquals( true, m.hasRequiredElements() );
       m = null;
 }
예제 #46
0
 /**
    * Copy constructor; creates a (deep) copy of the given Model object.
    *
    * @param orig the object to copy.
    */
 public Model(Model orig)
     : this(libsbmlPINVOKE.new_Model__SWIG_2(Model.getCPtr(orig)), true)
 {
     if (libsbmlPINVOKE.SWIGPendingException.Pending) throw libsbmlPINVOKE.SWIGPendingException.Retrieve();
 }
예제 #47
0
        internal static HandleRef getCPtrAndDisown(Model obj)
        {
            HandleRef ptr = new HandleRef(null, IntPtr.Zero);

            if (obj != null)
            {
            ptr             = obj.swigCPtr;
            obj.swigCMemOwn = false;
            }

            return ptr;
        }
예제 #48
0
 internal static HandleRef getCPtr(Model obj)
 {
     return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
 }
예제 #49
0
 /**
    * Copies a given Model object's subcomponents and appends the copies to
    * the appropriate places in this Model.
    *
    * This method also calls the <code>appendFrom</code> method on all libSBML
    * plug-in objects.
    *
    *
  *
  * SBML Level&nbsp;3 consists of a <em>Core</em> definition that can be extended
  * via optional SBML Level&nbsp;3 <em>packages</em>.  A given model may indicate
  * that it uses one or more SBML packages, and likewise, a software tool may be
  * able to support one or more packages.  LibSBML does not come preconfigured
  * with all possible packages included and enabled, in part because not all
  * package specifications have been finalized.  To support the ability for
  * software systems to enable support for the Level&nbsp;3 packages they choose,
  * libSBML features a <em>plug-in</em> mechanism.  Each SBML Level&nbsp;3
  * package is implemented in a separate code plug-in that can be enabled by the
  * application to support working with that SBML package.  A given SBML model
  * may thus contain not only objects defined by SBML Level&nbsp;3 Core, but also
  * objects created by libSBML plug-ins supporting additional Level&nbsp;3
  * packages.
  *
  *
    *
    * @param model the Model to merge with this one.
    *
    */
 public new int appendFrom(Model model)
 {
     int ret = libsbmlPINVOKE.Model_appendFrom(swigCPtr, Model.getCPtr(model));
     return ret;
 }
        public void test_Model_constructor()
        {
            SBase s;

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

              string msg = "";

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

              msg = "";

              try
              {
            s = new Model(SN99);
              }
              catch (SBMLConstructorException e)
              {
             msg = e.Message;
              }
              assertTrue(msg == ErrMsg);
        }
예제 #51
0
 public void test_create_l1v1_units()
 {
     SBMLDocument d;
       Model m;
       Compartment c;
       KineticLaw kl;
       Parameter p;
       Reaction r;
       Species s;
       SpeciesReference sr;
       Unit u;
       UnitDefinition ud;
       d = new  SBMLDocument();
       m = new  Model(2,4);
       d.setModel(m);
       ud = m.createUnitDefinition();
       ud.setName( "substance");
       u = m.createUnit();
       u.setKind(libsbml.UNIT_KIND_MOLE);
       u.setScale(-3);
       ud = m.createUnitDefinition();
       ud.setName( "mls");
       u = m.createUnit();
       u.setKind(libsbml.UNIT_KIND_MOLE);
       u.setScale(-3);
       u = m.createUnit();
       u.setKind(libsbml.UNIT_KIND_LITER);
       u.setExponent(-1);
       u = m.createUnit();
       u.setKind(libsbml.UNIT_KIND_SECOND);
       u.setExponent(-1);
       c = m.createCompartment();
       c.setName( "cell");
       s = m.createSpecies();
       s.setName( "x0");
       s.setCompartment( "cell");
       s.setInitialAmount(1);
       s = m.createSpecies();
       s.setName( "x1");
       s.setCompartment( "cell");
       s.setInitialAmount(1);
       s = m.createSpecies();
       s.setName( "s1");
       s.setCompartment( "cell");
       s.setInitialAmount(1);
       s = m.createSpecies();
       s.setName( "s2");
       s.setCompartment( "cell");
       s.setInitialAmount(1);
       p = m.createParameter();
       p.setName( "vm");
       p.setUnits( "mls");
       p.setValue(2);
       p = m.createParameter();
       p.setName( "km");
       p.setValue(2);
       r = m.createReaction();
       r.setName( "v1");
       sr = m.createReactant();
       sr.setSpecies( "x0");
       sr = m.createProduct();
       sr.setSpecies( "s1");
       kl = m.createKineticLaw();
       kl.setFormula( "(vm * s1)/(km + s1)");
       r = m.createReaction();
       r.setName( "v2");
       sr = m.createReactant();
       sr.setSpecies( "s1");
       sr = m.createProduct();
       sr.setSpecies( "s2");
       kl = m.createKineticLaw();
       kl.setFormula( "(vm * s2)/(km + s2)");
       r = m.createReaction();
       r.setName( "v3");
       sr = m.createReactant();
       sr.setSpecies( "s2");
       sr = m.createProduct();
       sr.setSpecies( "x1");
       kl = m.createKineticLaw();
       kl.setFormula( "(vm * s1)/(km + s1)");
       d = null;
 }
예제 #52
0
 /**
    * Creates a new L3ParserSettings object with specific values for all
    * possible settings.
    *
    * @param model a Model object to be used for disambiguating identifiers
    *
    * @param parselog a flag that controls how the parser will handle
    * the symbol @c log in formulas
    *
    * @param collapseminus a flag that controls how the parser will handle
    * minus signs
    *
    * @param parseunits a flag that controls how the parser will handle
    * apparent references to units of measurement associated with raw
    * numbers in a formula
    *
    * @param avocsymbol a flag that controls how the parser will handle
    * the appearance of the symbol @c avogadro in a formula
    *
    * @see getModel()
    * @see setModel(@if java Model model@endif)
    * @see unsetModel()
    * @see getParseLog()
    * @see setParseLog(@if java int type@endif)
    * @see getParseUnits()
    * @see setParseUnits(@if java bool units@endif)
    * @see getParseCollapseMinus()
    * @see setParseCollapseMinus(@if java bool collapseminus@endif)
    * @see getParseAvogadroCsymbol()
    * @see setParseAvogadroCsymbol(@if java bool l2only@endif)
    */
 public L3ParserSettings(Model model, int parselog, bool collapseminus, bool parseunits, bool avocsymbol)
     : this(libsbmlPINVOKE.new_L3ParserSettings__SWIG_1(Model.getCPtr(model), parselog, collapseminus, parseunits, avocsymbol), true)
 {
 }
예제 #53
0
 public static IdList mapComponentValues(Model m)
 {
     IdList ret = new IdList(libsbmlPINVOKE.SBMLTransforms_mapComponentValues(Model.getCPtr(m)), true);
     return ret;
 }
예제 #54
0
 /** */
 /* libsbml-internal */
 public static bool expandInitialAssignments(Model m)
 {
     bool ret = libsbmlPINVOKE.SBMLTransforms_expandInitialAssignments(Model.getCPtr(m));
     return ret;
 }
예제 #55
0
 /** */
 /* libsbml-internal */
 public static double evaluateASTNode(ASTNode node, Model m)
 {
     double ret = libsbmlPINVOKE.SBMLTransforms_evaluateASTNode__SWIG_0(ASTNode.getCPtr(node), Model.getCPtr(m));
     return ret;
 }
예제 #56
0
 /**
    * Sets the model reference in this L3ParserSettings object.
    *
    * When a Model object is provided, identifiers (values of type @c SId)
    * from that model are used in preference to pre-defined MathML
    * definitions.  More precisely, the Model entities whose identifiers will
    * shadow identical symbols in the mathematical formula are: Species,
    * Compartment, Parameter, Reaction, and SpeciesReference.  For instance,
    * if the parser is given a Model containing a Species with the identifier
    * &quot;<code>pi</code>&quot;, and the formula to be parsed is
    * &quot;<code>3*pi</code>&quot;, the MathML produced will contain the
    * construct <code>&lt;ci&gt; pi &lt;/ci&gt;</code> instead of the
    * construct <code>&lt;pi/&gt;</code>.
    * Similarly, when a Model object is provided, @c SId values of
    * user-defined functions present in the Model will be used preferentially
    * over pre-defined MathML functions.  For example, if the passed-in Model
    * contains a FunctionDefinition with the identifier
    * &quot;<code>sin</code>&quot;, that function will be used instead of the
    * predefined MathML function <code>&lt;sin/&gt;</code>.
    *
    * @param model a Model object to be used for disambiguating identifiers
    *
    * @warning <span class='warning'>This does @em not copy the Model object.
    * This means that modifications made to the object after invoking this
    * method may affect parsing behavior.</span>
    *
    * @see getModel()
    * @see unsetModel()
    */
 public void setModel(Model model)
 {
     libsbmlPINVOKE.L3ParserSettings_setModel(swigCPtr, Model.getCPtr(model));
 }
예제 #57
0
 public void test_L3_Model_createWithNS()
 {
     XMLNamespaces xmlns = new  XMLNamespaces();
       xmlns.add( "http://www.sbml.org", "testsbml");
       SBMLNamespaces sbmlns = new  SBMLNamespaces(3,1);
       sbmlns.addNamespaces(xmlns);
       Model m = new  Model(sbmlns);
       assertTrue( m.getTypeCode() == libsbml.SBML_MODEL );
       assertTrue( m.getMetaId() == "" );
       assertTrue( m.getNotes() == null );
       assertTrue( m.getAnnotation() == null );
       assertTrue( m.getLevel() == 3 );
       assertTrue( m.getVersion() == 1 );
       assertTrue( m.getNamespaces() != null );
       assertTrue( m.getNamespaces().getLength() == 2 );
       assertTrue( m.getId() == "" );
       assertTrue( m.getName() == "" );
       assertTrue( m.getSubstanceUnits() == "" );
       assertTrue( m.getTimeUnits() == "" );
       assertTrue( m.getVolumeUnits() == "" );
       assertTrue( m.getAreaUnits() == "" );
       assertTrue( m.getLengthUnits() == "" );
       assertTrue( m.getConversionFactor() == "" );
       assertEquals( false, m.isSetId() );
       assertEquals( false, m.isSetName() );
       assertEquals( false, m.isSetSubstanceUnits() );
       assertEquals( false, m.isSetTimeUnits() );
       assertEquals( false, m.isSetVolumeUnits() );
       assertEquals( false, m.isSetAreaUnits() );
       assertEquals( false, m.isSetLengthUnits() );
       assertEquals( false, m.isSetConversionFactor() );
       m = null;
 }
예제 #58
0
 /**
    * Sets the Model for this SBMLDocument to a copy of the given Model.
    *
    * @param m the new Model to use.
    *
    * @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 libsbmlcs.libsbml.LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS @endlink
    * @li @link libsbmlcs.libsbml.LIBSBML_LEVEL_MISMATCH LIBSBML_LEVEL_MISMATCH @endlink
    * @li @link libsbmlcs.libsbml.LIBSBML_VERSION_MISMATCH LIBSBML_VERSION_MISMATCH @endlink
    *
    * @see createModel()
    * @see getModel()
    */
 public int setModel(Model m)
 {
     int ret = libsbmlPINVOKE.SBMLDocument_setModel(swigCPtr, Model.getCPtr(m));
     return ret;
 }
예제 #59
0
 public void tearDown()
 {
     M = null;
 }
 public void test_Compartment_parent_add()
 {
     Compartment c = new Compartment(2,4);
       c.setId("c");
       Model m = new Model(2,4);
       m.addCompartment(c);
       c = null;
       ListOf lo = m.getListOfCompartments();
       assertTrue( lo == m.getCompartment(0).getParentSBMLObject() );
       assertTrue( m == lo.getParentSBMLObject() );
 }