Ejemplo n.º 1
0
        public void test_Model_getRules()
        {
            Rule ar  = new  AlgebraicRule(2, 4);
            Rule scr = new  AssignmentRule(2, 4);
            Rule cvr = new  AssignmentRule(2, 4);
            Rule pr  = new  AssignmentRule(2, 4);

            scr.setVariable("r2");
            cvr.setVariable("r3");
            pr.setVariable("r4");
            ar.setFormula("x + 1");
            scr.setFormula("k * t/(1 + k)");
            cvr.setFormula("0.10 * t");
            pr.setFormula("k3/k2");
            M.addRule(ar);
            M.addRule(scr);
            M.addRule(cvr);
            M.addRule(pr);
            assertTrue(M.getNumRules() == 4);
            ar  = M.getRule(0);
            scr = M.getRule(1);
            cvr = M.getRule(2);
            pr  = M.getRule(3);
            assertTrue(("x + 1" == ar.getFormula()));
            assertTrue(("k * t/(1 + k)" == scr.getFormula()));
            assertTrue(("0.10 * t" == cvr.getFormula()));
            assertTrue(("k3/k2" == pr.getFormula()));
        }
Ejemplo n.º 2
0
        public void test_AlgebraicRule()
        {
            AlgebraicRule ar = new AlgebraicRule(2, 4);

            assertEquals(true, ar.hasRequiredAttributes());
            ar = null;
        }
Ejemplo n.º 3
0
        public void AlgebraicRuleElement(Hashtable attrs)
        {
            AlgebraicRule algebraicRule = new AlgebraicRule(this.model);
            this.model.listOfRules.Add(algebraicRule);

            elementStack.Push(algebraicRule);
        }
        public void test_Rule_setVariable3()
        {
            Rule R1 = new  AlgebraicRule(1, 2);
            int  i  = R1.setVariable("r");

            assertTrue(i == libsbml.LIBSBML_UNEXPECTED_ATTRIBUTE);
            assertEquals(false, R1.isSetVariable());
            R1 = null;
        }
Ejemplo n.º 5
0
        public void test_AlgebraicRule_L1()
        {
            AlgebraicRule ar = new AlgebraicRule(1, 2);

            assertEquals(false, (ar.hasRequiredAttributes()));
            ar.setFormula("ar");
            assertEquals(true, ar.hasRequiredAttributes());
            ar = null;
        }
        public void test_AlgebraicRule()
        {
            AlgebraicRule ar = new AlgebraicRule(2, 4);

            assertEquals(false, (ar.hasRequiredElements()));
            ar.setMath(libsbml.parseFormula("ar"));
            assertEquals(true, ar.hasRequiredElements());
            ar = null;
        }
        public void test_AlgebraicRule_parent_create()
        {
            Model         m  = new Model(2, 4);
            AlgebraicRule r  = m.createAlgebraicRule();
            ListOf        lo = m.getListOfRules();

            assertTrue(lo == m.getRule(0).getParentSBMLObject());
            assertTrue(lo == r.getParentSBMLObject());
            assertTrue(m == lo.getParentSBMLObject());
        }
Ejemplo n.º 8
0
        public void test_AlgebraicRule_createWithMath()
        {
            ASTNode math = libsbml.parseFormula("1 + 1");
            Rule    ar   = new  AlgebraicRule(2, 4);

            ar.setMath(math);
            assertTrue(ar.getTypeCode() == libsbml.SBML_ALGEBRAIC_RULE);
            assertTrue(ar.getMetaId() == "");
            assertTrue(("1 + 1" == ar.getFormula()));
            assertTrue(ar.getMath() != math);
            ar = null;
        }
Ejemplo n.º 9
0
        public void test_Model_addRules()
        {
            Rule r1 = new  AlgebraicRule(2, 4);
            Rule r2 = new  AssignmentRule(2, 4);
            Rule r3 = new  RateRule(2, 4);

            r2.setVariable("r2");
            r3.setVariable("r3");
            r1.setMath(libsbml.parseFormula("2"));
            r2.setMath(libsbml.parseFormula("2"));
            r3.setMath(libsbml.parseFormula("2"));
            M.addRule(r1);
            M.addRule(r2);
            M.addRule(r3);
            assertTrue(M.getNumRules() == 3);
        }
Ejemplo n.º 10
0
        public void test_AlgebraicRule_createWithFormula()
        {
            ASTNode math;
            string  formula;
            Rule    ar = new  AlgebraicRule(2, 4);

            ar.setFormula("1 + 1");
            assertTrue(ar.getTypeCode() == libsbml.SBML_ALGEBRAIC_RULE);
            assertTrue(ar.getMetaId() == "");
            math = ar.getMath();
            assertTrue(math != null);
            formula = libsbml.formulaToString(math);
            assertTrue(formula != null);
            assertTrue(("1 + 1" == formula));
            assertTrue((formula == ar.getFormula()));
            ar = null;
        }
Ejemplo n.º 11
0
        public void test_AlgebraicRule_ancestor_create()
        {
            Model         m  = new Model(2, 4);
            AlgebraicRule r  = m.createAlgebraicRule();
            ListOf        lo = m.getListOfRules();

            assertTrue(r.getAncestorOfType(libsbml.SBML_MODEL) == m);
            assertTrue(r.getAncestorOfType(libsbml.SBML_LIST_OF) == lo);
            assertTrue(r.getAncestorOfType(libsbml.SBML_DOCUMENT) == null);
            assertTrue(r.getAncestorOfType(libsbml.SBML_EVENT) == null);
            Rule obj = m.getRule(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.º 12
0
        public void test_AlgebraicRule_createWithNS()
        {
            XMLNamespaces xmlns = new  XMLNamespaces();

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

            sbmlns.addNamespaces(xmlns);
            Rule r = new  AlgebraicRule(sbmlns);

            assertTrue(r.getTypeCode() == libsbml.SBML_ALGEBRAIC_RULE);
            assertTrue(r.getMetaId() == "");
            assertTrue(r.getNotes() == null);
            assertTrue(r.getAnnotation() == null);
            assertTrue(r.getLevel() == 2);
            assertTrue(r.getVersion() == 3);
            assertTrue(r.getNamespaces() != null);
            assertTrue(r.getNamespaces().getLength() == 2);
            r = null;
        }
Ejemplo n.º 13
0
        static void testClone(SBase s)
        {
            string ename = s.getElementName();
            SBase  c     = s.clone();

            if (c is Compartment)
            {
                Compartment x = (s as Compartment).clone(); c = x;
            }
            else if (c is CompartmentType)
            {
                CompartmentType x = (s as CompartmentType).clone(); c = x;
            }
            else if (c is Constraint)
            {
                Constraint x = (s as Constraint).clone(); c = x;
            }
            else if (c is Delay)
            {
                Delay x = (s as Delay).clone(); c = x;
            }
            else if (c is Event)
            {
                Event x = (s as Event).clone(); c = x;
            }
            else if (c is EventAssignment)
            {
                EventAssignment x = (s as EventAssignment).clone(); c = x;
            }
            else if (c is FunctionDefinition)
            {
                FunctionDefinition x = (s as FunctionDefinition).clone(); c = x;
            }
            else if (c is InitialAssignment)
            {
                InitialAssignment x = (s as InitialAssignment).clone(); c = x;
            }
            else if (c is KineticLaw)
            {
                KineticLaw x = (s as KineticLaw).clone(); c = x;
            }
            // currently return type of ListOf::clone() is SBase
            else if (c is ListOf)
            {
                SBase x = (s as ListOf).clone(); c = x;
            }
            else if (c is Model)
            {
                Model x = (s as Model).clone(); c = x;
            }
            else if (c is Parameter)
            {
                Parameter x = (s as Parameter).clone(); c = x;
            }
            else if (c is Reaction)
            {
                Reaction x = (s as Reaction).clone(); c = x;
            }
            else if (c is AlgebraicRule)
            {
                AlgebraicRule x = (s as AlgebraicRule).clone(); c = x;
            }
            else if (c is AssignmentRule)
            {
                AssignmentRule x = (s as AssignmentRule).clone(); c = x;
            }
            else if (c is RateRule)
            {
                RateRule x = (s as RateRule).clone(); c = x;
            }
            else if (c is SBMLDocument)
            {
                SBMLDocument x = (s as SBMLDocument).clone(); c = x;
            }
            else if (c is Species)
            {
                Species x = (s as Species).clone(); c = x;
            }
            else if (c is SpeciesReference)
            {
                SpeciesReference x = (s as SpeciesReference).clone(); c = x;
            }
            else if (c is SpeciesType)
            {
                SpeciesType x = (s as SpeciesType).clone(); c = x;
            }
            else if (c is SpeciesReference)
            {
                SpeciesReference x = (s as SpeciesReference).clone(); c = x;
            }
            else if (c is StoichiometryMath)
            {
                StoichiometryMath x = (s as StoichiometryMath).clone(); c = x;
            }
            else if (c is Trigger)
            {
                Trigger x = (s as Trigger).clone(); c = x;
            }
            else if (c is Unit)
            {
                Unit x = (s as Unit).clone(); c = x;
            }
            else if (c is UnitDefinition)
            {
                UnitDefinition x = (s as UnitDefinition).clone(); c = x;
            }
            else if (c is ListOfCompartmentTypes)
            {
                ListOfCompartmentTypes x = (s as ListOfCompartmentTypes).clone(); c = x;
            }
            else if (c is ListOfCompartments)
            {
                ListOfCompartments x = (s as ListOfCompartments).clone(); c = x;
            }
            else if (c is ListOfConstraints)
            {
                ListOfConstraints x = (s as ListOfConstraints).clone(); c = x;
            }
            else if (c is ListOfEventAssignments)
            {
                ListOfEventAssignments x = (s as ListOfEventAssignments).clone(); c = x;
            }
            else if (c is ListOfEvents)
            {
                ListOfEvents x = (s as ListOfEvents).clone(); c = x;
            }
            else if (c is ListOfFunctionDefinitions)
            {
                ListOfFunctionDefinitions x = (s as ListOfFunctionDefinitions).clone(); c = x;
            }
            else if (c is ListOfInitialAssignments)
            {
                ListOfInitialAssignments x = (s as ListOfInitialAssignments).clone(); c = x;
            }
            else if (c is ListOfParameters)
            {
                ListOfParameters x = (s as ListOfParameters).clone(); c = x;
            }
            else if (c is ListOfReactions)
            {
                ListOfReactions x = (s as ListOfReactions).clone(); c = x;
            }
            else if (c is ListOfRules)
            {
                ListOfRules x = (s as ListOfRules).clone(); c = x;
            }
            else if (c is ListOfSpecies)
            {
                ListOfSpecies x = (s as ListOfSpecies).clone(); c = x;
            }
            else if (c is ListOfSpeciesReferences)
            {
                ListOfSpeciesReferences x = (s as ListOfSpeciesReferences).clone(); c = x;
            }
            else if (c is ListOfSpeciesTypes)
            {
                ListOfSpeciesTypes x = (s as ListOfSpeciesTypes).clone(); c = x;
            }
            else if (c is ListOfUnitDefinitions)
            {
                ListOfUnitDefinitions x = (s as ListOfUnitDefinitions).clone(); c = x;
            }
            else if (c is ListOfUnits)
            {
                ListOfUnits x = (s as ListOfUnits).clone(); c = x;
            }
            else
            {
                ERR("[testClone] Error: (" + ename + ") : clone() failed.");
                return;
            }

            if (c == null)
            {
                ERR("[testClone] Error: (" + ename + ") : clone() failed.");
                return;
            }

            string enameClone = c.getElementName();

            if (ename == enameClone)
            {
                //Console.Out.WriteLine("[testClone] OK: (" + ename + ") clone(" + enameClone + ") : type match.");
                OK();
            }
            else
            {
                ERR("[testClone] Error: (" + ename + ") clone(" + enameClone + ") : type mismatch.");
            }
        }