Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -2402,7 +2402,15 @@ public ODEDataBlock getODEDataBlock(VCDataIdentifier vcdID) throws DataAccessExc
public LangevinBatchResultSet getLangevinBatchResultSet(VCDataIdentifier vcdID) throws DataAccessException {
if (lg.isTraceEnabled()) lg.trace("DataSetControllerImpl.getLangevinBatchResultSet()");
try {
VCData simData = getVCData(vcdID);
VCData vcData = getVCData(vcdID);
if(!(vcData instanceof SimulationData)) {
return null;
}
SimulationData simData = (SimulationData)vcData;
if(!(simData.getIsIDAData())) {
return null;
}

ODEDataInfo odeDataInfo = new ODEDataInfo(vcdID.getOwner(), vcdID.getID(),
simData.getDataBlockTimeStamp(ODE_DATA, 0));
int keepAtMost = 10000;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package cbit.vcell.simdata;

import cbit.vcell.solver.ode.ODESimData;

import java.io.*;

public class LangevinSolverResultSet implements Serializable {

private final LangevinBatchResultSet raw;

public LangevinSolverResultSet(LangevinBatchResultSet raw) {
this.raw = raw;
}

// // safe getter that returns a deep copy, but I don't think we need it
// public LangevinBatchResultSet getLangevinBatchResultSetSafe() {
// return deepCopy(raw);
// }

// convenience getters
public ODESimData getAvg() {
return raw == null ? null : raw.getOdeSimDataAvg();
}
public ODESimData getMin() {
return raw == null ? null : raw.getOdeSimDataMin();
}
public ODESimData getMax() {
return raw == null ? null : raw.getOdeSimDataMax();
}
public ODESimData getStd() {
return raw == null ? null : raw.getOdeSimDataStd();
}
public ODESimData getClusterCounts() {
return raw == null ? null : raw.getOdeSimDataClusterCounts();
}
public ODESimData getClusterMean() {
return raw == null ? null : raw.getOdeSimDataClusterMean();
}
public ODESimData getClusterOverall() {
return raw == null ? null : raw.getOdeSimDataClusterOverall();
}

// helper functions
public boolean isAverageDataAvailable() {
return getAvg() != null &&
getMin() != null &&
getMax() != null &&
getStd() != null;
}
public boolean isClusterDataAvailable() {
return getClusterCounts() != null &&
getClusterMean() != null &&
getClusterOverall() != null;
}

private static LangevinBatchResultSet deepCopy(LangevinBatchResultSet original) {
if (original == null) {
return null;
}
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(bos);
out.writeObject(original);
out.flush();

ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(bos.toByteArray()));
return (LangevinBatchResultSet) in.readObject();

} catch (ClassNotFoundException | IOException e) {
throw new RuntimeException("Deep copy failed", e);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class ODEDataManager implements DataManager {
private VCDataIdentifier vcDataIdentifier = null;
private ODESolverResultSet odeSolverResultSet = null;
private NFSimMolecularConfigurations nFSimMolecularConfigurations = null;
private LangevinBatchResultSet langevinBatchResultSet = null;
private LangevinSolverResultSet langevinSolverResultSet = null;
private OutputContext outputContext = null;

public OutputContext getOutputContext() {
Expand Down Expand Up @@ -180,7 +180,11 @@ private void connect() throws DataAccessException {
// clone, so we can operate safely on it (adding/removing user-defined functions) - real remote data is being cached...
odeSolverResultSet = new ODESimData(getVCDataIdentifier(),getVCDataManager().getODEData(getVCDataIdentifier()));
nFSimMolecularConfigurations = getVCDataManager().getNFSimMolecularConfigurations(getVCDataIdentifier());
// langevinBatchResultSet = getVCDataManager().getLangevinBatchResultSet(getVCDataIdentifier());
LangevinBatchResultSet raw = getVCDataManager().getLangevinBatchResultSet(getVCDataIdentifier());
langevinSolverResultSet = new LangevinSolverResultSet(raw); // may be null
if( langevinSolverResultSet.isAverageDataAvailable()) {
odeSolverResultSet = langevinSolverResultSet.getAvg();
}
}

private void addOutputFunction(AnnotatedFunction function, ODESolverResultSet odeRS) {
Expand Down
16 changes: 11 additions & 5 deletions vcell-core/src/main/java/cbit/vcell/simdata/SimulationData.java
Original file line number Diff line number Diff line change
Expand Up @@ -639,11 +639,17 @@ public synchronized File getJobFunctionsFile() throws FileNotFoundException {



public synchronized boolean getIsODEData() throws DataAccessException {
refreshLogFile();
return isODEData;
}

public synchronized boolean getIsODEData() throws DataAccessException {
refreshLogFile();
return isODEData;
}
public synchronized boolean getIsIDAData() throws DataAccessException {
refreshLogFile();
return odeIdentifier.equals(IDA_DATA_IDENTIFIER);
}
public String getDataIdentifierSafe() {
return new String(odeIdentifier);
}

private long getLastModified(File pdeFile, File zipFile) throws IOException {
if (zipFile == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ public class LangevinResultsReadTest {
private static File langevin_input_file;
private static File messaging_config_file;

private static File euler_log_file;
private static File euler_ode_file;

// results for first task in the batch, named to match single run file (ending in "_") ex: SimID_303404574_0_
private static File ida_0_file;
// log produced by the solver for first task in the batch, named using the normal convention ex: SimID_303404574_0_0.log
Expand All @@ -56,6 +59,8 @@ public class LangevinResultsReadTest {
// SimID_303404574_0_.ida
private static File log_data_file;

// resource location of files for various test cases
private static String resourceBase = null;

@BeforeAll
public static void setUp() throws IOException {
Expand All @@ -71,6 +76,7 @@ public static void setUp() throws IOException {
throw new IOException("Failed to create subdirectory: " + localSimDir.getAbsolutePath());
}

resourceBase = "cbit/vcell/simdata/langevin/batch/";
functions_file = copyToPrimaryDir("SimID_303404574_0_.functions");
ida_0_file = copyToPrimaryDir("SimID_303404574_0_.ida"); // results for batch run0 (or for single run)
log_0_file = copyToPrimaryDir("SimID_303404574_0_0.log"); // langevin-made log for run 0
Expand All @@ -87,6 +93,11 @@ public static void setUp() throws IOException {
ida_min_file = copyToPrimaryDir("SimID_303404574_0__Min.ida");
ida_std_file = copyToPrimaryDir("SimID_303404574_0__Std.ida");

resourceBase = "cbit/vcell/simdata/langevin/euler/";
euler_log_file = copyToPrimaryDir("SimID_303690651_0_.log");
euler_ode_file = copyToPrimaryDir("SimID_303690651_0_.ode");


// ida_1_File = File.createTempFile("SimID_284673710_0_", ".ida");
// Resources.asByteSource(Resources.getResource("cbit/vcell/simdata/SimID_284673710_0_.ida"))
// .copyTo(com.google.common.io.Files.asByteSink(ida_1_File));
Expand All @@ -102,7 +113,7 @@ public static void tearDown() {


@Test
public void testReadData() throws IOException, DataAccessException, CacheException {
public void testReadDataLangevinBatch() throws IOException, DataAccessException, CacheException {

String simID = "303404574";
KeyValue key = new KeyValue(simID);
Expand All @@ -111,10 +122,13 @@ public void testReadData() throws IOException, DataAccessException, CacheExcepti

VCDataIdentifier vCDataIdentifier = new VCSimulationDataIdentifier(vcSimID, 0);
VCData vcData = new SimulationData(vCDataIdentifier, primaryDir, localSimDir, null);
SimulationData simData = (SimulationData)vcData;
String identifier = simData.getDataIdentifierSafe();
assertTrue(identifier.equals(SimDataConstants.IDA_DATA_IDENTIFIER), "Langevin simulation should be IDA data");
assertFalse(identifier.equals(SimDataConstants.ODE_DATA_IDENTIFIER), "Langevin simulation should not be ODE data");

Cachetable aCacheTable = new Cachetable(10 * Cachetable.minute, 100000);
aCacheTable.put(vCDataIdentifier, vcData);

DataSetControllerImpl dataSetControllerImpl = new DataSetControllerImpl(aCacheTable, primaryDir, localSimDir);

LangevinBatchResultSet lbrs = dataSetControllerImpl.getLangevinBatchResultSet(vCDataIdentifier);
Expand Down Expand Up @@ -143,6 +157,31 @@ public void testReadData() throws IOException, DataAccessException, CacheExcepti

}

// we should not try to read euler results using LangevinBatchResultSet
@Test
public void testReadDataEulerBatch() throws IOException, DataAccessException, CacheException {

String simID = "303690651";
KeyValue key = new KeyValue(simID);
User usr = new User("temp",key);
VCSimulationIdentifier vcSimID = new VCSimulationIdentifier(key, usr);

VCDataIdentifier vCDataIdentifier = new VCSimulationDataIdentifier(vcSimID, 0);
VCData vcData = new SimulationData(vCDataIdentifier, primaryDir, localSimDir, null);
SimulationData simData = (SimulationData)vcData;
String identifier = simData.getDataIdentifierSafe();
assertFalse(identifier.equals(SimDataConstants.IDA_DATA_IDENTIFIER), "Langevin simulation should not be IDA data");
assertTrue(identifier.equals(SimDataConstants.ODE_DATA_IDENTIFIER), "Langevin simulation should be ODE data");

Cachetable aCacheTable = new Cachetable(10 * Cachetable.minute, 100000);
aCacheTable.put(vCDataIdentifier, vcData);
DataSetControllerImpl dataSetControllerImpl = new DataSetControllerImpl(aCacheTable, primaryDir, localSimDir);

LangevinBatchResultSet lbrs = dataSetControllerImpl.getLangevinBatchResultSet(vCDataIdentifier);
assertNull(lbrs, "Result set should be null for Euler data when read as LangevinBatchResultSet");

}

// @Test
// public void testRead() throws IOException {
//
Expand All @@ -167,7 +206,7 @@ private static void deleteRecursively(File file) {

private static File copyToPrimaryDir(String resourceName) throws IOException {
File out = new File(primaryDir, resourceName);
Resources.asByteSource(Resources.getResource("cbit/vcell/simdata/langevin/batch/" + resourceName))
Resources.asByteSource(Resources.getResource(resourceBase + resourceName))
.copyTo(com.google.common.io.Files.asByteSink(out));
return out;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ODEData logfile
CompactODEData binary format version 1
SimID_303690651_0_.ode
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<SimulationTask xmlns="http://sourceforge.net/projects/vcell/vcml" TaskId="0" JobIndex="0" isPowerUser="false">
<MathDescription Name="unnamed_generated">
<Constant Name="_F_">96485.3321</Constant>
<Constant Name="_F_nmol_">9.64853321E-5</Constant>
<Constant Name="_K_GHK_">1.0E-9</Constant>
<Constant Name="_N_pmol_">6.02214179E11</Constant>
<Constant Name="_PI_">3.141592653589793</Constant>
<Constant Name="_R_">8314.46261815</Constant>
<Constant Name="_T_">300.0</Constant>
<Constant Name="EmptySet_init_mole_litre_1">1.0</Constant>
<Constant Name="k4">180.0</Constant>
<Constant Name="k4prime">0.018</Constant>
<Constant Name="k6">1.0</Constant>
<Constant Name="K_millivolts_per_volt">1000.0</Constant>
<Constant Name="kappa">0.015</Constant>
<Constant Name="KMOLE">0.001660538783162726</Constant>
<Constant Name="Size_cell">1.0</Constant>
<Constant Name="u_init_mole_litre_1">0.0</Constant>
<Constant Name="v_init_mole_litre_1">0.0</Constant>
<VolumeVariable Name="u" Domain="Compartment" />
<VolumeVariable Name="v" Domain="Compartment" />
<Function Name="alpha">(k4prime / k4)</Function>
<Function Name="EmptySet" Domain="Compartment">(K_EmptySet_total / Size_cell)</Function>
<Function Name="K_EmptySet_total" Domain="Compartment">(Size_cell * EmptySet_init_mole_litre_1)</Function>
<Function Name="K_s_z_total" Domain="Compartment">(Size_cell * s_z_init_mole_litre_1)</Function>
<Function Name="LumpedJ_r0" Domain="Compartment">((k4 * (v - u) * (alpha + pow(u,2.0))) - (k6 * u))</Function>
<Function Name="LumpedJ_r1" Domain="Compartment">(kappa - (k6 * u))</Function>
<Function Name="s_z" Domain="Compartment">(K_s_z_total / Size_cell)</Function>
<Function Name="s_z_init_mole_litre_1" Domain="Compartment">(v_init_mole_litre_1 - u_init_mole_litre_1)</Function>
<CompartmentSubDomain Name="Compartment">
<BoundaryType Boundary="Xm" Type="Value" />
<BoundaryType Boundary="Xp" Type="Value" />
<BoundaryType Boundary="Ym" Type="Value" />
<BoundaryType Boundary="Yp" Type="Value" />
<BoundaryType Boundary="Zm" Type="Value" />
<BoundaryType Boundary="Zp" Type="Value" />
<OdeEquation Name="u" SolutionType="Unknown">
<Rate>(LumpedJ_r0 / Size_cell)</Rate>
<Initial>u_init_mole_litre_1</Initial>
</OdeEquation>
<OdeEquation Name="v" SolutionType="Unknown">
<Rate>(LumpedJ_r1 / Size_cell)</Rate>
<Initial>v_init_mole_litre_1</Initial>
</OdeEquation>
</CompartmentSubDomain>
<Version Name="unnamed_generated" KeyValue="164204547" BranchId="164138400" Archived="0" Date="15-Aug-2019 17:46:00" FromVersionable="false">
<Owner Name="danv" Identifier="26766043" />
<GroupAccess Type="1" />
</Version>
</MathDescription>
<Simulation Name="Copy of Copy of Simulation0">
<SolverTaskDescription TaskType="Unsteady" UseSymbolicJacobian="false" Solver="Forward Euler (First Order, Fixed Time Step)">
<TimeBound StartTime="0.0" EndTime="100.0" />
<TimeStep DefaultTime="0.1" MinTime="1.0E-8" MaxTime="1.0" />
<ErrorTolerance Absolut="1.0E-9" Relative="1.0E-9" />
<OutputOptions KeepEvery="1" KeepAtMost="1000" />
<NumberProcessors>1</NumberProcessors>
</SolverTaskDescription>
<MathOverrides />
<Version Name="Copy of Copy of Simulation0" KeyValue="303690651" BranchId="303690652" Archived="0" Date="03-Feb-2026 21:49:49" FromVersionable="false">
<Owner Name="danv" Identifier="26766043" />
<GroupAccess Type="1" />
</Version>
</Simulation>
<Geometry Name="Compartmental1134096228" Dimension="0">
<Extent X="10.0" Y="10.0" Z="10.0" />
<Origin X="0.0" Y="0.0" Z="0.0" />
<SubVolume Name="Compartment" Handle="0" Type="Compartmental" KeyValue="164138398" />
<Version Name="Compartmental1134096228" KeyValue="164138394" BranchId="164138395" Archived="0" Date="14-Aug-2019 23:06:24" FromVersionable="false">
<Owner Name="danv" Identifier="26766043" />
<GroupAccess Type="1" />
</Version>
</Geometry>
</SimulationTask>
Loading