use of org.vcell.util.BigString in project vcell by virtualcell.
the class VCComprehensiveStatistics method collectBioModelStats.
private void collectBioModelStats(long startDateInMs, long endDateInMs) throws DataAccessException {
retrieveUsers();
for (User user : userList) {
if (!userConstraintList.contains(user.getName())) {
continue;
}
if (!internalDeveloper.contains(user.getName())) {
boolean bInternal = internalUsers.contains(user.getName());
ModelStat modelStat = bioModelStats[bInternal ? 0 : 1];
BioModelInfo[] bioModelInfos = dbServerImpl.getBioModelInfos(user, false);
for (BioModelInfo bmi : bioModelInfos) {
Date createDate = bmi.getVersion().getDate();
long t = createDate.getTime();
// }
if (t < startDateInMs || t > endDateInMs) {
continue;
}
// modelStat.count_model ++;
try {
BigString bioModelXML = dbServerImpl.getBioModelXML(user, bmi.getVersion().getVersionKey());
BioModel bioModel = (BioModel) waitForModel(bioModelXML, false);
if (bioModel == null) {
System.out.println("---------- Skipped BioModel " + bmi.getVersion() + " ----------");
continue;
}
modelStat.count_model++;
for (SimulationContext simContext : bioModel.getSimulationContexts()) {
modelStat.count_geoDimApplications[simContext.getGeometry().getDimension()]++;
if (simContext.isStoch()) {
modelStat.count_app_stochastic++;
} else {
modelStat.count_app_deterministic++;
}
}
boolean bHasCompletedSim = false;
for (Simulation sim : bioModel.getSimulations()) {
SimulationStatusPersistent ss = dbServerImpl.getSimulationStatus(sim.getKey());
if (ss != null) {
for (int scan = 0; scan < sim.getScanCount(); scan++) {
SimulationJobStatusPersistent jobStatus = ss.getJobStatus(scan);
if (jobStatus != null) {
if (jobStatus.getSchedulerStatus() == SchedulerStatus.COMPLETED) {
bHasCompletedSim = true;
long elapsed = jobStatus.getEndDate().getTime() - jobStatus.getStartDate().getTime();
if (elapsed < 2 * MINUTE_IN_MS) {
modelStat.runningTimeHistogram[0]++;
} else if (elapsed < 5 * MINUTE_IN_MS) {
modelStat.runningTimeHistogram[1]++;
} else if (elapsed < 20 * MINUTE_IN_MS) {
modelStat.runningTimeHistogram[2]++;
} else if (elapsed < HOUR_IN_MS) {
modelStat.runningTimeHistogram[3]++;
} else if (elapsed < DAY_IN_MS) {
modelStat.runningTimeHistogram[4]++;
} else {
modelStat.runningTimeHistogram[5]++;
}
}
int dimension = sim.getMathDescription().getGeometry().getDimension();
modelStat.count_geoDimSim[dimension]++;
if (sim.getMathDescription().isNonSpatialStoch() || sim.getMathDescription().isSpatialStoch()) {
modelStat.count_sim_stochastic++;
} else {
modelStat.count_sim_deterministic++;
}
if (dimension > 0) {
if (sim.getSolverTaskDescription().getSolverDescription().isSemiImplicitPdeSolver()) {
modelStat.count_semiSim++;
} else {
modelStat.count_fullySim++;
}
}
}
}
}
}
if (bHasCompletedSim) {
modelStat.count_model_simcomplete++;
}
} catch (Exception e2) {
e2.printStackTrace(System.out);
}
}
}
}
itemCount++;
statOutputPW.println(itemCount + ". BioModel Statistics ");
statOutputPW.println("====================================================");
for (ModelStat modelStat : bioModelStats) {
statOutputPW.println("\t" + modelStat.title);
statOutputPW.println("========================================");
statOutputPW.println("number of biomodels saved :\t" + modelStat.count_model);
statOutputPW.println("number of biomodels that has at least 1 completed simulation :\t" + modelStat.count_model_simcomplete);
statOutputPW.println();
statOutputPW.println("Application statistics :");
statOutputPW.println("number of application ODE :\t" + modelStat.count_geoDimApplications[0]);
statOutputPW.println("number of application 1D :\t" + modelStat.count_geoDimApplications[1]);
statOutputPW.println("number of application 2D :\t" + modelStat.count_geoDimApplications[2]);
statOutputPW.println("number of application 3D :\t" + modelStat.count_geoDimApplications[3]);
statOutputPW.println("number of application stochastic :\t" + modelStat.count_app_stochastic);
statOutputPW.println("number of application deterministic :\t" + modelStat.count_app_deterministic);
statOutputPW.println();
statOutputPW.println("Simulation statistics (including all simulations (stopped, failed, completed) :");
statOutputPW.println("number of run simulation ODE :\t" + modelStat.count_geoDimSim[0]);
statOutputPW.println("number of run simulation 1D :\t" + modelStat.count_geoDimSim[1]);
statOutputPW.println("number of run simulation 2D :\t" + modelStat.count_geoDimSim[2]);
statOutputPW.println("number of run simulation 3D :\t" + modelStat.count_geoDimSim[3]);
statOutputPW.println("number of run simulation Semi-Implicit :\t" + modelStat.count_semiSim);
statOutputPW.println("number of run simulation Fully-Implicit :\t" + modelStat.count_fullySim);
statOutputPW.println("number of run simulation stochastic :\t" + modelStat.count_sim_stochastic);
statOutputPW.println("number of run simulation deterministic :\t" + modelStat.count_sim_deterministic);
statOutputPW.println();
statOutputPW.println("Running time histogram for completed simulations only:");
statOutputPW.println("0 ~ 2min:\t" + modelStat.runningTimeHistogram[0]);
statOutputPW.println("2 ~ 5min:\t" + modelStat.runningTimeHistogram[1]);
statOutputPW.println("5 ~ 20min:\t" + modelStat.runningTimeHistogram[2]);
statOutputPW.println("20min ~ 1hr:\t" + modelStat.runningTimeHistogram[3]);
statOutputPW.println("1hr ~ 1day:\t" + modelStat.runningTimeHistogram[4]);
statOutputPW.println(">1day:\t" + modelStat.runningTimeHistogram[5]);
statOutputPW.println();
statOutputPW.println();
statOutputPW.flush();
}
}
use of org.vcell.util.BigString in project vcell by virtualcell.
the class VCDatabaseScanner method scanBioModels.
/**
* Insert the method's description here.
* Creation date: (2/2/01 3:40:29 PM)
* @throws DataAccessException
* @throws XmlParseException
*/
public void scanBioModels(VCDatabaseVisitor databaseVisitor, PrintStream logFilePrintStream, User[] users, KeyValue singleModelKey, HashSet<KeyValue> includeHash, HashSet<KeyValue> excludeHash, boolean bAbortOnDataAccessException) throws DataAccessException, XmlParseException {
if (users == null) {
users = getAllUsers();
}
try {
// start visiting models and writing log
logFilePrintStream.println("Start scanning bio-models......");
logFilePrintStream.println("\n");
// adapter for verifyMathDescriptionsUnchanged
PrintWriter logFilePrintWriter = new PrintWriter(logFilePrintStream);
for (int i = 0; i < users.length; i++) {
User user = users[i];
BioModelInfo[] bioModelInfos = dbServerImpl.getBioModelInfos(user, false);
for (int j = 0; j < bioModelInfos.length; j++) {
if (singleModelKey != null && !bioModelInfos[j].getVersion().getVersionKey().compareEqual(singleModelKey)) {
System.out.println("skipping biomodel, not the single one that we wanted");
continue;
}
if (excludeHash != null && excludeHash.contains(bioModelInfos[j].getVersion().getVersionKey())) {
System.out.println("skipping bioModel with key '" + bioModelInfos[j].getVersion().getVersionKey() + "'");
continue;
}
if (includeHash != null && !includeHash.contains(bioModelInfos[j].getVersion().getVersionKey())) {
System.out.println("not including bioModel with key '" + bioModelInfos[j].getVersion().getVersionKey() + "'");
continue;
}
if (!databaseVisitor.filterBioModel(bioModelInfos[j])) {
continue;
}
try {
BigString bioModelXML = dbServerImpl.getBioModelXML(user, bioModelInfos[j].getVersion().getVersionKey());
BioModel bioModel = cbit.vcell.xml.XmlHelper.XMLToBioModel(new XMLSource(bioModelXML.toString()));
bioModel.refreshDependencies();
// + bioModelInfos[j].getVersion().getName() + " -----> ");
logFilePrintStream.println("---- " + (j + 1) + " ----> " + bioModel.getName());
databaseVisitor.visitBioModel(bioModel, logFilePrintStream);
// verifyMathDescriptionsUnchanged(bioModel, logFilePrintWriter);
} catch (Exception e2) {
lg.error(e2.getMessage(), e2);
logFilePrintStream.println("======= " + e2.getMessage());
if (bAbortOnDataAccessException) {
throw e2;
}
}
}
}
logFilePrintStream.close();
} catch (Exception e) {
e.printStackTrace();
System.err.println("error writing to log file.");
}
}
use of org.vcell.util.BigString in project vcell by virtualcell.
the class VCDatabaseScanner method multiScanBioModels.
/**
* Insert the method's description here.
* Creation date: (2/2/01 3:40:29 PM)
* @throws DataAccessException
* @throws XmlParseException
*/
public void multiScanBioModels(VCMultiBioVisitor databaseVisitor, Writer writer, User[] users, boolean bAbortOnDataAccessException) throws DataAccessException, XmlParseException {
assert users != null;
try {
PrintWriter printWriter = new PrintWriter(writer);
// start visiting models and writing log
printWriter.println("Start scanning bio-models......");
printWriter.println("\n");
for (int i = 0; i < users.length; i++) {
User user = users[i];
BioModelInfo[] bioModelInfos = dbServerImpl.getBioModelInfos(user, false);
for (int j = 0; j < bioModelInfos.length; j++) {
BioModelInfo bmi = bioModelInfos[j];
if (!databaseVisitor.filterBioModel(bmi)) {
continue;
}
try {
BigString bioModelXML = dbServerImpl.getBioModelXML(user, bmi.getVersion().getVersionKey());
BioModel storedModel = cbit.vcell.xml.XmlHelper.XMLToBioModel(new XMLSource(bioModelXML.toString()));
System.out.println(storedModel.getName());
if (databaseVisitor.filterBioModel(storedModel)) {
storedModel.refreshDependencies();
verifyMathDescriptionsUnchanged(storedModel, printWriter);
databaseVisitor.setBioModel(storedModel, printWriter);
// + bioModelInfos[j].getVersion().getName() + " -----> ");
printWriter.println("---- " + (j + 1) + " ----> " + storedModel.getName());
for (BioModel bioModel : databaseVisitor) {
SimulationContext[] simContexts = bioModel.getSimulationContexts();
for (SimulationContext sc : simContexts) {
try {
sc.createNewMathMapping().getMathDescription();
} catch (Exception e) {
printWriter.println("\t " + bioModel.getName() + " :: " + sc.getName() + " ----> math regeneration failed.s");
// e.printStackTrace();
}
}
}
}
} catch (Exception e2) {
lg.error(e2.getMessage(), e2);
printWriter.println("======= " + e2.getMessage());
if (bAbortOnDataAccessException) {
throw e2;
}
}
}
}
printWriter.close();
} catch (Exception e) {
e.printStackTrace();
}
}
use of org.vcell.util.BigString in project vcell by virtualcell.
the class VCDatabaseScanner method scanGeometries.
/**
* Insert the method's description here.
* Creation date: (2/2/01 3:40:29 PM)
* @throws DataAccessException
* @throws XmlParseException
*/
public void scanGeometries(VCDatabaseVisitor databaseVisitor, PrintStream logFilePrintStream, User[] users, KeyValue singleGeometryKey, HashSet<KeyValue> includeHash, HashSet<KeyValue> excludeHash, boolean bAbortOnDataAccessException) throws DataAccessException, XmlParseException {
if (users == null) {
users = getAllUsers();
}
try {
// start visiting models and writing log
logFilePrintStream.println("Start scanning geometries......");
logFilePrintStream.println("\n");
for (int i = 0; i < users.length; i++) {
User user = users[i];
GeometryInfo[] geoInfos = dbServerImpl.getGeometryInfos(user, false);
for (int j = 0; j < geoInfos.length; j++) {
if (singleGeometryKey != null && !geoInfos[j].getVersion().getVersionKey().compareEqual(singleGeometryKey)) {
System.out.println("skipping geometry, not the single one that we wanted");
continue;
}
if (excludeHash != null && excludeHash.contains(geoInfos[j].getVersion().getVersionKey())) {
System.out.println("skipping geometry with key '" + geoInfos[j].getVersion().getVersionKey() + "'");
continue;
}
if (includeHash != null && !includeHash.contains(geoInfos[j].getVersion().getVersionKey())) {
System.out.println("not including geometry with key '" + geoInfos[j].getVersion().getVersionKey() + "'");
continue;
}
if (!databaseVisitor.filterGeometry(geoInfos[j])) {
continue;
}
try {
BigString geometryXML = dbServerImpl.getGeometryXML(user, geoInfos[j].getVersion().getVersionKey());
Geometry geometry = cbit.vcell.xml.XmlHelper.XMLToGeometry(new XMLSource(geometryXML.toString()));
geometry.refreshDependencies();
databaseVisitor.visitGeometry(geometry, logFilePrintStream);
} catch (Exception e2) {
lg.error(e2.getMessage(), e2);
if (bAbortOnDataAccessException) {
throw e2;
}
}
}
}
logFilePrintStream.close();
} catch (Exception e) {
System.err.println("error writing to log file.");
}
}
use of org.vcell.util.BigString in project vcell by virtualcell.
the class NagiosVCellCheck method checkVCell.
private static String checkVCell(VCELL_CHECK_LEVEL checkLevel, String rmiHostName, int rmiPort, String rmiBootstrapStubName, String vcellNagiosPassword, int warningTimeout, int criticalTimeout) throws Exception {
long startTime = System.currentTimeMillis();
SimulationStatusPersistent lastSimStatus = null;
if (rmiHostName == null || rmiPort == -1) {
throw new UnexpectedTestStateException("Host name/ip and rmiPort required for testing, rmihostname=" + rmiHostName + " rmiport=" + rmiPort);
}
String rmiUrl = "//" + rmiHostName + ":" + rmiPort + "/" + rmiBootstrapStubName;
VCellBootstrap vcellBootstrap = null;
try {
vcellBootstrap = (VCellBootstrap) Naming.lookup(rmiUrl);
} catch (Exception e) {
throw new UnexpectedTestStateException("Error during bootstrap lookup, " + e.getClass().getSimpleName() + " " + e.getMessage());
}
if (checkLevel.ordinal() >= VCELL_CHECK_LEVEL.CONNECT_1.ordinal()) {
if (vcellNagiosPassword == null) {
throw new UnexpectedTestStateException("vcellNagios Password required for " + VCELL_CHECK_LEVEL.CONNECT_1.toString() + " and above");
}
VCellConnection vcellConnection = vcellBootstrap.getVCellConnection(new UserLoginInfo("vcellNagios", new DigestedPassword(vcellNagiosPassword)));
if (checkLevel.ordinal() >= VCELL_CHECK_LEVEL.INFOS_2.ordinal()) {
VCInfoContainer vcInfoContainer = vcellConnection.getUserMetaDbServer().getVCInfoContainer();
if (checkLevel.ordinal() >= VCELL_CHECK_LEVEL.LOAD_3.ordinal()) {
KeyValue bioModelKey = null;
final String testModelName = "Solver Suite 5.1 (BETA only ode)";
for (BioModelInfo bioModelInfo : vcInfoContainer.getBioModelInfos()) {
if (bioModelInfo.getVersion().getName().equals(testModelName)) {
bioModelKey = bioModelInfo.getVersion().getVersionKey();
break;
}
}
BigString bioModelXML = vcellConnection.getUserMetaDbServer().getBioModelXML(bioModelKey);
BioModel bioModel = XmlHelper.XMLToBioModel(new XMLSource(bioModelXML.toString()));
bioModel.refreshDependencies();
if (checkLevel.ordinal() >= VCELL_CHECK_LEVEL.DATA_4.ordinal()) {
final String testSimContextName = "non-spatial ODE";
SimulationContext simulationContext = bioModel.getSimulationContext(testSimContextName);
final String testSimName = "Copy of combined ida/cvode";
Simulation simulation = simulationContext.getSimulation(testSimName);
if (simulation == null) {
throw new UnexpectedTestStateException("Couldn't find sim '" + testSimName + "' for " + checkLevel.toString());
}
VCSimulationDataIdentifier vcSimulationDataIdentifier = new VCSimulationDataIdentifier(simulation.getSimulationInfo().getAuthoritativeVCSimulationIdentifier(), 0);
ArrayList<AnnotatedFunction> outputFunctionsList = simulationContext.getOutputFunctionContext().getOutputFunctionsList();
OutputContext outputContext = new OutputContext(outputFunctionsList.toArray(new AnnotatedFunction[outputFunctionsList.size()]));
double[] times = vcellConnection.getDataSetController().getDataSetTimes(vcSimulationDataIdentifier);
ODESimData odeSimData = vcellConnection.getDataSetController().getODEData(vcSimulationDataIdentifier);
// SimDataBlock simDataBlock = vcellConnection.getDataSetController().getSimDataBlock(outputContext, vcSimulationDataIdentifier, "RanC_cyt",times[times.length-1]);
if (checkLevel.ordinal() >= VCELL_CHECK_LEVEL.RUN_5.ordinal()) {
KeyValue copy1Key = null;
KeyValue copy2Key = null;
try {
if (simulationContext.getSimulations().length != 1) {
throw new UnexpectedTestStateException("Expecting only 1 sim to be copied for " + checkLevel.toString());
}
SimulationStatusPersistent simulationStatus = vcellConnection.getUserMetaDbServer().getSimulationStatus(simulation.getVersion().getVersionKey());
if (!simulationStatus.isCompleted()) {
throw new UnexpectedTestStateException("Expecting completed sim to copy for " + checkLevel.toString());
}
String copyModelName = testModelName + "_" + rmiHostName + "_" + rmiPort;
for (BioModelInfo bioModelInfo : vcInfoContainer.getBioModelInfos()) {
if (bioModelInfo.getVersion().getName().equals(copyModelName)) {
throw new UnexpectedTestStateException("Messy test environment, not expecting " + copyModelName + " to exist at this point");
}
}
BigString copyBioModelXMLStr = vcellConnection.getUserMetaDbServer().saveBioModelAs(bioModelXML, copyModelName, null);
BioModel copyBioModel = XmlHelper.XMLToBioModel(new XMLSource(copyBioModelXMLStr.toString()));
copy1Key = copyBioModel.getVersion().getVersionKey();
copyBioModel.refreshDependencies();
Simulation copySim = copyBioModel.getSimulationContext(testSimContextName).copySimulation(copyBioModel.getSimulationContext(testSimContextName).getSimulation(testSimName));
final String copyTestSimName = "test";
copySim.setName(copyTestSimName);
copyBioModel.refreshDependencies();
copyBioModelXMLStr = new BigString(XmlHelper.bioModelToXML(copyBioModel));
copyBioModelXMLStr = vcellConnection.getUserMetaDbServer().saveBioModel(copyBioModelXMLStr, null);
copyBioModel = XmlHelper.XMLToBioModel(new XMLSource(copyBioModelXMLStr.toString()));
copy2Key = copyBioModel.getVersion().getVersionKey();
copyBioModel.refreshDependencies();
Simulation newSimulation = copyBioModel.getSimulationContext(testSimContextName).getSimulation(copyTestSimName);
simulationStatus = vcellConnection.getUserMetaDbServer().getSimulationStatus(newSimulation.getVersion().getVersionKey());
if (simulationStatus != null && !simulationStatus.isNeverRan()) {
throw new UnexpectedTestStateException("Expecting new sim to have 'never ran' status for " + checkLevel.toString());
}
VCSimulationIdentifier newSimID = new VCSimulationIdentifier(newSimulation.getVersion().getVersionKey(), copyBioModel.getVersion().getOwner());
vcellConnection.getSimulationController().startSimulation(newSimID, 1);
lastSimStatus = simulationStatus;
MessageEvent[] messageEvents = null;
while (simulationStatus == null || (!simulationStatus.isStopped() && !simulationStatus.isCompleted() && !simulationStatus.isFailed())) {
Thread.sleep(200);
if (((System.currentTimeMillis() - startTime) / 1000) > criticalTimeout) {
vcellConnection.getSimulationController().stopSimulation(newSimID);
vcellConnection.getMessageEvents();
break;
}
simulationStatus = vcellConnection.getUserMetaDbServer().getSimulationStatus(newSimulation.getVersion().getVersionKey());
if (simulationStatus != null && !simulationStatus.toString().equals((lastSimStatus == null ? null : lastSimStatus.toString()))) {
lastSimStatus = simulationStatus;
}
messageEvents = vcellConnection.getMessageEvents();
}
} finally {
try {
if (copy1Key != null) {
vcellConnection.getUserMetaDbServer().deleteBioModel(copy1Key);
}
} catch (Exception e) {
e.printStackTrace();
}
try {
if (copy2Key != null) {
vcellConnection.getUserMetaDbServer().deleteBioModel(copy2Key);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
}
}
}
long endTime = System.currentTimeMillis();
if (criticalTimeout != -1 && ((endTime - startTime) / 1000) > criticalTimeout) {
throw new Exception(checkLevel.toString() + " test exceeded criticalTimeout=" + criticalTimeout + " seconds lastSimStatus=" + lastSimStatus);
}
if (warningTimeout != -1 && ((endTime - startTime) / 1000) > warningTimeout) {
throw new WarningTestConditionException(checkLevel.toString() + " test exceeded warningTimeout=" + warningTimeout + " seconds lastSimStatus=" + lastSimStatus);
}
return vcellBootstrap.getVCellSoftwareVersion();
}
Aggregations