Exemple #1
0
        public void test_L3_SpeciesReference_createWithNS()
        {
            XMLNamespaces xmlns = new  XMLNamespaces();

            xmlns.add("http://www.sbml.org", "testsbml");
            SBMLNamespaces sbmlns = new  SBMLNamespaces(3, 1);

            sbmlns.addNamespaces(xmlns);
            SpeciesReference sr = new  SpeciesReference(sbmlns);

            assertTrue(sr.getTypeCode() == libsbml.SBML_SPECIES_REFERENCE);
            assertTrue(sr.getMetaId() == "");
            assertTrue(sr.getNotes() == null);
            assertTrue(sr.getAnnotation() == null);
            assertTrue(sr.getLevel() == 3);
            assertTrue(sr.getVersion() == 1);
            assertTrue(sr.getNamespaces() != null);
            assertTrue(sr.getNamespaces().getLength() == 2);
            assertTrue(sr.getId() == "");
            assertTrue(sr.getName() == "");
            assertTrue(sr.getSpecies() == "");
            assertEquals(true, isnan(sr.getStoichiometry()));
            assertTrue(sr.getConstant() == false);
            assertEquals(false, sr.isSetId());
            assertEquals(false, sr.isSetName());
            assertEquals(false, sr.isSetSpecies());
            assertEquals(false, sr.isSetStoichiometry());
            assertEquals(false, sr.isSetConstant());
            sr = null;
        }
Exemple #2
0
        public void test_SBMLConvert_convertToL3_stoichiometryMath()
        {
            SBMLDocument d = new  SBMLDocument(2, 1);
            Model        m = d.createModel();
            Compartment  c = m.createCompartment();

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

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

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

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

            assertTrue((rule.getVariable() == sr.getId()));
            d = null;
        }
        public void test_SpeciesReference()
        {
            SpeciesReference sr = new SpeciesReference(2, 4);

            assertEquals(true, sr.hasRequiredElements());
            sr = null;
        }
        public void test_Reaction_parent_NULL()
        {
            SBMLDocument     d  = new SBMLDocument();
            Model            m  = d.createModel();
            Reaction         c  = m.createReaction();
            SpeciesReference sr = c.createReactant();
            KineticLaw       kl = c.createKineticLaw();

            assertTrue(c.getAncestorOfType(libsbml.SBML_MODEL) == m);
            assertEquals(c.getSBMLDocument(), d);
            assertTrue(sr.getAncestorOfType(libsbml.SBML_REACTION) == c);
            assertTrue(kl.getAncestorOfType(libsbml.SBML_REACTION) == c);
            Reaction c1 = c.clone();

            d = null;
            assertTrue(c1.getAncestorOfType(libsbml.SBML_MODEL) == null);
            assertTrue(c1.getParentSBMLObject() == null);
            assertEquals(c1.getSBMLDocument(), null);
            SpeciesReference sr1 = c1.getReactant(0);

            assertTrue(sr1.getAncestorOfType(libsbml.SBML_MODEL) == null);
            assertTrue(sr1.getAncestorOfType(libsbml.SBML_REACTION) == c1);
            assertEquals(sr1.getSBMLDocument(), null);
            assertTrue(c1.getKineticLaw().getAncestorOfType(libsbml.SBML_MODEL) == null);
            assertTrue(c1.getKineticLaw().getAncestorOfType(libsbml.SBML_REACTION) == c1);
            assertEquals(c1.getKineticLaw().getSBMLDocument(), null);
            c1 = null;
        }
Exemple #5
0
        public void test_SBMLConvert_convertToL3_localParameters()
        {
            SBMLDocument d = new  SBMLDocument(1, 2);
            Model        m = d.createModel();
            Compartment  c = m.createCompartment();

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

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

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

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

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

            d = null;
        }
Exemple #6
0
        /// <summary>
        ///     Creates a MoBi ReactionPartner by a given SBML Species Reference
        /// </summary>
        private IReactionPartnerBuilder CreateReactionPartner(SpeciesReference speciesReference, Model model)
        {
            var molecule = _sbmlInformation.GetMoleculeBySBMLId(speciesReference.getSpecies());

            if (molecule == null)
            {
                return(null);
            }

            IReactionPartnerBuilder productBuilder = new ReactionPartnerBuilder
            {
                MoleculeName = molecule.Name,
            };

            if (speciesReference.isSetStoichiometryMath())
            {
                CreateStoichiometryErrorMsg(speciesReference.getSpecies());
            }
            productBuilder.StoichiometricCoefficient = speciesReference.isSetStoichiometry() ? speciesReference.getStoichiometry() : SBMLConstants.SBML_STOICHIOMETRY_DEFAULT;

            var species = GetSpeciesById(speciesReference.getSpecies(), model);

            if (species == null)
            {
                return(productBuilder);
            }
            if (species.getConstant() && species.getBoundaryCondition() == false)
            {
                productBuilder.StoichiometricCoefficient = 0;
            }

            return(productBuilder);
        }
        public void test_SpeciesReference_setStoichiometryMath7()
        {
            SpeciesReference sr1 = new  SpeciesReference(1, 2);
            int i = sr1.unsetStoichiometryMath();

            assertTrue(i == libsbml.LIBSBML_UNEXPECTED_ATTRIBUTE);
            sr1 = null;
        }
        public void test_SpeciesReference_setName3()
        {
            SpeciesReference c = new  SpeciesReference(2, 1);
            int i = c.setName("cell");

            assertTrue(i == libsbml.LIBSBML_UNEXPECTED_ATTRIBUTE);
            assertEquals(false, c.isSetName());
            c = null;
        }
        public void test_SpeciesReference_setDenominator2()
        {
            SpeciesReference c = new  SpeciesReference(2, 2);
            int i = c.setDenominator(4);

            assertTrue(i == libsbml.LIBSBML_OPERATION_SUCCESS);
            assertTrue(c.getDenominator() == 4);
            c = null;
        }
        public void test_SpeciesReference_setStoichiometry2()
        {
            SpeciesReference c = new  SpeciesReference(2, 2);
            int i = c.setStoichiometry(4);

            assertTrue(i == libsbml.LIBSBML_OPERATION_SUCCESS);
            assertTrue(c.getStoichiometry() == 4.0);
            c = null;
        }
        public void test_SpeciesReference_setSpecies2()
        {
            SpeciesReference c = new  SpeciesReference(2, 2);
            int i = c.setSpecies("1cell");

            assertTrue(i == libsbml.LIBSBML_INVALID_ATTRIBUTE_VALUE);
            assertEquals(false, c.isSetSpecies());
            c = null;
        }
Exemple #12
0
        public void test_SpeciesReference()
        {
            SpeciesReference sr = new SpeciesReference(2, 4);

            assertEquals(false, (sr.hasRequiredAttributes()));
            sr.setSpecies("sr");
            assertEquals(true, sr.hasRequiredAttributes());
            sr = null;
        }
 public void setUp()
 {
     sr = new  SpeciesReference(2, 4);
     if (sr == null)
     {
         ;
     }
     {
     }
 }
        public void test_Reaction_createReactant()
        {
            Reaction         m = new  Reaction(2, 2);
            SpeciesReference p = m.createReactant();

            assertTrue(m.getNumReactants() == 1);
            assertTrue((p).getLevel() == 2);
            assertTrue((p).getVersion() == 2);
            m = null;
        }
        public void test_Reaction_addReactant4()
        {
            Reaction         m = new  Reaction(2, 2);
            SpeciesReference p = null;
            int i = m.addReactant(p);

            assertTrue(i == libsbml.LIBSBML_OPERATION_FAILED);
            assertTrue(m.getNumReactants() == 0);
            m = null;
        }
        public void test_SpeciesReference_setSpecies3()
        {
            SpeciesReference c = new  SpeciesReference(2, 2);
            int i = c.setSpecies("mole");

            assertTrue(i == libsbml.LIBSBML_OPERATION_SUCCESS);
            assertTrue(("mole" == c.getSpecies()));
            assertEquals(true, c.isSetSpecies());
            c = null;
        }
Exemple #17
0
 public void setUp()
 {
     SR = new  SpeciesReference(3, 1);
     if (SR == null)
     {
         ;
     }
     {
     }
 }
        public void test_SpeciesReference_Reactant_parent_create()
        {
            Reaction         r  = new Reaction(2, 4);
            SpeciesReference sr = r.createReactant();
            ListOf           lo = r.getListOfReactants();

            assertTrue(lo == r.getReactant(0).getParentSBMLObject());
            assertTrue(lo == sr.getParentSBMLObject());
            assertTrue(r == lo.getParentSBMLObject());
        }
        public void test_WriteL3SBML_SpeciesReference()
        {
            string           expected = "<speciesReference species=\"s\"" + " stoichiometry=\"3\" constant=\"true\"/>";
            SpeciesReference sr       = D.createModel().createReaction().createReactant();

            sr.setSpecies("s");
            sr.setStoichiometry(3);
            sr.setConstant(true);
            assertEquals(true, equals(expected, sr.toSBML()));
        }
        public void test_Model_createReactant()
        {
            Model            m  = new  Model(2, 2);
            Reaction         p  = m.createReaction();
            SpeciesReference sr = m.createReactant();

            assertTrue(p.getNumReactants() == 1);
            assertTrue((sr).getLevel() == 2);
            assertTrue((sr).getVersion() == 2);
            m = null;
        }
        public void test_SpeciesReference_Product_parent_create_model()
        {
            Model            m  = new Model(2, 4);
            Reaction         r  = m.createReaction();
            SpeciesReference sr = m.createProduct();
            ListOf           lo = r.getListOfProducts();

            assertTrue(lo == r.getProduct(0).getParentSBMLObject());
            assertTrue(lo == sr.getParentSBMLObject());
            assertTrue(r == lo.getParentSBMLObject());
        }
Exemple #22
0
        public void test_L3_SpeciesReference_hasRequiredAttributes()
        {
            SpeciesReference sr = new  SpeciesReference(3, 1);

            assertEquals(false, sr.hasRequiredAttributes());
            sr.setSpecies("id");
            assertEquals(false, sr.hasRequiredAttributes());
            sr.setConstant(false);
            assertEquals(true, sr.hasRequiredAttributes());
            sr = null;
        }
        public void test_Reaction_addReactant()
        {
            SpeciesReference sr = new  SpeciesReference(2, 4);

            sr.setSpecies("s");
            R.addReactant(sr);
            assertTrue(R.getNumReactants() == 1);
            assertTrue(R.getNumProducts() == 0);
            assertTrue(R.getNumModifiers() == 0);
            sr = null;
        }
        public void test_StoichiometryMath_parent_add()
        {
            StoichiometryMath m = new StoichiometryMath(2, 4);

            m.setMath(libsbml.parseFormula("1"));
            SpeciesReference sr = new SpeciesReference(2, 4);

            sr.setStoichiometryMath(m);
            m = null;
            assertTrue(sr == sr.getStoichiometryMath().getParentSBMLObject());
            sr = null;
        }
Exemple #25
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);
        }
Exemple #26
0
        public void test_SpeciesReference_copyConstructor()
        {
            SpeciesReference o1 = new SpeciesReference(2, 4);

            o1.setId("c");
            assertTrue(o1.getId() == "c");
            SpeciesReference o2 = new SpeciesReference(o1);

            assertTrue(o2.getId() == "c");
            assertTrue(o2.getParentSBMLObject() == o1.getParentSBMLObject());
            o2 = null;
            o1 = null;
        }
        public void test_SpeciesReference_Reactant_parent_add()
        {
            SpeciesReference sr = new SpeciesReference(2, 4);
            Reaction         r  = new Reaction(2, 4);

            sr.setSpecies("s");
            r.addReactant(sr);
            sr = null;
            ListOf lo = r.getListOfReactants();

            assertTrue(lo == r.getReactant(0).getParentSBMLObject());
            assertTrue(r == lo.getParentSBMLObject());
        }
        public void test_Reaction_addProduct2()
        {
            Reaction         m = new  Reaction(2, 2);
            SpeciesReference p = new  SpeciesReference(2, 1);

            p.setSpecies("k");
            int i = m.addProduct(p);

            assertTrue(i == libsbml.LIBSBML_VERSION_MISMATCH);
            assertTrue(m.getNumProducts() == 0);
            p = null;
            m = null;
        }
        public void test_Reaction_addReactant3()
        {
            Reaction         m = new  Reaction(2, 2);
            SpeciesReference p = new  SpeciesReference(1, 2);

            p.setSpecies("k");
            int i = m.addReactant(p);

            assertTrue(i == libsbml.LIBSBML_LEVEL_MISMATCH);
            assertTrue(m.getNumReactants() == 0);
            p = null;
            m = null;
        }
Exemple #30
0
        public void test_SBMLConvert_convertToL3_reactant()
        {
            SBMLDocument     d  = new  SBMLDocument(2, 2);
            Model            m  = d.createModel();
            Reaction         r  = m.createReaction();
            SpeciesReference sr = r.createReactant();
            SpeciesReference sr1;

            sr.setSpecies("s");
            assertTrue(d.setLevelAndVersion(3, 1, false) == true);
            sr1 = m.getReaction(0).getReactant(0);
            assertTrue(sr1.hasRequiredAttributes() == true);
            d = null;
        }
Exemple #31
0
 public void setSpeciesReference(int linkNumber, ComponentLinkType linkType, SpeciesReference reference)
 {
     switch (linkType)
     {
         case ComponentLinkType.Input:
             reactants[linkNumber] = reference;
             break;
         case ComponentLinkType.Output:
             products[linkNumber] = reference;
             break;
     }
 }
Exemple #32
0
        public void SpeciesReferenceElement(Hashtable attrs)
        {
            String speciesId;
            Species species;

            try
            {
            speciesId = (String)attrs["species"];
            species = (Species)this.model.findObject(speciesId);

            // find out if it is a list of reactants or products
            if (((String)elementStack.Pop()) == "listOfReactants")
            {
                SpeciesReference speciesRef;
                List<SpeciesReference> reactantsList = (List<SpeciesReference>)elementStack.Peek();

                if (attrs.Contains("stoichiometry"))
                {
                    speciesRef = new SpeciesReference(this.model, species,
                        (double)(Double.Parse((String)attrs["stoichiometry"])));
                }
                else
                {
                    speciesRef = new SpeciesReference(this.model, species);
                }

                reactantsList.Add(speciesRef);
                elementStack.Push("listOfReactants");
            }

            else
                // list of products instead
            {
                SpeciesReference speciesRef;
                List<SpeciesReference> productsList = (List<SpeciesReference>)elementStack.Peek();

                if (attrs.Contains("stoichiometry"))
                {
                    speciesRef = new SpeciesReference(this.model, species,
                        (double)(Double.Parse((String)attrs["stoichiometry"])));
                }
                else
                {
                    speciesRef = new SpeciesReference(this.model, species);
                }

                productsList.Add(speciesRef);
                elementStack.Push("listOfProducts");
            }

            }
            catch (ArgumentNullException e)
            {
            Console.WriteLine("speciesReference element missing required attribute 'species'");
            throw (e);
            }
        }