public void TestConstructorOfStructs() { // CompartmentStruct c = new CompartmentStruct( "ID", "Name", 0, 0.0, 0.0, "Unit", "Parent", false); // EventStruct e = new EventStruct( "ID", "Name", "Trigger", "delay", "TimeUnit", new List<EventAssignmentStruct>()); // EventAssignmentStruct ea = new EventAssignmentStruct( "Variable", "Formula"); // FunctionDefinitionStruct fd = new FunctionDefinitionStruct( "ID", "Name", "Formula"); // ParameterStruct p = new ParameterStruct( "ID", "Name", 0.0, "Unit", false); // ReactionStruct r = new ReactionStruct( "ID", "Name", new List<KineticLawStruct>(), false, false, new List<ReactantStruct>(), new List<ProductStruct>(), new List<string>()); // KineticLawStruct k = new KineticLawStruct( "Formula", new List<string>(), "TimeUnit", "Substance", new List<ParameterStruct>(), null); // ReactantStruct rs = new ReactantStruct( "Species", 0, "Formula", 0); // ProductStruct ps = new ProductStruct( "Species", 0.0, "Formula", 0); // RuleStruct rule = new RuleStruct( 0, "Formula", "Variable"); // SpeciesStruct s = new SpeciesStruct( "ID", "Name", "Parent", 0.0, 0.0, "Substance", "Spatial", "Unit", false, false, 0, false); // UnitDefinitionStruct ud = new UnitDefinitionStruct( "ID", "Name", new List<UnitStruct>()); // UnitStruct u = new UnitStruct( "Kind", 0, 0, 0.0, 0.0); // VariableReferenceStruct v = new VariableReferenceStruct( "Name", "Variable", 0); // InitialAssignmentStruct i = new InitialAssignmentStruct( "Name", 0.0); }
/// <summary> /// [ FunctionDefinitionStruct ] /// [[ Id , Name , String ]] /// <param name="aSBMLmodel"></param> /// </summary> public static List<FunctionDefinitionStruct> getFunctionDefinition(Model aSBMLmodel) { List<FunctionDefinitionStruct> list = new List<FunctionDefinitionStruct>(); ListOfFunctionDefinitions functionDefinitions = aSBMLmodel.getListOfFunctionDefinitions(); for (int i = 0; i < functionDefinitions.size(); i++ ) { FunctionDefinition aFunctionDefinition = aSBMLmodel.getFunctionDefinition(i); string anId_FD = aFunctionDefinition.getId(); string aName_FD = aFunctionDefinition.getName(); ASTNode anASTNode_FD = aFunctionDefinition.getMath(); string aString_FD = libsbml.libsbml.formulaToString(anASTNode_FD ); FunctionDefinitionStruct fd = new FunctionDefinitionStruct( anId_FD, aName_FD, aString_FD); list.Add(fd); } return list; }
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."); }