public void test_internal_consistency_check_20306() { SBMLDocument d = new SBMLDocument(3,1); long errors; Model m = d.createModel(); FunctionDefinition fd = m.createFunctionDefinition(); fd.setId("fd"); errors = d.checkInternalConsistency(); assertTrue( errors == 1 ); assertTrue( d.getError(0).getErrorId() == 20306 ); ASTNode ast = libsbml.parseFormula("lambda(x, 2*x)"); fd.setMath(ast); errors = d.checkInternalConsistency(); assertTrue( errors == 0 ); d = null; }
public void test_internal_consistency_check_20419() { SBMLDocument d = new SBMLDocument(3,1); long errors; Model m = d.createModel(); UnitDefinition ud = m.createUnitDefinition(); errors = d.checkInternalConsistency(); assertTrue( errors == 1 ); assertTrue( d.getError(0).getErrorId() == 20419 ); ud.setId("ud"); d.getErrorLog().clearLog(); errors = d.checkInternalConsistency(); assertTrue( errors == 0 ); d = null; }
public void test_internal_consistency_check_20623() { SBMLDocument d = new SBMLDocument(3,1); long errors; Model m = d.createModel(); Compartment c = m.createCompartment(); c.setId("c"); c.setConstant(true); Species s = m.createSpecies(); errors = d.checkInternalConsistency(); assertTrue( errors == 5 ); assertTrue( d.getError(0).getErrorId() == 20623 ); assertTrue( d.getError(1).getErrorId() == 20614 ); assertTrue( d.getError(2).getErrorId() == 20623 ); assertTrue( d.getError(3).getErrorId() == 20623 ); assertTrue( d.getError(4).getErrorId() == 20623 ); s.setId("s"); d.getErrorLog().clearLog(); errors = d.checkInternalConsistency(); assertTrue( errors == 4 ); assertTrue( d.getError(0).getErrorId() == 20614 ); assertTrue( d.getError(1).getErrorId() == 20623 ); assertTrue( d.getError(2).getErrorId() == 20623 ); assertTrue( d.getError(3).getErrorId() == 20623 ); s.setCompartment("c"); d.getErrorLog().clearLog(); errors = d.checkInternalConsistency(); assertTrue( errors == 3 ); assertTrue( d.getError(0).getErrorId() == 20623 ); assertTrue( d.getError(1).getErrorId() == 20623 ); assertTrue( d.getError(2).getErrorId() == 20623 ); s.setHasOnlySubstanceUnits(true); d.getErrorLog().clearLog(); errors = d.checkInternalConsistency(); assertTrue( errors == 2 ); assertTrue( d.getError(0).getErrorId() == 20623 ); assertTrue( d.getError(1).getErrorId() == 20623 ); s.setBoundaryCondition(true); d.getErrorLog().clearLog(); errors = d.checkInternalConsistency(); assertTrue( errors == 1 ); assertTrue( d.getError(0).getErrorId() == 20623 ); s.setConstant(true); d.getErrorLog().clearLog(); errors = d.checkInternalConsistency(); assertTrue( errors == 0 ); d = null; }
public void test_ReadSBML_FunctionDefinition_OnlyBVars() { FunctionDefinition fd; SBMLError error; int numErrors; ASTNode math; string formula; string s = wrapSBML_L2v1("<listOfFunctionDefinitions>" + " <functionDefinition id='invalid'>" + " <math xmlns='http://www.w3.org/1998/Math/MathML'>" + " <lambda>" + " <bvar><ci> x </ci></bvar>" + " <bvar><ci> y </ci></bvar>" + " <bvar><ci> z </ci></bvar>" + " </lambda>" + " </math>" + " </functionDefinition>" + "</listOfFunctionDefinitions>"); D = libsbml.readSBMLFromString(s); M = D.getModel(); D.checkInternalConsistency(); D.checkConsistency(); numErrors = (int)D.getNumErrors(); assertTrue( numErrors == 1 ); error = D.getError(0); int errorId = (int)error.getErrorId(); assertTrue( errorId == libsbml.NoBodyInFunctionDef ); assertTrue( M.getNumFunctionDefinitions() == 1 ); fd = M.getFunctionDefinition(0); assertTrue( fd != null ); assertEquals( true, fd.isSetId() ); assertEquals( false, fd.isSetName() ); assertTrue(( "invalid" == fd.getId() )); assertTrue( fd.getBody() == null ); assertEquals( true, fd.isSetMath() ); math = fd.getMath(); formula = libsbml.formulaToString(math); assertTrue( formula != null ); assertTrue(( "lambda(x, y, z)" == formula )); }
public void test_internal_consistency_check_99904_rule_rate() { SBMLDocument d = new SBMLDocument(2,4); long errors; Rule r = new RateRule(2,4); d.setLevelAndVersion(1,2,false); Model m = d.createModel(); Compartment c = m.createCompartment(); c.setId("cc"); c.setConstant(false); r.setVariable("cc"); r.setFormula("2"); r.setMetaId("mmm"); m.addRule(r); errors = d.checkInternalConsistency(); assertTrue( errors == 0 ); d = null; }
public void test_internal_consistency_check_99904_react() { SBMLDocument d = new SBMLDocument(2,4); long errors; Reaction r = new Reaction(2,4); d.setLevelAndVersion(1,2,false); Model m = d.createModel(); Compartment c = m.createCompartment(); c.setId("cc"); r.setId("r"); r.setMetaId("mmm"); m.addReaction(r); errors = d.checkInternalConsistency(); assertTrue( errors == 0 ); d = null; }
public void test_internal_consistency_check_99904_model() { SBMLDocument d = new SBMLDocument(2,4); long errors; d.setLevelAndVersion(1,2,false); Model m = new Model(2,4); Compartment c = m.createCompartment(); c.setId("cc"); m.setMetaId("mmm"); d.setModel(m); errors = d.checkInternalConsistency(); assertTrue( errors == 1 ); assertTrue( d.getError(0).getErrorId() == 20201 ); d = null; }
public void test_internal_consistency_check_99903_param() { SBMLDocument d = new SBMLDocument(2,4); long errors; Parameter p = new Parameter(2,4); d.setLevelAndVersion(1,2,false); Model m = d.createModel(); Compartment c = m.createCompartment(); c.setId("cc"); p.setConstant(true); p.setId("c"); m.addParameter(p); Rule r = m.createAssignmentRule(); r.setVariable("c"); r.setFormula("2*3"); errors = d.checkInternalConsistency(); assertTrue( errors == 2 ); d = null; }
public void test_internal_consistency_check_99925() { SBMLDocument d = new SBMLDocument(2,4); long errors; Unit u = new Unit(2,4); d.setLevelAndVersion(1,2,false); Model m = d.createModel(); Compartment c = m.createCompartment(); c.setId("cc"); UnitDefinition ud = m.createUnitDefinition(); ud.setId("ud"); u.setKind(libsbml.UNIT_KIND_MOLE); u.setOffset(9); ud.addUnit(u); errors = d.checkInternalConsistency(); assertTrue( errors == 0 ); d = null; }
public void test_internal_consistency_check_99923() { SBMLDocument d = new SBMLDocument(2,4); long errors; StoichiometryMath sm = new StoichiometryMath(2,4); Model m = d.createModel(); d.setLevelAndVersion(1,2,false); Species s = m.createSpecies(); s.setId("s"); Compartment c = m.createCompartment(); c.setId("c"); s.setCompartment("c"); Reaction r = m.createReaction(); r.setId("r"); SpeciesReference sr = r.createProduct(); sr.setSpecies("s"); sr.setStoichiometryMath(sm); errors = d.checkInternalConsistency(); assertTrue( errors == 0 ); d = null; }
public void test_internal_consistency_check_99922() { SBMLDocument d = new SBMLDocument(2,4); long errors; SpeciesType ct = new SpeciesType(2,4); Model m = d.createModel(); ct.setId("st"); d.setLevelAndVersion(2,1,false); m.addSpeciesType(ct); errors = d.checkInternalConsistency(); assertTrue( errors == 0 ); d = null; }
public void test_internal_consistency_check_99921() { SBMLDocument d = new SBMLDocument(2,4); long errors; SpeciesReference sr = new SpeciesReference(2,4); d.setLevelAndVersion(2,1,false); Model m = d.createModel(); Compartment c = m.createCompartment(); c.setId("c"); Species s = m.createSpecies(); s.setId("s"); Reaction r = m.createReaction(); r.setId("r"); s.setCompartment("c"); sr.setSpecies("s"); sr.setName("mmm"); r.addReactant(sr); errors = d.checkInternalConsistency(); assertTrue( errors == 1 ); assertTrue( d.getError(0).getErrorId() == 21101 ); d = null; }
public void test_internal_consistency_check_99916_rule() { SBMLDocument d = new SBMLDocument(2,4); long errors; Species s = new Species(2,4); d.setLevelAndVersion(1,2,false); Model m = d.createModel(); Compartment c = m.createCompartment(); c.setId("c"); s.setId("s"); s.setCompartment("c"); s.setConstant(true); m.addSpecies(s); Rule r = m.createAssignmentRule(); r.setVariable("s"); r.setFormula("2"); errors = d.checkInternalConsistency(); assertTrue( errors == 2 ); d = null; }
public void test_internal_consistency_check_99916_reaction() { SBMLDocument d = new SBMLDocument(2,4); long errors; Species s = new Species(2,4); d.setLevelAndVersion(1,2,false); Model m = d.createModel(); Compartment c = m.createCompartment(); c.setId("c"); Reaction r = m.createReaction(); r.setId("r"); SpeciesReference sr = r.createReactant(); s.setId("s"); s.setCompartment("c"); s.setConstant(true); sr.setSpecies("s"); m.addSpecies(s); errors = d.checkInternalConsistency(); assertTrue( errors == 0 ); d = null; }
public void test_internal_consistency_check_99915_rate() { SBMLDocument d = new SBMLDocument(2,4); long errors; d.setLevelAndVersion(1,2,false); Model m = d.createModel(); Compartment c = m.createCompartment(); c.setId("c"); c.setConstant(false); RateRule r = m.createRateRule(); r.setL1TypeCode(libsbml.SBML_SPECIES_CONCENTRATION_RULE); r.setFormula("2"); r.setVariable("c"); r.setUnits("mmm"); errors = d.checkInternalConsistency(); assertTrue( errors == 0 ); d = null; }
public void test_internal_consistency_check_21231() { SBMLDocument d = new SBMLDocument(3,1); long errors; Model m = d.createModel(); Event r = m.createEvent(); r.setUseValuesFromTriggerTime(true); ASTNode ast = libsbml.parseFormula("2*x"); Trigger t = r.createTrigger(); t.setMath(ast); t.setPersistent(true); t.setInitialValue(false); EventAssignment ea = r.createEventAssignment(); ea.setVariable("ea"); ea.setMath(ast); Priority prior = r.createPriority(); d.getErrorLog().clearLog(); errors = d.checkInternalConsistency(); assertTrue( errors == 1 ); assertTrue( d.getError(0).getErrorId() == 21231 ); prior.setMath(ast); d.getErrorLog().clearLog(); errors = d.checkInternalConsistency(); assertTrue( errors == 0 ); d = null; }
public void test_internal_consistency_check_99902() { SBMLDocument d = new SBMLDocument(2,4); long errors; Compartment c = new Compartment(2,4); d.setLevelAndVersion(1,2,false); Model m = d.createModel(); c.setCompartmentType("hh"); c.setId("c"); m.addCompartment(c); errors = d.checkInternalConsistency(); assertTrue( errors == 1 ); assertTrue( d.getError(0).getErrorId() == 10103 ); d = null; }
public void test_internal_consistency_check_20706() { SBMLDocument d = new SBMLDocument(3,1); long errors; Model m = d.createModel(); Parameter p = m.createParameter(); errors = d.checkInternalConsistency(); assertTrue( errors == 2 ); assertTrue( d.getError(0).getErrorId() == 20706 ); assertTrue( d.getError(1).getErrorId() == 20706 ); p.setId("c"); d.getErrorLog().clearLog(); errors = d.checkInternalConsistency(); assertTrue( errors == 1 ); assertTrue( d.getError(0).getErrorId() == 20706 ); p.setConstant(true); d.getErrorLog().clearLog(); errors = d.checkInternalConsistency(); assertTrue( errors == 0 ); d = null; }
public void test_internal_consistency_check_99903_localparam() { SBMLDocument d = new SBMLDocument(2,4); long errors; Parameter p = new Parameter(2,4); d.setLevelAndVersion(1,2,false); Model m = d.createModel(); Compartment c = m.createCompartment(); c.setId("cc"); Reaction r = m.createReaction(); r.setId("r"); SpeciesReference sr = r.createReactant(); sr.setSpecies("s"); KineticLaw kl = r.createKineticLaw(); kl.setFormula("2"); p.setId("p"); p.setConstant(false); kl.addParameter(p); errors = d.checkInternalConsistency(); assertTrue( errors == 0 ); d = null; }
public void test_internal_consistency_check_20805() { SBMLDocument d = new SBMLDocument(3,1); long errors; Model m = d.createModel(); InitialAssignment ia = m.createInitialAssignment(); ASTNode ast = libsbml.parseFormula("lambda(x, 2*x)"); ia.setMath(ast); errors = d.checkInternalConsistency(); assertTrue( errors == 1 ); assertTrue( d.getError(0).getErrorId() == 20805 ); ia.setSymbol("fd"); d.getErrorLog().clearLog(); errors = d.checkInternalConsistency(); assertTrue( errors == 0 ); d = null; }
public void test_internal_consistency_check_99904_kl() { SBMLDocument d = new SBMLDocument(2,4); long errors; KineticLaw kl = new KineticLaw(2,4); Model m = d.createModel(); d.setLevelAndVersion(1,2,false); Compartment c = m.createCompartment(); c.setId("cc"); Reaction r = m.createReaction(); r.setId("r"); SpeciesReference sr = r.createReactant(); sr.setSpecies("s"); kl.setFormula("2"); kl.setMetaId("mmm"); r.setKineticLaw(kl); errors = d.checkInternalConsistency(); assertTrue( errors == 0 ); d = null; }
public void test_internal_consistency_check_20908() { SBMLDocument d = new SBMLDocument(3,1); long errors; Model m = d.createModel(); AssignmentRule r = m.createAssignmentRule(); ASTNode ast = libsbml.parseFormula("lambda(x, 2*x)"); r.setMath(ast); errors = d.checkInternalConsistency(); assertTrue( errors == 1 ); assertTrue( d.getError(0).getErrorId() == 20908 ); r.setVariable("fd"); d.getErrorLog().clearLog(); errors = d.checkInternalConsistency(); assertTrue( errors == 0 ); d = null; }
public void test_internal_consistency_check_99904_param() { SBMLDocument d = new SBMLDocument(2,4); long errors; Parameter p = new Parameter(2,4); d.setLevelAndVersion(1,2,false); Model m = d.createModel(); Compartment c = m.createCompartment(); c.setId("cc"); p.setId("p"); p.setMetaId("mmm"); m.addParameter(p); errors = d.checkInternalConsistency(); assertTrue( errors == 0 ); d = null; }
public void test_internal_consistency_check_21007() { SBMLDocument d = new SBMLDocument(3,1); long errors; Model m = d.createModel(); Constraint r = m.createConstraint(); errors = d.checkInternalConsistency(); assertTrue( errors == 1 ); assertTrue( d.getError(0).getErrorId() == 21007 ); ASTNode ast = libsbml.parseFormula("lambda(x, 2*x)"); r.setMath(ast); d.getErrorLog().clearLog(); errors = d.checkInternalConsistency(); assertTrue( errors == 0 ); d = null; }
public void test_internal_consistency_check_20421() { SBMLDocument d = new SBMLDocument(3,1); long errors; Model m = d.createModel(); UnitDefinition ud = m.createUnitDefinition(); ud.setId("ud"); Unit u = ud.createUnit(); errors = d.checkInternalConsistency(); assertTrue( errors == 4 ); assertTrue( d.getError(0).getErrorId() == 20421 ); assertTrue( d.getError(1).getErrorId() == 20421 ); assertTrue( d.getError(2).getErrorId() == 20421 ); assertTrue( d.getError(3).getErrorId() == 20421 ); u.setKind(libsbml.UNIT_KIND_MOLE); d.getErrorLog().clearLog(); errors = d.checkInternalConsistency(); assertTrue( errors == 3 ); assertTrue( d.getError(0).getErrorId() == 20421 ); assertTrue( d.getError(1).getErrorId() == 20421 ); assertTrue( d.getError(2).getErrorId() == 20421 ); u.setExponent(1.0); d.getErrorLog().clearLog(); errors = d.checkInternalConsistency(); assertTrue( errors == 2 ); assertTrue( d.getError(0).getErrorId() == 20421 ); assertTrue( d.getError(1).getErrorId() == 20421 ); u.setScale(0); d.getErrorLog().clearLog(); errors = d.checkInternalConsistency(); assertTrue( errors == 1 ); assertTrue( d.getError(0).getErrorId() == 20421 ); u.setMultiplier(1.0); d.getErrorLog().clearLog(); errors = d.checkInternalConsistency(); assertTrue( errors == 0 ); d = null; }
public void test_internal_consistency_check_21117() { SBMLDocument d = new SBMLDocument(3,1); long errors; Model m = d.createModel(); Reaction r = m.createReaction(); r.setId("r"); r.setReversible(true); r.setFast(false); SpeciesReference sr = r.createReactant(); sr.setSpecies("s"); sr.setConstant(true); ModifierSpeciesReference msr = r.createModifier(); d.getErrorLog().clearLog(); errors = d.checkInternalConsistency(); assertTrue( errors == 1 ); assertTrue( d.getError(0).getErrorId() == 21117 ); msr.setSpecies("s"); d.getErrorLog().clearLog(); errors = d.checkInternalConsistency(); assertTrue( errors == 0 ); d = null; }
public void test_internal_consistency_check_99904_species() { SBMLDocument d = new SBMLDocument(2,4); long errors; Species s = new Species(2,4); d.setLevelAndVersion(1,2,false); Model m = d.createModel(); Compartment c = m.createCompartment(); c.setId("c"); s.setCompartment("c"); s.setId("s"); s.setMetaId("mmm"); m.addSpecies(s); errors = d.checkInternalConsistency(); assertTrue( errors == 0 ); d = null; }
public void test_internal_consistency_check_21172() { SBMLDocument d = new SBMLDocument(3,1); long errors; Model m = d.createModel(); Reaction r = m.createReaction(); r.setId("r"); r.setReversible(true); r.setFast(false); SpeciesReference sr = r.createReactant(); sr.setSpecies("s"); sr.setConstant(true); KineticLaw kl = r.createKineticLaw(); ASTNode ast = libsbml.parseFormula("2*x"); kl.setMath(ast); LocalParameter lp = kl.createLocalParameter(); errors = d.checkInternalConsistency(); assertTrue( errors == 1 ); assertTrue( d.getError(0).getErrorId() == 21172 ); lp.setId("pp"); d.getErrorLog().clearLog(); errors = d.checkInternalConsistency(); assertTrue( errors == 0 ); d = null; }
//=============================================================================== // // // Helper functions for writing/validating the given SBML documents. // // //=============================================================================== /** * * Validates the given SBMLDocument. * * This function is based on validateSBML.cpp implemented by * Sarah Keating, Ben Bornstein, and Michael Hucka. * */ private static bool validateExampleSBML(SBMLDocument sbmlDoc) { if (sbmlDoc == null) { Console.Error.WriteLine("validateExampleSBML: given a null SBML Document"); return false; } string consistencyMessages = ""; string validationMessages = ""; bool noProblems = true; int numCheckFailures = 0; int numConsistencyErrors = 0; int numConsistencyWarnings = 0; int numValidationErrors = 0; int numValidationWarnings = 0; // LibSBML 3.3 is lenient when generating models from scratch using the // API for creating objects. Once the whole model is done and before it // gets written out, it's important to check that the whole model is in // fact complete, consistent and valid. numCheckFailures = (int)sbmlDoc.checkInternalConsistency(); if (numCheckFailures > 0) { noProblems = false; for (int i = 0; i < numCheckFailures; i++) { SBMLError sbmlErr = sbmlDoc.getError(i); if (sbmlErr.isFatal() || sbmlErr.isError()) { ++numConsistencyErrors; } else { ++numConsistencyWarnings; } } consistencyMessages = sbmlDoc.getErrorLog().toString(); } // If the internal checks fail, it makes little sense to attempt // further validation, because the model may be too compromised to // be properly interpreted. if (numConsistencyErrors > 0) { consistencyMessages += "Further validation aborted."; } else { numCheckFailures = (int)sbmlDoc.checkConsistency(); if (numCheckFailures > 0) { noProblems = false; for (int i = 0; i < numCheckFailures; i++) { SBMLError sbmlErr = sbmlDoc.getError(i); if (sbmlErr.isFatal() || sbmlErr.isError()) { ++numValidationErrors; } else { ++numValidationWarnings; } } validationMessages = sbmlDoc.getErrorLog().toString(); } } if (noProblems) return true; else { if (numConsistencyErrors > 0) { Console.WriteLine("ERROR: encountered " + numConsistencyErrors + " consistency error" + (numConsistencyErrors == 1 ? "" : "s") + " in model '" + sbmlDoc.getModel().getId() + "'."); } if (numConsistencyWarnings > 0) { Console.WriteLine("Notice: encountered " + numConsistencyWarnings + " consistency warning" + (numConsistencyWarnings == 1 ? "" : "s") + " in model '" + sbmlDoc.getModel().getId() + "'."); } Console.WriteLine(); Console.WriteLine(consistencyMessages); if (numValidationErrors > 0) { Console.WriteLine("ERROR: encountered " + numValidationErrors + " validation error" + (numValidationErrors == 1 ? "" : "s") + " in model '" + sbmlDoc.getModel().getId() + "'."); } if (numValidationWarnings > 0) { Console.WriteLine("Notice: encountered " + numValidationWarnings + " validation warning" + (numValidationWarnings == 1 ? "" : "s") + " in model '" + sbmlDoc.getModel().getId() + "'."); } Console.WriteLine(); Console.WriteLine(validationMessages); return (numConsistencyErrors == 0 && numValidationErrors == 0); } }
public void test_internal_consistency_check_99915_alg() { SBMLDocument d = new SBMLDocument(2,4); long errors; Model m = d.createModel(); Rule r = new AlgebraicRule(2,4); d.setLevelAndVersion(2,1,false); r.setUnits("kk"); m.addRule(r); errors = d.checkInternalConsistency(); assertTrue( errors == 0 ); d = null; }