コード例 #1
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);
            }
コード例 #2
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;
        }
コード例 #3
0
 public void test_Compartment_unsetSize()
 {
     C.setSize(0.2);
     assertTrue(C.getSize() == 0.2);
     assertEquals(true, C.isSetSize());
     C.unsetSize();
     assertEquals(false, C.isSetSize());
 }
コード例 #4
0
        public void test_Compartment_setSize1()
        {
            int i = C.setSize(2.0);

            assertTrue(i == libsbml.LIBSBML_OPERATION_SUCCESS);
            assertTrue(C.getSize() == 2.0);
            i = C.unsetSize();
            assertTrue(i == libsbml.LIBSBML_OPERATION_SUCCESS);
        }
コード例 #5
0
        public void test_L3_Compartment_size()
        {
            double size = 0.2;

            assertEquals(false, C.isSetSize());
            assertEquals(true, isnan(C.getSize()));
            C.setSize(size);
            assertTrue(C.getSize() == size);
            assertEquals(true, C.isSetSize());
            C.unsetSize();
            assertEquals(false, C.isSetSize());
            assertEquals(true, isnan(C.getSize()));
        }
コード例 #6
0
        public void test_Compartment_setSize2()
        {
            Compartment c = new  Compartment(2, 2);
            int         i = c.setSize(4);

            assertTrue(i == libsbml.LIBSBML_OPERATION_SUCCESS);
            assertTrue(c.getSize() == 4);
            assertEquals(true, c.isSetSize());
            i = c.unsetSize();
            assertTrue(i == libsbml.LIBSBML_OPERATION_SUCCESS);
            assertEquals(false, c.isSetSize());
            c = null;
        }
コード例 #7
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);
        }
コード例 #8
0
        public void test_SBMLConvert_convertFromL3()
        {
            SBMLDocument d   = new  SBMLDocument(3, 1);
            Model        m   = d.createModel();
            string       sid = "C";
            Compartment  c   = m.createCompartment();

            c.setId(sid);
            c.setSize(1.2);
            c.setConstant(true);
            c.setSpatialDimensions(3.4);
            assertTrue(d.setLevelAndVersion(1, 1, true) == false);
            assertTrue(d.setLevelAndVersion(1, 2, true) == false);
            assertTrue(d.setLevelAndVersion(2, 1, true) == false);
            assertTrue(d.setLevelAndVersion(2, 2, true) == false);
            assertTrue(d.setLevelAndVersion(2, 3, true) == false);
            assertTrue(d.setLevelAndVersion(2, 4, true) == false);
            assertTrue(d.setLevelAndVersion(3, 1, true) == true);
        }
コード例 #9
0
        public void test_SBMLConvert_convertToL3_defaultUnits()
        {
            SBMLDocument d   = new  SBMLDocument(1, 2);
            Model        m   = d.createModel();
            string       sid = "C";
            Compartment  c   = m.createCompartment();

            c.setId(sid);
            c.setSize(1.2);
            c.setUnits("volume");
            assertTrue(m.getNumUnitDefinitions() == 0);
            assertTrue(d.setLevelAndVersion(3, 1, true) == true);
            assertTrue(m.getNumUnitDefinitions() == 2);
            UnitDefinition ud = m.getUnitDefinition(0);

            assertTrue(ud != null);
            assertTrue(("volume" == ud.getId()));
            assertTrue(ud.getNumUnits() == 1);
            Unit u = ud.getUnit(0);

            assertTrue(u.getKind() == libsbml.UNIT_KIND_LITRE);
            assertTrue(u.getExponent() == 1);
            assertTrue(u.getMultiplier() == 1);
            assertTrue(u.getScale() == 0);
            ud = m.getUnitDefinition(1);
            assertTrue(ud != null);
            assertTrue(("area" == ud.getId()));
            assertTrue(ud.getNumUnits() == 1);
            u = ud.getUnit(0);
            assertTrue(u.getKind() == libsbml.UNIT_KIND_METRE);
            assertTrue(u.getExponent() == 2);
            assertTrue(u.getMultiplier() == 1);
            assertTrue(u.getScale() == 0);
            assertTrue(("second" == m.getTimeUnits()));
            d = null;
        }
コード例 #10
0
    static void Main(string[] args)
    {
        SBMLNamespaces sbmlns   = new SBMLNamespaces(3, 1, "fbc", 1);
        SBMLDocument   document = new SBMLDocument(sbmlns);

        // create the Model

        Model model = document.createModel();

        // create the Compartment

        Compartment compartment = model.createCompartment();

        compartment.setId("compartment");
        compartment.setConstant(true);
        compartment.setSize(1);

        // create the Species

        Species species = model.createSpecies();

        species.setId("Node1");
        species.setCompartment("compartment");
        species.setConstant(false);
        species.setHasOnlySubstanceUnits(false);
        species.setBoundaryCondition(false);

        species = model.createSpecies();
        species.setId("Node2");
        species.setCompartment("compartment");
        species.setConstant(false);
        species.setHasOnlySubstanceUnits(false);
        species.setConstant(false);
        species.setHasOnlySubstanceUnits(false);
        species.setBoundaryCondition(false);

        species = model.createSpecies();
        species.setId("Node3");
        species.setCompartment("compartment");
        species.setConstant(false);
        species.setHasOnlySubstanceUnits(false);
        species.setBoundaryCondition(false);

        species = model.createSpecies();
        species.setId("Node4");
        species.setCompartment("compartment");
        species.setConstant(false);
        species.setHasOnlySubstanceUnits(false);
        species.setBoundaryCondition(false);

        species = model.createSpecies();
        species.setId("Node5");
        species.setCompartment("compartment");
        species.setConstant(false);
        species.setHasOnlySubstanceUnits(false);
        species.setBoundaryCondition(false);

        species = model.createSpecies();
        species.setId("Node6");
        species.setCompartment("compartment");
        species.setConstant(false);
        species.setHasOnlySubstanceUnits(false);
        species.setBoundaryCondition(false);

        species = model.createSpecies();
        species.setId("Node7");
        species.setCompartment("compartment");
        species.setConstant(false);
        species.setHasOnlySubstanceUnits(false);
        species.setBoundaryCondition(false);

        species = model.createSpecies();
        species.setId("Node8");
        species.setCompartment("compartment");
        species.setConstant(false);
        species.setHasOnlySubstanceUnits(false);
        species.setBoundaryCondition(false);

        species = model.createSpecies();
        species.setId("Node0");
        species.setCompartment("compartment");
        species.setConstant(false);
        species.setHasOnlySubstanceUnits(false);
        species.setBoundaryCondition(true);

        species = model.createSpecies();
        species.setId("Node9");
        species.setCompartment("compartment");
        species.setConstant(false);
        species.setHasOnlySubstanceUnits(false);
        species.setBoundaryCondition(true);

        Reaction reaction = model.createReaction();

        reaction.setId("J0");
        reaction.setReversible(false);
        reaction.setFast(false);
        SpeciesReference reactant = reaction.createReactant();

        reactant.setSpecies("Node0");
        reactant.setStoichiometry(1);
        reactant.setConstant(true);
        SpeciesReference product = reaction.createProduct();

        product.setSpecies("Node1");
        product.setStoichiometry(1);
        product.setConstant(true);

        reaction = model.createReaction();
        reaction.setId("J1");
        reaction.setReversible(false);
        reaction.setFast(false);
        reactant = reaction.createReactant();
        reactant.setSpecies("Node1");
        reactant.setStoichiometry(1);
        reactant.setConstant(true);
        product = reaction.createProduct();
        product.setSpecies("Node2");
        product.setStoichiometry(1);
        product.setConstant(true);

        reaction = model.createReaction();
        reaction.setId("J2");
        reaction.setReversible(false);
        reaction.setFast(false);
        reactant = reaction.createReactant();
        reactant.setSpecies("Node2");
        reactant.setStoichiometry(1);
        reactant.setConstant(true);
        product = reaction.createProduct();
        product.setSpecies("Node3");
        product.setStoichiometry(1);
        product.setConstant(true);

        reaction = model.createReaction();
        reaction.setId("J3");
        reaction.setReversible(false);
        reaction.setFast(false);
        reactant = reaction.createReactant();
        reactant.setSpecies("Node1");
        reactant.setStoichiometry(1);
        reactant.setConstant(true);
        product = reaction.createProduct();
        product.setSpecies("Node4");
        product.setStoichiometry(1);
        product.setConstant(true);

        reaction = model.createReaction();
        reaction.setId("J4");
        reaction.setReversible(false);
        reaction.setFast(false);
        reactant = reaction.createReactant();
        reactant.setSpecies("Node4");
        reactant.setStoichiometry(1);
        reactant.setConstant(true);
        product = reaction.createProduct();
        product.setSpecies("Node3");
        product.setStoichiometry(1);
        product.setConstant(true);

        reaction = model.createReaction();
        reaction.setId("J5");
        reaction.setReversible(false);
        reaction.setFast(false);
        reactant = reaction.createReactant();
        reactant.setSpecies("Node3");
        reactant.setStoichiometry(1);
        reactant.setConstant(true);
        product = reaction.createProduct();
        product.setSpecies("Node5");
        product.setStoichiometry(1);
        product.setConstant(true);

        reaction = model.createReaction();
        reaction.setId("J6");
        reaction.setReversible(false);
        reaction.setFast(false);
        reactant = reaction.createReactant();
        reactant.setSpecies("Node5");
        reactant.setStoichiometry(1);
        reactant.setConstant(true);
        product = reaction.createProduct();
        product.setSpecies("Node6");
        product.setStoichiometry(1);
        product.setConstant(true);

        reaction = model.createReaction();
        reaction.setId("J7");
        reaction.setReversible(false);
        reaction.setFast(false);
        reactant = reaction.createReactant();
        reactant.setSpecies("Node6");
        reactant.setStoichiometry(1);
        reactant.setConstant(true);
        product = reaction.createProduct();
        product.setSpecies("Node7");
        product.setStoichiometry(1);
        product.setConstant(true);

        reaction = model.createReaction();
        reaction.setId("J8");
        reaction.setReversible(false);
        reaction.setFast(false);
        reactant = reaction.createReactant();
        reactant.setSpecies("Node5");
        reactant.setStoichiometry(1);
        reactant.setConstant(true);
        product = reaction.createProduct();
        product.setSpecies("Node8");
        product.setStoichiometry(1);
        product.setConstant(true);

        reaction = model.createReaction();
        reaction.setId("J9");
        reaction.setReversible(false);
        reaction.setFast(false);
        reactant = reaction.createReactant();
        reactant.setSpecies("Node8");
        reactant.setStoichiometry(1);
        reactant.setConstant(true);
        product = reaction.createProduct();
        product.setSpecies("Node7");
        product.setStoichiometry(1);
        product.setConstant(true);

        reaction = model.createReaction();
        reaction.setId("J10");
        reaction.setReversible(false);
        reaction.setFast(false);
        reactant = reaction.createReactant();
        reactant.setSpecies("Node7");
        reactant.setStoichiometry(1);
        reactant.setConstant(true);
        product = reaction.createProduct();
        product.setSpecies("Node9");
        product.setStoichiometry(1);
        product.setConstant(true);


        //
        // Get a FbcModelPlugin object plugged in the model object.
        //
        // The type of the returned value of SBase::getPlugin() function is SBasePlugin, and
        // thus the value needs to be casted for the corresponding derived class.
        //
        FbcModelPlugin mplugin = (FbcModelPlugin)(model.getPlugin("fbc"));

        FluxBound bound = mplugin.createFluxBound();

        bound.setId("bound1");
        bound.setReaction("J0");
        bound.setOperation("equal");
        bound.setValue(10);

        Objective objective = mplugin.createObjective();

        objective.setId("obj1");
        objective.setType("maximize");

        // mark obj1 as active objective
        mplugin.setActiveObjectiveId("obj1");

        FluxObjective fluxObjective = objective.createFluxObjective();

        fluxObjective.setReaction("J8");
        fluxObjective.setCoefficient(1);

        libsbml.writeSBMLToFile(document, "fbc_example1.xml");
    }