상속: IDisposable
예제 #1
0
 public void TestAll()
 {
     SBMLReader reader = new SBMLReader();
     SBMLDocument document = reader.readSBML(TestConstant.SBML_BIOMD0000000003);
     Model sbmlModel = document.getModel();
     // Set FunctionDefinition
     ASTNode math = libsbml.libsbml.parseFormula("V0 * 5");
     FunctionDefinition fd = sbmlModel.createFunctionDefinition();
     fd.setId("FD");
     fd.setName("FD");
     fd.setMath(math);
     // Set Event
     Event ev = sbmlModel.createEvent();
     ev.setId("Event");
     ev.setName("Event");
     ev.setTrigger(new Trigger(2,3));
     EventAssignment ea = ev.createEventAssignment();
     ea.setId("Assignment");
     ea.setName("Assignment");
     // Set Initial Amount
     InitialAssignment ia = sbmlModel.createInitialAssignment();
     ia.setSymbol("M1");
     ia.setMath(math);
     // Set UnitDefinition
     UnitDefinition ud = sbmlModel.createUnitDefinition();
     ud.setId("UD");
     ud.setName("UD");
     Unit unit = ud.createUnit();
     unit.setId("Unit");
     unit.setName("Unit");
     //
     SBML_Model model = new SBML_Model(sbmlModel);
 }
예제 #2
0
 public void test_SBMLTransforms_replaceFD()
 {
     SBMLReader reader = new SBMLReader();
       SBMLDocument d;
       Model m;
       ASTNode ast;
       FunctionDefinition fd;
       ListOfFunctionDefinitions lofd;
       string filename =  "../../sbml/test/test-data/";
       filename += "multiple-functions.xml";
       d = reader.readSBML(filename);
       if (d == null);
       {
       }
       m = d.getModel();
       assertTrue( m.getNumFunctionDefinitions() == 2 );
       d.expandFunctionDefinitions();
       assertTrue( d.getModel().getNumFunctionDefinitions() == 0 );
       ast = d.getModel().getReaction(0).getKineticLaw().getMath();
       assertTrue((  "S1 * p * compartmentOne / t" == libsbml.formulaToString(ast) ));
       ast = d.getModel().getReaction(1).getKineticLaw().getMath();
       assertTrue((  "S1 * p * compartmentOne / t" == libsbml.formulaToString(ast) ));
       ast = d.getModel().getReaction(2).getKineticLaw().getMath();
       assertTrue((  "S1 * p * compartmentOne / t" == libsbml.formulaToString(ast) ));
 }
예제 #3
0
        internal static HandleRef getCPtrAndDisown(SBMLReader obj)
        {
            HandleRef ptr = new HandleRef(null, IntPtr.Zero);

            if (obj != null)
            {
                ptr             = obj.swigCPtr;
                obj.swigCMemOwn = false;
            }

            return(ptr);
        }
예제 #4
0
 public void test_read_l2v4_new()
 {
     SBMLReader reader = new SBMLReader();
       SBMLDocument d;
       Model m;
       Compartment c;
       Event e;
       Trigger trigger;
       EventAssignment ea;
       ASTNode ast;
       string filename =  "../../sbml/test/test-data/";
       filename += "l2v4-new.xml";
       d = reader.readSBML(filename);
       if (d == null);
       {
       }
       assertTrue( d.getLevel() == 2 );
       assertTrue( d.getVersion() == 4 );
       m = d.getModel();
       assertTrue( m != null );
       assertTrue( m.getId() ==  "l2v4_all" );
       assertTrue( m.getNumCompartments() == 1 );
       c = m.getCompartment(0);
       assertTrue( c != null );
       assertTrue( c.getId() ==  "a" );
       assertTrue( c.getSize() == 1 );
       assertEquals( false, c.getConstant() );
       assertTrue( m.getNumEvents() == 1 );
       e = m.getEvent(0);
       assertTrue( e != null );
       assertEquals( true, e.getUseValuesFromTriggerTime() );
       assertEquals( true, e.isSetTrigger() );
       trigger = e.getTrigger();
       assertTrue( trigger != null );
       ast = trigger.getMath();
       assertTrue((  "lt(x, 3)" == libsbml.formulaToString(ast) ));
       assertTrue( e.getNumEventAssignments() == 1 );
       ea = e.getEventAssignment(0);
       assertTrue( ea != null );
       assertTrue( ea.getVariable() ==  "a" );
       ast = ea.getMath();
       assertTrue((  "x * p3" == libsbml.formulaToString(ast) ));
       d = null;
 }
예제 #5
0
 public void test_consistency_checks()
 {
     SBMLReader reader = new SBMLReader();
       SBMLDocument d;
       long errors;
       string filename =  "../../sbml/test/test-data/";
       filename += "inconsistent.xml";
       d = reader.readSBML(filename);
       if (d == null);
       {
       }
       errors = d.checkConsistency();
       assertTrue( errors == 1 );
       assertTrue( d.getError(0).getErrorId() == 10301 );
       d.getErrorLog().clearLog();
       d.setConsistencyChecks(libsbml.LIBSBML_CAT_IDENTIFIER_CONSISTENCY,false);
       errors = d.checkConsistency();
       assertTrue( errors == 1 );
       assertTrue( d.getError(0).getErrorId() == 20612 );
       d.getErrorLog().clearLog();
       d.setConsistencyChecks(libsbml.LIBSBML_CAT_GENERAL_CONSISTENCY,false);
       errors = d.checkConsistency();
       assertTrue( errors == 1 );
       assertTrue( d.getError(0).getErrorId() == 10701 );
       d.getErrorLog().clearLog();
       d.setConsistencyChecks(libsbml.LIBSBML_CAT_SBO_CONSISTENCY,false);
       errors = d.checkConsistency();
       assertTrue( errors == 1 );
       assertTrue( d.getError(0).getErrorId() == 10214 );
       d.getErrorLog().clearLog();
       d.setConsistencyChecks(libsbml.LIBSBML_CAT_MATHML_CONSISTENCY,false);
       errors = d.checkConsistency();
       assertTrue( errors == 3 );
       assertTrue( d.getError(0).getErrorId() == 99505 );
       assertTrue( d.getError(1).getErrorId() == 99505 );
       assertTrue( d.getError(2).getErrorId() == 80701 );
       d.getErrorLog().clearLog();
       d.setConsistencyChecks(libsbml.LIBSBML_CAT_UNITS_CONSISTENCY,false);
       errors = d.checkConsistency();
       assertTrue( errors == 0 );
       d = null;
 }
예제 #6
0
 public void test_SBMLTransforms_replaceIA()
 {
     SBMLReader reader = new SBMLReader();
       SBMLDocument d;
       Model m;
       ASTNode ast;
       FunctionDefinition fd;
       ListOfFunctionDefinitions lofd;
       string filename =  "../../sbml/test/test-data/";
       filename += "initialAssignments.xml";
       d = reader.readSBML(filename);
       if (d == null);
       {
       }
       m = d.getModel();
       assertTrue( m.getNumInitialAssignments() == 2 );
       assertEquals( false, (m.getCompartment(0).isSetSize()) );
       assertTrue( m.getParameter(1).getValue() == 2 );
       d.expandInitialAssignments();
       assertTrue( d.getModel().getNumInitialAssignments() == 0 );
       assertEquals( true, d.getModel().getCompartment(0).isSetSize() );
       assertTrue( d.getModel().getCompartment(0).getSize() == 25.0 );
       assertTrue( m.getParameter(1).getValue() == 50 );
 }
예제 #7
0
        public void TestSBML_Parameter()
        {
            SBMLReader reader = new SBMLReader();
            SBMLDocument document = reader.readSBML(TestConstant.SBML_Oscillation);

            SBML_Model model = new SBML_Model(document.getModel());
            SBML_Parameter p = new SBML_Parameter(model);

            ParameterStruct ps = new ParameterStruct();

            // getParameterID
            ps.ID = "Test1";
            string id = p.getParameterID(ps);
            Assert.AreEqual("/SBMLParameter:Test1", id, "getParameterID returns unexpected value.");
            try
            {
                ps.ID = "";
                id = p.getParameterID(ps);
            }
            catch (Exception)
            {
            }
            model.Level = 1;
            ps.Name = "Test2";
            id = p.getParameterID(ps);
            Assert.AreEqual("/SBMLParameter:Test2", id, "getParameterID returns unexpected value.");
            try
            {
                ps.Name = "";
                id = p.getParameterID(ps);
            }
            catch (Exception)
            {
            }
            try
            {
                model.Level = 0;
                id = p.getParameterID(ps);
            }
            catch (Exception)
            {
            }
        }
예제 #8
0
 internal static HandleRef getCPtr(SBMLReader obj)
 {
     return((obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr);
 }
예제 #9
0
 public void test_read_l3v1_new()
 {
     SBMLReader reader = new SBMLReader();
       SBMLDocument d;
       Model m;
       UnitDefinition ud;
       Unit u;
       Compartment c;
       Species s;
       Parameter p;
       Reaction r;
       SpeciesReference sr;
       KineticLaw kl;
       LocalParameter lp;
       string filename =  "../../sbml/test/test-data/";
       filename += "l3v1-new.xml";
       d = reader.readSBML(filename);
       if (d == null);
       {
       }
       assertTrue( d.getLevel() == 3 );
       assertTrue( d.getVersion() == 1 );
       m = d.getModel();
       assertTrue( m != null );
       assertEquals( true, m.isSetSubstanceUnits() );
       assertEquals( true, m.isSetTimeUnits() );
       assertEquals( true, m.isSetVolumeUnits() );
       assertEquals( true, m.isSetLengthUnits() );
       assertEquals( true, m.isSetAreaUnits() );
       assertEquals( true, m.isSetExtentUnits() );
       assertEquals( true, m.isSetConversionFactor() );
       assertTrue( m.getSubstanceUnits() ==  "mole" );
       assertTrue( m.getTimeUnits() ==  "second" );
       assertTrue( m.getVolumeUnits() ==  "litre" );
       assertTrue( m.getLengthUnits() ==  "metre" );
       assertTrue( m.getAreaUnits() ==  "metre" );
       assertTrue( m.getExtentUnits() ==  "mole" );
       assertTrue( m.getConversionFactor() ==  "p" );
       assertTrue( m.getNumUnitDefinitions() == 2 );
       ud = m.getUnitDefinition(0);
       assertTrue( ud.getNumUnits() == 1 );
       u = ud.getUnit(0);
       assertEquals( false, u.isSetExponent() );
       assertEquals( false, u.isSetScale() );
       assertEquals( false, u.isSetMultiplier() );
       assertEquals( true, isnan(u.getExponentAsDouble()) );
       assertTrue( u.getScale() == SBML_INT_MAX );
       assertEquals( true, isnan(u.getMultiplier()) );
       ud = m.getUnitDefinition(1);
       assertTrue( ud.getNumUnits() == 3 );
       u = ud.getUnit(0);
       assertEquals( true, u.isSetExponent() );
       assertEquals( true, u.isSetScale() );
       assertEquals( true, u.isSetMultiplier() );
       assertTrue( u.getExponent() == -1 );
       assertTrue( u.getExponentAsDouble() == -1 );
       assertTrue( u.getScale() == 2 );
       assertTrue( u.getMultiplier() == 1.3 );
       u = ud.getUnit(1);
       assertEquals( true, u.isSetExponent() );
       assertEquals( true, u.isSetScale() );
       assertEquals( true, u.isSetMultiplier() );
       assertTrue( u.getExponentAsDouble() == 1.5 );
       assertTrue( u.getScale() == 10 );
       assertTrue( u.getMultiplier() == 0.5 );
       u = ud.getUnit(2);
       assertEquals( true, u.isSetExponent() );
       assertEquals( true, u.isSetScale() );
       assertEquals( true, u.isSetMultiplier() );
       assertTrue( u.getExponent() == 1 );
       assertTrue( u.getScale() == 0 );
       assertTrue( u.getMultiplier() == 1 );
       assertTrue( m.getNumCompartments() == 3 );
       c = m.getCompartment(0);
       assertEquals( true, c.isSetSize() );
       assertEquals( true, c.isSetSpatialDimensions() );
       assertEquals( true, c.isSetConstant() );
       assertTrue( c.getId() ==  "comp" );
       assertTrue( c.getSize() == 1e-14 );
       assertTrue( c.getSpatialDimensions() == 3 );
       assertTrue( c.getSpatialDimensionsAsDouble() == 3 );
       assertTrue( c.getUnits() ==  "litre" );
       assertTrue( c.getConstant() == true );
       c = m.getCompartment(1);
       assertEquals( false, c.isSetSize() );
       assertEquals( false, c.isSetSpatialDimensions() );
       assertEquals( true, c.isSetConstant() );
       assertTrue( c.getId() ==  "comp1" );
       assertEquals( true, isnan(c.getSize()) );
       assertEquals( true, isnan(c.getSpatialDimensionsAsDouble()) );
       assertTrue( c.getConstant() == false );
       c = m.getCompartment(2);
       assertEquals( false, c.isSetSize() );
       assertEquals( true, c.isSetSpatialDimensions() );
       assertEquals( false, c.isSetConstant() );
       assertTrue( c.getId() ==  "comp2" );
       assertTrue( c.getSpatialDimensionsAsDouble() == 4.6 );
       assertTrue( m.getNumSpecies() == 2 );
       s = m.getSpecies(0);
       assertTrue( s.getId() ==  "ES" );
       assertTrue( s.getCompartment() ==  "comp" );
       assertEquals( true, s.isSetConversionFactor() );
       assertTrue( s.getConversionFactor() ==  "p" );
       assertEquals( true, s.isSetBoundaryCondition() );
       assertTrue( s.getBoundaryCondition() == false );
       assertEquals( true, s.isSetHasOnlySubstanceUnits() );
       assertTrue( s.getHasOnlySubstanceUnits() == false );
       assertEquals( true, s.isSetSubstanceUnits() );
       assertTrue( s.getSubstanceUnits() ==  "mole" );
       assertEquals( true, s.isSetConstant() );
       assertTrue( s.getConstant() == false );
       assertEquals( true, s.isSetInitialAmount() );
       assertTrue( s.getInitialAmount() == 0 );
       assertEquals( false, s.isSetInitialConcentration() );
       assertEquals( true, isnan(s.getInitialConcentration()) );
       s = m.getSpecies(1);
       assertTrue( s.getId() ==  "P" );
       assertTrue( s.getCompartment() ==  "comp" );
       assertEquals( false, s.isSetConversionFactor() );
       assertTrue( s.getConversionFactor() ==  "" );
       assertEquals( false, s.isSetBoundaryCondition() );
       assertEquals( false, s.isSetHasOnlySubstanceUnits() );
       assertEquals( false, s.isSetSubstanceUnits() );
       assertTrue( s.getSubstanceUnits() ==  "" );
       assertEquals( false, s.isSetConstant() );
       assertEquals( false, s.isSetInitialAmount() );
       assertEquals( true, isnan(s.getInitialAmount()) );
       assertEquals( false, s.isSetInitialConcentration() );
       assertEquals( true, isnan(s.getInitialConcentration()) );
       assertTrue( m.getNumParameters() == 3 );
       p = m.getParameter(0);
       assertTrue( p.getId() ==  "Keq" );
       assertEquals( true, p.isSetValue() );
       assertTrue( p.getValue() == 2.5 );
       assertEquals( true, p.isSetUnits() );
       assertTrue( p.getUnits() ==  "dimensionless" );
       assertEquals( true, p.isSetConstant() );
       assertTrue( p.getConstant() == true );
       p = m.getParameter(1);
       assertTrue( p.getId() ==  "Keq1" );
       assertEquals( false, p.isSetValue() );
       assertEquals( true, isnan(p.getValue()) );
       assertEquals( false, p.isSetUnits() );
       assertTrue( p.getUnits() ==  "" );
       assertEquals( true, p.isSetConstant() );
       assertTrue( p.getConstant() == false );
       p = m.getParameter(2);
       assertTrue( p.getId() ==  "Keq2" );
       assertEquals( false, p.isSetValue() );
       assertEquals( true, isnan(p.getValue()) );
       assertEquals( false, p.isSetUnits() );
       assertTrue( p.getUnits() ==  "" );
       assertEquals( false, p.isSetConstant() );
       assertTrue( m.getNumReactions() == 3 );
       r = m.getReaction(0);
       assertEquals( true, r.isSetFast() );
       assertTrue( r.getFast() == false );
       assertEquals( true, r.isSetReversible() );
       assertTrue( r.getReversible() == false );
       assertEquals( true, r.isSetCompartment() );
       assertTrue( r.getCompartment() ==  "comp" );
       sr = r.getReactant(0);
       assertEquals( true, sr.isSetConstant() );
       assertTrue( sr.getConstant() == true );
       assertEquals( true, sr.isSetStoichiometry() );
       assertTrue( sr.getStoichiometry() == 1 );
       sr = r.getProduct(0);
       assertEquals( true, sr.isSetConstant() );
       assertTrue( sr.getConstant() == false );
       assertEquals( false, sr.isSetStoichiometry() );
       assertEquals( true, isnan(sr.getStoichiometry()) );
       kl = r.getKineticLaw();
       assertTrue( kl.getNumLocalParameters() == 2 );
       assertTrue( kl.getNumParameters() == 2 );
       p = kl.getParameter(0);
       assertEquals( true, p.isSetUnits() );
       assertTrue( p.getUnits() ==  "per_second" );
       assertEquals( true, p.isSetValue() );
       assertTrue( p.getValue() == 0.1 );
       lp = kl.getLocalParameter(0);
       assertEquals( true, lp.isSetUnits() );
       assertTrue( lp.getUnits() ==  "per_second" );
       assertEquals( true, lp.isSetValue() );
       assertTrue( lp.getValue() == 0.1 );
       lp = kl.getLocalParameter(1);
       assertEquals( false, lp.isSetUnits() );
       assertTrue( lp.getUnits() ==  "" );
       assertEquals( false, lp.isSetValue() );
       assertEquals( true, isnan(lp.getValue()) );
       r = m.getReaction(1);
       assertEquals( true, r.isSetFast() );
       assertTrue( r.getFast() == true );
       assertEquals( true, r.isSetReversible() );
       assertTrue( r.getReversible() == true );
       assertEquals( false, r.isSetCompartment() );
       assertTrue( r.getCompartment() ==  "" );
       sr = r.getReactant(0);
       assertEquals( false, sr.isSetConstant() );
       r = m.getReaction(2);
       assertEquals( false, r.isSetFast() );
       assertEquals( false, r.isSetReversible() );
       assertEquals( false, r.isSetCompartment() );
       assertTrue( r.getCompartment() ==  "" );
       d = null;
 }
예제 #10
0
 public void test_read_l2v3_all()
 {
     SBMLReader reader = new SBMLReader();
       SBMLDocument d;
       Model m;
       Compartment c;
       CompartmentType ct;
       Species s;
       Parameter p;
       AssignmentRule ar;
       Reaction r;
       SpeciesReference sr;
       KineticLaw kl;
       UnitDefinition ud;
       Constraint con;
       Event e;
       Delay delay;
       Trigger trigger;
       EventAssignment ea;
       FunctionDefinition fd;
       InitialAssignment ia;
       AlgebraicRule alg;
       RateRule rr;
       SpeciesType st;
       StoichiometryMath stoich;
       Unit u;
       ListOfEvents loe;
       Event e1;
       ListOfEventAssignments loea;
       EventAssignment ea1;
       ListOfFunctionDefinitions lofd;
       FunctionDefinition fd1;
       ListOfParameters lop;
       Parameter p1;
       ListOfSpeciesTypes lost;
       SpeciesType st1;
       ListOfUnitDefinitions loud;
       UnitDefinition ud1;
       ListOfUnits lou;
       Unit u1;
       ASTNode ast;
       string filename =  "../../sbml/test/test-data/";
       filename += "l2v3-all.xml";
       d = reader.readSBML(filename);
       if (d == null);
       {
       }
       assertTrue( d.getLevel() == 2 );
       assertTrue( d.getVersion() == 3 );
       m = d.getModel();
       assertTrue( m != null );
       assertTrue( m.getId() ==  "l2v3_all" );
       assertTrue( m.getNumCompartments() == 1 );
       c = m.getCompartment(0);
       assertTrue( c != null );
       assertTrue( c.getId() ==  "a" );
       assertEquals(c.getCompartmentType(), "hh");
       assertTrue( c.getSBOTerm() == 236 );
       assertTrue( c.getSBOTermID() ==  "SBO:0000236" );
       assertTrue( c.getSize() == 2.3 );
       assertTrue( m.getNumCompartmentTypes() == 1 );
       ct = m.getCompartmentType(0);
       assertTrue( ct != null );
       assertTrue( ct.getId() ==  "hh" );
       assertTrue( ct.getSBOTerm() == 236 );
       assertTrue( ct.getSBOTermID() ==  "SBO:0000236" );
       assertTrue( m.getNumSpeciesTypes() == 1 );
       st = m.getSpeciesType(0);
       assertTrue( st != null );
       assertTrue( st.getId() ==  "gg" );
       assertTrue( st.getName() ==  "dd" );
       assertTrue( st.getSBOTerm() == 236 );
       assertTrue( st.getSBOTermID() ==  "SBO:0000236" );
       lost = m.getListOfSpeciesTypes();
       st1 = lost.get(0);
       assertTrue( st1 == st );
       st1 = lost.get("gg");
       assertTrue( st1 == st );
       assertTrue( m.getNumConstraints() == 1 );
       con = m.getConstraint(0);
       assertTrue( con != null );
       ast = con.getMath();
       assertTrue((  "lt(x, 3)" == libsbml.formulaToString(ast) ));
       assertTrue( m.getNumEvents() == 1 );
       e = m.getEvent(0);
       assertTrue( e != null );
       assertTrue( e.getId() ==  "e1" );
       assertTrue( e.getSBOTerm() == 231 );
       assertTrue( e.getSBOTermID() ==  "SBO:0000231" );
       assertEquals( true, e.isSetDelay() );
       delay = e.getDelay();
       assertTrue( delay != null );
       assertTrue( delay.getSBOTerm() == 64 );
       assertTrue( delay.getSBOTermID() ==  "SBO:0000064" );
       ast = delay.getMath();
       assertTrue((  "p + 3" == libsbml.formulaToString(ast) ));
       assertEquals( true, e.isSetTrigger() );
       trigger = e.getTrigger();
       assertTrue( trigger != null );
       assertTrue( trigger.getSBOTerm() == 64 );
       assertTrue( trigger.getSBOTermID() ==  "SBO:0000064" );
       ast = trigger.getMath();
       assertTrue((  "lt(x, 3)" == libsbml.formulaToString(ast) ));
       loe = m.getListOfEvents();
       e1 = loe.get(0);
       assertTrue( e1 == e );
       e1 = loe.get("e1");
       assertTrue( e1 == e );
       assertTrue( e.getNumEventAssignments() == 1 );
       ea = e.getEventAssignment(0);
       assertTrue( ea != null );
       assertTrue( ea.getVariable() ==  "a" );
       assertTrue( ea.getSBOTerm() == 64 );
       assertTrue( ea.getSBOTermID() ==  "SBO:0000064" );
       ast = ea.getMath();
       assertTrue((  "x * p3" == libsbml.formulaToString(ast) ));
       loea = e.getListOfEventAssignments();
       ea1 = loea.get(0);
       assertTrue( ea1 == ea );
       ea1 = loea.get("a");
       assertTrue( ea1 == ea );
       assertTrue( m.getNumFunctionDefinitions() == 1 );
       fd = m.getFunctionDefinition(0);
       assertTrue( fd != null );
       assertTrue( fd.getId() ==  "fd" );
       assertTrue( fd.getSBOTerm() == 64 );
       assertTrue( fd.getSBOTermID() ==  "SBO:0000064" );
       ast = fd.getMath();
       assertTrue((  "lambda(x, pow(x, 3))" == libsbml.formulaToString(ast) ));
       lofd = m.getListOfFunctionDefinitions();
       fd1 = lofd.get(0);
       assertTrue( fd1 == fd );
       fd1 = lofd.get("fd");
       assertTrue( fd1 == fd );
       assertTrue( m.getNumInitialAssignments() == 1 );
       ia = m.getInitialAssignment(0);
       assertTrue( ia != null );
       assertTrue( ia.getSymbol() ==  "p1" );
       ast = ia.getMath();
       assertTrue((  "x * p3" == libsbml.formulaToString(ast) ));
       assertTrue( m.getNumRules() == 3 );
       alg = (AlgebraicRule)  m.getRule(0);
       assertTrue( alg != null );
       assertTrue( alg.getSBOTerm() == 64 );
       assertTrue( alg.getSBOTermID() ==  "SBO:0000064" );
       ast = alg.getMath();
       assertTrue((  "pow(x, 3)" == libsbml.formulaToString(ast) ));
       ar = (AssignmentRule) m.getRule(1);
       assertTrue( ar != null );
       assertTrue( ar.getVariable() ==  "p2" );
       assertTrue( ar.getSBOTerm() == 64 );
       assertTrue( ar.getSBOTermID() ==  "SBO:0000064" );
       ast = ar.getMath();
       assertTrue((  "x * p3" == libsbml.formulaToString(ast) ));
       rr = (RateRule) m.getRule(2);
       assertTrue( rr != null );
       assertTrue( rr.getVariable() ==  "p3" );
       assertTrue( rr.getSBOTerm() == 64 );
       assertTrue( rr.getSBOTermID() ==  "SBO:0000064" );
       ast = rr.getMath();
       assertTrue((  "p1 / p" == libsbml.formulaToString(ast) ));
       assertTrue( m.getNumSpecies() == 1 );
       s = m.getSpecies(0);
       assertTrue( s != null );
       assertTrue( s.getId() ==  "s" );
       assertEquals(s.getSpeciesType(), "gg");
       assertTrue( s.getCompartment() ==  "a" );
       assertTrue( s.getSBOTerm() == 236 );
       assertTrue( s.getSBOTermID() ==  "SBO:0000236" );
       assertEquals( true, s.isSetInitialAmount() );
       assertEquals( false, s.isSetInitialConcentration() );
       assertTrue( s.getInitialAmount() == 0 );
       assertTrue( m.getNumReactions() == 1 );
       r = m.getReaction(0);
       assertTrue( r != null );
       assertTrue( r.getId() ==  "r" );
       assertEquals( false, r.getReversible() );
       assertEquals( true, r.getFast() );
       assertEquals( true, r.isSetKineticLaw() );
       kl = r.getKineticLaw();
       assertTrue( kl != null );
       assertEquals( true, kl.isSetMath() );
       ast = kl.getMath();
       assertTrue((  "s * k / p" == libsbml.formulaToString(ast) ));
       assertTrue( kl.getNumParameters() == 2 );
       p = kl.getParameter(0);
       assertTrue( p != null );
       assertTrue( p.getId() ==  "k" );
       assertTrue( p.getUnits() ==  "litre" );
       assertTrue( p.getValue() == 9 );
       ud = p.getDerivedUnitDefinition();
       assertTrue( ud.getNumUnits() == 1 );
       assertTrue( ud.getUnit(0).getKind() == libsbml.UNIT_KIND_LITRE );
       assertTrue( ud.getUnit(0).getExponent() == 1 );
       lop = kl.getListOfParameters();
       p1 = lop.get(0);
       assertTrue( p1 == p );
       p1 = lop.get("k");
       assertTrue( p1 == p );
       p = kl.getParameter(1);
       assertTrue( p != null );
       assertTrue( p.getId() ==  "k1" );
       assertTrue( p.getUnits() ==  "ud1" );
       assertTrue( p.getValue() == 9 );
       ud = p.getDerivedUnitDefinition();
       assertTrue( ud.getNumUnits() == 1 );
       assertTrue( ud.getUnit(0).getKind() == libsbml.UNIT_KIND_MOLE );
       assertTrue( ud.getUnit(0).getExponent() == 1 );
       assertTrue( r.getNumReactants() == 1 );
       assertTrue( r.getNumProducts() == 0 );
       assertTrue( r.getNumModifiers() == 0 );
       sr = r.getReactant(0);
       assertTrue( sr != null );
       assertTrue( sr.getSpecies() ==  "s" );
       assertTrue( sr.getSBOTerm() == 11 );
       assertTrue( sr.getSBOTermID() ==  "SBO:0000011" );
       stoich = sr.getStoichiometryMath();
       assertTrue( stoich != null );
       assertTrue( stoich.getSBOTerm() == 64 );
       assertTrue( stoich.getSBOTermID() ==  "SBO:0000064" );
       ast = stoich.getMath();
       assertTrue((  "s * p" == libsbml.formulaToString(ast) ));
       assertTrue( m.getNumUnitDefinitions() == 1 );
       ud = m.getUnitDefinition(0);
       assertTrue( ud != null );
       assertTrue( ud.getId() ==  "ud1" );
       loud = m.getListOfUnitDefinitions();
       ud1 = loud.get(0);
       assertTrue( ud1 == ud );
       ud1 = loud.get("ud1");
       assertTrue( ud1 == ud );
       assertTrue( ud.getNumUnits() == 1 );
       u = ud.getUnit(0);
       assertTrue( u != null );
       assertTrue( u.getKind() == libsbml.UNIT_KIND_MOLE );
       lou = ud.getListOfUnits();
       u1 = lou.get(0);
       assertTrue( u1 == u );
       d = null;
 }
예제 #11
0
 public void test_read_MathML_2()
 {
     SBMLReader reader = new SBMLReader();
       SBMLDocument d;
       Model m;
       FunctionDefinition fd;
       InitialAssignment ia;
       Rule r;
       string filename =  "../../math/test/test-data/";
       filename += "mathML_2.xml";
       d = reader.readSBML(filename);
       if (d == null);
       {
       }
       m = d.getModel();
       assertTrue( m != null );
       assertTrue( m.getNumFunctionDefinitions() == 2 );
       assertTrue( m.getNumInitialAssignments() == 1 );
       assertTrue( m.getNumRules() == 2 );
       fd = m.getFunctionDefinition(0);
       ASTNode fd_math = fd.getMath();
       assertTrue( fd_math.getType() == libsbml.AST_LAMBDA );
       assertTrue( fd_math.getNumChildren() == 1 );
       assertTrue((  "lambda()" == libsbml.formulaToString(fd_math) ));
       ASTNode child = fd_math.getChild(0);
       assertTrue( child.getType() == libsbml.AST_UNKNOWN );
       assertTrue( child.getNumChildren() == 0 );
       assertTrue((  "" == libsbml.formulaToString(child) ));
       fd = m.getFunctionDefinition(1);
       ASTNode fd1_math = fd.getMath();
       assertTrue( fd1_math.getType() == libsbml.AST_LAMBDA );
       assertTrue( fd1_math.getNumChildren() == 2 );
       assertTrue((                            "lambda(x, piecewise(p, leq(x, 4)))" == libsbml.formulaToString(fd1_math) ));
       ASTNode child1 = fd1_math.getRightChild();
       assertTrue( child1.getType() == libsbml.AST_FUNCTION_PIECEWISE );
       assertTrue( child1.getNumChildren() == 2 );
       assertTrue((                                      "piecewise(p, leq(x, 4))" == libsbml.formulaToString(child1) ));
       ASTNode c1 = child1.getChild(0);
       assertTrue( c1.getType() == libsbml.AST_NAME );
       assertTrue( c1.getNumChildren() == 0 );
       assertTrue((  "p" == libsbml.formulaToString(c1) ));
       ASTNode c2 = child1.getChild(1);
       assertTrue( c2.getType() == libsbml.AST_RELATIONAL_LEQ );
       assertTrue( c2.getNumChildren() == 2 );
       assertTrue((  "leq(x, 4)" == libsbml.formulaToString(c2) ));
       ia = m.getInitialAssignment(0);
       ASTNode ia_math = ia.getMath();
       assertTrue( ia_math.getType() == libsbml.AST_FUNCTION_PIECEWISE );
       assertTrue( ia_math.getNumChildren() == 4 );
       assertTrue((                      "piecewise(-x, lt(x, 0), 0, eq(x, 0))" == libsbml.formulaToString(ia_math) ));
       child1 = ia_math.getChild(0);
       ASTNode child2 = ia_math.getChild(1);
       ASTNode child3 = ia_math.getChild(2);
       ASTNode child4 = ia_math.getChild(3);
       assertTrue( child1.getType() == libsbml.AST_MINUS );
       assertTrue( child1.getNumChildren() == 1 );
       assertTrue((  "-x" == libsbml.formulaToString(child1) ));
       assertTrue( child2.getType() == libsbml.AST_RELATIONAL_LT );
       assertTrue( child2.getNumChildren() == 2 );
       assertTrue((  "lt(x, 0)" == libsbml.formulaToString(child2) ));
       assertTrue( child3.getType() == libsbml.AST_REAL );
       assertTrue( child3.getNumChildren() == 0 );
       assertTrue((  "0" == libsbml.formulaToString(child3) ));
       assertTrue( child4.getType() == libsbml.AST_RELATIONAL_EQ );
       assertTrue( child4.getNumChildren() == 2 );
       assertTrue((  "eq(x, 0)" == libsbml.formulaToString(child4) ));
       r = m.getRule(0);
       ASTNode r_math = r.getMath();
       assertTrue( r_math.getType() == libsbml.AST_CONSTANT_TRUE );
       assertTrue( r_math.getNumChildren() == 0 );
       assertTrue((  "true" == libsbml.formulaToString(r_math) ));
       r = m.getRule(1);
       ASTNode r1_math = r.getMath();
       assertTrue( r1_math.getType() == libsbml.AST_FUNCTION_LOG );
       assertTrue( r1_math.getNumChildren() == 2 );
       assertTrue((  "log(3, x)" == libsbml.formulaToString(r1_math) ));
       child1 = r1_math.getChild(0);
       child2 = r1_math.getChild(1);
       assertTrue( child1.getType() == libsbml.AST_REAL );
       assertTrue( child1.getNumChildren() == 0 );
       assertTrue((  "3" == libsbml.formulaToString(child1) ));
       assertTrue( child2.getType() == libsbml.AST_NAME );
       assertTrue( child2.getNumChildren() == 0 );
       assertTrue((  "x" == libsbml.formulaToString(child2) ));
       d = null;
 }
예제 #12
0
        public void TestSBML_Species()
        {
            SBMLReader reader = new SBMLReader();
            SBMLDocument document = reader.readSBML(TestConstant.SBML_Oscillation);

            SBML_Model model = new SBML_Model(document.getModel());
            SBML_Compartment sc = new SBML_Compartment(model);
            SBML_Species species = new SBML_Species(model);

            // getConstant
            SpeciesStruct ss = new SpeciesStruct();
            int i = species.getConstant(ss);
            Assert.AreEqual(0, i, "getConstant returns unexpected value.");

            ss.Constant = true;
            i = species.getConstant(ss);
            Assert.AreEqual(1, i, "getConstant returns unexpected value.");

            model.Level = 1;
            i = species.getConstant(ss);
            Assert.AreEqual(0, i, "getConstant returns unexpected value.");

            ss.BoundaryCondition = true;
            i = species.getConstant(ss);
            Assert.AreEqual(1, i, "getConstant returns unexpected value.");

            try
            {
                model.Level = 0;
                i = species.getConstant(ss);
            }
            catch (Exception)
            {
            }

            // getSpeciesValue
            double d = species.getSpeciesValue(ss);
            Assert.AreEqual(0.0, d, "getSpeciesValue returns unexpected value.");

            model.Level = 2;
            ss.InitialAmount = double.NaN;
            ss.Compartment = "cell";
            d = species.getSpeciesValue(ss);
            Assert.AreEqual(0.0, d, "getSpeciesValue returns unexpected value.");

            try
            {
                ss.InitialConcentration = double.NaN;
                d = species.getSpeciesValue(ss);
            }
            catch (Exception)
            {
            }

            // getSpeciesID
            ss.ID = "Test1";
            string id = species.getSpeciesID(ss);
            Assert.AreEqual("/cell:Test1", id, "getSpeciesID returns unexpected value.");

            try
            {
                model.Level = 1;
                ss.Name = "Test2";
                id = species.getSpeciesID(ss);
            }
            catch (Exception)
            {
            }

            try
            {
                model.Level = 0;
                id = species.getSpeciesID(ss);
            }
            catch (Exception)
            {
            }

            try
            {
                model.Level = 2;
                ss.Compartment = "";
                id = species.getSpeciesID(ss);
            }
            catch (Exception)
            {
            }
        }
예제 #13
0
 public void test_read_l2v1_assignment()
 {
     SBMLReader reader = new SBMLReader();
       SBMLDocument d;
       Model m;
       Compartment c;
       Species s;
       Parameter p;
       AssignmentRule ar;
       Reaction r;
       SpeciesReference sr;
       KineticLaw kl;
       UnitDefinition ud;
       Reaction r1;
       ListOfCompartments loc;
       Compartment c1;
       ListOfRules lor;
       AssignmentRule ar1;
       ListOfParameters lop;
       Parameter p1;
       ListOfSpecies los;
       Species s1;
       string filename =  "../../sbml/test/test-data/";
       filename += "l2v1-assignment.xml";
       d = reader.readSBML(filename);
       if (d == null);
       {
       }
       assertTrue( d.getLevel() == 2 );
       assertTrue( d.getVersion() == 1 );
       m = d.getModel();
       assertTrue( m != null );
       assertTrue( m.getNumCompartments() == 1 );
       c = m.getCompartment(0);
       assertTrue( c != null );
       assertTrue( c.getId() ==  "cell" );
       ud = c.getDerivedUnitDefinition();
       assertTrue( ud.getNumUnits() == 1 );
       assertTrue( ud.getUnit(0).getKind() == libsbml.UNIT_KIND_LITRE );
       loc = m.getListOfCompartments();
       c1 = loc.get(0);
       assertTrue( c1 == c );
       c1 = loc.get("cell");
       assertTrue( c1 == c );
       assertTrue( m.getNumSpecies() == 5 );
       s = m.getSpecies(0);
       assertTrue( s != null );
       assertTrue( s.getId() ==  "X0"   );
       assertTrue( s.getCompartment() ==  "cell" );
       assertTrue( s.getInitialConcentration() == 1.0 );
       los = m.getListOfSpecies();
       s1 = los.get(0);
       assertTrue( s1 == s );
       s1 = los.get("X0");
       assertTrue( s1 == s );
       s = m.getSpecies(1);
       assertTrue( s != null );
       assertTrue( s.getId() ==  "X1"   );
       assertTrue( s.getCompartment() ==  "cell" );
       assertTrue( s.getInitialConcentration() == 0.0 );
       s = m.getSpecies(2);
       assertTrue( s != null );
       assertTrue( s.getId() ==  "T"    );
       assertTrue( s.getCompartment() ==  "cell" );
       assertTrue( s.getInitialConcentration() == 0.0 );
       s = m.getSpecies(3);
       assertTrue( s != null );
       assertTrue( s.getId() ==  "S1"   );
       assertTrue( s.getCompartment() ==  "cell" );
       assertTrue( s.getInitialConcentration() == 0.0 );
       s = m.getSpecies(4);
       assertTrue( s != null );
       assertTrue( s.getId() ==  "S2"   );
       assertTrue( s.getCompartment() ==  "cell" );
       assertTrue( s.getInitialConcentration() == 0.0 );
       assertTrue( m.getNumParameters() == 1 );
       p = m.getParameter(0);
       assertTrue( p != null );
       assertTrue( p.getId() ==  "Keq" );
       assertTrue( p.getValue() == 2.5 );
       lop = m.getListOfParameters();
       p1 = lop.get(0);
       assertTrue( p1 == p );
       p1 = lop.get("Keq");
       assertTrue( p1 == p );
       ud = p.getDerivedUnitDefinition();
       assertTrue( ud.getNumUnits() == 0 );
       assertTrue( m.getNumRules() == 2 );
       ar = (AssignmentRule)  m.getRule(0);
       assertTrue( ar != null );
       assertTrue( ar.getVariable() ==  "S1"            );
       assertTrue( ar.getFormula() ==  "T / (1 + Keq)" );
       ud = ar.getDerivedUnitDefinition();
       assertTrue( ud.getNumUnits() == 2 );
       assertTrue( ud.getUnit(0).getKind() == libsbml.UNIT_KIND_MOLE );
       assertTrue( ud.getUnit(0).getExponent() == 1 );
       assertTrue( ud.getUnit(1).getKind() == libsbml.UNIT_KIND_LITRE );
       assertTrue( ud.getUnit(1).getExponent() == -1 );
       assertTrue( ar.containsUndeclaredUnits() == true );
       lor = m.getListOfRules();
       ar1 = (AssignmentRule) lor.get(0);
       assertTrue( ar1 == ar );
       ar1 = (AssignmentRule) lor.get("S1");
       assertTrue( ar1 == ar );
       ar = (AssignmentRule)  m.getRule(1);
       assertTrue( ar != null );
       assertTrue( ar.getVariable() ==  "S2"       );
       assertTrue( ar.getFormula() ==  "Keq * S1" );
       assertTrue( m.getNumReactions() == 2 );
       r = m.getReaction(0);
       assertTrue( r != null );
       assertTrue( r.getId() ==  "in" );
       assertTrue( r.getNumReactants() == 1 );
       assertTrue( r.getNumProducts() == 1 );
       sr = r.getReactant(0);
       assertTrue( sr != null );
       assertTrue( sr.getSpecies() ==  "X0" );
       sr = r.getProduct(0);
       assertTrue( sr != null );
       assertTrue( sr.getSpecies() ==  "T"  );
       kl = r.getKineticLaw();
       assertTrue( kl != null );
       assertTrue( kl.getFormula() ==  "k1 * X0" );
       assertTrue( kl.getNumParameters() == 1 );
       r1 = (Reaction) kl.getParentSBMLObject();
       assertTrue( r1 != null );
       assertTrue( r1.getId() ==  "in" );
       assertTrue( r1.getNumReactants() == 1 );
       assertTrue( r1.getNumProducts() == 1 );
       p = kl.getParameter(0);
       assertTrue( p != null );
       assertTrue( p.getId() ==  "k1" );
       assertTrue( p.getValue() == 0.1 );
       kl = (KineticLaw) p.getParentSBMLObject().getParentSBMLObject();
       assertTrue( kl != null );
       assertTrue( kl.getFormula() ==  "k1 * X0" );
       assertTrue( kl.getNumParameters() == 1 );
       r = m.getReaction(1);
       assertTrue( r != null );
       assertTrue( r.getId() ==  "out" );
       assertTrue( r.getNumReactants() == 1 );
       assertTrue( r.getNumProducts() == 1 );
       sr = r.getReactant(0);
       assertTrue( sr != null );
       assertTrue( sr.getSpecies() ==  "T"  );
       sr = r.getProduct(0);
       assertTrue( sr != null );
       assertTrue( sr.getSpecies() ==  "X1" );
       kl = r.getKineticLaw();
       assertTrue( kl != null );
       assertTrue( kl.getFormula() ==  "k2 * T" );
       assertTrue( kl.getNumParameters() == 1 );
       p = kl.getParameter(0);
       assertTrue( p != null );
       assertTrue( p.getId() ==  "k2" );
       assertTrue( p.getValue() == 0.15 );
       d = null;
 }
예제 #14
0
        internal static HandleRef getCPtrAndDisown(SBMLReader obj)
        {
            HandleRef ptr = new HandleRef(null, IntPtr.Zero);

            if (obj != null)
            {
            ptr             = obj.swigCPtr;
            obj.swigCMemOwn = false;
            }

            return ptr;
        }
예제 #15
0
        public void TestSBML_Model()
        {
            SBMLReader reader = new SBMLReader();
            SBMLDocument document = reader.readSBML(TestConstant.SBML_Oscillation);

            SBML_Model model = new SBML_Model(document.getModel());

            // getSpeciesReferenceID
            SpeciesStruct ss = new SpeciesStruct();
            ss.Compartment = "cell";
            ss.ID = "Test1";
            ss.Name = "Test1";

            string id;
            try
            {
                id = model.getSpeciesReferenceID(ss.ID);
            }
            catch (Exception)
            {
            }
            model.SpeciesList.Add(ss);
            id = model.getSpeciesReferenceID(ss.ID);
            Assert.AreEqual("/cell:Test1", id, "getEventID returns unexpected value.");

            try
            {
                model.Level = 1;
                id = model.getSpeciesReferenceID(ss.ID);
            }
            catch (Exception)
            {
            }

            try
            {
                model.Level = 0;
                id = model.getSpeciesReferenceID(ss.ID);
            }
            catch (Exception)
            {
            }

            // setFunctionDefinitionToDictionary
            FunctionDefinitionStruct ud = new FunctionDefinitionStruct();
            ud.ID = "Function";
            ud.Name = "Function";
            ud.Formula = "1 * 2";
            model.FunctionDefinitionList.Add(ud);

            Type type = model.GetType();
            MethodInfo info1 = type.GetMethod("setFunctionDefinitionToDictionary", BindingFlags.NonPublic | BindingFlags.Instance);
            info1.Invoke(model, new object[] { });

            // getNewUnitValue
            MethodInfo info2 = type.GetMethod("getNewUnitValue", BindingFlags.NonPublic | BindingFlags.Instance);
            UnitStruct unit = new UnitStruct("Kind", 2, 1, 0.5, 3);
            double value = (double)info2.Invoke(model, new object[] { unit });
            Assert.AreEqual(28.0d, value, "getNewUnitValue returns unexpected value.");

            // convertUnit
            model.Level = 2;
            value = model.convertUnit("test", 0.1d);
            Assert.AreEqual(0.1d, value, "convertUnit returns unexpected value.");

            value = model.convertUnit("substance", 1.0d);
            Assert.AreEqual(1.0d, value, "convertUnit returns unexpected value.");

            model.Level = 1;
            value = model.convertUnit("test", 0.1d);
            Assert.AreEqual(0.1d, value, "convertUnit returns unexpected value.");

            value = model.convertUnit("minute", 1.0d);
            Assert.AreEqual(60.0d, value, "convertUnit returns unexpected value.");

            try
            {
                model.Level = 0;
                model.convertUnit("test", 0.1d);
            }
            catch (Exception)
            {
            }

            // getPath
            string path;
            try
            {
                path = model.getPath("");
            }
            catch (Exception)
            {
            }
            path = model.getPath("default");
            Assert.AreEqual("/", path, "getPath returns unexpected value.");
        }
예제 #16
0
        public void TestSBML_Event()
        {
            SBMLReader reader = new SBMLReader();
            SBMLDocument document = reader.readSBML(TestConstant.SBML_Oscillation);

            SBML_Model model = new SBML_Model(document.getModel());
            SBML_Event e = new SBML_Event(model);

            EventStruct es = new EventStruct();
            es.ID = "Test1";
            string id = e.getEventID(es);
            Assert.AreEqual("Process:/:Test1", id, "getEventID returns unexpected value.");

            model.Level = 1;
            es.Name = "Test2";
            id = e.getEventID(es);
            Assert.AreEqual("Process:/:Test2", id, "getEventID returns unexpected value.");

            model.Level = 0;
            id = e.getEventID(es);
            Assert.AreEqual("Process:/:Event0", id, "getEventID returns unexpected value.");
        }
예제 #17
0
        public void TestSBML_Compartment()
        {
            SBMLReader reader = new SBMLReader();
            SBMLDocument document = reader.readSBML(TestConstant.SBML_Oscillation);

            SBML_Model model = new SBML_Model(document.getModel());
            SBML_Compartment c = new SBML_Compartment(model);

            CompartmentStruct cs = new CompartmentStruct();
            try
            {
                c.getCompartmentID(cs);
            }
            catch (Exception)
            {
            }
            string id;

            cs.Outside = "";
            cs.ID = "Test1";
            id = c.getCompartmentID(cs);
            Assert.AreEqual("System:/:Test1", id, "getCompartmentID returns unexpected value.");

            try
            {
                model.Level = 1;
                id = c.getCompartmentID(cs);
            }
            catch (Exception)
            {
            }

            try
            {
                model.Level = 0;
                id = c.getCompartmentID(cs);
            }
            catch (Exception)
            {
            }

            model.Level = 2;
            cs.Outside = "cell";
            id = c.getCompartmentID(cs);
            Assert.AreEqual("System:/cell:Test1", id, "getCompartmentID returns unexpected value.");

            try
            {
                model.Level = 1;
                id = c.getCompartmentID(cs);
            }
            catch (Exception)
            {
            }

            try
            {
                model.Level = 0;
                id = c.getCompartmentID(cs);
            }
            catch (Exception)
            {
            }

            // GetModuleType
            Type type = c.GetType();
            MethodInfo info1 = type.GetMethod("setSizeToDictionary", BindingFlags.NonPublic | BindingFlags.Instance);
            MethodInfo info2 = type.GetMethod("setUnitToDictionary", BindingFlags.NonPublic | BindingFlags.Instance);
            try
            {
                info1.Invoke(c, new object[] { cs });
            }
            catch (Exception)
            {
            }
            try
            {
                info2.Invoke(c, new object[] { cs });
            }
            catch (Exception)
            {
            }
            model.Level = 1;
            cs.Volume = double.NaN;
            cs.Name = "Test1";
            info1.Invoke(c, new object[] { cs });
            info2.Invoke(c, new object[] { cs });

            // getOutsideSize
            model.Level = 2;
            MethodInfo info3 = type.GetMethod("getOutsideSize", BindingFlags.NonPublic | BindingFlags.Instance);
            double size;
            size = (double)info3.Invoke(c, new object[] { "" });
            Assert.AreEqual(1.0d, size, "getOutsideSize returns unexpected value.");

            size = (double)info3.Invoke(c, new object[] { "cell" });
            Assert.AreEqual(1.0d, size, "getOutsideSize returns unexpected value.");

            // getOutsideUnit
            MethodInfo info4 = type.GetMethod("getOutsideUnit", BindingFlags.NonPublic | BindingFlags.Instance);
            string unit;
            unit = (string)info4.Invoke(c, new object[] { "" });
            Assert.AreEqual("", unit, "getCompartmentSize returns unexpected value.");

            unit = (string)info4.Invoke(c, new object[] { "cell" });
            Assert.AreEqual("", unit, "getCompartmentSize returns unexpected value.");

            // getCompartmentSize
            size = c.getCompartmentSize(cs);
            Assert.AreEqual(1.0d, size, "getCompartmentSize returns unexpected value.");

            model.Level = 1;
            size = c.getCompartmentSize(cs);
            Assert.AreEqual(1.0d, size, "getCompartmentSize returns unexpected value.");

            try
            {
                model.Level = 0;
                size = c.getCompartmentSize(cs);
            }
            catch (Exception)
            {
            }

            // getCompartmentUnit
            model.Level = 2;
            id = c.getCompartmentUnit(cs);
            Assert.AreEqual(null, id, "getCompartmentUnit returns unexpected value.");

            model.Level = 1;
            id = c.getCompartmentUnit(cs);
            Assert.AreEqual(null, id, "getCompartmentUnit returns unexpected value.");

            try
            {
                model.Level = 0;
                id = c.getCompartmentUnit(cs);
            }
            catch (Exception)
            {
            }
        }
예제 #18
0
 public void test_read_l2v2_newComponents()
 {
     SBMLReader reader = new SBMLReader();
       SBMLDocument d;
       Model m;
       Compartment c;
       CompartmentType ct;
       Species s;
       Parameter p;
       Reaction r;
       SpeciesReference sr;
       KineticLaw kl;
       Constraint con;
       InitialAssignment ia;
       SpeciesType st;
       ListOfCompartmentTypes loct;
       CompartmentType ct1;
       ListOfConstraints locon;
       Constraint con1;
       ListOfInitialAssignments loia;
       InitialAssignment ia1;
       ListOfReactions lor;
       Reaction r1;
       ListOfSpeciesReferences losr;
       SpeciesReference sr1;
       ASTNode ast;
       string filename =  "../../sbml/test/test-data/";
       filename += "l2v2-newComponents.xml";
       d = reader.readSBML(filename);
       if (d == null);
       {
       }
       assertTrue( d.getLevel() == 2 );
       assertTrue( d.getVersion() == 2 );
       m = d.getModel();
       assertTrue( m != null );
       assertTrue( m.getId() ==  "l2v2_newComponents" );
       assertTrue( m.getSBOTerm() == 4 );
       assertTrue( m.getSBOTermID() ==  "SBO:0000004" );
       assertTrue( m.getNumCompartments() == 2 );
       c = m.getCompartment(0);
       assertTrue( c != null );
       assertTrue( c.getId() ==  "cell" );
       assertEquals(c.getCompartmentType(), "mitochondria");
       assertTrue( c.getOutside() ==  "m" );
       assertTrue( c.getSBOTerm() == -1 );
       assertTrue( c.getSBOTermID() ==  "" );
       c = m.getCompartment(1);
       assertTrue( c != null );
       assertTrue( c.getId() ==  "m" );
       assertEquals(c.getCompartmentType(), "mitochondria");
       assertTrue( m.getNumCompartmentTypes() == 1 );
       ct = m.getCompartmentType(0);
       assertTrue( ct != null );
       assertTrue( ct.getId() ==  "mitochondria" );
       loct = m.getListOfCompartmentTypes();
       ct1 = loct.get(0);
       assertTrue( ct1 == ct );
       ct1 = loct.get("mitochondria");
       assertTrue( ct1 == ct );
       assertTrue( m.getNumSpeciesTypes() == 1 );
       st = m.getSpeciesType(0);
       assertTrue( st != null );
       assertTrue( st.getId() ==  "Glucose" );
       assertTrue( m.getNumSpecies() == 2 );
       s = m.getSpecies(0);
       assertTrue( s != null );
       assertTrue( s.getId() ==  "X0" );
       assertEquals(s.getSpeciesType(), "Glucose");
       assertTrue( s.getCompartment() ==  "cell" );
       assertEquals( false, s.isSetInitialAmount() );
       assertEquals( false, s.isSetInitialConcentration() );
       s = m.getSpecies(1);
       assertTrue( s != null );
       assertTrue( s.getId() ==  "X1" );
       assertEquals( false, s.isSetSpeciesType() );
       assertTrue( s.getCompartment() ==  "cell" );
       assertTrue( s.getInitialConcentration() == 0.013 );
       assertEquals( false, s.isSetInitialAmount() );
       assertEquals( true, s.isSetInitialConcentration() );
       assertTrue( m.getNumParameters() == 1 );
       p = m.getParameter(0);
       assertTrue( p != null );
       assertTrue( p.getId() ==  "y" );
       assertTrue( p.getValue() == 2 );
       assertTrue( p.getUnits() ==  "dimensionless" );
       assertTrue( p.getId() ==  "y" );
       assertTrue( p.getSBOTerm() == 2 );
       assertTrue( p.getSBOTermID() ==  "SBO:0000002" );
       assertTrue( m.getNumConstraints() == 1 );
       con = m.getConstraint(0);
       assertTrue( con != null );
       assertTrue( con.getSBOTerm() == 64 );
       assertTrue( con.getSBOTermID() ==  "SBO:0000064" );
       ast = con.getMath();
       assertTrue((  "lt(1, cell)" == libsbml.formulaToString(ast) ));
       locon = m.getListOfConstraints();
       con1 = locon.get(0);
       assertTrue( con1 == con );
       assertTrue( m.getNumInitialAssignments() == 1 );
       ia = m.getInitialAssignment(0);
       assertTrue( ia != null );
       assertTrue( ia.getSBOTerm() == 64 );
       assertTrue( ia.getSBOTermID() ==  "SBO:0000064" );
       assertTrue( ia.getSymbol() ==  "X0" );
       ast = ia.getMath();
       assertTrue((  "y * X1" == libsbml.formulaToString(ast) ));
       loia = m.getListOfInitialAssignments();
       ia1 = loia.get(0);
       assertTrue( ia1 == ia );
       ia1 = loia.get("X0");
       assertTrue( ia1 == ia );
       assertTrue( m.getNumReactions() == 1 );
       r = m.getReaction(0);
       assertTrue( r != null );
       assertTrue( r.getSBOTerm() == 231 );
       assertTrue( r.getSBOTermID() ==  "SBO:0000231" );
       assertTrue( r.getId() ==  "in" );
       lor = m.getListOfReactions();
       r1 = lor.get(0);
       assertTrue( r1 == r );
       r1 = lor.get("in");
       assertTrue( r1 == r );
       assertEquals( true, r.isSetKineticLaw() );
       kl = r.getKineticLaw();
       assertTrue( kl != null );
       assertTrue( kl.getSBOTerm() == 1 );
       assertTrue( kl.getSBOTermID() ==  "SBO:0000001" );
       assertEquals( true, kl.isSetMath() );
       ast = kl.getMath();
       assertTrue((  "v * X0 / t" == libsbml.formulaToString(ast) ));
       assertTrue( kl.getNumParameters() == 2 );
       p = kl.getParameter(0);
       assertTrue( p != null );
       assertTrue( p.getSBOTerm() == 2 );
       assertTrue( p.getSBOTermID() ==  "SBO:0000002" );
       assertTrue( p.getId() ==  "v" );
       assertTrue( p.getUnits() ==  "litre" );
       assertTrue( r.getNumReactants() == 1 );
       assertTrue( r.getNumProducts() == 0 );
       assertTrue( r.getNumModifiers() == 0 );
       sr = r.getReactant(0);
       assertTrue( sr != null );
       assertTrue( sr.getName() ==  "sarah" );
       assertTrue( sr.getId() ==  "me" );
       assertTrue( sr.getSpecies() ==  "X0" );
       losr = r.getListOfReactants();
       sr1 = (SpeciesReference) losr.get(0);
       assertTrue( sr1 == sr );
       sr1 = (SpeciesReference) losr.get("me");
       assertTrue( sr1 == sr );
       d = null;
 }
예제 #19
0
 public void test_read_MathML_1()
 {
     SBMLReader reader = new SBMLReader();
       SBMLDocument d;
       Model m;
       FunctionDefinition fd;
       InitialAssignment ia;
       Rule r;
       KineticLaw kl;
       string filename =  "../../math/test/test-data/";
       filename += "mathML_1.xml";
       d = reader.readSBML(filename);
       if (d == null);
       {
       }
       m = d.getModel();
       assertTrue( m != null );
       assertTrue( m.getNumFunctionDefinitions() == 2 );
       assertTrue( m.getNumInitialAssignments() == 1 );
       assertTrue( m.getNumRules() == 2 );
       assertTrue( m.getNumReactions() == 1 );
       fd = m.getFunctionDefinition(0);
       ASTNode fd_math = fd.getMath();
       assertTrue( fd_math.getType() == libsbml.AST_LAMBDA );
       assertTrue( fd_math.getNumChildren() == 2 );
       assertTrue((  "lambda(x, )" == libsbml.formulaToString(fd_math) ));
       assertTrue( fd_math.getParentSBMLObject() == fd );
       ASTNode child = fd_math.getRightChild();
       assertTrue( child.getType() == libsbml.AST_UNKNOWN );
       assertTrue( child.getNumChildren() == 0 );
       assertTrue((  "" == libsbml.formulaToString(child) ));
       fd = m.getFunctionDefinition(1);
       ASTNode fd1_math = fd.getMath();
       assertTrue( fd1_math.getType() == libsbml.AST_LAMBDA );
       assertTrue( fd1_math.getNumChildren() == 2 );
       assertTrue((  "lambda(x, true)" == libsbml.formulaToString(fd1_math) ));
       assertTrue( fd1_math.getParentSBMLObject() == fd );
       ASTNode child1 = fd1_math.getRightChild();
       assertTrue( child1.getType() == libsbml.AST_CONSTANT_TRUE );
       assertTrue( child1.getNumChildren() == 0 );
       assertTrue((  "true" == libsbml.formulaToString(child1) ));
       ia = m.getInitialAssignment(0);
       ASTNode ia_math = ia.getMath();
       assertTrue( ia_math.getType() == libsbml.AST_UNKNOWN );
       assertTrue( ia_math.getNumChildren() == 0 );
       assertTrue((  "" == libsbml.formulaToString(ia_math) ));
       assertTrue( ia_math.getParentSBMLObject() == ia );
       r = m.getRule(0);
       ASTNode r_math = r.getMath();
       assertTrue( r_math.getType() == libsbml.AST_CONSTANT_TRUE );
       assertTrue( r_math.getNumChildren() == 0 );
       assertTrue((  "true" == libsbml.formulaToString(r_math) ));
       assertTrue( r_math.getParentSBMLObject() == r );
       r = m.getRule(1);
       ASTNode r1_math = r.getMath();
       assertTrue( r1_math.getType() == libsbml.AST_REAL );
       assertTrue( r1_math.getNumChildren() == 0 );
       assertTrue((  "INF" == libsbml.formulaToString(r1_math) ));
       assertTrue( r1_math.getParentSBMLObject() == r );
       kl = m.getReaction(0).getKineticLaw();
       ASTNode kl_math = kl.getMath();
       assertTrue( kl_math.getType() == libsbml.AST_REAL );
       assertTrue( kl_math.getNumChildren() == 0 );
       assertTrue((  "4.5" == libsbml.formulaToString(kl_math) ));
       assertTrue( kl_math.getParentSBMLObject() == kl );
       d = null;
 }
예제 #20
0
 internal static HandleRef getCPtr(SBMLReader obj)
 {
     return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
 }
예제 #21
0
        public void TestSBML_Reaction()
        {
            SBMLReader reader = new SBMLReader();
            SBMLDocument document = reader.readSBML(TestConstant.SBML_Oscillation);

            SBML_Model model = new SBML_Model(document.getModel());
            SBML_Reaction reaction = new SBML_Reaction(model);
        }
예제 #22
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="filename"></param>
        public static EcellModel Convert(string filename)
        {
            if (!File.Exists(filename))
                throw new EcellException(string.Format(MessageResources.ErrFindFile, filename));

            string sbml = File.ReadAllText(filename);
            SBMLReader reader = new SBMLReader();
            SBMLDocument document = reader.readSBMLFromString(sbml);
            Model model = document.getModel();
            if (model == null)
            {
                throw new EcellException(string.Format("{0} has no model.", filename));
            }
            SBML_Model theModel = new SBML_Model(model);
            SBML_Compartment theCompartment = new SBML_Compartment(theModel);
            SBML_Parameter theParameter = new SBML_Parameter( theModel );
            SBML_Species theSpecies = new SBML_Species( theModel );
            SBML_Rule theRule = new SBML_Rule( theModel );
            SBML_Reaction theReaction = new SBML_Reaction(theModel);
            SBML_Event theEvent = new SBML_Event(theModel);

            document.Dispose();

            //Eml eml = new Eml(null);
            string modelId = Path.GetFileNameWithoutExtension(filename);
            EcellModel modelObject = (EcellModel)EcellObject.CreateObject(modelId, "", Constants.xpathModel, "", new List<EcellData>());
            // Set Layer
            List<EcellLayer> layers = new List<EcellLayer>();
            layers.Add(new EcellLayer(SbmlConstant.GlobalParameters, true));
            modelObject.Layers = layers;

            //
            // Set Stepper.
            //
            EcellObject stepper = EcellObject.CreateObject(modelId, "DE", EcellObject.STEPPER, "FixedODE1Stepper", new List<EcellData>());
            modelObject.Children.Add(stepper);

            //
            // Set Compartment ( System ).
            //
            EcellSystem rootSystem = (EcellSystem)EcellObject.CreateObject(modelId, "/", EcellObject.SYSTEM, EcellObject.SYSTEM, new List<EcellData>());
            rootSystem.SetEcellValue("StepperID", new EcellValue("DE"));
            rootSystem.SetEcellValue("Name", new EcellValue("Default"));
            modelObject.Children.Add(rootSystem);

            EcellSystem system = rootSystem;
            foreach (CompartmentStruct aCompartment in theModel.CompartmentList)
            {
                // getPath
                string aPath = "";
                if ( theModel.Level == 1 )
                    aPath = theModel.getPath( aCompartment.Name );
                else if ( theModel.Level == 2 )
                    aPath = theModel.getPath( aCompartment.ID );

                // setFullID
                if( aPath != "/" )
                {
                    system = (EcellSystem)EcellObject.CreateObject(modelId, aPath, EcellObject.SYSTEM, EcellObject.SYSTEM, new List<EcellData>());
                    modelObject.Children.Add(system);
                }

                // setStepper
                system.SetEcellValue("StepperID", new EcellValue("DE"));

                // setName( default = [] )
                if (theModel.Level == 2)
                    if (aCompartment.Name != "")
                        system.SetEcellValue("Name", new EcellValue(aCompartment.Name));

                // setDimensions( default = 3 )
                EcellObject dimension = EcellObject.CreateObject(modelId, aPath + ":Dimensions", EcellObject.VARIABLE, EcellObject.VARIABLE, new List<EcellData>());
                dimension.SetEcellValue("Value", new EcellValue((int)aCompartment.SpatialDimension));
                system.Children.Add(dimension);

                // setSIZE
                EcellObject size = EcellObject.CreateObject(modelId, aPath + ":SIZE", EcellObject.VARIABLE, EcellObject.VARIABLE, new List<EcellData>());
                size.SetEcellValue("Value", new EcellValue((double)theCompartment.getCompartmentSize(aCompartment)));
                system.Children.Add(size);
            }

            // Set GlobalParameter ( Variable )
            if ( theModel.ParameterList.Count > 0)
            {
                foreach(ParameterStruct aParameter in theModel.ParameterList)
                {
                    // setFullID
                    string parameterKey = theParameter.getParameterID( aParameter );
                    EcellObject parameter = EcellObject.CreateObject(modelId, parameterKey, EcellObject.VARIABLE, EcellObject.VARIABLE, new List<EcellData>());
                    // Set Layer
                    parameter.Layer = SbmlConstant.GlobalParameters;
                    // setName
                    if ( aParameter.Name != "" )
                        parameter.SetEcellValue("Name", new EcellValue(aParameter.Name));

                    // setValue
                    parameter.SetEcellValue("Value", new EcellValue(aParameter.Value));

                    // setFixed ( default = 1 )
                    if ( aParameter.Constant)
                        parameter.SetEcellValue("Fixed", new EcellValue(1));

                    // set to system.
                    rootSystem.Children.Add(parameter);
                }
            }

            // Set Species ( Variable )
            foreach(SpeciesStruct aSpecies in theModel.SpeciesList)
            {
                // Create
                string aSpeciesID = theSpecies.getSpeciesID( aSpecies );
                EcellObject variable = EcellObject.CreateObject(modelId, aSpeciesID, EcellObject.VARIABLE, EcellObject.VARIABLE, new List<EcellData>());
                // setName
                if( theModel.Level == 2 )
                    if ( aSpecies.Name != "" )
                        variable.SetEcellValue("Name", new EcellValue(aSpecies.Name));

                // setValue
                variable.SetEcellValue("Value", new EcellValue(theSpecies.getSpeciesValue( aSpecies )));

                // setFixed
                variable.SetEcellValue("Fixed", new EcellValue(theSpecies.getConstant( aSpecies )));

                // add
                modelObject.AddEntity(variable);
            }

            // Set Rule ( Process )
            if ( theModel.RuleList.Count > 0)
            {
                // make Rule System
                string aSystemKey = "/SBMLRule";
                system = (EcellSystem)EcellObject.CreateObject(modelId, aSystemKey, EcellObject.SYSTEM, EcellObject.SYSTEM, new List<EcellData>());
                system.SetEcellValue("Name", new EcellValue("System for SBML Rule"));
                system.SetEcellValue("StepperID", new EcellValue("DE"));
                modelObject.Children.Add(system);

                foreach(RuleStruct aRule in theModel.RuleList)
                {
                    theRule.initialize();

                    // setFullID
                    string aRuleID = theRule.getRuleID();
                    EcellObject process = EcellObject.CreateObject(modelId, aRuleID, EcellObject.PROCESS, EcellObject.PROCESS, new List<EcellData>());
                    modelObject.AddEntity(process);

                    // Algebraic Rule
                    if ( aRule.RuleType == libsbml.libsbml.SBML_ALGEBRAIC_RULE )
                    {
                        process.Classname = "ExpressionAlgebraicProcess";
                    }
                    // Assignment Rule
                    else if (aRule.RuleType == libsbml.libsbml.SBML_ASSIGNMENT_RULE ||
                           aRule.RuleType == libsbml.libsbml.SBML_SPECIES_CONCENTRATION_RULE ||
                           aRule.RuleType == libsbml.libsbml.SBML_COMPARTMENT_VOLUME_RULE ||
                           aRule.RuleType == libsbml.libsbml.SBML_PARAMETER_RULE)
                    {
                        process.Classname = "ExpressionAssignmentProcess";

                        int aVariableType = theRule.getVariableType( aRule.Variable );

                        if (aVariableType == libsbml.libsbml.SBML_SPECIES)
                            theRule.setSpeciesToVariableReference( aRule.Variable, 1 );
                        else if (aVariableType == libsbml.libsbml.SBML_PARAMETER)
                            theRule.setParameterToVariableReference( aRule.Variable, 1 );
                        else if (aVariableType == libsbml.libsbml.SBML_COMPARTMENT)
                            theRule.setCompartmentToVariableReference( aRule.Variable, 1 );
                        else
                            throw new EcellException("Variable type must be Species, Parameter, or Compartment");
                    }
                    // Rate Rule
                    else if (aRule.RuleType == libsbml.libsbml.SBML_RATE_RULE)
                    {
                        process.Classname = "ExpressionFluxProcess";

                        int aVariableType = theRule.getVariableType( aRule.Variable );

                        if (aVariableType == libsbml.libsbml.SBML_SPECIES)
                            theRule.setSpeciesToVariableReference( aRule.Variable, 1 );
                        else if (aVariableType == libsbml.libsbml.SBML_PARAMETER)
                            theRule.setParameterToVariableReference( aRule.Variable, 1 );
                        else if (aVariableType == libsbml.libsbml.SBML_COMPARTMENT)
                            theRule.setCompartmentToVariableReference( aRule.Variable, 1 );
                        else
                            throw new EcellException("Variable type must be Species, Parameter, or Compartment");
                    }
                    else
                        throw new EcellException(" The type of Rule must be Algebraic, Assignment or Rate Rule");

                    // convert SBML formula to E-Cell formula
                    string convertedFormula = theRule.convertRuleFormula( aRule.Formula );

                    // set Expression Property
                    process.SetEcellValue("Expression", new EcellValue(convertedFormula));

                    // setVariableReferenceList
                    process.SetEcellValue("VariableReferenceList", new EcellValue(theRule.GetVariableReferenceList()));
                }
            }

            // Set Reaction ( Process )
            foreach(ReactionStruct aReaction in theModel.ReactionList)
            {
                theReaction.initialize();

                // setFullID
                string aReactionID = theReaction.getReactionID( aReaction );
                EcellProcess process = (EcellProcess)EcellObject.CreateObject(modelId, aReactionID, EcellObject.PROCESS, "ExpressionFluxProcess", new List<EcellData>());

                // setName
                if ( theModel.Level == 2 )
                    if( aReaction.Name != "" )
                        process.SetEcellValue("Name",new EcellValue(aReaction.Name));

                // setSubstrate
                foreach(ReactantStruct aSubstrate in aReaction.Reactants)
                {
                    string name = "S" + theReaction.SubstrateNumber.ToString();
                    string aSubstrateID = theModel.getSpeciesReferenceID( aSubstrate.Species );
                    if ( aSubstrateID == null )
                        throw new EcellException("Species "+aSubstrate.Species+" not found");

                    if ( aSubstrate.Denominator != 1 )
                        throw new EcellException("Stoichiometry Error : E-Cell System can't set a floating Stoichiometry");
                    int coefficient = -1 * theReaction.getStoichiometry(aSubstrate.Species, aSubstrate.Stoichiometry );

                    VariableReferenceStruct aSubstrateList = new VariableReferenceStruct(name, "Variable:" + aSubstrateID, coefficient);
                    theReaction.VariableReferenceList.Add( aSubstrateList );
                    theReaction.SubstrateNumber = theReaction.SubstrateNumber + 1;
                }

                // setProduct
                foreach(ProductStruct aProduct in aReaction.Products)
                {
                    string name = 'P' + theReaction.ProductNumber.ToString();
                    string aProductID = theModel.getSpeciesReferenceID( aProduct.Species );
                    if ( aProductID == "" )
                        throw new EcellException("Species "+aProduct.Species+" not found");

                    if ( aProduct.Denominator != 1 )
                        throw new EcellException("Stoichiometry Error : E-Cell System can't set a floating Stoichiometry");

                    int coefficient = 1 * theReaction.getStoichiometry(aProduct.Species,  aProduct.Stoichiometry );

                    VariableReferenceStruct aProductList = new VariableReferenceStruct(name, "Variable:" + aProductID, coefficient);
                    theReaction.VariableReferenceList.Add( aProductList );
                    theReaction.ProductNumber = theReaction.ProductNumber + 1;
                }

                // setCatalyst
                foreach(string aModifier in aReaction.Modifiers)
                {
                    string name = "C" + theReaction.ModifierNumber.ToString();
                    string aModifierID = theModel.getSpeciesReferenceID( aModifier );
                    if ( aModifierID == "" )
                        throw new EcellException("Species "+aModifier+" not found");

                    VariableReferenceStruct aModifierList = new VariableReferenceStruct(name, "Variable:" + aModifierID, 0);
                    theReaction.VariableReferenceList.Add( aModifierList );
                    theReaction.ModifierNumber = theReaction.ModifierNumber + 1;

                }

                // setProperty
                foreach(KineticLawStruct kineticLaw in aReaction.KineticLaws)
                {
                    foreach(ParameterStruct aParameter in kineticLaw.Parameters)
                    {
                        if (theModel.Level == 1)
                            process.SetEcellValue(aParameter.Name, new EcellValue(aParameter.Value));
                        else if (theModel.Level == 2)
                            process.SetEcellValue(aParameter.ID, new EcellValue(aParameter.Value));
                    }

                    // set "Expression" Property
                    // convert SBML format formula to E-Cell format formula
                    if( kineticLaw.Formula != "" )
                    {
                        string anExpression = theReaction.convertKineticLawFormula( kineticLaw.Formula );

                        // set Expression Property for ExpressionFluxProcess
                        process.SetEcellValue("Expression", new EcellValue(anExpression));

                        // setVariableReferenceList
                        process.SetEcellValue("VariableReferenceList", new EcellValue(theReaction.GetVariableReferenceList()));
                    }
                }
                // Set Parent System.
                string sysKey = process.ParentSystemID;
                foreach (EcellReference er in process.ReferenceList)
                {
                    if (er.Coefficient == -1)
                        sysKey = er.Key.Split(':')[0];
                }
                foreach (EcellReference er in process.ReferenceList)
                {
                    if (er.Coefficient == 1)
                        sysKey = er.Key.Split(':')[0];
                }
                process.Key = sysKey + ":" + process.LocalID;
                // Update EntityPath.
                foreach (EcellData data in process.Value)
                {
                    data.EntityPath = process.FullID + ":" + data.Name;
                }

                modelObject.AddEntity(process);

            }

            return modelObject;
        }
예제 #23
0
 public void TestSBML_Rule()
 {
     SBMLReader reader = new SBMLReader();
     SBMLDocument document = reader.readSBML(TestConstant.SBML_BIOMD0000000003);
     Model sbmlModel = document.getModel();
     SBML_Model model = new SBML_Model(sbmlModel);
     SBML_Compartment sc = new SBML_Compartment(model);
     SBML_Species species = new SBML_Species(model);
     SBML_Rule rule = new SBML_Rule(model);
 }