Skip to content

Commit c212311

Browse files
committed
properly read the cluster statistics, extending the test
1 parent 0c430ee commit c212311

4 files changed

Lines changed: 53 additions & 83 deletions

File tree

vcell-core/src/main/java/cbit/vcell/simdata/DataSetControllerImpl.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2430,21 +2430,21 @@ public LangevinBatchResultSet getLangevinBatchResultSet(VCDataIdentifier vcdID)
24302430
lbrs.setOdeSimDataStd(odeSimData_std);
24312431
}
24322432

2433-
// TODO: call ODESimData readCSVDataFile(VCDataIdentifier vcdId, File csvFile) to read cluster analysis results
2434-
// File counts = simData.getLangevinFile(LangevinFileType.ClusterCounts);
2435-
// if (counts != null && counts.exists()) {
2436-
// lbrs.setClusterCounts(readCSVDataFile(vcdID, counts));
2437-
// }
2438-
//
2439-
// File mean = simData.getLangevinFile(LangevinFileType.ClusterMean);
2440-
// if (mean != null && mean.exists()) {
2441-
// lbrs.setClusterMeans(readCSVDataFile(vcdID, mean));
2442-
// }
2443-
//
2444-
// File overall = simData.getLangevinFile(LangevinFileType.ClusterOverall);
2445-
// if (overall != null && overall.exists()) {
2446-
// lbrs.setClusterOverall(readCSVDataFile(vcdID, overall));
2447-
// }
2433+
File counts = simData.getLangevinFile(LangevinBatchResultSet.LangevinFileType.ClusterCounts);
2434+
if (counts != null && counts.exists()) {
2435+
ODESimData odeSimData_clusterCounts = ODESimData.readCSVDataFile(vcdID, counts);
2436+
lbrs.setOdeSimDataClusterCounts(odeSimData_clusterCounts);
2437+
}
2438+
File mean = simData.getLangevinFile(LangevinBatchResultSet.LangevinFileType.ClusterMean);
2439+
if (mean != null && mean.exists()) {
2440+
ODESimData odeSimData_clusterMean = ODESimData.readCSVDataFile(vcdID, mean);
2441+
lbrs.setOdeSimDataClusterMean(odeSimData_clusterMean);
2442+
}
2443+
File overall = simData.getLangevinFile(LangevinBatchResultSet.LangevinFileType.ClusterOverall);
2444+
if (overall != null && overall.exists()) {
2445+
ODESimData odeSimData_clusterOverall = ODESimData.readCSVDataFile(vcdID, overall);
2446+
lbrs.setOdeSimDataClusterOverall(odeSimData_clusterOverall);
2447+
}
24482448

24492449
return lbrs;
24502450
} catch (IOException e) {

vcell-core/src/main/java/cbit/vcell/simdata/LangevinBatchResultSet.java

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@
77

88
public class LangevinBatchResultSet implements Serializable {
99

10-
private ODEDataInfo odeDataInfo;
11-
private ODESimData odeSimDataAvg;
12-
private ODESimData odeSimDataMax;
13-
private ODESimData odeSimDataMin;
14-
private ODESimData odeSimDataStd;
10+
private ODEDataInfo odeDataInfo = null;
11+
private ODESimData odeSimDataAvg = null;
12+
private ODESimData odeSimDataMax = null;
13+
private ODESimData odeSimDataMin = null;
14+
private ODESimData odeSimDataStd = null;
15+
private ODESimData odeSimDataClusterCounts = null;
16+
private ODESimData odeSimDataClusterMean = null;
17+
private ODESimData odeSimDataClusterOverall = null;
1518

1619
public enum LangevinFileType {
1720

@@ -41,22 +44,9 @@ public String buildFilename(String baseName) {
4144
}
4245
}
4346

44-
public LangevinBatchResultSet(
45-
ODEDataInfo odeDataInfo,
46-
ODESimData odeSimDataAvg,
47-
ODESimData odeSimDataMax,
48-
ODESimData odeSimDataMin,
49-
ODESimData odeSimDataStd) {
47+
public LangevinBatchResultSet(ODEDataInfo odeDataInfo) {
5048

5149
this.odeDataInfo = odeDataInfo;
52-
this.odeSimDataAvg = odeSimDataAvg;
53-
this.odeSimDataMax = odeSimDataMax;
54-
this.odeSimDataMin = odeSimDataMin;
55-
this.odeSimDataStd = odeSimDataStd;
56-
}
57-
58-
public LangevinBatchResultSet(ODEDataInfo odeDataInfo) {
59-
this(odeDataInfo, null, null, null, null);
6050
}
6151

6252
public ODEDataInfo getOdeDataInfo() {
@@ -90,5 +80,20 @@ public ODESimData getOdeSimDataStd() {
9080
public void setOdeSimDataStd(ODESimData odeSimDataStd) {
9181
this.odeSimDataStd = odeSimDataStd;
9282
}
83+
84+
public ODESimData getOdeSimDataClusterCounts() { return odeSimDataClusterCounts; }
85+
public void setOdeSimDataClusterCounts(ODESimData odeSimDataClusterCounts) {
86+
this.odeSimDataClusterCounts = odeSimDataClusterCounts;
87+
}
88+
89+
public ODESimData getOdeSimDataClusterMean() { return odeSimDataClusterMean; }
90+
public void setOdeSimDataClusterMean(ODESimData odeSimDataClusterMean) {
91+
this.odeSimDataClusterMean = odeSimDataClusterMean;
92+
}
93+
94+
public ODESimData getOdeSimDataClusterOverall() { return odeSimDataClusterOverall; }
95+
public void setOdeSimDataClusterOverall(ODESimData odeSimDataClusterOverall) {
96+
this.odeSimDataClusterOverall = odeSimDataClusterOverall;
97+
}
9398
}
9499

vcell-core/src/main/java/cbit/vcell/solver/ode/ODESimData.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,6 @@ public void writeOut(DataOutputStream output) throws IOException {
408408
}
409409
}
410410

411-
// TODO: work in progress, untested
412411
public static ODESimData readCSVDataFile(VCDataIdentifier vcdId, File csvFile)
413412
throws DataAccessException {
414413

vcell-core/src/test/java/cbit/vcell/simdata/LangevinResultsReadTest.java

Lines changed: 14 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -87,25 +87,18 @@ public static void setUp() throws IOException {
8787
ida_min_file = copyToPrimaryDir("SimID_303404574_0__Min.ida");
8888
ida_std_file = copyToPrimaryDir("SimID_303404574_0__Std.ida");
8989

90-
91-
92-
93-
// ida_0_File = File.createTempFile("SimID_284673710_0_", ".ida");
90+
// ida_1_File = File.createTempFile("SimID_284673710_0_", ".ida");
9491
// Resources.asByteSource(Resources.getResource("cbit/vcell/simdata/SimID_284673710_0_.ida"))
95-
// .copyTo(com.google.common.io.Files.asByteSink(ida_0_File));
92+
// .copyTo(com.google.common.io.Files.asByteSink(ida_1_File));
9693

9794
}
9895

9996
@AfterAll
10097
public static void tearDown() {
10198

10299
deleteRecursively(primaryDir);
103-
// ida_0_File.delete();
104100
// ida_1_File.delete();
105-
// ida_2_File.delete();
106-
// if (inputStream != null) {
107-
// inputStream.close();
108-
}
101+
}
109102

110103

111104
@Test
@@ -136,55 +129,28 @@ public void testReadData() throws IOException, DataAccessException, CacheExcepti
136129
ODESimData odeSimDataAvg = lbrs.getOdeSimDataAvg();
137130
assertNotNull(odeSimDataAvg, "Avg ODE data should be loaded");
138131
assertTrue(odeSimDataAvg.getMathName().contains(simID), "Avg ODE data mathName should contain the simulation ID");
139-
140132
// --- Minimal structural checks ---
141133
assertTrue(odeSimDataAvg.getDataColumnCount() > 0, "Avg ODE data should have at least one column");
142134
assertTrue(odeSimDataAvg.getRowCount() > 0, "Avg ODE data should have at least one row");
143135

136+
// Cluster Counts data loaded
137+
ODESimData odeSimDataClusterCounts = lbrs.getOdeSimDataClusterCounts();
138+
assertNotNull(odeSimDataClusterCounts, "Cluster Counts ODE data should be loaded");
139+
assertTrue(odeSimDataClusterCounts.getMathName().contains(simID), "Cluster Counts ODE data mathName should contain the simulation ID");
140+
// --- Minimal structural checks ---
141+
assertTrue(odeSimDataClusterCounts.getDataColumnCount() > 0, "Cluster Counts ODE data should have at least one column");
142+
assertTrue(odeSimDataClusterCounts.getRowCount() > 0, "Cluster Counts ODE data should have at least one row");
143+
144144
}
145145

146146
// @Test
147-
// @Disabled("Deprecated: postprocessing moved to solver")
148147
// public void testRead() throws IOException {
149148
//
150-
// // read the input data (3 .IDA files)
151-
// ODESolverResultSet osrs_0 = getOdeSolverResultSet(ida_0_File);
149+
// // read the input data
152150
// ODESolverResultSet osrs_1 = getOdeSolverResultSet(ida_1_File);
153-
// ODESolverResultSet osrs_2 = getOdeSolverResultSet(ida_2_File);
154-
//
155-
// Map<Integer, ODESolverResultSet> odeSolverResultSetMap = new LinkedHashMap<>();
156-
// odeSolverResultSetMap.put(0, osrs_0);
157-
// odeSolverResultSetMap.put(1, osrs_1);
158-
// odeSolverResultSetMap.put(2, osrs_2);
159-
//
160-
// LangevinPostProcessorInput lppInput = new LangevinPostProcessorInput(null, null);
161-
// lppInput.setFailed(false);
162-
// lppInput.setOdeSolverResultSetMap(odeSolverResultSetMap);
163-
//
164-
// // compute primary statistics
165-
// // note: LangevinPostProcessor is deprecated, but this test is kept for it contains some reusable code
166-
// LangevinPostProcessor lpp = new LangevinPostProcessor();
167-
// LangevinPostProcessorOutput lppOutput = lpp.postProcessLangevinResults(lppInput);
168-
//
169-
// assertFalse(lppOutput.isFailed(), "expected to not fail");
170-
// assertTrue(lppOutput.isMultiTrial(), "expected to be multi-trial");
171-
//
172-
// // get some timepoint for some variable
173-
// String name = osrs_0.getColumnDescriptions()[7].getName();
174-
// double anAverage = lppOutput.getAveragesResultSet().getRow(10)[7]; // TOTAL_MT0__Site1__state0
175-
// double aStd = lppOutput.getStdResultSet().getRow(10)[7];
176-
// double aMin = lppOutput.getMinResultSet().getRow(10)[7];
177-
// double aMax = lppOutput.getMaxResultSet().getRow(10)[7];
178-
//
179-
// // compare to what's expected
180-
// assertTrue("TOTAL_MT0__Site1__state0".contentEquals(name), "expecting column name 'TOTAL_MT0__Site1__state0', found: '" + name + "'");
181-
// assertTrue(anAverage == 21.0 ? true : false, "expecting 21.0, found " + anAverage);
182-
// assertTrue(aStd == 0.816496580927726 ? true : false, "expecting 0.816496580927726, found " + aStd);
183-
// assertTrue(aMin == 20.0 ? true : false, "expecting 20.0, found " + aMin);
184-
// assertTrue(aMax == 22.0 ? true : false, "expecting 22.0, found " + aMax);
151+
// assertNotNull(osrs_1, "Failed to read IDA file: " + ida_1_File.getAbsolutePath());
185152
// }
186153

187-
188154
private static void deleteRecursively(File file) {
189155
if (file == null || !file.exists()) {
190156
return;
@@ -206,7 +172,7 @@ private static File copyToPrimaryDir(String resourceName) throws IOException {
206172
return out;
207173
}
208174

209-
175+
// also see ODESimData.readIDADataFile()
210176
private static ODESolverResultSet getOdeSolverResultSet(File idaFile) throws IOException {
211177
ODESolverResultSet odeSolverResultSet = new ODESolverResultSet();
212178
FileInputStream inputStream = null;

0 commit comments

Comments
 (0)