public void test_SBMLConvertStrict_convertL1ParamRule()
        {
            SBMLDocument d = new  SBMLDocument(1, 2);
            Model        m = d.createModel();
            Compartment  c = m.createCompartment();

            c.setId("c");
            Parameter p = m.createParameter();

            p.setId("p");
            Parameter p1 = m.createParameter();

            p1.setId("p1");
            ASTNode math = libsbml.parseFormula("p");
            Rule    ar   = m.createAssignmentRule();

            ar.setVariable("p1");
            ar.setMath(math);
            ar.setUnits("mole");
            assertTrue(d.setLevelAndVersion(2, 1, true) == true);
            assertTrue(d.getLevel() == 2);
            assertTrue(d.getVersion() == 1);
            Rule r1 = d.getModel().getRule(0);

            assertTrue(r1.getUnits() == "");
            d = null;
        }
        public void test_SBMLConvertStrict_convertNonStrictSBO()
        {
            SBMLDocument d = new  SBMLDocument(2, 4);
            Model        m = d.createModel();
            Compartment  c = m.createCompartment();

            c.setId("c");
            c.setConstant(false);
            (c).setSBOTerm(64);
            assertTrue(d.setLevelAndVersion(2, 3, true) == false);
            assertTrue(d.getLevel() == 2);
            assertTrue(d.getVersion() == 4);
            assertTrue(d.setLevelAndVersion(2, 2, true) == false);
            assertTrue(d.getLevel() == 2);
            assertTrue(d.getVersion() == 4);
            assertTrue(d.setLevelAndVersion(2, 1, true) == true);
            assertTrue(d.getLevel() == 2);
            assertTrue(d.getVersion() == 1);
            Compartment c1 = d.getModel().getCompartment(0);

            assertTrue((c1).getSBOTerm() == -1);
            assertTrue(d.setLevelAndVersion(1, 2, true) == true);
            assertTrue(d.getLevel() == 1);
            assertTrue(d.getVersion() == 2);
            Compartment c2 = d.getModel().getCompartment(0);

            assertTrue((c2).getSBOTerm() == -1);
            d = null;
        }
Example #3
0
        public void test_SBMLConvert_convertToL3_stoichiometryMath()
        {
            SBMLDocument d = new  SBMLDocument(2, 1);
            Model        m = d.createModel();
            Compartment  c = m.createCompartment();

            c.setId("c");
            Species s = m.createSpecies();

            s.setId("s");
            s.setCompartment("c");
            Reaction         r  = m.createReaction();
            SpeciesReference sr = r.createReactant();

            sr.setSpecies("s");
            StoichiometryMath sm  = sr.createStoichiometryMath();
            ASTNode           ast = libsbml.parseFormula("c*2");

            sm.setMath(ast);
            assertTrue(m.getNumRules() == 0);
            assertTrue(sr.isSetId() == false);
            assertTrue(d.setLevelAndVersion(3, 1, false) == true);
            m  = d.getModel();
            r  = m.getReaction(0);
            sr = r.getReactant(0);
            assertTrue(m.getNumRules() == 1);
            assertTrue(sr.isSetId() == true);
            Rule rule = m.getRule(0);

            assertTrue((rule.getVariable() == sr.getId()));
            d = null;
        }
Example #4
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);
            }
Example #5
0
        public void test_SBMLConvert_convertToL3_localParameters()
        {
            SBMLDocument d = new  SBMLDocument(1, 2);
            Model        m = d.createModel();
            Compartment  c = m.createCompartment();

            c.setId("c");
            Species s = m.createSpecies();

            s.setId("s");
            s.setCompartment("c");
            Reaction         r  = m.createReaction();
            SpeciesReference sr = r.createReactant();

            sr.setSpecies("s");
            KineticLaw kl = r.createKineticLaw();

            kl.setFormula("s*k");
            Parameter p = kl.createParameter();

            p.setId("k");
            assertTrue(kl.getNumLocalParameters() == 0);
            assertTrue(d.setLevelAndVersion(3, 1, false) == true);
            m  = d.getModel();
            r  = m.getReaction(0);
            kl = r.getKineticLaw();
            assertTrue(kl.getNumLocalParameters() == 1);
            LocalParameter lp = kl.getLocalParameter(0);

            d = null;
        }
Example #6
0
        public void test_SBMLConvert_convertToL1_Species_Concentration()
        {
            SBMLDocument d   = new  SBMLDocument(2, 1);
            Model        m   = d.createModel();
            string       sid = "C";
            Compartment  c   = new  Compartment(2, 1);
            Species      s   = new  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);
            assertTrue(d.setLevelAndVersion(1, 2, true) == true);
            Species s1 = m.getSpecies(0);

            assertTrue(s1 != null);
            assertTrue(("C" == s1.getCompartment()));
            assertTrue(m.getCompartment("C").getSize() == 1.2);
            assertTrue(s1.getInitialConcentration() == 2.34);
            assertTrue(s1.isSetInitialConcentration() == true);
            d = null;
        }
        public void test_L3_Compartment_initDefaults()
        {
            Compartment c = new  Compartment(3, 1);

            c.setId("A");
            assertEquals(true, c.isSetId());
            assertEquals(false, c.isSetName());
            assertEquals(false, c.isSetSize());
            assertEquals(false, c.isSetVolume());
            assertEquals(false, c.isSetUnits());
            assertEquals(false, c.isSetConstant());
            assertEquals(false, c.isSetSpatialDimensions());
            c.initDefaults();
            assertTrue(("A" == c.getId()));
            assertTrue(c.getName() == "");
            assertTrue(("litre" == c.getUnits()));
            assertTrue(c.getSpatialDimensions() == 3);
            assertTrue(c.getSize() == 1);
            assertTrue(c.getConstant() == true);
            assertEquals(true, c.isSetId());
            assertEquals(false, c.isSetName());
            assertEquals(false, c.isSetSize());
            assertEquals(false, c.isSetVolume());
            assertEquals(true, c.isSetUnits());
            assertEquals(true, c.isSetConstant());
            assertEquals(true, c.isSetSpatialDimensions());
            c = null;
        }
        public void test_SBMLConvertStrict_convertToL1()
        {
            SBMLDocument d = new  SBMLDocument(2, 4);
            Model        m = d.createModel();

            (m).setMetaId("_m");
            Compartment c = m.createCompartment();

            c.setId("c");
            (c).setSBOTerm(240);
            Species s = m.createSpecies();

            s.setId("s");
            s.setCompartment("c");
            assertTrue(d.setLevelAndVersion(1, 2, true) == true);
            assertTrue(d.getLevel() == 1);
            assertTrue(d.getVersion() == 2);
            Model m1 = d.getModel();

            assertTrue((m1).getMetaId() == "");
            Compartment c1 = m1.getCompartment(0);

            assertTrue((c1).getSBOTerm() == -1);
            Species s1 = m1.getSpecies(0);

            assertTrue(s1.getHasOnlySubstanceUnits() == false);
            d = null;
        }
        public void test_SBMLConvertStrict_convertNonStrictUnits()
        {
            SBMLDocument d = new  SBMLDocument(2, 4);
            Model        m = d.createModel();
            Compartment  c = m.createCompartment();

            c.setId("c");
            c.setConstant(false);
            Parameter p = m.createParameter();

            p.setId("p");
            p.setUnits("mole");
            ASTNode math = libsbml.parseFormula("p");
            Rule    ar   = m.createAssignmentRule();

            ar.setVariable("c");
            ar.setMath(math);
            assertTrue(d.setLevelAndVersion(2, 1, true) == false);
            assertTrue(d.getLevel() == 2);
            assertTrue(d.getVersion() == 4);
            assertTrue(d.setLevelAndVersion(2, 2, true) == false);
            assertTrue(d.getLevel() == 2);
            assertTrue(d.getVersion() == 4);
            assertTrue(d.setLevelAndVersion(2, 3, true) == false);
            assertTrue(d.getLevel() == 2);
            assertTrue(d.getVersion() == 4);
            assertTrue(d.setLevelAndVersion(1, 2, true) == false);
            assertTrue(d.getLevel() == 2);
            assertTrue(d.getVersion() == 4);
            d = null;
        }
Example #10
0
        public void test_Model_addCompartment()
        {
            Compartment c = new  Compartment(2, 4);

            c.setId("c");
            M.addCompartment(c);
            assertTrue(M.getNumCompartments() == 1);
        }
        public void test_WriteL3SBML_Compartment()
        {
            string      expected = "<compartment id=\"A\" constant=\"true\"/>";
            Compartment c        = D.createModel().createCompartment();

            c.setId("A");
            c.setConstant(true);
            assertEquals(true, equals(expected, c.toSBML()));
        }
Example #12
0
        public void test_Compartment_setId4()
        {
            Compartment c = new  Compartment(2, 2);
            int         i = c.setId("");

            assertTrue(i == libsbml.LIBSBML_OPERATION_SUCCESS);
            assertEquals(false, c.isSetId());
            c = null;
        }
Example #13
0
        public void test_Compartment_setId2()
        {
            Compartment c = new  Compartment(2, 2);
            int         i = c.setId("1cell");

            assertTrue(i == libsbml.LIBSBML_INVALID_ATTRIBUTE_VALUE);
            assertEquals(false, c.isSetId());
            c = null;
        }
Example #14
0
        public void test_Compartment()
        {
            Compartment c = new Compartment(2, 4);

            assertEquals(false, (c.hasRequiredAttributes()));
            c.setId("c");
            assertEquals(true, c.hasRequiredAttributes());
            c = null;
        }
        public void test_L3_Compartment_hasRequiredAttributes()
        {
            Compartment c = new  Compartment(3, 1);

            assertEquals(false, c.hasRequiredAttributes());
            c.setId("id");
            assertEquals(false, c.hasRequiredAttributes());
            c.setConstant(false);
            assertEquals(true, c.hasRequiredAttributes());
            c = null;
        }
Example #16
0
        static void testCreateSBML()
        {
            SBMLDocument d = new SBMLDocument(defLevel, defVersion);

            Model m = d.createModel();

            m.setId("testmodel");

            Compartment c1 = m.createCompartment();
            Compartment c2 = m.createCompartment();

            c1.setId("c1");
            c2.setId("c2");

            Species s1 = m.createSpecies();
            Species s2 = m.createSpecies();

            string id1 = "s1";
            string id2 = "s2";

            // strings with non-ASCII characters (multibyte characters)
            string n1 = "γ-lyase";
            string n2 = "β-synthase";

            s1.setId(id1);
            s1.setName(n1);
            s1.setCompartment("c1");

            s2.setId(id2);
            s2.setName(n2);
            s2.setCompartment("c2");

            string file = "test2.xml";

            try
            {
                if (libsbml.writeSBML(d, file) == 0)
                {
                    ERR("[CreateSBML] Error: cannot write " + file);
                }
                else
                {
                    OK();
                }
            }
            catch (Exception e)
            {
                ERR("[CreateSBML] (" + file + ") Error: Exception thrown : " + e.Message);
            }

            testReadSBMLFromFile(file);
        }
        public void test_Model_addCompartment3()
        {
            Model       m = new  Model(2, 2);
            Compartment c = new  Compartment(1, 2);

            c.setId("c");
            int i = m.addCompartment(c);

            assertTrue(i == libsbml.LIBSBML_LEVEL_MISMATCH);
            assertTrue(m.getNumCompartments() == 0);
            c = null;
            m = null;
        }
        public void test_WriteL3SBML_Compartment_spatialDimensions()
        {
            string      expected  = "<compartment id=\"A\" spatialDimensions=\"2.1\" " + "constant=\"false\"/>";
            string      expected1 = "<compartment id=\"A\" constant=\"false\"/>";
            Compartment c         = D.createModel().createCompartment();

            c.setId("A");
            c.setConstant(false);
            c.setSpatialDimensions(2.1);
            assertEquals(true, equals(expected, c.toSBML()));
            c.unsetSpatialDimensions();
            assertEquals(true, equals(expected1, c.toSBML()));
        }
        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;
        }
        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());
        }
Example #21
0
        public void test_SBMLConvert_convertToL3_compartment()
        {
            SBMLDocument d   = new  SBMLDocument(2, 2);
            Model        m   = d.createModel();
            string       sid = "C";
            Compartment  c   = m.createCompartment();
            Compartment  c1;

            c.setId(sid);
            assertTrue(d.setLevelAndVersion(3, 1, false) == true);
            c1 = m.getCompartment(0);
            assertTrue(c1.hasRequiredAttributes() == true);
            d = null;
        }
Example #22
0
        public void test_Model_getCompartmentById()
        {
            Compartment c1 = new  Compartment(2, 4);
            Compartment c2 = new  Compartment(2, 4);

            c1.setId("A");
            c2.setId("B");
            M.addCompartment(c1);
            M.addCompartment(c2);
            assertTrue(M.getNumCompartments() == 2);
            assertTrue(M.getCompartment("A") != c1);
            assertTrue(M.getCompartment("B") != c2);
            assertTrue(M.getCompartment("C") == null);
        }
        public void test_L3_Compartment_id()
        {
            string id = "mitochondria";

            assertEquals(false, C.isSetId());
            C.setId(id);
            assertTrue((id == C.getId()));
            assertEquals(true, C.isSetId());
            if (C.getId() == id)
            {
                ;
            }
            {
            }
        }
Example #24
0
        public void test_Model_getCompartment()
        {
            Compartment c1 = new  Compartment(2, 4);
            Compartment c2 = new  Compartment(2, 4);

            c1.setId("A");
            c2.setId("B");
            M.addCompartment(c1);
            M.addCompartment(c2);
            assertTrue(M.getNumCompartments() == 2);
            c1 = M.getCompartment(0);
            c2 = M.getCompartment(1);
            assertTrue(("A" == c1.getId()));
            assertTrue(("B" == c2.getId()));
        }
Example #25
0
        public void test_SBMLConvert_invalidLevelVersion()
        {
            SBMLDocument d   = new  SBMLDocument(2, 1);
            Model        m   = d.createModel();
            string       sid = "C";
            Compartment  c   = m.createCompartment();

            c.setId(sid);
            c.setSize(1.2);
            c.setUnits("volume");
            assertTrue(d.setLevelAndVersion(1, 3, true) == false);
            assertTrue(d.setLevelAndVersion(2, 7, true) == false);
            assertTrue(d.setLevelAndVersion(3, 5, true) == false);
            assertTrue(d.setLevelAndVersion(4, 1, true) == false);
        }
Example #26
0
        public void test_Compartment_copyConstructor()
        {
            Compartment o1 = new Compartment(2, 4);

            o1.setId("c");
            o1.setOutside("c2");
            assertTrue(o1.getId() == "c");
            assertTrue(o1.getOutside() == "c2");
            Compartment o2 = new Compartment(o1);

            assertTrue(o2.getId() == "c");
            assertTrue(o2.getOutside() == "c2");
            assertTrue(o2.getParentSBMLObject() == o1.getParentSBMLObject());
            o2 = null;
            o1 = null;
        }
Example #27
0
        public void test_Compartment_ancestor_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();
            Compartment obj = m.getCompartment(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);
        }
Example #28
0
        public void test_SBMLConvert_convertToL1_Species_Amount()
        {
            SBMLDocument d   = new  SBMLDocument(2, 4);
            Model        m   = d.createModel();
            string       sid = "C";
            Compartment  c   = new  Compartment(2, 4);
            Species      s   = new  Species(2, 4);

            c.setId(sid);
            m.addCompartment(c);
            s.setCompartment(sid);
            s.setInitialAmount(2.34);
            m.addSpecies(s);
            assertTrue(d.setLevelAndVersion(1, 2, true) == true);
            assertTrue(s.getInitialAmount() == 2.34);
            d = null;
        }
Example #29
0
        public void test_Compartment_createWith()
        {
            Compartment c = new  Compartment(2, 4);

            c.setId("A");
            assertTrue(c.getTypeCode() == libsbml.SBML_COMPARTMENT);
            assertTrue(c.getMetaId() == "");
            assertTrue(c.getNotes() == null);
            assertTrue(c.getAnnotation() == null);
            assertTrue(c.getName() == "");
            assertTrue(c.getSpatialDimensions() == 3);
            assertTrue(("A" == c.getId()));
            assertTrue(c.getConstant() == true);
            assertEquals(true, c.isSetId());
            assertEquals(false, c.isSetName());
            c = null;
        }
Example #30
0
        public void test_Compartment_assignmentOperator()
        {
            Compartment o1 = new Compartment(2, 4);

            o1.setId("c");
            o1.setOutside("c2");
            assertTrue(o1.getId() == "c");
            assertTrue(o1.getOutside() == "c2");
            Compartment o2 = new Compartment(2, 4);

            o2 = o1;
            assertTrue(o2.getId() == "c");
            assertTrue(o2.getOutside() == "c2");
            assertTrue(o2.getParentSBMLObject() == o1.getParentSBMLObject());
            o2 = null;
            o1 = null;
        }