当前位置: 首页>>代码示例>>C#>>正文


C# Model.getUnitDefinition方法代码示例

本文整理汇总了C#中libsbml.Model.getUnitDefinition方法的典型用法代码示例。如果您正苦于以下问题:C# Model.getUnitDefinition方法的具体用法?C# Model.getUnitDefinition怎么用?C# Model.getUnitDefinition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在libsbml.Model的用法示例。


在下文中一共展示了Model.getUnitDefinition方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: getUnitDefinition

        /// <summary>
        /// [ UnitDefinitionStruct ]
        /// [[ Id , Name , [ UnitStruct ] ]]
        /// </summary>
        /// <param name="aSBMLmodel"></param>
        /// <returns></returns>
        public static List<UnitDefinitionStruct> getUnitDefinition(Model aSBMLmodel)
        {
            List<UnitDefinitionStruct> list = new List<UnitDefinitionStruct>();

            ListOfUnitDefinitions listOfUnitDefinitions = aSBMLmodel.getListOfUnitDefinitions();
            for (int i = 0; i < listOfUnitDefinitions.size(); i++ )
            {
                UnitDefinition anUnitDefinition = aSBMLmodel.getUnitDefinition(i);

                string anId = anUnitDefinition.getId();
                string aName = anUnitDefinition.getName();

                List<UnitStruct> unitList = new List<UnitStruct>();

                ListOfUnits listOfUnits = anUnitDefinition.getListOfUnits();
                for (int j = 0; j < listOfUnits.size(); j++)
                {
                    Unit anUnit = anUnitDefinition.getUnit(j);

                    int anUnitKind = anUnit.getKind();
                    string aKind = libsbml.libsbml.UnitKind_toString( anUnitKind );
                    int anExponent = anUnit.getExponent();
                    int aScale = anUnit.getScale();
                    double aMultiplier = anUnit.getMultiplier();
                    double anOffset = anUnit.getOffset();

                    UnitStruct unit = new UnitStruct(
                        aKind,
                        anExponent,
                        aScale,
                        aMultiplier,
                        anOffset );

                    unitList.Add( unit );
                }

                UnitDefinitionStruct unitDefinition = new UnitDefinitionStruct(
                    anId,
                    aName,
                    unitList );

                list.Add(unitDefinition);
            }

            return list;
        }
开发者ID:ecell,项目名称:ecell3-ide,代码行数:52,代码来源:SbmlFunctions.cs

示例2: test_UnitDefinition_parent_add

 public void test_UnitDefinition_parent_add()
 {
     UnitDefinition ia = new UnitDefinition(2,4);
       Model m = new Model(2,4);
       ia.setId("u");
       ia.createUnit();
       m.addUnitDefinition(ia);
       ia = null;
       ListOf lo = m.getListOfUnitDefinitions();
       assertTrue( lo == m.getUnitDefinition(0).getParentSBMLObject() );
       assertTrue( m == lo.getParentSBMLObject() );
 }
开发者ID:mgaldzic,项目名称:copasi_api,代码行数:12,代码来源:TestSBMLParentObject.cs

示例3: test_UnitDefinition_parent_create

 public void test_UnitDefinition_parent_create()
 {
     Model m = new Model(2,4);
       UnitDefinition ud = m.createUnitDefinition();
       ListOf lo = m.getListOfUnitDefinitions();
       assertTrue( lo == m.getUnitDefinition(0).getParentSBMLObject() );
       assertTrue( lo == ud.getParentSBMLObject() );
       assertTrue( m == lo.getParentSBMLObject() );
 }
开发者ID:mgaldzic,项目名称:copasi_api,代码行数:9,代码来源:TestSBMLParentObject.cs

示例4: test_UnitDefinition_ancestor_add

 public void test_UnitDefinition_ancestor_add()
 {
     UnitDefinition ia = new UnitDefinition(2,4);
       Model m = new Model(2,4);
       ia.setId("u");
       ia.createUnit();
       m.addUnitDefinition(ia);
       ia = null;
       ListOf lo = m.getListOfUnitDefinitions();
       UnitDefinition obj = m.getUnitDefinition(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 );
 }
开发者ID:mgaldzic,项目名称:copasi_api,代码行数:15,代码来源:TestAncestor.cs

示例5: test_UnitDefinition_ancestor_create

 public void test_UnitDefinition_ancestor_create()
 {
     Model m = new Model(2,4);
       UnitDefinition ud = m.createUnitDefinition();
       ListOf lo = m.getListOfUnitDefinitions();
       assertTrue( ud.getAncestorOfType(libsbml.SBML_MODEL) == m );
       assertTrue( ud.getAncestorOfType(libsbml.SBML_LIST_OF) == lo );
       assertTrue( ud.getAncestorOfType(libsbml.SBML_DOCUMENT) == null );
       assertTrue( ud.getAncestorOfType(libsbml.SBML_EVENT) == null );
       UnitDefinition obj = m.getUnitDefinition(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 );
 }
开发者ID:mgaldzic,项目名称:copasi_api,代码行数:15,代码来源:TestAncestor.cs

示例6: test_ReadSBML_metaid

 public void test_ReadSBML_metaid()
 {
     SBase sb;
       string s = wrapSBML_L2v1("<listOfFunctionDefinitions>" +
     "  <functionDefinition metaid='fd'/>" +
     "</listOfFunctionDefinitions>" +
     "<listOfUnitDefinitions>" +
     "  <unitDefinition metaid='ud'/>" +
     "</listOfUnitDefinitions>" +
     "<listOfCompartments>" +
     "  <compartment metaid='c'/>" +
     "</listOfCompartments>" +
     "<listOfSpecies>" +
     "  <species metaid='s'/>" +
     "</listOfSpecies>" +
     "<listOfParameters>" +
     "  <parameter metaid='p'/>" +
     "</listOfParameters>" +
     "<listOfRules>" +
     "  <rateRule metaid='rr'/>" +
     "</listOfRules>" +
     "<listOfReactions>" +
     "  <reaction metaid='rx'/>" +
     "</listOfReactions>" +
     "<listOfEvents>" +
     " <event metaid='e'/>" +
     "</listOfEvents>");
       D = libsbml.readSBMLFromString(s);
       M = D.getModel();
       assertTrue( M != null );
       sb = M.getFunctionDefinition(0);
       assertEquals( true, sb.isSetMetaId() );
       assertTrue((  "fd" == sb.getMetaId() ));
       sb = M.getUnitDefinition(0);
       assertEquals( true, sb.isSetMetaId() );
       assertTrue((  "ud" == sb.getMetaId() ));
       sb = M.getCompartment(0);
       assertEquals( true, sb.isSetMetaId() );
       assertTrue((  "c" == sb.getMetaId() ));
       sb = M.getSpecies(0);
       assertEquals( true, sb.isSetMetaId() );
       assertTrue((  "s" == sb.getMetaId() ));
       sb = M.getParameter(0);
       assertEquals( true, sb.isSetMetaId() );
       assertTrue((  "p" == sb.getMetaId() ));
       sb = M.getRule(0);
       assertEquals( true, sb.isSetMetaId() );
       assertTrue((  "rr" == sb.getMetaId() ));
       sb = M.getReaction(0);
       assertEquals( true, sb.isSetMetaId() );
       assertTrue((  "rx" == sb.getMetaId() ));
       sb = M.getEvent(0);
       assertEquals( true, sb.isSetMetaId() );
       assertTrue((  "e" == sb.getMetaId() ));
 }
开发者ID:mgaldzic,项目名称:copasi_api,代码行数:55,代码来源:TestReadSBML.cs

示例7: test_ReadSBML_metaid_Unit

 public void test_ReadSBML_metaid_Unit()
 {
     SBase sb;
       UnitDefinition ud;
       string s = wrapSBML_L2v1("<listOfUnitDefinitions>" +
     "  <unitDefinition metaid='ud'>" +
     "    <listOfUnits metaid='lou'>" +
     "      <unit metaid='u'/>" +
     "    </listOfUnits>" +
     "  </unitDefinition>" +
     "</listOfUnitDefinitions>");
       D = libsbml.readSBMLFromString(s);
       M = D.getModel();
       assertTrue( M != null );
       ud = M.getUnitDefinition(0);
       sb = ud;
       assertEquals( true, sb.isSetMetaId() );
       assertTrue((  "ud" == sb.getMetaId() ));
       sb = ud.getListOfUnits();
       assertEquals( true, sb.isSetMetaId() );
       assertTrue((  "lou" == sb.getMetaId() ));
       sb = ud.getUnit(0);
       assertEquals( true, sb.isSetMetaId() );
       assertTrue((  "u" == sb.getMetaId() ));
 }
开发者ID:mgaldzic,项目名称:copasi_api,代码行数:25,代码来源:TestReadSBML.cs

示例8: test_ReadSBML_Unit_L2

 public void test_ReadSBML_Unit_L2()
 {
     Unit u;
       UnitDefinition ud;
       string s = wrapSBML_L2v1("<listOfUnitDefinitions>" +
     "  <unitDefinition id='Fahrenheit'>" +
     "    <listOfUnits>" +
     "      <unit kind='Celsius' multiplier='1.8' offset='32'/>" +
     "    </listOfUnits>" +
     "  </unitDefinition>" +
     "</listOfUnitDefinitions>");
       D = libsbml.readSBMLFromString(s);
       M = D.getModel();
       assertTrue( M.getNumUnitDefinitions() == 1 );
       ud = M.getUnitDefinition(0);
       assertEquals( true, ud.isSetId() );
       assertTrue((  "Fahrenheit" == ud.getId() ));
       assertTrue( ud.getNumUnits() == 1 );
       u = ud.getUnit(0);
       assertTrue( u.getKind() == libsbml.UNIT_KIND_CELSIUS );
       assertTrue( u.getExponent() == 1 );
       assertTrue( u.getScale() == 0 );
       assertTrue( u.getMultiplier() == 1.8 );
       assertTrue( u.getOffset() == 32 );
 }
开发者ID:mgaldzic,项目名称:copasi_api,代码行数:25,代码来源:TestReadSBML.cs

示例9: test_ReadSBML_Unit_defaults_L1_L2

 public void test_ReadSBML_Unit_defaults_L1_L2()
 {
     Unit u;
       UnitDefinition ud;
       string s = wrapSBML_L1v2("<listOfUnitDefinitions>" +
     "  <unitDefinition name='bogomips'>" +
     "    <listOfUnits> <unit kind='second'/> </listOfUnits>" +
     "  </unitDefinition>" +
     "</listOfUnitDefinitions>");
       D = libsbml.readSBMLFromString(s);
       M = D.getModel();
       assertTrue( M.getNumUnitDefinitions() == 1 );
       ud = M.getUnitDefinition(0);
       assertTrue((  "bogomips" == ud.getId() ));
       assertTrue( ud.getNumUnits() == 1 );
       u = ud.getUnit(0);
       assertTrue( u.getKind() == libsbml.UNIT_KIND_SECOND );
       assertTrue( u.getExponent() == 1 );
       assertTrue( u.getScale() == 0 );
       assertTrue( u.getMultiplier() == 1.0 );
       assertTrue( u.getOffset() == 0.0 );
 }
开发者ID:mgaldzic,项目名称:copasi_api,代码行数:22,代码来源:TestReadSBML.cs

示例10: test_ReadSBML_UnitDefinition_L2

 public void test_ReadSBML_UnitDefinition_L2()
 {
     UnitDefinition ud;
       string s = wrapSBML_L2v1("<listOfUnitDefinitions>" +
     "  <unitDefinition id='mmls' name='mmol/ls'/>" +
     "</listOfUnitDefinitions>");
       D = libsbml.readSBMLFromString(s);
       M = D.getModel();
       assertTrue( M.getNumUnitDefinitions() == 1 );
       ud = M.getUnitDefinition(0);
       assertEquals( true, ud.isSetId() );
       assertEquals( true, ud.isSetName() );
       assertTrue((  "mmls" == ud.getId() ));
       assertTrue((  "mmol/ls" == ud.getName() ));
 }
开发者ID:mgaldzic,项目名称:copasi_api,代码行数:15,代码来源:TestReadSBML.cs

示例11: test_ReadSBML_UnitDefinition

 public void test_ReadSBML_UnitDefinition()
 {
     UnitDefinition ud;
       string s = wrapSBML_L1v2("<listOfUnitDefinitions>" +
     "  <unitDefinition name='mmls'/>" +
     "</listOfUnitDefinitions>");
       D = libsbml.readSBMLFromString(s);
       M = D.getModel();
       assertTrue( M.getNumUnitDefinitions() == 1 );
       ud = M.getUnitDefinition(0);
       assertTrue((  "mmls" == ud.getId() ));
 }
开发者ID:mgaldzic,项目名称:copasi_api,代码行数:12,代码来源:TestReadSBML.cs

示例12: test_ReadSBML_Unit

 public void test_ReadSBML_Unit()
 {
     Unit u;
       UnitDefinition ud;
       string s = wrapSBML_L1v2("<listOfUnitDefinitions>" +
     "  <unitDefinition name='substance'>" +
     "    <listOfUnits> <unit kind='mole' scale='-3'/> </listOfUnits>" +
     "  </unitDefinition>" +
     "</listOfUnitDefinitions>");
       D = libsbml.readSBMLFromString(s);
       M = D.getModel();
       assertTrue( M.getNumUnitDefinitions() == 1 );
       ud = M.getUnitDefinition(0);
       assertTrue((  "substance" == ud.getId() ));
       assertTrue( ud.getNumUnits() == 1 );
       u = ud.getUnit(0);
       assertTrue( u.getKind() == libsbml.UNIT_KIND_MOLE );
       assertTrue( u.getExponent() == 1 );
       assertTrue( u.getScale() == -3 );
 }
开发者ID:mgaldzic,项目名称:copasi_api,代码行数:20,代码来源:TestReadSBML.cs


注:本文中的libsbml.Model.getUnitDefinition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。