Example #1
0
 def test_Model_getCompartmentById(self):
     c1 = libsbml.Compartment(2, 4)
     c2 = libsbml.Compartment(2, 4)
     c1.setId("A")
     c2.setId("B")
     self.M.addCompartment(c1)
     self.M.addCompartment(c2)
     self.assert_(self.M.getNumCompartments() == 2)
     self.assert_(self.M.getCompartment("A") != c1)
     self.assert_(self.M.getCompartment("B") != c2)
     self.assert_(self.M.getCompartment("C") == None)
     pass
Example #2
0
 def test_Model_getCompartment(self):
     c1 = libsbml.Compartment(2, 4)
     c2 = libsbml.Compartment(2, 4)
     c1.setId("A")
     c2.setId("B")
     self.M.addCompartment(c1)
     self.M.addCompartment(c2)
     self.assert_(self.M.getNumCompartments() == 2)
     c1 = self.M.getCompartment(0)
     c2 = self.M.getCompartment(1)
     self.assert_(("A" == c1.getId()))
     self.assert_(("B" == c2.getId()))
     pass
Example #3
0
 def test_Compartment_copyConstructor(self):
   o1 = libsbml.Compartment(2,4)
   o1.setId("c")
   o1.setOutside("c2")
   self.assert_( o1.getId() ==  "c" )
   self.assert_( o1.getOutside() ==  "c2" )
   o2 = libsbml.Compartment(o1)
   self.assert_( o2.getId() ==  "c" )
   self.assert_( o2.getOutside() ==  "c2" )
   self.assert_( o2.getParentSBMLObject() == o1.getParentSBMLObject() )
   o2 = None
   o1 = None
   pass  
Example #4
0
 def test_Compartment_assignmentOperator(self):
   o1 = libsbml.Compartment(2,4)
   o1.setId("c")
   o1.setOutside("c2")
   self.assert_( o1.getId() ==  "c" )
   self.assert_( o1.getOutside() ==  "c2" )
   o2 = libsbml.Compartment(2,4)
   o2 = o1
   self.assert_( o2.getId() ==  "c" )
   self.assert_( o2.getOutside() ==  "c2" )
   self.assert_( o2.getParentSBMLObject() == o1.getParentSBMLObject() )
   o2 = None
   o1 = None
   pass  
Example #5
0
 def test_Compartment(self):
     c = libsbml.Compartment(2, 4)
     self.assertEqual(False, (c.hasRequiredAttributes()))
     c.setId("c")
     self.assertEqual(True, c.hasRequiredAttributes())
     c = None
     pass
Example #6
0
 def test_L3_Compartment_initDefaults(self):
     c = libsbml.Compartment(3, 1)
     c.setId("A")
     self.assertEqual(True, c.isSetId())
     self.assertEqual(False, c.isSetName())
     self.assertEqual(False, c.isSetSize())
     self.assertEqual(False, c.isSetVolume())
     self.assertEqual(False, c.isSetUnits())
     self.assertEqual(False, c.isSetConstant())
     self.assertEqual(False, c.isSetSpatialDimensions())
     c.initDefaults()
     self.assert_(("A" == c.getId()))
     self.assert_(c.getName() == "")
     self.assert_(("litre" == c.getUnits()))
     self.assert_(c.getSpatialDimensions() == 3)
     self.assert_(c.getSize() == 1)
     self.assert_(c.getConstant() == True)
     self.assertEqual(True, c.isSetId())
     self.assertEqual(False, c.isSetName())
     self.assertEqual(False, c.isSetSize())
     self.assertEqual(False, c.isSetVolume())
     self.assertEqual(True, c.isSetUnits())
     self.assertEqual(True, c.isSetConstant())
     self.assertEqual(True, c.isSetSpatialDimensions())
     _dummyList = [c]
     _dummyList[:] = []
     del _dummyList
     pass
Example #7
0
 def test_L3_Compartment_createWithNS(self):
     xmlns = libsbml.XMLNamespaces()
     xmlns.add("http://www.sbml.org", "testsbml")
     sbmlns = libsbml.SBMLNamespaces(3, 1)
     sbmlns.addNamespaces(xmlns)
     c = libsbml.Compartment(sbmlns)
     self.assert_(c.getTypeCode() == libsbml.SBML_COMPARTMENT)
     self.assert_(c.getMetaId() == "")
     self.assert_(c.getNotes() == None)
     self.assert_(c.getAnnotation() == None)
     self.assert_(c.getLevel() == 3)
     self.assert_(c.getVersion() == 1)
     self.assert_(c.getNamespaces() != None)
     self.assert_(c.getNamespaces().getLength() == 2)
     self.assert_(c.getId() == "")
     self.assert_(c.getName() == "")
     self.assert_(c.getUnits() == "")
     self.assert_(c.getOutside() == "")
     self.assertEqual(True, isnan(c.getSpatialDimensionsAsDouble()))
     self.assertEqual(True, isnan(c.getVolume()))
     self.assert_(c.getConstant() == True)
     self.assertEqual(False, c.isSetId())
     self.assertEqual(False, c.isSetSpatialDimensions())
     self.assertEqual(False, c.isSetName())
     self.assertEqual(False, c.isSetSize())
     self.assertEqual(False, c.isSetVolume())
     self.assertEqual(False, c.isSetUnits())
     self.assertEqual(False, c.isSetOutside())
     self.assertEqual(False, c.isSetConstant())
     _dummyList = [c]
     _dummyList[:] = []
     del _dummyList
     pass
 def test_L3_Compartment_hasRequiredAttributes(self):
   c = libsbml.Compartment(3,1)
   self.assertEqual( False, c.hasRequiredAttributes() )
   c.setId( "id")
   self.assertEqual( False, c.hasRequiredAttributes() )
   c.setConstant(False)
   self.assertEqual( True, c.hasRequiredAttributes() )
   _dummyList = [ c ]; _dummyList[:] = []; del _dummyList
   pass  
Example #9
0
 def test_Compartment_setCompartmentType4(self):
     c = libsbml.Compartment(2, 2)
     i = c.setCompartmentType("")
     self.assert_(i == libsbml.LIBSBML_OPERATION_SUCCESS)
     self.assertEqual(False, c.isSetCompartmentType())
     _dummyList = [c]
     _dummyList[:] = []
     del _dummyList
     pass
Example #10
0
 def test_Compartment_setConstant2(self):
     c = libsbml.Compartment(2, 2)
     i = c.setConstant(False)
     self.assert_(i == libsbml.LIBSBML_OPERATION_SUCCESS)
     self.assert_(c.getConstant() == False)
     _dummyList = [c]
     _dummyList[:] = []
     del _dummyList
     pass
Example #11
0
 def test_Compartment_setSpatialDimensions5(self):
     c = libsbml.Compartment(2, 2)
     i = c.setSpatialDimensions(2.2)
     self.assert_(i == libsbml.LIBSBML_INVALID_ATTRIBUTE_VALUE)
     self.assert_(c.getSpatialDimensions() == 3)
     _dummyList = [c]
     _dummyList[:] = []
     del _dummyList
     pass
Example #12
0
 def test_Compartment_setId2(self):
     c = libsbml.Compartment(2, 2)
     i = c.setId("1cell")
     self.assert_(i == libsbml.LIBSBML_INVALID_ATTRIBUTE_VALUE)
     self.assertEqual(False, c.isSetId())
     _dummyList = [c]
     _dummyList[:] = []
     del _dummyList
     pass
Example #13
0
 def test_Compartment_setSpatialDimensions4(self):
     c = libsbml.Compartment(2, 2)
     i = c.setSpatialDimensions(2.0)
     self.assert_(i == libsbml.LIBSBML_OPERATION_SUCCESS)
     self.assert_(c.getSpatialDimensions() == 2)
     _dummyList = [c]
     _dummyList[:] = []
     del _dummyList
     pass
Example #14
0
 def test_sbase_has_read(self):
     compartment = libsbml.Compartment(3, 1)
     assert compartment is not None
     stream = libsbml.XMLInputStream(
         """<?xml version="1.0" encoding="utf-8"?>
     <compartment id="vol1" name="compartment 1" size="2.0" />""", False)
     compartment.read(stream)
     assert compartment.id == 'vol1'
     assert compartment.name == 'compartment 1'
     assert compartment.volume == 2.0
Example #15
0
 def test_Compartment_parent_add(self):
     c = libsbml.Compartment(2, 4)
     c.setId("c")
     m = libsbml.Model(2, 4)
     m.addCompartment(c)
     c = None
     lo = m.getListOfCompartments()
     self.assert_(lo == m.getCompartment(0).getParentSBMLObject())
     self.assert_(m == lo.getParentSBMLObject())
     pass
Example #16
0
 def test_Compartment_setId3(self):
     c = libsbml.Compartment(2, 2)
     i = c.setId("cell")
     self.assert_(i == libsbml.LIBSBML_OPERATION_SUCCESS)
     self.assertEqual(True, c.isSetId())
     self.assert_(("cell" == c.getId()))
     _dummyList = [c]
     _dummyList[:] = []
     del _dummyList
     pass
Example #17
0
 def test_Compartment_setCompartmentType2(self):
     c = libsbml.Compartment(2, 2)
     i = c.setCompartmentType("1cell")
     self.assert_(i == libsbml.LIBSBML_INVALID_ATTRIBUTE_VALUE)
     self.assertEqual(False, c.isSetCompartmentType())
     i = c.unsetCompartmentType()
     self.assert_(i == libsbml.LIBSBML_OPERATION_SUCCESS)
     self.assertEqual(False, c.isSetCompartmentType())
     _dummyList = [c]
     _dummyList[:] = []
     del _dummyList
     pass
Example #18
0
 def test_Compartment_ancestor_add(self):
   c = libsbml.Compartment(2,4)
   c.setId("C")
   m = libsbml.Model(2,4)
   m.addCompartment(c)
   c = None
   lo = m.getListOfCompartments()
   obj = m.getCompartment(0)
   self.assert_( obj.getAncestorOfType(libsbml.SBML_MODEL) == m )
   self.assert_( obj.getAncestorOfType(libsbml.SBML_LIST_OF) == lo )
   self.assert_( obj.getAncestorOfType(libsbml.SBML_DOCUMENT) == None )
   self.assert_( obj.getAncestorOfType(libsbml.SBML_EVENT) == None )
   pass  
Example #19
0
 def test_Compartment_setVolume2(self):
     c = libsbml.Compartment(2, 2)
     i = c.setVolume(4)
     self.assert_(i == libsbml.LIBSBML_OPERATION_SUCCESS)
     self.assert_(c.getVolume() == 4.0)
     self.assertEqual(True, c.isSetVolume())
     i = c.unsetVolume()
     self.assert_(i == libsbml.LIBSBML_OPERATION_SUCCESS)
     self.assertEqual(False, c.isSetVolume())
     _dummyList = [c]
     _dummyList[:] = []
     del _dummyList
     pass
 def test_Model_addCompartment5(self):
     m = libsbml.Model(2, 2)
     c = libsbml.Compartment(2, 2)
     c.setId("c")
     c1 = libsbml.Compartment(2, 2)
     c1.setId("c")
     i = m.addCompartment(c)
     self.assert_(i == libsbml.LIBSBML_OPERATION_SUCCESS)
     self.assert_(m.getNumCompartments() == 1)
     i = m.addCompartment(c1)
     self.assert_(i == libsbml.LIBSBML_DUPLICATE_OBJECT_ID)
     self.assert_(m.getNumCompartments() == 1)
     _dummyList = [c]
     _dummyList[:] = []
     del _dummyList
     _dummyList = [c1]
     _dummyList[:] = []
     del _dummyList
     _dummyList = [m]
     _dummyList[:] = []
     del _dummyList
     pass
 def test_internal_consistency_check_99905(self):
   d = libsbml.SBMLDocument(2,4)
   c = libsbml.Compartment(2,4)
   d.setLevelAndVersion(1,2,False)
   m = d.createModel()
   c.setId("c")
   c.setSBOTerm(2)
   m.addCompartment(c)
   errors = d.checkInternalConsistency()
   self.assert_( errors == 1 )
   self.assert_( d.getError(0).getErrorId() == 10103 )
   d = None
   pass  
    def insertRows(self, position, rows=1, index=QModelIndex()):
        self.beginInsertRows(QModelIndex(), position,
                             position + rows - 1)  # mandatory Qt call

        for row in range(
                rows
        ):  # we don't take the actual row into account as the libSBML always appends at the end
            newCompartment = libsbml.Compartment()
            self.mainModel.SbmlModel.addCompartment(SBMLEntity(newCompartment))

        self.endInsertRows()  # mandatory Qt call
        self.Dirty = True
        return True
 def test_Model_addCompartment3(self):
     m = libsbml.Model(2, 2)
     c = libsbml.Compartment(1, 2)
     c.setId("c")
     i = m.addCompartment(c)
     self.assert_(i == libsbml.LIBSBML_LEVEL_MISMATCH)
     self.assert_(m.getNumCompartments() == 0)
     _dummyList = [c]
     _dummyList[:] = []
     del _dummyList
     _dummyList = [m]
     _dummyList[:] = []
     del _dummyList
     pass
 def test_internal_consistency_check_99903(self):
   d = libsbml.SBMLDocument(2,4)
   c = libsbml.Compartment(2,4)
   d.setLevelAndVersion(1,2,False)
   m = d.createModel()
   c.setConstant(True)
   c.setId("c")
   m.addCompartment(c)
   r = m.createAssignmentRule()
   r.setVariable("c")
   r.setFormula("2*3")
   errors = d.checkInternalConsistency()
   self.assert_( errors == 3 )
   d = None
   pass  
Example #25
0
 def test_SBMLConvert_convertToL1_Species_Amount(self):
   d = libsbml.SBMLDocument(2,1)
   m = d.createModel()
   sid =  "C";
   c = libsbml.Compartment(2,4)
   s = libsbml.Species(2,4)
   c.setId(sid)
   m.addCompartment(c)
   s.setCompartment(sid)
   s.setInitialAmount(2.34)
   m.addSpecies(s)
   self.assert_( d.setLevelAndVersion(1,2,True) == True )
   self.assert_( s.getInitialAmount() == 2.34 )
   _dummyList = [ d ]; _dummyList[:] = []; del _dummyList
   pass  
 def test_Model_addCompartment1(self):
     m = libsbml.Model(2, 2)
     c = libsbml.Compartment(2, 2)
     i = m.addCompartment(c)
     self.assert_(i == libsbml.LIBSBML_INVALID_OBJECT)
     c.setId("c")
     i = m.addCompartment(c)
     self.assert_(i == libsbml.LIBSBML_OPERATION_SUCCESS)
     self.assert_(m.getNumCompartments() == 1)
     _dummyList = [c]
     _dummyList[:] = []
     del _dummyList
     _dummyList = [m]
     _dummyList[:] = []
     del _dummyList
     pass
Example #27
0
 def test_ListOf_append(self):
   m = libsbml.Model(2,4)
   m.createCompartment()
   loc = m.getListOfCompartments()
   self.assert_( loc.size() == 1 )
   c = libsbml.Compartment(2,4)
   i = loc.append(c)
   self.assert_( i == libsbml.LIBSBML_OPERATION_SUCCESS )
   self.assert_( loc.size() == 2 )
   sp = libsbml.Species(2,4)
   i = loc.append(sp)
   self.assert_( i == libsbml.LIBSBML_INVALID_OBJECT )
   self.assert_( loc.size() == 2 )
   _dummyList = [ m ]; _dummyList[:] = []; del _dummyList
   _dummyList = [ sp ]; _dummyList[:] = []; del _dummyList
   pass  
 def test_Compartment_createWith(self):
     c = libsbml.Compartment(2, 4)
     c.setId("A")
     self.assert_(c.getTypeCode() == libsbml.SBML_COMPARTMENT)
     self.assert_(c.getMetaId() == "")
     self.assert_(c.getNotes() == None)
     self.assert_(c.getAnnotation() == None)
     self.assert_(c.getName() == "")
     self.assert_(c.getSpatialDimensions() == 3)
     self.assert_(("A" == c.getId()))
     self.assert_(c.getConstant() == True)
     self.assertEqual(True, c.isSetId())
     self.assertEqual(False, c.isSetName())
     _dummyList = [c]
     _dummyList[:] = []
     del _dummyList
     pass
 def test_Compartment_createWithNS(self):
     xmlns = libsbml.XMLNamespaces()
     xmlns.add("http://www.sbml.org", "testsbml")
     sbmlns = libsbml.SBMLNamespaces(2, 1)
     sbmlns.addNamespaces(xmlns)
     c = libsbml.Compartment(sbmlns)
     self.assert_(c.getTypeCode() == libsbml.SBML_COMPARTMENT)
     self.assert_(c.getMetaId() == "")
     self.assert_(c.getNotes() == None)
     self.assert_(c.getAnnotation() == None)
     self.assert_(c.getLevel() == 2)
     self.assert_(c.getVersion() == 1)
     self.assert_(c.getNamespaces() != None)
     self.assert_(c.getNamespaces().getLength() == 2)
     self.assert_(c.getName() == "")
     self.assert_(c.getSpatialDimensions() == 3)
     self.assert_(c.getConstant() == True)
     _dummyList = [c]
     _dummyList[:] = []
     del _dummyList
     pass
Example #30
0
 def test_SBMLConvert_convertToL1_Species_Concentration(self):
   d = libsbml.SBMLDocument(2,1)
   m = d.createModel()
   sid =  "C";
   c = libsbml.Compartment(2,1)
   s = libsbml.Species(2,1)
   c.setId(sid)
   c.setSize(1.2)
   m.addCompartment(c)
   s.setId( "s"  )
   s.setCompartment(sid)
   s.setInitialConcentration(2.34)
   m.addSpecies(s)
   self.assert_( d.setLevelAndVersion(1,2,True) == True )
   s1 = m.getSpecies(0)
   self.assert_( s1 != None )
   self.assert_((  "C" == s1.getCompartment() ))
   self.assert_( m.getCompartment( "C").getSize() == 1.2 )
   self.assert_( s1.getInitialConcentration() == 2.34 )
   self.assert_( s1.isSetInitialConcentration() == True )
   _dummyList = [ d ]; _dummyList[:] = []; del _dummyList
   pass