コード例 #1
0
 public void test_L3_Compartment_constant()
 {
     assertTrue(C.isSetConstant() == false);
     C.setConstant(true);
     assertTrue(C.getConstant() == true);
     assertTrue(C.isSetConstant() == true);
     C.setConstant(false);
     assertTrue(C.getConstant() == false);
     assertTrue(C.isSetConstant() == true);
 }
コード例 #2
0
        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;
        }
コード例 #3
0
        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;
        }
コード例 #4
0
        public void test_Compartment_setConstant1()
        {
            int i = C.setConstant(false);

            assertTrue(i == libsbml.LIBSBML_UNEXPECTED_ATTRIBUTE);
            assertTrue(C.getConstant() == false);
        }
コード例 #5
0
        public void test_Compartment_setConstant2()
        {
            Compartment c = new  Compartment(2, 2);
            int         i = c.setConstant(false);

            assertTrue(i == libsbml.LIBSBML_OPERATION_SUCCESS);
            assertTrue(c.getConstant() == false);
            c = null;
        }
コード例 #6
0
        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()));
        }
コード例 #7
0
        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;
        }
コード例 #8
0
        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()));
        }
コード例 #9
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);
        }
コード例 #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");
    }
コード例 #11
0
    public static void Main(string[] args)
    {
//
// Creates an SBMLNamespaces object with the given SBML level, version
// package name, package version.
//
// (NOTE) By defualt, the name of package (i.e. "groups") will be used
// if the arugment for the prefix is missing or empty. Thus the argument
// for the prefix can be added as follows:
//
//    SBMLNamespaces sbmlns(3,1,"groups",1,"GROUP");
//

        SBMLNamespaces sbmlns = new SBMLNamespaces(3, 1, "groups", 1);

//
// (NOTES) The above code creating an SBMLNamespaces object can be replaced
//         with one of the following other styles.
//
// (1) Creates an SBMLNamespace object with a SBML core namespace and then
//     adds a groups package namespace to the object.
//
//         SBMLNamespaces sbmlns(3,1);
//         sbmlns.addPkgNamespace("groups",1);
//
//          OR
//
//         SBMLNamespaces sbmlns(3,1);
//         sbmlns.addNamespace(GroupsExtension::XmlnsL3V1V1,"groups");
//
// (2) Creates a GroupsPkgNamespaces object (SBMLNamespace derived class for
//     groups package. The class is basically used for createing an SBase derived
//     objects defined in the groups package) with the given SBML level, version,
//     and package version
//
//        GroupsPkgNamespaces sbmlns(3,1,1);
//


// create the document

        SBMLDocument document = new SBMLDocument(sbmlns);

// create the Model

        Model model = document.createModel();

// create the Compartment

        Compartment compartment = model.createCompartment();

        compartment.setId("cytosol");
        compartment.setConstant(true);

        compartment = model.createCompartment();
        compartment.setId("mitochon");
        compartment.setConstant(true);

// create the Species

        Species species = model.createSpecies();

        species.setId("ATPc");
        species.setCompartment("cytosol");
        species.setInitialConcentration(1);
        species.setHasOnlySubstanceUnits(false);
        species.setBoundaryCondition(false);
        species.setConstant(false);

        species = model.createSpecies();
        species.setId("ATPm");
        species.setCompartment("mitochon");
        species.setInitialConcentration(2);
        species.setHasOnlySubstanceUnits(false);
        species.setBoundaryCondition(false);
        species.setConstant(false);

// create the Groups

//
// Get a GroupsModelPlugin 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.
//
        GroupsModelPlugin mplugin = (GroupsModelPlugin)(model.getPlugin("groups"));

//
// Creates a Group object via GroupsModelPlugin object.
//
        Group group = mplugin.createGroup();

        group.setId("ATP");
        group.setKind(libsbml.GROUP_KIND_CLASSIFICATION);
        group.setSBOTerm("SBO:0000252");

        Member member = group.createMember();

        member.setIdRef("ATPc");

        member = group.createMember();
        member.setIdRef("ATPm");

        libsbml.writeSBML(document, "groups_example1-cs.xml");
    }
コード例 #12
0
    static void Main(string[] args)
    {
        SBMLNamespaces sbmlns = new SBMLNamespaces(3, 1, "multi", 1);

        // create the document

        SBMLDocument document = new SBMLDocument(sbmlns);

        // set the required attribute to true
        SBMLDocumentPlugin docPlug =
            (SBMLDocumentPlugin)(document.getPlugin("multi"));

        docPlug.setRequired(true);


        // create the Model

        Model model = document.createModel();

        // create the compartments

        Compartment c = model.createCompartment();

        c.setId("membrane");
        c.setConstant(true);

        // set the multi attribute isType via the compartmentPlugin
        MultiCompartmentPlugin compPlug =
            (MultiCompartmentPlugin)(c.getPlugin("multi"));

        compPlug.setIsType(true);

        // create the speciesTypes

        MultiModelPlugin modelPlug =
            (MultiModelPlugin)(model.getPlugin("multi"));

        MultiSpeciesType st = modelPlug.createMultiSpeciesType();

        st.setId("stX");
        st.setCompartment("membrane");

        // create species
        Species s = model.createSpecies();

        s.setId("s1");
        s.setCompartment("membrane");
        s.setBoundaryCondition(false);
        s.setHasOnlySubstanceUnits(false);
        s.setConstant(false);

        // set the multi attribute speciesType via the compartmentPlugin
        MultiSpeciesPlugin spPlug =
            (MultiSpeciesPlugin)(s.getPlugin("multi"));

        spPlug.setSpeciesType("stX");

        // create species feature
        SpeciesFeature sf = spPlug.createSpeciesFeature();

        sf.setSpeciesFeatureType("a");
        sf.setOccur(1);
        sf.setComponent("b");

        SpeciesFeatureValue sfv = sf.createSpeciesFeatureValue();

        sfv.setValue("c");

        // create a subListOfSpeciesFeatures
        SubListOfSpeciesFeatures subloSF = spPlug.createSubListOfSpeciesFeatures();

        subloSF.setRelation(libsbml.Relation_fromString("and"));

        // add speciesFeatures to the subList
        SpeciesFeature sf1 = new SpeciesFeature(3, 1, 1);

        sf1.setSpeciesFeatureType("a1");
        sf1.setOccur(1);
        sf1.setComponent("b1");

        SpeciesFeatureValue sfv1 = sf1.createSpeciesFeatureValue();

        sfv1.setValue("c1");

        subloSF.appendAndOwn(sf1);

        sf1 = new SpeciesFeature(3, 1, 1);
        sf1.setSpeciesFeatureType("a2");
        sf1.setOccur(1);
        sf1.setComponent("b2");

        sfv1 = sf1.createSpeciesFeatureValue();
        sfv1.setValue("c2");

        subloSF.appendAndOwn(sf1);

        // create a second subListOfSpeciesfeatures
        subloSF = spPlug.createSubListOfSpeciesFeatures();
        subloSF.setRelation(libsbml.Relation_fromString("or"));

        sf1 = new SpeciesFeature(3, 1, 1);
        sf1.setSpeciesFeatureType("a3");
        sf1.setOccur(1);
        sf1.setComponent("b3");

        sfv1 = sf1.createSpeciesFeatureValue();
        sfv1.setValue("c3");

        subloSF.appendAndOwn(sf1);

        sf1 = new SpeciesFeature(3, 1, 1);
        sf1.setSpeciesFeatureType("a4");
        sf1.setOccur(1);
        sf1.setComponent("b4");

        sfv1 = sf1.createSpeciesFeatureValue();
        sfv1.setValue("c4");

        subloSF.appendAndOwn(sf1);

        libsbml.writeSBML(document, "multi_example3.xml");
    }
コード例 #13
0
    public static void Main(string[] args)
    {
        //
        // Creates an SBMLNamespaces object with the given SBML level, version
        // package name, package version.
        //
        // (NOTE) By defualt, the name of package (i.e. "layout") will be used
        // if the arugment for the prefix is missing or empty. Thus the argument
        // for the prefix can be added as follows:
        //
        //    SBMLNamespaces sbmlns(3,1,"layout",1,"LAYOUT");
        //

        SBMLNamespaces sbmlns = new SBMLNamespaces(3, 1, "layout", 1);

        //
        // (NOTES) The above code creating an SBMLNamespaces object can be replaced
        //         with one of the following other styles.
        //
        // (1) Creates an SBMLNamespace object with a SBML core namespace and then
        //     adds a layout package namespace to the object.
        //
        //         SBMLNamespaces sbmlns(3,1);
        //         sbmlns.addPkgNamespace("layout",1);
        //
        //           OR
        //
        //         SBMLNamespaces sbmlns(3,1);
        //         sbmlns.addNamespace(LayoutExtension::XmlnsL3V1V1,"layout");
        //
        // (2) Creates a LayoutPkgNamespaces object (SBMLNamespace derived class for
        //     layout package. The class is basically used for createing an SBase derived
        //     objects belonging to the layout package) with the given SBML level, version,
        //     and package version
        //
        //        LayoutPkgNamespaces sbmlns(3,1,1);
        //

        // create the document

        SBMLDocument document = new SBMLDocument(sbmlns);

        // set the "required" attribute of layout package  to "true"
        document.setPkgRequired("layout", true);

        // create the Model

        Model model = document.createModel();

        model.setId("TestModel");
        document.setModel(model);


        // create the Compartment

        Compartment compartment = model.createCompartment();

        compartment.setId("Compartment_1");
        compartment.setConstant(true);

        // create the Species

        Species species1 = model.createSpecies();

        species1.setId("Species_1");
        species1.setCompartment(compartment.getId());
        species1.setHasOnlySubstanceUnits(false);
        species1.setBoundaryCondition(false);
        species1.setConstant(false);

        Species species2 = model.createSpecies();

        species2.setId("Species_2");
        species2.setCompartment(compartment.getId());
        species2.setHasOnlySubstanceUnits(false);
        species2.setBoundaryCondition(false);
        species2.setConstant(false);

        // create the Reactions

        Reaction reaction1 = model.createReaction();

        reaction1.setId("Reaction_1");
        reaction1.setReversible(false);
        reaction1.setFast(false);

        SpeciesReference reference1 = reaction1.createReactant();

        reference1.setSpecies(species1.getId());
        reference1.setId("SpeciesReference_1");
        reference1.setConstant(false);


        SpeciesReference reference2 = reaction1.createProduct();

        reference2.setSpecies(species2.getId());
        reference2.setId("SpeciesReference_2");
        reference2.setConstant(false);

        Reaction reaction2 = model.createReaction();

        reaction2.setId("Reaction_2");
        reaction2.setReversible(false);
        reaction2.setFast(false);

        SpeciesReference reference3 = reaction2.createReactant();

        reference3.setSpecies(species2.getId());
        reference3.setId("SpeciesReference_3");
        reference3.setConstant(false);

        SpeciesReference reference4 = reaction2.createProduct();

        reference4.setSpecies(species1.getId());
        reference4.setId("SpeciesReference_4");
        reference4.setConstant(false);


        // create the Layout

        //
        // set the LayoutPkgNamespaces for Level 3 Version1 Layout Version 1
        //
        LayoutPkgNamespaces layoutns = new LayoutPkgNamespaces(3, 1, 1);

        //
        // Get a LayoutModelPlugin 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.
        //

        LayoutModelPlugin mplugin = (LayoutModelPlugin)(model.getPlugin("layout"));

        if (mplugin == null)
        {
            Console.Error.WriteLine("[Fatal Error] Layout Extension Level " + layoutns.getLevel() + " Version " + layoutns.getVersion() + " package version " + layoutns.getPackageVersion() + " is not registered.");
            Environment.Exit(1);
        }

        //
        // Creates a Layout object via LayoutModelPlugin object.
        //
        Layout layout = mplugin.createLayout();

        layout.setId("Layout_1");
        Dimensions dim = new Dimensions(layoutns, 400.0, 220.0);

        layout.setDimensions(dim);


        // create the CompartmentGlyph

        CompartmentGlyph compartmentGlyph = layout.createCompartmentGlyph();

        compartmentGlyph.setId("CompartmentGlyph_1");
        compartmentGlyph.setCompartmentId(compartment.getId());
        BoundingBox bb = new BoundingBox(layoutns, "bb1", 5, 5, 390, 210);

        compartmentGlyph.setBoundingBox(bb);


        // create the SpeciesGlyphs

        SpeciesGlyph speciesGlyph1 = layout.createSpeciesGlyph();

        speciesGlyph1.setId("SpeciesGlyph_1");
        speciesGlyph1.setSpeciesId(species1.getId());
        bb = new BoundingBox(layoutns, "bb2", 80, 26, 240, 24);
        speciesGlyph1.setBoundingBox(bb);

        TextGlyph textGlyph1 = layout.createTextGlyph();

        textGlyph1.setId("TextGlyph_01");
        bb = new BoundingBox(layoutns, "bbA", 92, 26, 228, 24);
        textGlyph1.setBoundingBox(bb);
        textGlyph1.setOriginOfTextId(speciesGlyph1.getId());
        textGlyph1.setGraphicalObjectId(speciesGlyph1.getId());

        SpeciesGlyph speciesGlyph2 = layout.createSpeciesGlyph();

        speciesGlyph2.setId("SpeciesGlyph_2");
        speciesGlyph2.setSpeciesId(species2.getId());
        bb = new BoundingBox(layoutns, "bb3", 80, 170, 240, 24);
        speciesGlyph2.setBoundingBox(bb);

        TextGlyph textGlyph2 = layout.createTextGlyph();

        textGlyph2.setId("TextGlyph_02");
        bb = new BoundingBox(layoutns, "bbB", 92, 170, 228, 24);
        textGlyph2.setBoundingBox(bb);
        textGlyph2.setOriginOfTextId(speciesGlyph2.getId());
        textGlyph2.setGraphicalObjectId(speciesGlyph2.getId());

        // create the ReactionGlyphs

        ReactionGlyph reactionGlyph1 = layout.createReactionGlyph();

        reactionGlyph1.setId("ReactionGlyph_1");
        reactionGlyph1.setReactionId(reaction1.getId());

        Curve       reactionCurve1 = reactionGlyph1.getCurve();
        LineSegment ls             = reactionCurve1.createLineSegment();
        Point       p = new Point(layoutns, 165, 105);

        ls.setStart(p);
        p = new Point(layoutns, 165, 115);
        ls.setEnd(p);

        ReactionGlyph reactionGlyph2 = layout.createReactionGlyph();

        reactionGlyph2.setId("ReactionGlyph_1");
        reactionGlyph2.setReactionId(reaction2.getId());

        Curve reactionCurve2 = reactionGlyph2.getCurve();

        ls = reactionCurve2.createLineSegment();
        p  = new Point(layoutns, 235, 105);
        ls.setStart(p);
        p = new Point(layoutns, 235, 115);
        ls.setEnd(p);

        // add the SpeciesReferenceGlyphs

        SpeciesReferenceGlyph speciesReferenceGlyph1 = reactionGlyph1.createSpeciesReferenceGlyph();

        speciesReferenceGlyph1.setId("SpeciesReferenceGlyph_1");
        speciesReferenceGlyph1.setSpeciesGlyphId(speciesGlyph1.getId());
        speciesReferenceGlyph1.setSpeciesReferenceId(reference1.getId());
        speciesReferenceGlyph1.setRole(libsbml.SPECIES_ROLE_SUBSTRATE);

        Curve       speciesReferenceCurve1 = speciesReferenceGlyph1.getCurve();
        CubicBezier cb = speciesReferenceCurve1.createCubicBezier();

        p = new Point(layoutns, 165, 105);
        cb.setStart(p);
        p = new Point(layoutns, 165, 90);
        cb.setBasePoint1(p);
        p = new Point(layoutns, 165, 90);
        cb.setBasePoint2(p);
        p = new Point(layoutns, 195, 60);
        cb.setEnd(p);

        SpeciesReferenceGlyph speciesReferenceGlyph2 = reactionGlyph1.createSpeciesReferenceGlyph();

        speciesReferenceGlyph2.setId("SpeciesReferenceGlyph_2");
        speciesReferenceGlyph2.setSpeciesGlyphId(speciesGlyph2.getId());
        speciesReferenceGlyph2.setSpeciesReferenceId(reference2.getId());
        speciesReferenceGlyph2.setRole(libsbml.SPECIES_ROLE_PRODUCT);

        Curve speciesReferenceCurve2 = speciesReferenceGlyph2.getCurve();

        cb = speciesReferenceCurve2.createCubicBezier();
        p  = new Point(layoutns, 165, 115);
        cb.setStart(p);
        p = new Point(layoutns, 165, 130);
        cb.setBasePoint1(p);
        p = new Point(layoutns, 165, 130);
        cb.setBasePoint2(p);
        p = new Point(layoutns, 195, 160);
        cb.setEnd(p);


        SpeciesReferenceGlyph speciesReferenceGlyph3 = reactionGlyph2.createSpeciesReferenceGlyph();

        speciesReferenceGlyph3.setId("SpeciesReferenceGlyph_3");
        speciesReferenceGlyph3.setSpeciesGlyphId(speciesGlyph2.getId());
        speciesReferenceGlyph3.setSpeciesReferenceId(reference3.getId());
        speciesReferenceGlyph3.setRole(libsbml.SPECIES_ROLE_SUBSTRATE);

        Curve speciesReferenceCurve3 = speciesReferenceGlyph3.getCurve();

        cb = speciesReferenceCurve3.createCubicBezier();
        p  = new Point(layoutns, 235, 115);
        cb.setStart(p);
        p = new Point(layoutns, 235, 130);
        cb.setBasePoint1(p);
        p = new Point(layoutns, 235, 130);
        cb.setBasePoint2(p);
        p = new Point(layoutns, 205, 160);
        cb.setEnd(p);

        SpeciesReferenceGlyph speciesReferenceGlyph4 = reactionGlyph2.createSpeciesReferenceGlyph();

        speciesReferenceGlyph4.setId("SpeciesReferenceGlyph_4");
        speciesReferenceGlyph4.setSpeciesGlyphId(speciesGlyph1.getId());
        speciesReferenceGlyph4.setSpeciesReferenceId(reference4.getId());
        speciesReferenceGlyph4.setRole(libsbml.SPECIES_ROLE_PRODUCT);

        Curve speciesReferenceCurve4 = speciesReferenceGlyph4.getCurve();

        cb = speciesReferenceCurve4.createCubicBezier();
        p  = new Point(layoutns, 235, 105);
        cb.setStart(p);
        p = new Point(layoutns, 235, 90);
        cb.setBasePoint1(p);
        p = new Point(layoutns, 235, 90);
        cb.setBasePoint2(p);
        p = new Point(layoutns, 205, 60);
        cb.setEnd(p);

        libsbml.writeSBML(document, "layout_example1_L3-cs.xml");
        Console.WriteLine("all done ...");
    }
コード例 #14
0
    public static int Main(string[] args)
    {
        // Creates an SBMLNamespaces object with the given SBML level, version
        // package name, package version.
        SBMLNamespaces sbmlns = new SBMLNamespaces(3, 1, "qual", 1);

        // create the document
        SBMLDocument document = new SBMLDocument(sbmlns);

        // mark qual as required
        document.setPackageRequired("qual", true);

        // create the Model
        Model model = document.createModel();

        // create the Compartment
        Compartment compartment = model.createCompartment();

        compartment.setId("c");
        compartment.setConstant(true);

        // Get a QualModelPlugin object plugged in the model object.
        QualModelPlugin mplugin = (QualModelPlugin)(model.getPlugin("qual"));

        // create the QualitativeSpecies
        QualitativeSpecies qs = mplugin.createQualitativeSpecies();

        qs.setId("s1");
        qs.setCompartment("c");
        qs.setConstant(false);
        qs.setInitialLevel(1);
        qs.setMaxLevel(4);
        qs.setName("sss");

        // create the Transition
        Transition t = mplugin.createTransition();

        t.setId("d");
        t.setSBOTerm(1);

        Input i = t.createInput();

        i.setId("RD");
        i.setQualitativeSpecies("s1");
        i.setTransitionEffect(libsbml.INPUT_TRANSITION_EFFECT_NONE);
        i.setSign(libsbml.INPUT_SIGN_NEGATIVE);
        i.setThresholdLevel(2);
        i.setName("aa");

        Output o = t.createOutput();

        o.setId("wd");
        o.setQualitativeSpecies("s1");
        o.setTransitionEffect(libsbml.OUTPUT_TRANSITION_EFFECT_PRODUCTION);
        o.setOutputLevel(2);
        o.setName("aa");

        FunctionTerm ft   = t.createFunctionTerm();
        ASTNode      math = libsbml.parseL3Formula("geq(s1, 2)");

        ft.setResultLevel(1);
        ft.setMath(math);

        DefaultTerm dt = t.createDefaultTerm();

        dt.setResultLevel(2);

        int result = libsbml.writeSBML(document, "qual_example1.xml");

        if (result == 1)
        {
            Console.WriteLine("Wrote file");
            return(0);
        }
        else
        {
            Console.WriteLine("Failed to write");
            return(1);
        }
    }
コード例 #15
0
ファイル: CreateArrays1.cs プロジェクト: carolc24/roadrunner
    public static void Main(string[] args)
    {
        ArraysPkgNamespaces arraysNs = new ArraysPkgNamespaces();
        SBMLDocument        doc      = new SBMLDocument(arraysNs);

        doc.setPackageRequired("arrays", true);
        Model model = doc.createModel();

        // create compartment
        Compartment comp = model.createCompartment();

        comp.setMetaId("dd");
        comp.setId("s");
        comp.setConstant(true);

        // set dimensions
        ArraysSBasePlugin compPlugin = (ArraysSBasePlugin)comp.getPlugin("arrays");
        Dimension         dim        = compPlugin.createDimension();

        dim.setId("i");
        dim.setSize("n");

        // create species
        Species species = model.createSpecies();

        species.setId("A");
        species.setCompartment("s");
        species.setHasOnlySubstanceUnits(false);
        species.setBoundaryCondition(false);
        species.setConstant(false);

        ArraysSBasePlugin splugin = (ArraysSBasePlugin)species.getPlugin("arrays");

        dim = splugin.createDimension();
        dim.setId("i");
        dim.setSize("n");

        species = model.createSpecies();
        species.setId("B");
        species.setCompartment("s");
        species.setHasOnlySubstanceUnits(false);
        species.setBoundaryCondition(false);
        species.setConstant(false);

        splugin = (ArraysSBasePlugin)species.getPlugin("arrays");
        dim     = splugin.createDimension();
        dim.setId("i");
        dim.setSize("n");

        species = model.createSpecies();
        species.setId("C");
        species.setCompartment("s");
        species.setHasOnlySubstanceUnits(false);
        species.setBoundaryCondition(false);
        species.setConstant(false);

        splugin = (ArraysSBasePlugin)species.getPlugin("arrays");
        dim     = splugin.createDimension();
        dim.setId("i");
        dim.setSize("n");

        // create parameter
        Parameter param = model.createParameter();

        param.setId("n");
        param.setValue(100);
        param.setConstant(true);

        // create reaction
        Reaction reaction = model.createReaction();

        reaction.setId("reaction1");
        reaction.setReversible(false);
        reaction.setFast(false);

        ArraysSBasePlugin reactionPlugin = (ArraysSBasePlugin)reaction.getPlugin("arrays");

        dim = reactionPlugin.createDimension();
        dim.setId("i");
        dim.setSize("n");

        SpeciesReference speciesRef = reaction.createReactant();

        speciesRef.setSpecies("A");
        speciesRef.setConstant(false);
        ArraysSBasePlugin refPlugin = (ArraysSBasePlugin)speciesRef.getPlugin("arrays");
        Index             index     = refPlugin.createIndex();
        ASTNode           ast       = new ASTNode(libsbml.AST_LINEAR_ALGEBRA_SELECTOR);
        ASTNode           ci        = new ASTNode(libsbml.AST_NAME);

        ci.setName("A");
        ast.addChild(ci);
        ci = new ASTNode(libsbml.AST_NAME);
        ci.setName("i");
        ast.addChild(ci);
        index.setMath(ast);

        speciesRef = reaction.createProduct();
        speciesRef.setSpecies("C");
        speciesRef.setConstant(false);
        refPlugin = (ArraysSBasePlugin)speciesRef.getPlugin("arrays");
        index     = refPlugin.createIndex();
        ast       = new ASTNode(libsbml.AST_LINEAR_ALGEBRA_SELECTOR);
        ci        = new ASTNode(libsbml.AST_NAME);
        ci.setName("C");
        ast.addChild(ci);
        ci = new ASTNode(libsbml.AST_NAME);
        ci.setName("i");
        ast.addChild(ci);
        index.setMath(ast);

        libsbml.writeSBMLToFile(doc, "arrays1.xml");
    }
コード例 #16
0
ファイル: multi_example1.cs プロジェクト: Tubbz-alt/carbon
    static void Main(string[] args)
    {
        SBMLNamespaces sbmlns = new SBMLNamespaces(3, 1, "multi", 1);

        // create the document

        SBMLDocument document = new SBMLDocument(sbmlns);

        // set the required attribute to true
        SBMLDocumentPlugin docPlug =
            (SBMLDocumentPlugin)(document.getPlugin("multi"));

        docPlug.setRequired(true);


        // create the Model

        Model model = document.createModel();

        // create the compartments

        Compartment c = model.createCompartment();

        c.setId("membrane");
        c.setConstant(true);

        // set the multi attribute isType via the compartmentPlugin
        MultiCompartmentPlugin compPlug =
            (MultiCompartmentPlugin)(c.getPlugin("multi"));

        compPlug.setIsType(true);

        c = model.createCompartment();
        c.setId("inter_membrane");
        c.setConstant(true);

        // set the multi attribute isType via the compartmentPlugin
        compPlug =
            (MultiCompartmentPlugin)(c.getPlugin("multi"));
        compPlug.setIsType(true);

        // create the compartmentReferences

        CompartmentReference compRef = compPlug.createCompartmentReference();

        compRef.setId("m1");
        compRef.setCompartment("membrane");

        compRef = compPlug.createCompartmentReference();
        compRef.setId("m2");
        compRef.setCompartment("membrane");

        // create the speciesTypes

        MultiModelPlugin modelPlug =
            (MultiModelPlugin)(model.getPlugin("multi"));

        MultiSpeciesType st = modelPlug.createMultiSpeciesType();

        st.setId("stX");
        st.setCompartment("ct");

        st = modelPlug.createMultiSpeciesType();
        st.setId("stXXcis");
        st.setCompartment("ct");

        // create speciesTypeInstances

        SpeciesTypeInstance sti = st.createSpeciesTypeInstance();

        sti.setId("stiX1");
        sti.setSpeciesType("stX");

        sti = st.createSpeciesTypeInstance();
        sti.setId("stiX2");
        sti.setSpeciesType("stX");

        // create speciesTypeBond

        InSpeciesTypeBond istb = st.createInSpeciesTypeBond();

        istb.setBindingSite1("stiX1");
        istb.setBindingSite2("stiX2");

        // another speciesType

        st = modelPlug.createMultiSpeciesType();
        st.setId("stXXtrans");
        st.setCompartment("cct");

        // create speciesTypeInstances

        sti = st.createSpeciesTypeInstance();
        sti.setId("stiX1");
        sti.setSpeciesType("stX");
        sti.setCompartmentReference("cr1");

        sti = st.createSpeciesTypeInstance();
        sti.setId("stiX2");
        sti.setSpeciesType("stX");
        sti.setCompartmentReference("cr2");

        // create speciesTypeBond

        istb = st.createInSpeciesTypeBond();
        istb.setBindingSite1("stiX1");
        istb.setBindingSite2("stiX2");

        libsbml.writeSBML(document, "multi_example1.xml");
    }
コード例 #17
0
    static void Main(string[] args)
    {
        SBMLNamespaces sbmlns = new SBMLNamespaces(3, 1, "multi", 1);

        // create the document

        SBMLDocument document = new SBMLDocument(sbmlns);

        // set the required attribute to true
        SBMLDocumentPlugin docPlug =
            (SBMLDocumentPlugin)(document.getPlugin("multi"));

        docPlug.setRequired(true);


        // create the Model

        Model model = document.createModel();

        // create a  compartment

        Compartment c = model.createCompartment();

        c.setId("membrane");
        c.setConstant(true);

        // set the multi attribute isType via the compartmentPlugin
        MultiCompartmentPlugin compPlug =
            (MultiCompartmentPlugin)(c.getPlugin("multi"));

        compPlug.setIsType(true);

        // create species
        Species s = model.createSpecies();

        s.setId("s1");
        s.setCompartment("membrane");
        s.setBoundaryCondition(false);
        s.setHasOnlySubstanceUnits(false);
        s.setConstant(false);

        // create reaction
        Reaction r = model.createReaction();

        r.setId("r1");
        r.setFast(false);
        r.setReversible(false);

        // createReactant
        SpeciesReference sr = r.createReactant();

        sr.setId("sr1");
        sr.setSpecies("s1");
        sr.setConstant(false);

        KineticLaw kl = r.createKineticLaw();

        ASTNode ci = new ASTNode(libsbml.AST_NAME);

        ci.setName("s1");
        MultiASTPlugin astPlugin = (MultiASTPlugin)(ci.getPlugin("multi"));

        astPlugin.setSpeciesReference("r1");

        ASTNode        ci1        = new ASTNode(libsbml.AST_NAME);
        MultiASTPlugin astPlugin1 = (MultiASTPlugin)(ci1.getPlugin("multi"));

        astPlugin1.setRepresentationType("sum");
        ci1.setName("s1");

        ASTNode math = new ASTNode(libsbml.AST_TIMES);

        math.addChild(ci);
        math.addChild(ci1);

        kl.setMath(math);

        libsbml.writeSBML(document, "multi_example2.xml");
    }
コード例 #18
0
 public void test_Compartment_getsetConstant()
 {
     C.setConstant(true);
     assertTrue(C.getConstant() == true);
 }