setId() public method

public setId ( string sid ) : int
sid string
return int
Esempio n. 1
0
 public void test_KineticLaw_getParameterById()
 {
     Parameter k1 = new  Parameter(2,4);
       Parameter k2 = new  Parameter(2,4);
       k1.setId( "k1");
       k2.setId( "k2");
       k1.setValue(3.14);
       k2.setValue(2.72);
       M.addParameter(k1);
       M.addParameter(k2);
       Reaction r1 = new  Reaction(2,4);
       r1.setId( "reaction_1" );
       KineticLaw kl = new  KineticLaw(2,4);
       kl.setFormula( "k1 * X0");
       Parameter k3 = new  Parameter(2,4);
       Parameter k4 = new  Parameter(2,4);
       k3.setId( "k1");
       k4.setId( "k2");
       k3.setValue(2.72);
       k4.setValue(3.14);
       kl.addParameter(k3);
       kl.addParameter(k4);
       r1.setKineticLaw(kl);
       M.addReaction(r1);
       KineticLaw kl1 = M.getReaction(0).getKineticLaw();
       assertNotEquals(kl1.getParameter( "k1" ),k3);
       assertNotEquals(kl1.getParameter( "k1" ),k1);
       assertNotEquals(kl1.getParameter( "k2" ),k4);
       assertEquals(kl1.getParameter( "k3" ),null);
 }
Esempio n. 2
0
        protected override void Context()
        {
            base.Context();
            _sbmlModel       = new Model(3, 1);
            _sbmlInformation = new SBMLInformation();

            //one compartment reaction
            _reaction = _sbmlModel.createReaction();
            _reaction.setId("r1");

            //reaction partner
            var s1 = _sbmlModel.createSpecies();

            s1.setId("s1");
            s1.setCompartment("default");

            var s2 = _sbmlModel.createSpecies();

            s2.setId("s2");
            s2.setCompartment("default");

            var m  = new MoleculeInformation(s1);
            var m2 = new MoleculeInformation(s2);

            _sbmlInformation.MoleculeInformation.Add(m);
            _sbmlInformation.MoleculeInformation.Add(m2);

            //SRef
            var s1Ref = _reaction.createReactant();

            s1Ref.setSpecies("s1");
            s1Ref.setStoichiometry(1);

            var s2Ref = _reaction.createProduct();

            s2Ref.setSpecies("s2");
            s2Ref.setStoichiometry(2);
            _reaction.addProduct(s2Ref);

            //Modifier
            var mod = _reaction.createModifier();

            mod.setId("mod");
            mod.setName("mod");
            mod.setSpecies("s1");

            //Kinetic Law
            var kl = _reaction.createKineticLaw();

            kl.setId("kl");
            kl.setMath(libsbml.parseFormula("2*3"));
        }
 public void test_Reaction_ancestor_add()
 {
     Reaction ia = new Reaction(2,4);
       Model m = new Model(2,4);
       ia.setId("k");
       m.addReaction(ia);
       ia = null;
       ListOf lo = m.getListOfReactions();
       Reaction obj = m.getReaction(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 );
 }
 public void test_L3_Reaction_hasRequiredAttributes()
 {
     Reaction r = new  Reaction(3,1);
       assertEquals( false, r.hasRequiredAttributes() );
       r.setId( "id");
       assertEquals( false, r.hasRequiredAttributes() );
       r.setFast(false);
       assertEquals( false, r.hasRequiredAttributes() );
       r.setReversible(false);
       assertEquals( true, r.hasRequiredAttributes() );
       r = null;
 }
Esempio n. 5
0
 public void test_Model_addReaction3()
 {
     Model m = new  Model(2,2);
       Reaction r = new  Reaction(1,2);
       r.setId( "r");
       int i = m.addReaction(r);
       assertTrue( i == libsbml.LIBSBML_LEVEL_MISMATCH );
       assertTrue( m.getNumReactions() == 0 );
       r = null;
       m = null;
 }
Esempio n. 6
0
 public void test_Model_addReaction5()
 {
     Model m = new  Model(2,2);
       Reaction r = new  Reaction(2,2);
       r.setId( "r");
       Reaction r1 = new  Reaction(2,2);
       r1.setId( "r");
       int i = m.addReaction(r);
       assertTrue( i == libsbml.LIBSBML_OPERATION_SUCCESS );
       assertTrue( m.getNumReactions() == 1 );
       i = m.addReaction(r1);
       assertTrue( i == libsbml.LIBSBML_DUPLICATE_OBJECT_ID );
       assertTrue( m.getNumReactions() == 1 );
       r = null;
       r1 = null;
       m = null;
 }
Esempio n. 7
0
 public void test_Model_getSpeciesReferenceById()
 {
     Reaction r1 = new  Reaction(2,4);
       r1.setId( "r1");
       SpeciesReference sr = r1.createReactant();
       sr.setId( "s1");
       M.addReaction(r1);
       assertTrue( M.getNumReactions() == 1 );
       assertNotEquals(M.getSpeciesReference( "s1" ),sr);
 }
Esempio n. 8
0
 public void test_Model_addReaction1()
 {
     Model m = new  Model(2,2);
       Reaction r = new  Reaction(2,2);
       int i = m.addReaction(r);
       assertTrue( i == libsbml.LIBSBML_INVALID_OBJECT );
       r.setId( "r");
       i = m.addReaction(r);
       assertTrue( i == libsbml.LIBSBML_OPERATION_SUCCESS );
       assertTrue( m.getNumReactions() == 1 );
       r = null;
       m = null;
 }
 public void test_Reaction_copyConstructor()
 {
     Reaction o1 = new Reaction(2,4);
       o1.setId("c");
       assertTrue( o1.getId() ==  "c" );
       KineticLaw kl = new KineticLaw(2,4);
       kl.setMath(libsbml.parseFormula("1"));
       o1.setKineticLaw(kl);
       kl = null;
       assertTrue( o1.isSetKineticLaw() == true );
       assertNotEquals(o1.getKineticLaw(),null);
       Reaction o2 = new Reaction(o1);
       assertTrue( o2.getId() ==  "c" );
       assertTrue( o2.isSetKineticLaw() == true );
       assertNotEquals(o2.getKineticLaw(),null);
       assertTrue( o2.getParentSBMLObject() == o1.getParentSBMLObject() );
       o2 = null;
       o1 = null;
 }
Esempio n. 10
0
 public void test_Model_getReactionById()
 {
     Reaction r1 = new  Reaction(2,4);
       Reaction r2 = new  Reaction(2,4);
       r1.setId( "reaction_1" );
       r2.setId( "reaction_2" );
       M.addReaction(r1);
       M.addReaction(r2);
       assertTrue( M.getNumReactions() == 2 );
       assertNotEquals(M.getReaction( "reaction_1" ),r1);
       assertNotEquals(M.getReaction( "reaction_2" ),r2);
       assertEquals(M.getReaction( "reaction_3" ),null);
 }
Esempio n. 11
0
 public void test_Model_addReaction()
 {
     Reaction r = new  Reaction(2,4);
       r.setId( "r");
       M.addReaction(r);
       assertTrue( M.getNumReactions() == 1 );
 }
 public void test_Reaction_parent_add()
 {
     Reaction ia = new Reaction(2,4);
       Model m = new Model(2,4);
       ia.setId("k");
       m.addReaction(ia);
       ia = null;
       ListOf lo = m.getListOfReactions();
       assertTrue( lo == m.getReaction(0).getParentSBMLObject() );
       assertTrue( m == lo.getParentSBMLObject() );
 }
 public void test_internal_consistency_check_99904_react()
 {
     SBMLDocument d = new SBMLDocument(2,4);
       long errors;
       Reaction r = new Reaction(2,4);
       d.setLevelAndVersion(1,2,false);
       Model m = d.createModel();
       Compartment c = m.createCompartment();
       c.setId("cc");
       r.setId("r");
       r.setMetaId("mmm");
       m.addReaction(r);
       errors = d.checkInternalConsistency();
       assertTrue( errors == 0 );
       d = null;
 }
 public void test_internal_consistency_check_99911_react()
 {
     SBMLDocument d = new SBMLDocument(2,4);
       long errors;
       Model m = d.createModel();
       Reaction r = new Reaction(2,4);
       d.setLevelAndVersion(2,1,false);
       r.setId("r");
       r.setSBOTerm(2);
       m.addReaction(r);
       errors = d.checkInternalConsistency();
       assertTrue( errors == 0 );
       d = null;
 }
Esempio n. 15
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;
        }
Esempio n. 16
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;
        }
 public void test_Reaction()
 {
     Reaction r = new Reaction(2,4);
       assertEquals( false, (r.hasRequiredAttributes()) );
       r.setId("r");
       assertEquals( true, r.hasRequiredAttributes() );
       r = null;
 }
Esempio n. 18
0
 public void test_Model_getReaction()
 {
     Reaction r1 = new  Reaction(2,4);
       Reaction r2 = new  Reaction(2,4);
       r1.setId( "reaction_1");
       r2.setId( "reaction_2");
       M.addReaction(r1);
       M.addReaction(r2);
       assertTrue( M.getNumReactions() == 2 );
       r1 = M.getReaction(0);
       r2 = M.getReaction(1);
       assertTrue((  "reaction_1" == r1.getId() ));
       assertTrue((  "reaction_2" == r2.getId() ));
 }
 public void test_Reaction_clone()
 {
     Reaction o1 = new Reaction(2,4);
       o1.setId("c");
       assertTrue( o1.getId() ==  "c" );
       KineticLaw kl = new KineticLaw(2,4);
       o1.setKineticLaw(kl);
       kl = null;
       assertTrue( o1.isSetKineticLaw() == true );
       assertNotEquals(o1.getKineticLaw(),null);
       Reaction o2 = o1.clone();
       assertTrue( o2.getId() ==  "c" );
       assertTrue( o2.isSetKineticLaw() == true );
       assertNotEquals(o2.getKineticLaw(),null);
       assertTrue( o2.getParentSBMLObject() == o1.getParentSBMLObject() );
       o2 = null;
       o1 = null;
 }