예제 #1
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="aModel">the model object.</param>
 public SBML_Compartment( SBML_Model aModel)
 {
     this.Model = aModel;
     foreach (CompartmentStruct aCompartment in aModel.CompartmentList)
     {
         setSizeToDictionary(aCompartment);
         setUnitToDictionary(aCompartment);
     }
 }
예제 #2
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="aModel"></param>
 public SBML_Reaction(SBML_Model aModel)
 {
     this.Model = aModel;
 }
예제 #3
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="aModel"></param>
 public SBML_Species(SBML_Model aModel)
 {
     this.Model = aModel;
 }
예제 #4
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="filename"></param>
        public static EcellModel Convert(string filename)
        {
            if (!File.Exists(filename))
                throw new EcellException(string.Format(MessageResources.ErrFindFile, filename));

            string sbml = File.ReadAllText(filename);
            SBMLReader reader = new SBMLReader();
            SBMLDocument document = reader.readSBMLFromString(sbml);
            Model model = document.getModel();
            if (model == null)
            {
                throw new EcellException(string.Format("{0} has no model.", filename));
            }
            SBML_Model theModel = new SBML_Model(model);
            SBML_Compartment theCompartment = new SBML_Compartment(theModel);
            SBML_Parameter theParameter = new SBML_Parameter( theModel );
            SBML_Species theSpecies = new SBML_Species( theModel );
            SBML_Rule theRule = new SBML_Rule( theModel );
            SBML_Reaction theReaction = new SBML_Reaction(theModel);
            SBML_Event theEvent = new SBML_Event(theModel);

            document.Dispose();

            //Eml eml = new Eml(null);
            string modelId = Path.GetFileNameWithoutExtension(filename);
            EcellModel modelObject = (EcellModel)EcellObject.CreateObject(modelId, "", Constants.xpathModel, "", new List<EcellData>());
            // Set Layer
            List<EcellLayer> layers = new List<EcellLayer>();
            layers.Add(new EcellLayer(SbmlConstant.GlobalParameters, true));
            modelObject.Layers = layers;

            //
            // Set Stepper.
            //
            EcellObject stepper = EcellObject.CreateObject(modelId, "DE", EcellObject.STEPPER, "FixedODE1Stepper", new List<EcellData>());
            modelObject.Children.Add(stepper);

            //
            // Set Compartment ( System ).
            //
            EcellSystem rootSystem = (EcellSystem)EcellObject.CreateObject(modelId, "/", EcellObject.SYSTEM, EcellObject.SYSTEM, new List<EcellData>());
            rootSystem.SetEcellValue("StepperID", new EcellValue("DE"));
            rootSystem.SetEcellValue("Name", new EcellValue("Default"));
            modelObject.Children.Add(rootSystem);

            EcellSystem system = rootSystem;
            foreach (CompartmentStruct aCompartment in theModel.CompartmentList)
            {
                // getPath
                string aPath = "";
                if ( theModel.Level == 1 )
                    aPath = theModel.getPath( aCompartment.Name );
                else if ( theModel.Level == 2 )
                    aPath = theModel.getPath( aCompartment.ID );

                // setFullID
                if( aPath != "/" )
                {
                    system = (EcellSystem)EcellObject.CreateObject(modelId, aPath, EcellObject.SYSTEM, EcellObject.SYSTEM, new List<EcellData>());
                    modelObject.Children.Add(system);
                }

                // setStepper
                system.SetEcellValue("StepperID", new EcellValue("DE"));

                // setName( default = [] )
                if (theModel.Level == 2)
                    if (aCompartment.Name != "")
                        system.SetEcellValue("Name", new EcellValue(aCompartment.Name));

                // setDimensions( default = 3 )
                EcellObject dimension = EcellObject.CreateObject(modelId, aPath + ":Dimensions", EcellObject.VARIABLE, EcellObject.VARIABLE, new List<EcellData>());
                dimension.SetEcellValue("Value", new EcellValue((int)aCompartment.SpatialDimension));
                system.Children.Add(dimension);

                // setSIZE
                EcellObject size = EcellObject.CreateObject(modelId, aPath + ":SIZE", EcellObject.VARIABLE, EcellObject.VARIABLE, new List<EcellData>());
                size.SetEcellValue("Value", new EcellValue((double)theCompartment.getCompartmentSize(aCompartment)));
                system.Children.Add(size);
            }

            // Set GlobalParameter ( Variable )
            if ( theModel.ParameterList.Count > 0)
            {
                foreach(ParameterStruct aParameter in theModel.ParameterList)
                {
                    // setFullID
                    string parameterKey = theParameter.getParameterID( aParameter );
                    EcellObject parameter = EcellObject.CreateObject(modelId, parameterKey, EcellObject.VARIABLE, EcellObject.VARIABLE, new List<EcellData>());
                    // Set Layer
                    parameter.Layer = SbmlConstant.GlobalParameters;
                    // setName
                    if ( aParameter.Name != "" )
                        parameter.SetEcellValue("Name", new EcellValue(aParameter.Name));

                    // setValue
                    parameter.SetEcellValue("Value", new EcellValue(aParameter.Value));

                    // setFixed ( default = 1 )
                    if ( aParameter.Constant)
                        parameter.SetEcellValue("Fixed", new EcellValue(1));

                    // set to system.
                    rootSystem.Children.Add(parameter);
                }
            }

            // Set Species ( Variable )
            foreach(SpeciesStruct aSpecies in theModel.SpeciesList)
            {
                // Create
                string aSpeciesID = theSpecies.getSpeciesID( aSpecies );
                EcellObject variable = EcellObject.CreateObject(modelId, aSpeciesID, EcellObject.VARIABLE, EcellObject.VARIABLE, new List<EcellData>());
                // setName
                if( theModel.Level == 2 )
                    if ( aSpecies.Name != "" )
                        variable.SetEcellValue("Name", new EcellValue(aSpecies.Name));

                // setValue
                variable.SetEcellValue("Value", new EcellValue(theSpecies.getSpeciesValue( aSpecies )));

                // setFixed
                variable.SetEcellValue("Fixed", new EcellValue(theSpecies.getConstant( aSpecies )));

                // add
                modelObject.AddEntity(variable);
            }

            // Set Rule ( Process )
            if ( theModel.RuleList.Count > 0)
            {
                // make Rule System
                string aSystemKey = "/SBMLRule";
                system = (EcellSystem)EcellObject.CreateObject(modelId, aSystemKey, EcellObject.SYSTEM, EcellObject.SYSTEM, new List<EcellData>());
                system.SetEcellValue("Name", new EcellValue("System for SBML Rule"));
                system.SetEcellValue("StepperID", new EcellValue("DE"));
                modelObject.Children.Add(system);

                foreach(RuleStruct aRule in theModel.RuleList)
                {
                    theRule.initialize();

                    // setFullID
                    string aRuleID = theRule.getRuleID();
                    EcellObject process = EcellObject.CreateObject(modelId, aRuleID, EcellObject.PROCESS, EcellObject.PROCESS, new List<EcellData>());
                    modelObject.AddEntity(process);

                    // Algebraic Rule
                    if ( aRule.RuleType == libsbml.libsbml.SBML_ALGEBRAIC_RULE )
                    {
                        process.Classname = "ExpressionAlgebraicProcess";
                    }
                    // Assignment Rule
                    else if (aRule.RuleType == libsbml.libsbml.SBML_ASSIGNMENT_RULE ||
                           aRule.RuleType == libsbml.libsbml.SBML_SPECIES_CONCENTRATION_RULE ||
                           aRule.RuleType == libsbml.libsbml.SBML_COMPARTMENT_VOLUME_RULE ||
                           aRule.RuleType == libsbml.libsbml.SBML_PARAMETER_RULE)
                    {
                        process.Classname = "ExpressionAssignmentProcess";

                        int aVariableType = theRule.getVariableType( aRule.Variable );

                        if (aVariableType == libsbml.libsbml.SBML_SPECIES)
                            theRule.setSpeciesToVariableReference( aRule.Variable, 1 );
                        else if (aVariableType == libsbml.libsbml.SBML_PARAMETER)
                            theRule.setParameterToVariableReference( aRule.Variable, 1 );
                        else if (aVariableType == libsbml.libsbml.SBML_COMPARTMENT)
                            theRule.setCompartmentToVariableReference( aRule.Variable, 1 );
                        else
                            throw new EcellException("Variable type must be Species, Parameter, or Compartment");
                    }
                    // Rate Rule
                    else if (aRule.RuleType == libsbml.libsbml.SBML_RATE_RULE)
                    {
                        process.Classname = "ExpressionFluxProcess";

                        int aVariableType = theRule.getVariableType( aRule.Variable );

                        if (aVariableType == libsbml.libsbml.SBML_SPECIES)
                            theRule.setSpeciesToVariableReference( aRule.Variable, 1 );
                        else if (aVariableType == libsbml.libsbml.SBML_PARAMETER)
                            theRule.setParameterToVariableReference( aRule.Variable, 1 );
                        else if (aVariableType == libsbml.libsbml.SBML_COMPARTMENT)
                            theRule.setCompartmentToVariableReference( aRule.Variable, 1 );
                        else
                            throw new EcellException("Variable type must be Species, Parameter, or Compartment");
                    }
                    else
                        throw new EcellException(" The type of Rule must be Algebraic, Assignment or Rate Rule");

                    // convert SBML formula to E-Cell formula
                    string convertedFormula = theRule.convertRuleFormula( aRule.Formula );

                    // set Expression Property
                    process.SetEcellValue("Expression", new EcellValue(convertedFormula));

                    // setVariableReferenceList
                    process.SetEcellValue("VariableReferenceList", new EcellValue(theRule.GetVariableReferenceList()));
                }
            }

            // Set Reaction ( Process )
            foreach(ReactionStruct aReaction in theModel.ReactionList)
            {
                theReaction.initialize();

                // setFullID
                string aReactionID = theReaction.getReactionID( aReaction );
                EcellProcess process = (EcellProcess)EcellObject.CreateObject(modelId, aReactionID, EcellObject.PROCESS, "ExpressionFluxProcess", new List<EcellData>());

                // setName
                if ( theModel.Level == 2 )
                    if( aReaction.Name != "" )
                        process.SetEcellValue("Name",new EcellValue(aReaction.Name));

                // setSubstrate
                foreach(ReactantStruct aSubstrate in aReaction.Reactants)
                {
                    string name = "S" + theReaction.SubstrateNumber.ToString();
                    string aSubstrateID = theModel.getSpeciesReferenceID( aSubstrate.Species );
                    if ( aSubstrateID == null )
                        throw new EcellException("Species "+aSubstrate.Species+" not found");

                    if ( aSubstrate.Denominator != 1 )
                        throw new EcellException("Stoichiometry Error : E-Cell System can't set a floating Stoichiometry");
                    int coefficient = -1 * theReaction.getStoichiometry(aSubstrate.Species, aSubstrate.Stoichiometry );

                    VariableReferenceStruct aSubstrateList = new VariableReferenceStruct(name, "Variable:" + aSubstrateID, coefficient);
                    theReaction.VariableReferenceList.Add( aSubstrateList );
                    theReaction.SubstrateNumber = theReaction.SubstrateNumber + 1;
                }

                // setProduct
                foreach(ProductStruct aProduct in aReaction.Products)
                {
                    string name = 'P' + theReaction.ProductNumber.ToString();
                    string aProductID = theModel.getSpeciesReferenceID( aProduct.Species );
                    if ( aProductID == "" )
                        throw new EcellException("Species "+aProduct.Species+" not found");

                    if ( aProduct.Denominator != 1 )
                        throw new EcellException("Stoichiometry Error : E-Cell System can't set a floating Stoichiometry");

                    int coefficient = 1 * theReaction.getStoichiometry(aProduct.Species,  aProduct.Stoichiometry );

                    VariableReferenceStruct aProductList = new VariableReferenceStruct(name, "Variable:" + aProductID, coefficient);
                    theReaction.VariableReferenceList.Add( aProductList );
                    theReaction.ProductNumber = theReaction.ProductNumber + 1;
                }

                // setCatalyst
                foreach(string aModifier in aReaction.Modifiers)
                {
                    string name = "C" + theReaction.ModifierNumber.ToString();
                    string aModifierID = theModel.getSpeciesReferenceID( aModifier );
                    if ( aModifierID == "" )
                        throw new EcellException("Species "+aModifier+" not found");

                    VariableReferenceStruct aModifierList = new VariableReferenceStruct(name, "Variable:" + aModifierID, 0);
                    theReaction.VariableReferenceList.Add( aModifierList );
                    theReaction.ModifierNumber = theReaction.ModifierNumber + 1;

                }

                // setProperty
                foreach(KineticLawStruct kineticLaw in aReaction.KineticLaws)
                {
                    foreach(ParameterStruct aParameter in kineticLaw.Parameters)
                    {
                        if (theModel.Level == 1)
                            process.SetEcellValue(aParameter.Name, new EcellValue(aParameter.Value));
                        else if (theModel.Level == 2)
                            process.SetEcellValue(aParameter.ID, new EcellValue(aParameter.Value));
                    }

                    // set "Expression" Property
                    // convert SBML format formula to E-Cell format formula
                    if( kineticLaw.Formula != "" )
                    {
                        string anExpression = theReaction.convertKineticLawFormula( kineticLaw.Formula );

                        // set Expression Property for ExpressionFluxProcess
                        process.SetEcellValue("Expression", new EcellValue(anExpression));

                        // setVariableReferenceList
                        process.SetEcellValue("VariableReferenceList", new EcellValue(theReaction.GetVariableReferenceList()));
                    }
                }
                // Set Parent System.
                string sysKey = process.ParentSystemID;
                foreach (EcellReference er in process.ReferenceList)
                {
                    if (er.Coefficient == -1)
                        sysKey = er.Key.Split(':')[0];
                }
                foreach (EcellReference er in process.ReferenceList)
                {
                    if (er.Coefficient == 1)
                        sysKey = er.Key.Split(':')[0];
                }
                process.Key = sysKey + ":" + process.LocalID;
                // Update EntityPath.
                foreach (EcellData data in process.Value)
                {
                    data.EntityPath = process.FullID + ":" + data.Name;
                }

                modelObject.AddEntity(process);

            }

            return modelObject;
        }
예제 #5
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="aModel"></param>
 public SBML_Event(SBML_Model aModel)
 {
     this.Model = aModel;
     this.EventNumber = 0;
 }
예제 #6
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="aModel"></param>
 public SBML_Rule(SBML_Model aModel)
 {
     this.Model = aModel;
     this.RuleNumber = 0;
 }
예제 #7
0
 public void TestSBML_Rule()
 {
     SBMLReader reader = new SBMLReader();
     SBMLDocument document = reader.readSBML(TestConstant.SBML_BIOMD0000000003);
     Model sbmlModel = document.getModel();
     SBML_Model model = new SBML_Model(sbmlModel);
     SBML_Compartment sc = new SBML_Compartment(model);
     SBML_Species species = new SBML_Species(model);
     SBML_Rule rule = new SBML_Rule(model);
 }
예제 #8
0
        public void TestSBML_Species()
        {
            SBMLReader reader = new SBMLReader();
            SBMLDocument document = reader.readSBML(TestConstant.SBML_Oscillation);

            SBML_Model model = new SBML_Model(document.getModel());
            SBML_Compartment sc = new SBML_Compartment(model);
            SBML_Species species = new SBML_Species(model);

            // getConstant
            SpeciesStruct ss = new SpeciesStruct();
            int i = species.getConstant(ss);
            Assert.AreEqual(0, i, "getConstant returns unexpected value.");

            ss.Constant = true;
            i = species.getConstant(ss);
            Assert.AreEqual(1, i, "getConstant returns unexpected value.");

            model.Level = 1;
            i = species.getConstant(ss);
            Assert.AreEqual(0, i, "getConstant returns unexpected value.");

            ss.BoundaryCondition = true;
            i = species.getConstant(ss);
            Assert.AreEqual(1, i, "getConstant returns unexpected value.");

            try
            {
                model.Level = 0;
                i = species.getConstant(ss);
            }
            catch (Exception)
            {
            }

            // getSpeciesValue
            double d = species.getSpeciesValue(ss);
            Assert.AreEqual(0.0, d, "getSpeciesValue returns unexpected value.");

            model.Level = 2;
            ss.InitialAmount = double.NaN;
            ss.Compartment = "cell";
            d = species.getSpeciesValue(ss);
            Assert.AreEqual(0.0, d, "getSpeciesValue returns unexpected value.");

            try
            {
                ss.InitialConcentration = double.NaN;
                d = species.getSpeciesValue(ss);
            }
            catch (Exception)
            {
            }

            // getSpeciesID
            ss.ID = "Test1";
            string id = species.getSpeciesID(ss);
            Assert.AreEqual("/cell:Test1", id, "getSpeciesID returns unexpected value.");

            try
            {
                model.Level = 1;
                ss.Name = "Test2";
                id = species.getSpeciesID(ss);
            }
            catch (Exception)
            {
            }

            try
            {
                model.Level = 0;
                id = species.getSpeciesID(ss);
            }
            catch (Exception)
            {
            }

            try
            {
                model.Level = 2;
                ss.Compartment = "";
                id = species.getSpeciesID(ss);
            }
            catch (Exception)
            {
            }
        }
예제 #9
0
        public void TestSBML_Parameter()
        {
            SBMLReader reader = new SBMLReader();
            SBMLDocument document = reader.readSBML(TestConstant.SBML_Oscillation);

            SBML_Model model = new SBML_Model(document.getModel());
            SBML_Parameter p = new SBML_Parameter(model);

            ParameterStruct ps = new ParameterStruct();

            // getParameterID
            ps.ID = "Test1";
            string id = p.getParameterID(ps);
            Assert.AreEqual("/SBMLParameter:Test1", id, "getParameterID returns unexpected value.");
            try
            {
                ps.ID = "";
                id = p.getParameterID(ps);
            }
            catch (Exception)
            {
            }
            model.Level = 1;
            ps.Name = "Test2";
            id = p.getParameterID(ps);
            Assert.AreEqual("/SBMLParameter:Test2", id, "getParameterID returns unexpected value.");
            try
            {
                ps.Name = "";
                id = p.getParameterID(ps);
            }
            catch (Exception)
            {
            }
            try
            {
                model.Level = 0;
                id = p.getParameterID(ps);
            }
            catch (Exception)
            {
            }
        }
예제 #10
0
        public void TestSBML_Reaction()
        {
            SBMLReader reader = new SBMLReader();
            SBMLDocument document = reader.readSBML(TestConstant.SBML_Oscillation);

            SBML_Model model = new SBML_Model(document.getModel());
            SBML_Reaction reaction = new SBML_Reaction(model);
        }
예제 #11
0
        public void TestSBML_Model()
        {
            SBMLReader reader = new SBMLReader();
            SBMLDocument document = reader.readSBML(TestConstant.SBML_Oscillation);

            SBML_Model model = new SBML_Model(document.getModel());

            // getSpeciesReferenceID
            SpeciesStruct ss = new SpeciesStruct();
            ss.Compartment = "cell";
            ss.ID = "Test1";
            ss.Name = "Test1";

            string id;
            try
            {
                id = model.getSpeciesReferenceID(ss.ID);
            }
            catch (Exception)
            {
            }
            model.SpeciesList.Add(ss);
            id = model.getSpeciesReferenceID(ss.ID);
            Assert.AreEqual("/cell:Test1", id, "getEventID returns unexpected value.");

            try
            {
                model.Level = 1;
                id = model.getSpeciesReferenceID(ss.ID);
            }
            catch (Exception)
            {
            }

            try
            {
                model.Level = 0;
                id = model.getSpeciesReferenceID(ss.ID);
            }
            catch (Exception)
            {
            }

            // setFunctionDefinitionToDictionary
            FunctionDefinitionStruct ud = new FunctionDefinitionStruct();
            ud.ID = "Function";
            ud.Name = "Function";
            ud.Formula = "1 * 2";
            model.FunctionDefinitionList.Add(ud);

            Type type = model.GetType();
            MethodInfo info1 = type.GetMethod("setFunctionDefinitionToDictionary", BindingFlags.NonPublic | BindingFlags.Instance);
            info1.Invoke(model, new object[] { });

            // getNewUnitValue
            MethodInfo info2 = type.GetMethod("getNewUnitValue", BindingFlags.NonPublic | BindingFlags.Instance);
            UnitStruct unit = new UnitStruct("Kind", 2, 1, 0.5, 3);
            double value = (double)info2.Invoke(model, new object[] { unit });
            Assert.AreEqual(28.0d, value, "getNewUnitValue returns unexpected value.");

            // convertUnit
            model.Level = 2;
            value = model.convertUnit("test", 0.1d);
            Assert.AreEqual(0.1d, value, "convertUnit returns unexpected value.");

            value = model.convertUnit("substance", 1.0d);
            Assert.AreEqual(1.0d, value, "convertUnit returns unexpected value.");

            model.Level = 1;
            value = model.convertUnit("test", 0.1d);
            Assert.AreEqual(0.1d, value, "convertUnit returns unexpected value.");

            value = model.convertUnit("minute", 1.0d);
            Assert.AreEqual(60.0d, value, "convertUnit returns unexpected value.");

            try
            {
                model.Level = 0;
                model.convertUnit("test", 0.1d);
            }
            catch (Exception)
            {
            }

            // getPath
            string path;
            try
            {
                path = model.getPath("");
            }
            catch (Exception)
            {
            }
            path = model.getPath("default");
            Assert.AreEqual("/", path, "getPath returns unexpected value.");
        }
예제 #12
0
        public void TestSBML_Event()
        {
            SBMLReader reader = new SBMLReader();
            SBMLDocument document = reader.readSBML(TestConstant.SBML_Oscillation);

            SBML_Model model = new SBML_Model(document.getModel());
            SBML_Event e = new SBML_Event(model);

            EventStruct es = new EventStruct();
            es.ID = "Test1";
            string id = e.getEventID(es);
            Assert.AreEqual("Process:/:Test1", id, "getEventID returns unexpected value.");

            model.Level = 1;
            es.Name = "Test2";
            id = e.getEventID(es);
            Assert.AreEqual("Process:/:Test2", id, "getEventID returns unexpected value.");

            model.Level = 0;
            id = e.getEventID(es);
            Assert.AreEqual("Process:/:Event0", id, "getEventID returns unexpected value.");
        }
예제 #13
0
        public void TestSBML_Compartment()
        {
            SBMLReader reader = new SBMLReader();
            SBMLDocument document = reader.readSBML(TestConstant.SBML_Oscillation);

            SBML_Model model = new SBML_Model(document.getModel());
            SBML_Compartment c = new SBML_Compartment(model);

            CompartmentStruct cs = new CompartmentStruct();
            try
            {
                c.getCompartmentID(cs);
            }
            catch (Exception)
            {
            }
            string id;

            cs.Outside = "";
            cs.ID = "Test1";
            id = c.getCompartmentID(cs);
            Assert.AreEqual("System:/:Test1", id, "getCompartmentID returns unexpected value.");

            try
            {
                model.Level = 1;
                id = c.getCompartmentID(cs);
            }
            catch (Exception)
            {
            }

            try
            {
                model.Level = 0;
                id = c.getCompartmentID(cs);
            }
            catch (Exception)
            {
            }

            model.Level = 2;
            cs.Outside = "cell";
            id = c.getCompartmentID(cs);
            Assert.AreEqual("System:/cell:Test1", id, "getCompartmentID returns unexpected value.");

            try
            {
                model.Level = 1;
                id = c.getCompartmentID(cs);
            }
            catch (Exception)
            {
            }

            try
            {
                model.Level = 0;
                id = c.getCompartmentID(cs);
            }
            catch (Exception)
            {
            }

            // GetModuleType
            Type type = c.GetType();
            MethodInfo info1 = type.GetMethod("setSizeToDictionary", BindingFlags.NonPublic | BindingFlags.Instance);
            MethodInfo info2 = type.GetMethod("setUnitToDictionary", BindingFlags.NonPublic | BindingFlags.Instance);
            try
            {
                info1.Invoke(c, new object[] { cs });
            }
            catch (Exception)
            {
            }
            try
            {
                info2.Invoke(c, new object[] { cs });
            }
            catch (Exception)
            {
            }
            model.Level = 1;
            cs.Volume = double.NaN;
            cs.Name = "Test1";
            info1.Invoke(c, new object[] { cs });
            info2.Invoke(c, new object[] { cs });

            // getOutsideSize
            model.Level = 2;
            MethodInfo info3 = type.GetMethod("getOutsideSize", BindingFlags.NonPublic | BindingFlags.Instance);
            double size;
            size = (double)info3.Invoke(c, new object[] { "" });
            Assert.AreEqual(1.0d, size, "getOutsideSize returns unexpected value.");

            size = (double)info3.Invoke(c, new object[] { "cell" });
            Assert.AreEqual(1.0d, size, "getOutsideSize returns unexpected value.");

            // getOutsideUnit
            MethodInfo info4 = type.GetMethod("getOutsideUnit", BindingFlags.NonPublic | BindingFlags.Instance);
            string unit;
            unit = (string)info4.Invoke(c, new object[] { "" });
            Assert.AreEqual("", unit, "getCompartmentSize returns unexpected value.");

            unit = (string)info4.Invoke(c, new object[] { "cell" });
            Assert.AreEqual("", unit, "getCompartmentSize returns unexpected value.");

            // getCompartmentSize
            size = c.getCompartmentSize(cs);
            Assert.AreEqual(1.0d, size, "getCompartmentSize returns unexpected value.");

            model.Level = 1;
            size = c.getCompartmentSize(cs);
            Assert.AreEqual(1.0d, size, "getCompartmentSize returns unexpected value.");

            try
            {
                model.Level = 0;
                size = c.getCompartmentSize(cs);
            }
            catch (Exception)
            {
            }

            // getCompartmentUnit
            model.Level = 2;
            id = c.getCompartmentUnit(cs);
            Assert.AreEqual(null, id, "getCompartmentUnit returns unexpected value.");

            model.Level = 1;
            id = c.getCompartmentUnit(cs);
            Assert.AreEqual(null, id, "getCompartmentUnit returns unexpected value.");

            try
            {
                model.Level = 0;
                id = c.getCompartmentUnit(cs);
            }
            catch (Exception)
            {
            }
        }
예제 #14
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="aModel"></param>
 public SBML_Parameter(SBML_Model aModel)
 {
     this.Model = aModel;
 }
예제 #15
0
 public void TestAll()
 {
     SBMLReader reader = new SBMLReader();
     SBMLDocument document = reader.readSBML(TestConstant.SBML_BIOMD0000000003);
     Model sbmlModel = document.getModel();
     // Set FunctionDefinition
     ASTNode math = libsbml.libsbml.parseFormula("V0 * 5");
     FunctionDefinition fd = sbmlModel.createFunctionDefinition();
     fd.setId("FD");
     fd.setName("FD");
     fd.setMath(math);
     // Set Event
     Event ev = sbmlModel.createEvent();
     ev.setId("Event");
     ev.setName("Event");
     ev.setTrigger(new Trigger(2,3));
     EventAssignment ea = ev.createEventAssignment();
     ea.setId("Assignment");
     ea.setName("Assignment");
     // Set Initial Amount
     InitialAssignment ia = sbmlModel.createInitialAssignment();
     ia.setSymbol("M1");
     ia.setMath(math);
     // Set UnitDefinition
     UnitDefinition ud = sbmlModel.createUnitDefinition();
     ud.setId("UD");
     ud.setName("UD");
     Unit unit = ud.createUnit();
     unit.setId("Unit");
     unit.setName("Unit");
     //
     SBML_Model model = new SBML_Model(sbmlModel);
 }