setCompartment() public method

public setCompartment ( string sid ) : int
sid string
return int
 public void test_Species_parent_add()
 {
     Species ia = new Species(2,4);
       ia.setId("s");
       ia.setCompartment("c");
       Model m = new Model(2,4);
       m.addSpecies(ia);
       ia = null;
       ListOf lo = m.getListOfSpecies();
       assertTrue( lo == m.getSpecies(0).getParentSBMLObject() );
       assertTrue( m == lo.getParentSBMLObject() );
 }
Ejemplo n.º 2
0
 public void test_Model_addSpecies5()
 {
     Model m = new  Model(2,2);
       Species s = new  Species(2,2);
       s.setId( "s");
       s.setCompartment( "c");
       Species s1 = new  Species(2,2);
       s1.setId( "s");
       s1.setCompartment( "c");
       int i = m.addSpecies(s);
       assertTrue( i == libsbml.LIBSBML_OPERATION_SUCCESS );
       assertTrue( m.getNumSpecies() == 1 );
       i = m.addSpecies(s1);
       assertTrue( i == libsbml.LIBSBML_DUPLICATE_OBJECT_ID );
       assertTrue( m.getNumSpecies() == 1 );
       s = null;
       s1 = null;
       m = null;
 }
Ejemplo n.º 3
0
 public void test_Species_ancestor_add()
 {
     Species ia = new Species(2,4);
       Model m = new Model(2,4);
       ia.setId("s");
       ia.setCompartment("c");
       m.addSpecies(ia);
       ia = null;
       ListOf lo = m.getListOfSpecies();
       Species obj = m.getSpecies(0);
       assertTrue( obj.getAncestorOfType(libsbml.SBML_MODEL) == m );
       assertTrue( obj.getAncestorOfType(libsbml.SBML_LIST_OF) == lo );
       assertTrue( obj.getAncestorOfType(libsbml.SBML_DOCUMENT) == null );
       assertTrue( obj.getAncestorOfType(libsbml.SBML_EVENT) == null );
 }
Ejemplo n.º 4
0
 public void test_Model_addSpecies2()
 {
     Model m = new  Model(2,2);
       Species s = new  Species(2,1);
       s.setId( "s");
       s.setCompartment( "c");
       int i = m.addSpecies(s);
       assertTrue( i == libsbml.LIBSBML_VERSION_MISMATCH );
       assertTrue( m.getNumSpecies() == 0 );
       s = null;
       m = null;
 }
Ejemplo n.º 5
0
 public void test_Model_addSpecies3()
 {
     Model m = new  Model(2,2);
       Species s = new  Species(1,2);
       s.setId( "s");
       s.setCompartment( "c");
       s.setInitialAmount(2);
       int i = m.addSpecies(s);
       assertTrue( i == libsbml.LIBSBML_LEVEL_MISMATCH );
       assertTrue( m.getNumSpecies() == 0 );
       s = null;
       m = null;
 }
 public void test_Species_L1()
 {
     Species s = new Species(1,2);
       assertEquals( false, (s.hasRequiredAttributes()) );
       s.setId("s");
       assertEquals( false, (s.hasRequiredAttributes()) );
       s.setCompartment("c");
       assertEquals( false, (s.hasRequiredAttributes()) );
       s.setInitialAmount(2);
       assertEquals( true, s.hasRequiredAttributes() );
       s = null;
 }
Ejemplo n.º 7
0
 public void test_Model_getSpeciesById()
 {
     Species s1 = new  Species(2,4);
       Species s2 = new  Species(2,4);
       s1.setId( "Glucose"     );
       s2.setId( "Glucose_6_P" );
       s1.setCompartment( "c");
       s2.setCompartment( "c");
       M.addSpecies(s1);
       M.addSpecies(s2);
       assertTrue( M.getNumSpecies() == 2 );
       assertTrue( M.getSpecies( "Glucose"    ) != s1 );
       assertTrue( M.getSpecies( "Glucose_6_P") != s2 );
       assertTrue( M.getSpecies( "Glucose2"   ) == null );
 }
Ejemplo n.º 8
0
 public void test_Model_addSpecies()
 {
     Species s = new  Species(2,4);
       s.setId( "s");
       s.setCompartment( "c");
       M.addSpecies(s);
       assertTrue( M.getNumSpecies() == 1 );
 }
Ejemplo n.º 9
0
 public void test_Model_getNumSpeciesWithBoundaryCondition()
 {
     Species s1 = new  Species(2,4);
       Species s2 = new  Species(2,4);
       Species s3 = new  Species(2,4);
       s1.setId( "s1");
       s2.setId( "s2");
       s3.setId( "s3");
       s1.setCompartment( "c1");
       s2.setCompartment( "c2");
       s3.setCompartment( "c3");
       s1.setBoundaryCondition(true);
       s2.setBoundaryCondition(false);
       s3.setBoundaryCondition(true);
       assertTrue( M.getNumSpecies() == 0 );
       assertTrue( M.getNumSpeciesWithBoundaryCondition() == 0 );
       M.addSpecies(s1);
       assertTrue( M.getNumSpecies() == 1 );
       assertTrue( M.getNumSpeciesWithBoundaryCondition() == 1 );
       M.addSpecies(s2);
       assertTrue( M.getNumSpecies() == 2 );
       assertTrue( M.getNumSpeciesWithBoundaryCondition() == 1 );
       M.addSpecies(s3);
       assertTrue( M.getNumSpecies() == 3 );
       assertTrue( M.getNumSpeciesWithBoundaryCondition() == 2 );
 }
 public void test_internal_consistency_check_99916_rule()
 {
     SBMLDocument d = new SBMLDocument(2,4);
       long errors;
       Species s = new Species(2,4);
       d.setLevelAndVersion(1,2,false);
       Model m = d.createModel();
       Compartment c = m.createCompartment();
       c.setId("c");
       s.setId("s");
       s.setCompartment("c");
       s.setConstant(true);
       m.addSpecies(s);
       Rule r = m.createAssignmentRule();
       r.setVariable("s");
       r.setFormula("2");
       errors = d.checkInternalConsistency();
       assertTrue( errors == 2 );
       d = null;
 }
 public void test_internal_consistency_check_99904_species()
 {
     SBMLDocument d = new SBMLDocument(2,4);
       long errors;
       Species s = new Species(2,4);
       d.setLevelAndVersion(1,2,false);
       Model m = d.createModel();
       Compartment c = m.createCompartment();
       c.setId("c");
       s.setCompartment("c");
       s.setId("s");
       s.setMetaId("mmm");
       m.addSpecies(s);
       errors = d.checkInternalConsistency();
       assertTrue( errors == 0 );
       d = null;
 }
 public void test_internal_consistency_check_99916_reaction()
 {
     SBMLDocument d = new SBMLDocument(2,4);
       long errors;
       Species s = new Species(2,4);
       d.setLevelAndVersion(1,2,false);
       Model m = d.createModel();
       Compartment c = m.createCompartment();
       c.setId("c");
       Reaction r = m.createReaction();
       r.setId("r");
       SpeciesReference sr = r.createReactant();
       s.setId("s");
       s.setCompartment("c");
       s.setConstant(true);
       sr.setSpecies("s");
       m.addSpecies(s);
       errors = d.checkInternalConsistency();
       assertTrue( errors == 0 );
       d = null;
 }
Ejemplo n.º 13
0
        private static int Main(string[] args)
        {
            var retval = 0;
            var sbmlns = new SBMLNamespaces(3, 1, "comp", 1);

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

            //Define the external model definition
            var compdoc = (CompSBMLDocumentPlugin)(document.getPlugin("comp"));
            compdoc.setRequired(true);
            var extmod = compdoc.createExternalModelDefinition();
            extmod.setId("ExtMod1");
            extmod.setSource("enzyme_model.xml");
            extmod.setModelRef("enzyme");

            //Define the 'simple' model
            var mod1 = compdoc.createModelDefinition();
            mod1.setId("simple");
            var comp = mod1.createCompartment();
            comp.setSpatialDimensions(3);
            comp.setConstant(true);
            comp.setId("comp");
            comp.setSize(1L);

            var spec = new Species(sbmlns);
            //We have to construct it this way because we get the comp plugin from it later.
            spec.setCompartment("comp");
            spec.setHasOnlySubstanceUnits(false);
            spec.setConstant(false);
            spec.setBoundaryCondition(false);
            spec.setId("S");
            spec.setInitialConcentration(5);
            mod1.addSpecies(spec);
            spec.setId("D");
            spec.setInitialConcentration(10);
            mod1.addSpecies(spec);

            var rxn = new Reaction(3, 1);
            rxn.setReversible(true);
            rxn.setFast(false);
            rxn.setId("J0");

            var sr = new SpeciesReference(3, 1);
            sr.setConstant(true);
            sr.setStoichiometry(1);
            sr.setSpecies("S");
            rxn.addReactant(sr);
            sr.setSpecies("D");
            rxn.addProduct(sr);

            mod1.addReaction(rxn);

            var mod1plug = (CompModelPlugin)(mod1.getPlugin("comp"));
            var port = new Port();
            port.setId("S_port");
            port.setIdRef("S");
            mod1plug.addPort(port);

            var port2 = mod1plug.createPort();
            port2.setId("D_port");
            port2.setIdRef("D");

            port.setId("comp_port");
            port.setIdRef("comp");
            mod1plug.addPort(port);

            port.setId("J0_port");
            port.setIdRef("J0");
            mod1plug.addPort(port);

            // create the Model
            var model = document.createModel();
            model.setId("complexified");

            // Set the submodels
            var mplugin = (CompModelPlugin)(model.getPlugin("comp"));
            var submod1 = mplugin.createSubmodel();
            submod1.setId("A");
            submod1.setModelRef("ExtMod1");
            var submod2 = mplugin.createSubmodel();
            submod2.setId("B");
            submod2.setModelRef("simple");
            var del = submod2.createDeletion();
            del.setPortRef("J0_port");

            // Synchronize the compartments
            var mcomp = model.createCompartment();
            mcomp.setSpatialDimensions(3);
            mcomp.setConstant(true);
            mcomp.setId("comp");
            mcomp.setSize(1L);
            var compartplug = (CompSBasePlugin)(mcomp.getPlugin("comp"));
            var re = new ReplacedElement();
            re.setIdRef("comp");
            re.setSubmodelRef("A");
            compartplug.addReplacedElement(re);
            re.setSubmodelRef("B");
            re.unsetIdRef();
            re.setPortRef("comp_port");
            compartplug.addReplacedElement(re);

            //Synchronize the species
            spec.setId("S");
            spec.setInitialConcentration(5);
            var specplug = (CompSBasePlugin)(spec.getPlugin("comp"));
            var sre = specplug.createReplacedElement();
            sre.setSubmodelRef("A");
            sre.setIdRef("S");
            var sre2 = specplug.createReplacedElement();
            sre2.setSubmodelRef("B");
            sre2.setPortRef("S_port");
            model.addSpecies(spec);

            spec.setId("D");
            spec.setInitialConcentration(10);
            sre.setIdRef("D");
            sre2.setPortRef("D_port");
            model.addSpecies(spec);

            libsbml.writeSBMLToFile(document, "spec_example3.xml");
            document = libsbml.readSBMLFromFile("spec_example3.xml");
            if (document == null)
            {
                Console.WriteLine("Error reading back in file.");

                retval = -1;
            }
            else
            {
                document.setConsistencyChecks(libsbml.LIBSBML_CAT_UNITS_CONSISTENCY, false);
                document.checkConsistency();
                if (document.getErrorLog().getNumFailsWithSeverity(2) > 0 ||
                    document.getErrorLog().getNumFailsWithSeverity(3) > 0)
                {
                    var stream = new OStringStream();
                    document.printErrors(stream);
                    Console.WriteLine("Errors encoutered when round-tripping  SBML file: \n" +
                                      stream.str());
                    retval = -1;
                }
                libsbml.writeSBMLToFile(document, "spec_example3_rt.xml");
            }
            return retval;
        }
Ejemplo n.º 14
0
        private static int Main(string[] args)
        {
            var retval = 0;
            var sbmlns = new SBMLNamespaces(3, 1, "comp", 1);

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

            //Create our submodel
            var compdoc = (CompSBMLDocumentPlugin) (document.getPlugin("comp"));
            compdoc.setRequired(true);
            var mod1 = compdoc.createModelDefinition();
            mod1.setId("enzyme");
            mod1.setName("enzyme");
            var comp = mod1.createCompartment();
            comp.setSpatialDimensions(3);
            comp.setConstant(true);
            comp.setId("comp");
            comp.setSize(1L);
            var spec = new Species(3, 1);
            spec.setCompartment("comp");
            spec.setHasOnlySubstanceUnits(false);
            spec.setConstant(false);
            spec.setBoundaryCondition(false);
            spec.setId("S");
            mod1.addSpecies(spec);
            spec.setId("E");
            mod1.addSpecies(spec);
            spec.setId("D");
            mod1.addSpecies(spec);
            spec.setId("ES");
            mod1.addSpecies(spec);
            var rxn = new Reaction(3, 1);
            rxn.setReversible(true);
            rxn.setFast(false);
            var rxn2 = new Reaction(rxn);
            rxn.setId("J0");
            rxn2.setId("J1");
            var sr = new SpeciesReference(3, 1);
            sr.setConstant(true);
            sr.setStoichiometry(1);
            sr.setSpecies("S");
            rxn.addReactant(sr);
            sr.setSpecies("E");
            rxn.addReactant(sr);
            rxn2.addProduct(sr);
            sr.setSpecies("ES");
            rxn.addProduct(sr);
            rxn2.addReactant(sr);
            sr.setSpecies("D");
            rxn2.addProduct(sr);

            mod1.addReaction(rxn);
            mod1.addReaction(rxn2);

            // create the Model
            var model = document.createModel();
            model.setId("aggregate");

            // Create a submodel
            var mplugin = (CompModelPlugin) (model.getPlugin("comp"));
            var submod1 = mplugin.createSubmodel();
            submod1.setId("submod1");
            submod1.setModelRef("enzyme");

            var submod2 = new Submodel();
            submod2.setId("submod2");
            submod2.setModelRef("enzyme");
            mplugin.addSubmodel(submod2);

            libsbml.writeSBMLToFile(document, "enzyme_model.xml");
            document = libsbml.readSBMLFromFile("enzyme_model.xml");
            if (document == null)
            {
                Console.WriteLine("Error reading back in file.");
                retval = -1;
            }
            else
            {
                document.setConsistencyChecks(libsbml.LIBSBML_CAT_UNITS_CONSISTENCY, false);
                document.checkConsistency();
                if (document.getErrorLog().getNumFailsWithSeverity(2) > 0 ||
                    document.getErrorLog().getNumFailsWithSeverity(3) > 0)
                {
                    var stream = new OStringStream();
                    document.printErrors(stream);
                    Console.WriteLine("Errors encoutered when round-tripping  SBML file: \n" +
                                      stream.str());
                    retval = -1;
                }
                libsbml.writeSBMLToFile(document, "enzyme_model_rt.xml");
            }
            return retval;
        }
Ejemplo n.º 15
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;
 }
Ejemplo n.º 16
0
 public void test_Model_getSpecies()
 {
     Species s1 = new  Species(2,4);
       Species s2 = new  Species(2,4);
       s1.setId( "Glucose"     );
       s2.setId( "Glucose_6_P" );
       s1.setCompartment( "c");
       s2.setCompartment( "c");
       M.addSpecies(s1);
       M.addSpecies(s2);
       assertTrue( M.getNumSpecies() == 2 );
       s1 = M.getSpecies(0);
       s2 = M.getSpecies(1);
       assertTrue((  "Glucose"      == s1.getId() ));
       assertTrue((  "Glucose_6_P"  == s2.getId() ));
 }
Ejemplo n.º 17
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;
 }
Ejemplo n.º 18
0
 public void test_L3_Species_hasRequiredAttributes()
 {
     Species s = new  Species(3,1);
       assertEquals( false, s.hasRequiredAttributes() );
       s.setId( "id");
       assertEquals( false, s.hasRequiredAttributes() );
       s.setCompartment( "cell");
       assertEquals( false, s.hasRequiredAttributes() );
       s.setHasOnlySubstanceUnits(false);
       assertEquals( false, s.hasRequiredAttributes() );
       s.setBoundaryCondition(false);
       assertEquals( false, s.hasRequiredAttributes() );
       s.setConstant(false);
       assertEquals( true, s.hasRequiredAttributes() );
       s = null;
 }