Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GSoC - SBML L3V2 models support with some other bug fixes #48

Merged
merged 67 commits into from
Jul 3, 2020
Merged
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
70b1960
updated deprecated isFast() method to isSetFast() for reaction
hemilpanchiwala Jun 6, 2020
17cf2a2
resolve some SBML L3V2 simulation issues
hemilpanchiwala Jun 6, 2020
37f68f9
format SBMLinterpreter, no code change
hemilpanchiwala Jun 6, 2020
ed49ab0
fix fast reaction issue
hemilpanchiwala Jun 6, 2020
b3c0221
make tolerances more strict for integrator
hemilpanchiwala Jun 7, 2020
011e216
add testing with FluxBalanceAnalysis for fbc models
hemilpanchiwala Jun 8, 2020
cd14a3c
add log for test case of SBML Test Suite
hemilpanchiwala Jun 8, 2020
7280d2b
add FluxBalanceAnalysis for fbc models in the SBML Test Runner wrapper
hemilpanchiwala Jun 8, 2020
88a3817
small bugfix
hemilpanchiwala Jun 8, 2020
4b10ef5
resolve small issue
hemilpanchiwala Jun 8, 2020
f4ebacb
add the logical operator cases to computeDoubleValue for ASTNode
hemilpanchiwala Jun 8, 2020
58020be
add active objective function variable in FluxBalanceAnalysis
hemilpanchiwala Jun 8, 2020
69db129
change the absTol and relTol for the simulation
hemilpanchiwala Jun 10, 2020
287abf8
solve issue #42
hemilpanchiwala Jun 10, 2020
8667b81
solve issue #41
hemilpanchiwala Jun 10, 2020
03f91b6
update the calculate nodes method in ASTNodeInterpreter class
hemilpanchiwala Jun 11, 2020
690a0d9
update requested changes in commit 287abf8
hemilpanchiwala Jun 11, 2020
33222b1
add rateOf method
hemilpanchiwala Jun 13, 2020
42483ef
minor fix
hemilpanchiwala Jun 13, 2020
5a4aa68
minor fix and add comments
hemilpanchiwala Jun 13, 2020
b73b293
add changeRate variable to SBMLinterpreter class
hemilpanchiwala Jun 15, 2020
7fdd3eb
resolve rateOf at time t=0 in issue #43
hemilpanchiwala Jun 16, 2020
ff1aa32
add call computeDerivatives before process rules
hemilpanchiwala Jun 16, 2020
3c680b9
add constantHash to avoid repetitive checking | ref-issue #43
hemilpanchiwala Jun 16, 2020
243cf9f
minor fix to only calculate changeRate by ignoring processing rules |…
hemilpanchiwala Jun 17, 2020
7380c6d
add delay as paramter for computeDoubleValue in FunctionValue class |…
hemilpanchiwala Jun 17, 2020
e92ac14
resolve failed test case 1217, 1218 | ref issue #47
hemilpanchiwala Jun 18, 2020
cff8ae0
minor changes requested in last commit
hemilpanchiwala Jun 18, 2020
fe00ac8
format ASTNodeInterpreter, no code change
hemilpanchiwala Jun 18, 2020
6dc967c
format all classes of SBSCL | no code changes
hemilpanchiwala Jun 19, 2020
9fcfe55
format fix
hemilpanchiwala Jun 19, 2020
0fab3d5
documentation comp simulator
matthiaskoenig Jun 20, 2020
f488e10
better documentation of the SBMLTestSuiteWrapper
matthiaskoenig Jun 20, 2020
f0dd52a
Better documentation flux balance analysis and small improvement bugfix
matthiaskoenig Jun 20, 2020
939738e
update requested changes
hemilpanchiwala Jun 20, 2020
9e2d66c
fix issues in failing tests 1205, 1779, 1780 | ref issue #47
hemilpanchiwala Jun 20, 2020
bd69a57
update requested changes by @zakharc
hemilpanchiwala Jun 20, 2020
887ab7a
minor updates
hemilpanchiwala Jun 20, 2020
ac87f83
add template to .gitattributes for avoiding white space changes as su…
hemilpanchiwala Jun 21, 2020
50b820c
fix issues 1666, 1667, 1668 | ref issue #47
hemilpanchiwala Jun 21, 2020
eef6410
fix issues in failing tests 1220, 1308, 1463 | ref issue #47 | some j…
hemilpanchiwala Jun 22, 2020
511d793
fixes test case 1284 of SBML Test Suite | ref issue #47
hemilpanchiwala Jun 22, 2020
429e29f
small code improvement, saving if check
matthiaskoenig Jun 25, 2020
5c2bfc6
moving integer within block
matthiaskoenig Jun 25, 2020
e74952f
moved related methods together
matthiaskoenig Jun 25, 2020
1e3181d
refactored the updateSpeciesConcentration method
hemilpanchiwala Jun 25, 2020
4ce674a
minor comment fix
hemilpanchiwala Jun 25, 2020
8b112e9
add observer for getting timepoints and processed results
hemilpanchiwala Jun 26, 2020
8b21f87
minor updates requested in last commit
hemilpanchiwala Jun 27, 2020
7ea3fb9
update the column_name Time to time in results
hemilpanchiwala Jun 27, 2020
9fb3726
fix local paths
hemilpanchiwala Jun 27, 2020
0677654
minor bug fix | rules should be processed after processing events at …
hemilpanchiwala Jun 27, 2020
73ec69f
made tolerances strict by 0.1 | add delay property to SpeciesReferenc…
hemilpanchiwala Jun 28, 2020
6810ebd
update conversion factors after processing initialAssignments | passe…
hemilpanchiwala Jun 28, 2020
3ca0311
handle FBA tests with no feasible solution
hemilpanchiwala Jun 29, 2020
665c275
minor fix
hemilpanchiwala Jun 29, 2020
3aecf34
made tolerances more strict by 0.1 | passes test case 1395 | ref issu…
hemilpanchiwala Jun 30, 2020
263b184
make event object null if no rules | passes test case 1602 | ref issu…
hemilpanchiwala Jun 30, 2020
bfa4942
fix GLPK issue
hemilpanchiwala Jul 1, 2020
9774a2a
skip failed SBMLTestSuite tests
hemilpanchiwala Jul 1, 2020
23377b1
add reason for adding the NewGLPKSolver class
hemilpanchiwala Jul 1, 2020
b03756a
increase timeout for test to 60 seconds in maven
hemilpanchiwala Jul 1, 2020
5d092d0
fix small bug while simulating models with fast reactions
hemilpanchiwala Jul 2, 2020
9939e40
update the failed tests array
hemilpanchiwala Jul 2, 2020
d5b8e9f
update changes as requested by @matthiaskoenig
hemilpanchiwala Jul 3, 2020
f0975c1
minor indentation fix
hemilpanchiwala Jul 3, 2020
8d59935
remove @Ignore tag in FluxBalanceAnalysisTest
hemilpanchiwala Jul 3, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/main/java/org/simulator/About.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

/**
* This class displays a short about message for this library.
*
*
* @author Andreas Dräger
* @version $Rev$
* @since 1.1
Expand Down Expand Up @@ -67,5 +67,4 @@ public static void main(String[] args) {
System.out.println(message);
}
}

}
122 changes: 62 additions & 60 deletions src/main/java/org/simulator/comp/CompSimulator.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,78 +16,80 @@
import java.io.File;
import java.io.IOException;


/**
* Class for simulating comp models.
*
* TODO: support different simulation types (FBA, stochastic), currently limited to ode
* Class for simulating models encoded in the SBML comp package.
* <p>
* This class allows to simulate models encoded in the SBML hierarchical model
* composition package comp (http://sbml.org/Documents/Specifications/SBML_Level_3/Packages/comp).
* The models are simulated by applying model flattening, i.e., reducing the hierarchical
* models to standard (flat) SBML models.
*
* This class currently is limited to SBML core models (ODE).
* TODO: support additional simulations (FBA, stochastic)
*
* @author Shalin Shah, atthias König
* @author Shalin Shah, Matthias König
* @version $Rev$
* @since 1.5
*/
public class CompSimulator {
private static Logger logger = Logger.getLogger(CompSimulator.class.getName());
private SBMLDocument doc;
private SBMLDocument docFlat;

public CompSimulator(File file) throws IOException, XMLStreamException {

// Read original SBML file and add meta-info about original ID
doc = SBMLReader.read(file);
doc = AddMetaInfo.putOrigId(doc);

// Flatten the model extra information in userObjects
CompFlatteningConverter compFlatteningConverter = new CompFlatteningConverter();
docFlat = compFlatteningConverter.flatten(doc);
assert docFlat != null;
private static Logger logger = Logger.getLogger(CompSimulator.class.getName());
private SBMLDocument doc;
private SBMLDocument docFlat;

hemilpanchiwala marked this conversation as resolved.
Show resolved Hide resolved
public CompSimulator(File file) throws IOException, XMLStreamException {

// Read original SBML file and add meta-info about original ID
doc = SBMLReader.read(file);
doc = AddMetaInfo.putOrigId(doc);

// Flatten the model extra information in userObjects
CompFlatteningConverter compFlatteningConverter = new CompFlatteningConverter();
docFlat = compFlatteningConverter.flatten(doc);
assert docFlat != null;
hemilpanchiwala marked this conversation as resolved.
Show resolved Hide resolved
}

public SBMLDocument getDoc() {
return doc;
}

public SBMLDocument getDocFlat() {
hemilpanchiwala marked this conversation as resolved.
Show resolved Hide resolved
return docFlat;
}

hemilpanchiwala marked this conversation as resolved.
Show resolved Hide resolved
public MultiTable solve(double timeEnd, double stepSize)
throws DerivativeException, ModelOverdeterminedException {
DESSolver solver = new RosenbrockSolver();
return solve(timeEnd, stepSize, solver);
}

hemilpanchiwala marked this conversation as resolved.
Show resolved Hide resolved
public MultiTable solve(double timeEnd, double stepSize, DESSolver solver)
throws DerivativeException, ModelOverdeterminedException {
solver.setStepSize(stepSize);

// Execute the model using solver
hemilpanchiwala marked this conversation as resolved.
Show resolved Hide resolved
Model model = docFlat.getModel();
SBMLinterpreter interpreter = new SBMLinterpreter(model);
if (solver instanceof AbstractDESSolver) {
((AbstractDESSolver) solver).setIncludeIntermediates(false);
}

// Compute the numerical solution of the initial value problem
// TODO: Rel-Tolerance, Abs-Tolerance.
MultiTable solution = solver.solve(interpreter, interpreter.getInitialValues(), 0d, timeEnd);

public SBMLDocument getDoc() {
return doc;
}

public SBMLDocument getDocFlat() {
return docFlat;
}

public MultiTable solve(double timeEnd, double stepSize) throws DerivativeException, ModelOverdeterminedException {
DESSolver solver = new RosenbrockSolver();
return solve(timeEnd, stepSize, solver);
}
// If columns other than time exists map ids back to original
if (solution.getColumnCount() > 1) {
logger.warn("Output contains objects, trying to plot and extract ids:\n");

public MultiTable solve(double timeEnd, double stepSize, DESSolver solver) throws DerivativeException, ModelOverdeterminedException {
solver.setStepSize(stepSize);

// Execute the model using solver
Model model = docFlat.getModel();

SBMLinterpreter interpreter = new SBMLinterpreter(model);
if (solver instanceof AbstractDESSolver) {
((AbstractDESSolver) solver).setIncludeIntermediates(false);
}

// Compute the numerical solution of the initial value problem
// TODO: Rel-Tolerance, Abs-Tolerance.
MultiTable solution = solver.solve(interpreter, interpreter.getInitialValues(), 0d, timeEnd);

// If columns other than time exists map ids back to original
if(solution.getColumnCount() > 1) {
logger.warn("Output contains objects, trying to plot and extract ids:\n");
// Map the output ids back to the original model
for (int index = 1; index < solution.getColumnCount(); index++) {
AbstractTreeNode node = (AbstractTreeNode) doc.getElementBySId(solution.getColumnIdentifier(index));

if(node.isSetUserObjects()) {
System.out.println("flat id: " + solution.getColumnIdentifier(index) + "\t old id:" +
node.getUserObject(AddMetaInfo.ORIG_ID) + "\t model enclosing it: " + node.getUserObject(AddMetaInfo.MODEL_ID));
}
}
// Map the output ids back to the original model
for (int index = 1; index < solution.getColumnCount(); index++) {
AbstractTreeNode node = (AbstractTreeNode) doc.getElementBySId(solution.getColumnIdentifier(index));
if (node.isSetUserObjects()) {
System.out.println("flat id: " + solution.getColumnIdentifier(index) + "\t old id:" + node.getUserObject(AddMetaInfo.ORIG_ID) + "\t model enclosing it: " + node.getUserObject(AddMetaInfo.MODEL_ID));
hemilpanchiwala marked this conversation as resolved.
Show resolved Hide resolved
}

return solution;
}
}

return solution;
}
}
21 changes: 9 additions & 12 deletions src/main/java/org/simulator/examples/BiomodelsExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
/**
* This class can test the simulation of all models from
* <a href="http://www.ebi.ac.uk/biomodels-main/" target="_blank">BioModels database</a>.
*
*
* @author Roland Keller
* @version $Rev$
*/
Expand All @@ -52,6 +52,7 @@ public class BiomodelsExample {

/**
* Tests the models of biomodels.org using the {@link RosenbrockSolver} as integrator
*
* @param file
* @param from
* @param to
Expand Down Expand Up @@ -89,14 +90,10 @@ public static void testBiomodels(String file, int from, int to)
try {
double time1 = System.nanoTime();
SBMLinterpreter interpreter = new SBMLinterpreter(model);

if ((solver != null) && (interpreter != null)) {
solver.setStepSize(0.01);

// solve
solver.solve(interpreter,
interpreter.getInitialValues(), 0, 10);

solver.solve(interpreter, interpreter.getInitialValues(), 0, 10);
if (solver.isUnstable()) {
logger.warning("unstable!");
errors++;
Expand All @@ -116,27 +113,27 @@ public static void testBiomodels(String file, int from, int to)
}
System.out.println("Models: " + nModels);
System.out.println("Models with errors in simulation: " + errors);
System.out.println("Models with correct simulation: "
+ (nModels - errors));
for(int slowModel: slowModels) {
System.out.println("Models with correct simulation: " + (nModels - errors));
for (int slowModel : slowModels) {
System.out.println("Slow: #" + slowModel);
}
}


/**
* * Input:
* <ol>
* <li>directory with models (containing the biomodels),
* <li>first model to be simulated,
* <li>last model to be simulated,
* </ol>
*
*
* @param args
* @throws IOException
* @throws URISyntaxException
*/
public static void main(String[] args) throws IOException,URISyntaxException {
public static void main(String[] args)
throws IOException, URISyntaxException {
testBiomodels(args[0], Integer.parseInt(args[1]), Integer.parseInt(args[2]));
}

}
Loading