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.getNumCompartments() == 1 );
c = m.getCompartment(0);
assertTrue( c != null );
assertTrue( c.getId().equals( "cell") );
/* ud = c.getDerivedUnitDefinition();
assertTrue( ud.getNumUnits() == 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.getNumSpecies() == 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.getNumParameters() == 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.getNumUnits() == 0 );
assertTrue( m.getNumRules() == 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.getNumUnits() == 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.getNumReactions() == 2 );
r = m.getReaction(0);
assertTrue( r != null );
assertTrue( r.getId().equals( "in") );
assertTrue( r.getNumReactants() == 1 );
assertTrue( r.getNumProducts() == 1 );
sr = r.getReactant(0);
assertTrue( sr != null );
assertTrue( sr.getSpecies().equals( "X0") );
sr = r.getProduct(0);
assertTrue( sr != null );
assertTrue( sr.getSpecies().equals( "T" ) );
kl = r.getKineticLaw();
assertTrue( kl != null );
assertTrue( kl.getFormula().equals( "k1*X0") );
assertTrue( kl.getLocalParameterCount() == 1 );
r1 = (Reaction) kl.getParentSBMLObject();
assertTrue( r1 != null );
assertTrue( r1.getId().equals( "in") );
assertTrue( r1.getNumReactants() == 1 );
assertTrue( r1.getNumProducts() == 1 );
lp = kl.getLocalParameter(0);
assertTrue( lp != null );
assertTrue( lp.getId().equals( "k1") );
assertTrue( lp.getValue() == 0.1 );
kl = (KineticLaw) lp.getParentSBMLObject().getParentSBMLObject();
assertTrue( kl != null );
assertTrue( kl.getFormula().equals( "k1*X0") );
assertTrue( kl.getLocalParameterCount() == 1 );
r = m.getReaction(1);
assertTrue( r != null );
assertTrue( r.getId().equals( "out") );
assertTrue( r.getNumReactants() == 1 );
assertTrue( r.getNumProducts() == 1 );
sr = r.getReactant(0);
assertTrue( sr != null );
assertTrue( sr.getSpecies().equals( "T" ) );
sr = r.getProduct(0);
assertTrue( sr != null );
assertTrue( sr.getSpecies().equals( "X1") );
kl = r.getKineticLaw();
assertTrue( kl != null );
assertTrue( kl.getFormula().equals( "k2*T") );
assertTrue( kl.getLocalParameterCount() == 1 );
lp = kl.getLocalParameter(0);