getUnitDefinition() public method

public getUnitDefinition ( long n ) : UnitDefinition
n long
return UnitDefinition
Ejemplo n.º 1
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));
            }
        }
 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() );
 }
 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() );
 }
Ejemplo n.º 4
0
 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 );
 }
Ejemplo n.º 5
0
 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 );
 }
Ejemplo n.º 6
0
 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() ));
 }
Ejemplo n.º 7
0
 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() ));
 }
Ejemplo n.º 8
0
 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 );
 }
Ejemplo n.º 9
0
 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 );
 }
Ejemplo n.º 10
0
 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() ));
 }
Ejemplo n.º 11
0
 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() ));
 }
Ejemplo n.º 12
0
 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 );
 }