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

Support for stochastic simulation added #54

Merged
merged 48 commits into from
Aug 14, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
3a5b7dc
fix issue in comparing stochastic test suite results
hemilpanchiwala Jul 21, 2020
17de582
resolve event trigger issue
hemilpanchiwala Jul 23, 2020
4db0231
resolve an issue while executing events
hemilpanchiwala Jul 24, 2020
65b83fc
add predefined seeds to pass the sstochastic tests properly
hemilpanchiwala Jul 25, 2020
fb49a71
add timeout for StochasticTestSuiteTest
hemilpanchiwala Jul 25, 2020
ba5f3c7
add print results while testing the stochastic test suite
hemilpanchiwala Jul 25, 2020
fb06675
travis fix
hemilpanchiwala Jul 25, 2020
05df68d
minor fix in CSVImporter
hemilpanchiwala Jul 25, 2020
2e05196
remove repetitive initializations in SBMLinterpreter
hemilpanchiwala Jul 26, 2020
52a7b1b
refactor SBMLinterpreter by separating the initialization to new Equa…
hemilpanchiwala Jul 27, 2020
5b51adb
minor variable names update
hemilpanchiwala Jul 27, 2020
ce25e93
updated documentation comments
matthiaskoenig Jul 28, 2020
4b8e3f2
minor fix
hemilpanchiwala Jul 28, 2020
05bc582
minor refactoring
hemilpanchiwala Jul 31, 2020
d185e5c
refactor SBMLTestSuiteRunnerWrapper
hemilpanchiwala Jul 31, 2020
5814243
minor fix
hemilpanchiwala Aug 1, 2020
70c5866
add output processed results as simulation proceeds in SimulatorExample
hemilpanchiwala Aug 1, 2020
a0b216e
add propertyChangeListener parameter to all solve() methods in solver
hemilpanchiwala Aug 2, 2020
fc5c20c
refactor CSVImporter and update changes as requested by @matthiaskoenig
hemilpanchiwala Aug 3, 2020
71832f3
update CSVImporter
hemilpanchiwala Aug 4, 2020
95b652d
fixed SED-ML urns
matthiaskoenig Aug 4, 2020
504a87d
fixed incorrect urn
matthiaskoenig Aug 4, 2020
ab70d55
remove unused code in CSVImporter
hemilpanchiwala Aug 4, 2020
482bfe6
merge branch refactor-interpreter into fern branch
hemilpanchiwala Aug 4, 2020
1a25548
update some requested changes | run BiGGTests that were ignored | sma…
hemilpanchiwala Aug 4, 2020
b645223
ran 2 ignored tests from SedMLExecutorTest
hemilpanchiwala Aug 4, 2020
596b03d
remove logs for NewGLPKSolver as Travis fails due to log size more th…
hemilpanchiwala Aug 5, 2020
f782b51
update processViolation log to print once
hemilpanchiwala Aug 5, 2020
6d60265
minor updates
hemilpanchiwala Aug 5, 2020
c40246f
minor fix print logs
hemilpanchiwala Aug 5, 2020
c62e786
update the constraint violation log
hemilpanchiwala Aug 5, 2020
07f082a
modify constraint violation logs
hemilpanchiwala Aug 5, 2020
ad4396c
minor updates
hemilpanchiwala Aug 5, 2020
182ca60
fixes the long log issues and added the log when constraint violation…
hemilpanchiwala Aug 5, 2020
6ebeea1
minor updates
hemilpanchiwala Aug 6, 2020
9b92496
update BiGG models download script and BiGGTest
hemilpanchiwala Aug 7, 2020
c40ef21
BiGGTest updated to verify reference solutions | minor fix in FBA | u…
hemilpanchiwala Aug 7, 2020
5c2adab
update multiple instances of SBMLinterpreter to one in FERN
hemilpanchiwala Aug 8, 2020
ddc9171
remove SBMLNetwork dependency from some classes by using SBMLinterpreter
hemilpanchiwala Aug 8, 2020
41fb960
minor updates
hemilpanchiwala Aug 8, 2020
56a1442
update changes requested by @zakharc
hemilpanchiwala Aug 9, 2020
2644424
refactor SBMLTestSuiteTest
hemilpanchiwala Aug 9, 2020
11d14ea
add method overloading for the solve() method in DESolver
hemilpanchiwala Aug 9, 2020
bbed49a
remove SBMLNetwork dependency from other classes updating with the SB…
hemilpanchiwala Aug 9, 2020
088d929
refactor StochasticTestSuiteTest
hemilpanchiwala Aug 10, 2020
7555e15
minor updates
hemilpanchiwala Aug 10, 2020
a3caac8
update changes requested by @shalinshah1993 | completely refactored S…
hemilpanchiwala Aug 13, 2020
3d5ef31
minor update
hemilpanchiwala Aug 14, 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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ liblpsolve55j_x64.so
jsbml.log

# BiGG models
src/test/resources/bigg/
src/test/resources/bigg/v1.5/

# sbml-test-suite
src/test/resources/sbml-test-suite/
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/org/simulator/fba/FluxBalanceAnalysis.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@
import org.sbml.jsbml.validator.ModelOverdeterminedException;
import org.simulator.sbml.SBMLinterpreter;
import org.simulator.sbml.astnode.ASTNodeValue;
import scpsolver.constraints.LinearBiggerThanEqualsConstraint;
import scpsolver.constraints.LinearConstraint;
import scpsolver.constraints.LinearEqualsConstraint;
import scpsolver.constraints.LinearSmallerThanEqualsConstraint;
import scpsolver.lpsolver.LinearProgramSolver;
import scpsolver.lpsolver.SolverFactory;
import scpsolver.problems.LinearProgram;
Expand Down Expand Up @@ -235,7 +238,7 @@ public FluxBalanceAnalysis(SBMLDocument doc)
for (Pair<String, Double> pair : species2Reaction.get(species.getId())) {
weights[reaction2Index.get(pair.getKey())] = pair.getValue();
}
if (species2Reaction.get(species.getId()).size() > 1) {
if (species.isSetBoundaryCondition() && !species.getBoundaryCondition()) {
problem.addConstraint(new LinearEqualsConstraint(weights, 0.0, "cnstrt_" + species.getId()));
hemilpanchiwala marked this conversation as resolved.
Show resolved Hide resolved
}
}
Expand Down
49 changes: 23 additions & 26 deletions src/test/java/org/simulator/fba/BiGGTest.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.simulator.fba;

import org.junit.Ignore;
import org.junit.Assert;
import org.sbml.jsbml.SBMLDocument;
import org.sbml.jsbml.SBMLReader;
import org.simulator.TestUtils;
Expand All @@ -13,9 +13,10 @@
import org.slf4j.LoggerFactory;

import java.io.*;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.zip.GZIPInputStream;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
Expand All @@ -27,10 +28,24 @@
public class BiGGTest {
private String resource;
private static final Logger logger = LoggerFactory.getLogger(TestUtils.class);
private static final double RESULT_DEVIATION = 1E-6d;

/**
* HashMap for storing the reference results with key as the model names.
hemilpanchiwala marked this conversation as resolved.
Show resolved Hide resolved
*/
private Map<String, Double> referenceResults;

@Before
public void setUp(){ }
public void setUp() throws IOException {
BufferedReader reader = new BufferedReader(new FileReader(TestUtils.getPathForTestResource("/bigg/bigg_reference_solutions.csv")));
hemilpanchiwala marked this conversation as resolved.
Show resolved Hide resolved
referenceResults = new HashMap<>();
String line;

while ((line = reader.readLine()) != null) {
String[] solution = line.split(",");
referenceResults.put(solution[0], Double.parseDouble(solution[1]));
}
}

/**
* Returns location of BiGG test model directory from environment variable.
Expand All @@ -51,34 +66,16 @@ public static Iterable<Object[]> data(){

// find all BiGG models (compressed .xml.gz files)
String biggPath = getBiGGModelPath();
System.out.println("BiGG models path: " + biggPath);
return TestUtils.findResources(biggPath, ".xml.gz", filter, skip, mvnResource);
logger.info("BiGG models path: " + biggPath);
return TestUtils.findResources(biggPath, ".xml", filter, skip, mvnResource);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks awkward. Please adjust this TestUtils method to throw a corresponding exception, e.g. if the resource is missing.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, I think there is no exception. Whenever there are no files with this extension, it sends empty Iterable object.

}

@Test
public void testFBA() throws Exception {
logger.info("--------------------------------------------------------");
logger.info(String.format("%s", resource));
System.out.println("BiGG Resource:" + resource);

if ((resource.endsWith("iAF987.xml.gz") ||
(resource.endsWith("iAF692.xml.gz")))) {
/*
BiGG Resource://home/mkoenig/git/sbscl-shalin/src/test/resources/bigg/v1.5/iAF987.xml.gz
glp_free: memory allocation error
Error detected in file env/alloc.c at line 72

Process finished with exit code 134 (interrupted by signal 6: SIGABRT)
*/
return;
}


// read SBML
InputStream is = new FileInputStream(resource);
GZIPInputStream gzis = new GZIPInputStream(is);

SBMLDocument doc = SBMLReader.read(gzis);
SBMLDocument doc = SBMLReader.read(new File(resource));
assertNotNull(doc);

FluxBalanceAnalysis solver = new FluxBalanceAnalysis(doc);
Expand All @@ -90,8 +87,8 @@ public void testFBA() throws Exception {
double[] fluxes = solver.getValues();
assertNotNull(fluxes);

//TODO: check against reference solution
is.close();
Assert.assertEquals(objectiveValue, referenceResults.get(Paths.get(resource).getFileName().toString()), RESULT_DEVIATION);

}

}
85 changes: 85 additions & 0 deletions src/test/resources/bigg/bigg_reference_solutions.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
RECON1.xml,0
Recon3D.xml,755.0032156
STM_v1_0.xml,0.4778336608
e_coli_core.xml,0.873921507
iAB_RBC_283.xml,2.935561467
iAF1260.xml,0.7367009389
iAF1260b.xml,0.7367009389
iAF692.xml,0.02678046755
iAF987.xml,0.04732237668
iAPECO1_1312.xml,0.9824784387
iAT_PLT_636.xml,0
iB21_1397.xml,0.9756145116
iBWG_1329.xml,0.9824784387
iCHOv1.xml,0.0323689716
iE2348C_1286.xml,0.9824784387
iEC042_1314.xml,0.9824784387
iEC55989_1330.xml,0.9824784387
iECABU_c1320.xml,0.9824784387
iECBD_1354.xml,0.9756145116
iECB_1328.xml,0.9824784387
iECDH10B_1368.xml,1.037477544
iECDH1ME8569_1439.xml,0.9824784387
iECD_1391.xml,0.9756145116
iECED1_1282.xml,0.9824634434
iECH74115_1262.xml,0.9824784387
iECIAI1_1343.xml,20.52222563
iECIAI39_1322.xml,0.9828409641
iECNA114_1301.xml,0.9824784387
iECO103_1326.xml,0.9824784387
iECO111_1330.xml,0.9824784387
iECO26_1355.xml,0.9824784387
iECOK1_1307.xml,0.9824784387
iECP_1309.xml,0.9824784387
iECS88_1305.xml,0.9824784387
iECSE_1348.xml,0.9824784387
iECSF_1327.xml,0.9824784387
iECSP_1301.xml,0.9824784387
iECUMN_1333.xml,0.9826920128
iECW_1372.xml,0.9824784387
iECs_1301.xml,0.9824784387
iEKO11_1354.xml,0.9824784387
iETEC_1333.xml,0.9824784387
iEcDH1_1363.xml,0.9824784387
iEcE24377_1341.xml,0.9824784387
iEcHS_1320.xml,0.9824784387
iEcSMS35_1347.xml,0.9824784387
iEcolC_1368.xml,0.9824784387
iG2583_1286.xml,0.9824784387
iHN637.xml,0.2244545421
iIT341.xml,0.6928126937
iJB785.xml,0.05390186747
iJN678.xml,0.06314983713
iJN746.xml,1.4
iJO1366.xml,0.9823718127
iJR904.xml,0.9219480951
iLB1027_lipid.xml,0.3596067078
iLF82_1304.xml,0.9824784387
iLJ478.xml,0.228406792
iML1515.xml,0.8769972144
iMM1415.xml,1.363427906
iMM904.xml,0.2878657037
iND750.xml,0.0973233759
iNF517.xml,0.04263460544
iNJ661.xml,0.05254980101
iNRG857_1313.xml,0.9824784387
iPC815.xml,0.2835583812
iRC1080.xml,6.156851476
iSB619.xml,0.1580502916
iSBO_1134.xml,0.3998801249
iSDY_1059.xml,0.9378903141
iSFV_1184.xml,0.8938577496
iSF_1195.xml,0.9145918469
iSFxv_1172.xml,0.8940890262
iSSON_1240.xml,0.9826450753
iS_1188.xml,0.8570768327
iSbBS512_1146.xml,0.9828118164
iUMN146_1321.xml,0.9824784387
iUMNK88_1353.xml,0.9824784387
iUTI89_1310.xml,0.9824784387
iWFL_1372.xml,0.9824784387
iY75_1357.xml,0.9824784387
iYL1228.xml,1.042637498
iYO844.xml,0.1179663893
iZ_1308.xml,0.9824784387
ic_1306.xml,1.03192228
4 changes: 2 additions & 2 deletions src/test/scripts/download_bigg_models.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ TEST_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

# download and extract the bigg models for testing
cd $TEST_DIR/../resources/bigg
mkdir -p $TEST_DIR/../resources/bigg
cd $TEST_DIR/../resources/bigg
wget $BIGG_MODELS_BASE_URL/$FILE_NAME
tar xzf $FILE_NAME
rm $FILE_NAME
cd $TEST_DIR/../resources/bigg/v1.5/
gunzip *.gz

# set environment variable
export BIGG_MODELS_PATH=${TEST_DIR}/../resources/bigg/v1.5
Expand Down