Model m;
Compartment c;
Species s;
Parameter gp;
LocalParameter lp;
AssignmentRule ar;
Reaction r;
SpeciesReference sr;
KineticLaw kl;
UnitDefinition ud;
Reaction r1;
ListOf<Compartment> loc;
Compartment c1;
ListOf<Rule> lor;
AssignmentRule ar1;
ListOf<Parameter> lop;
Parameter p1;
ListOf<Species> los;
Species s1;
String filename = new String( DATA_FOLDER + "/libsbml-test-data/" );
filename += "l2v1-assignment.xml";
try {
d = reader.readSBML(filename);
} catch (IOException e) {
e.printStackTrace();
assert(false);
} catch (XMLStreamException e) {
e.printStackTrace();
assert(false);
}
System.out.println(" TestReadFromFile 5: reading done.");
assertTrue( d.getLevel() == 2 );
assertTrue( d.getVersion() == 1 );
m = d.getModel();
assertTrue( m != null );
assertTrue( m.getCompartmentCount() == 1 );
c = m.getCompartment(0);
assertTrue( c != null );
assertTrue( c.getId().equals( "cell") );
/* ud = c.getDerivedUnitDefinition();
assertTrue( ud.getUnitCount() == 1 );
assertTrue( ud.getUnit(0).getKind() == Kind.LITRE );
*/
loc = m.getListOfCompartments();
c1 = loc.get(0);
assertTrue( c1.equals(c) );
c1 = loc.get("cell");
assertTrue( c1.equals(c) );
assertTrue( m.getSpeciesCount() == 5 );
s = m.getSpecies(0);
assertTrue( s != null );
assertTrue( s.getId().equals( "X0" ) );
assertTrue( s.getCompartment().equals( "cell") );
assertTrue( s.getInitialConcentration() == 1.0 );
los = m.getListOfSpecies();
s1 = los.get(0);
assertTrue( s1.equals(s) );
s1 = los.get("X0");
assertTrue( s1.equals(s) );
s = m.getSpecies(1);
assertTrue( s != null );
assertTrue( s.getId().equals( "X1" ) );
assertTrue( s.getCompartment().equals( "cell") );
assertTrue( s.getInitialConcentration() == 0.0 );
s = m.getSpecies(2);
assertTrue( s != null );
assertTrue( s.getId().equals( "T" ) );
assertTrue( s.getCompartment().equals( "cell") );
assertTrue( s.getInitialConcentration() == 0.0 );
s = m.getSpecies(3);
assertTrue( s != null );
assertTrue( s.getId().equals( "S1" ) );
assertTrue( s.getCompartment().equals( "cell") );
assertTrue( s.getInitialConcentration() == 0.0 );
s = m.getSpecies(4);
assertTrue( s != null );
assertTrue( s.getId().equals( "S2" ) );
assertTrue( s.getCompartment().equals( "cell") );
assertTrue( s.getInitialConcentration() == 0.0 );
assertTrue( m.getParameterCount() == 1 );
gp = m.getParameter(0);
assertTrue( gp != null );
assertTrue( gp.getId().equals( "Keq") );
assertTrue( gp.getValue() == 2.5 );
lop = m.getListOfParameters();
p1 = lop.get(0);
assertTrue( p1.equals(gp) );
p1 = lop.get("Keq");
assertTrue( p1.equals(gp) );
/*
ud = gp.getDerivedUnitDefinition();
assertTrue( ud.getUnitCount() == 0 );
assertTrue( m.getRuleCount() == 2 );
*/
ar = (AssignmentRule) m.getRule(0);
assertTrue( ar != null );
assertTrue( ar.getVariable().equals( "S1" ) );
assertTrue( ar.getFormula().equals( "T/(1+Keq)") );
/*
ud = ar.getDerivedUnitDefinition();
assertTrue( ud.getUnitCount() == 2 );
assertTrue( ud.getUnit(0).getKind() == Kind.MOLE );
assertTrue( ud.getUnit(0).getExponent() == 1 );
assertTrue( ud.getUnit(1).getKind() == Kind.LITRE );
assertTrue( ud.getUnit(1).getExponent() == -1 );
*/
assertTrue( ar.containsUndeclaredUnits() == true );
lor = m.getListOfRules();
ar1 = (AssignmentRule) lor.get(0);
assertTrue( ar1.equals(ar) );
ar1 = (AssignmentRule) lor.get("S1");
assertTrue( ar1.equals(ar) );
ar = (AssignmentRule) m.getRule(1);
assertTrue( ar != null );
assertTrue( ar.getVariable().equals( "S2" ) );
assertTrue( ar.getFormula().equals( "Keq*S1") );
assertTrue( m.getReactionCount() == 2 );