use of org.vcell.util.DataAccessException in project vcell by virtualcell.
the class SimulationDataSpatialHdf5 method readLogFile.
/**
* This method was created in VisualAge.
* @throws IOException
*/
private synchronized void readLogFile() throws DataAccessException, IOException {
VCMongoMessage.sendTrace("SimulationDataSpatialHdf5.readLog() <<ENTER>>");
if (logFile == null) {
VCMongoMessage.sendTrace("SimulationDataSpatialHdf5.readLog() log file not found <<EXIT-Exception>>");
throw new DataAccessException("log file not found for " + vcDataId);
}
VCMongoMessage.sendTrace("SimulationDataSpatialHdf5.readLog() logFile exists");
long length = logFile.length();
long lastModified = logFile.lastModified();
if (lastModified == logFileLastModified && logFileLength == length) {
VCMongoMessage.sendTrace("SimulationDataSpatialHdf5.readLog() hasn't been modified ... <<EXIT>>");
return;
}
logFileLastModified = lastModified;
logFileLength = length;
logfileEntryList.clear();
//
// read log file and check whether ODE or PDE data
//
String logfileContent = FileUtils.readFileToString(logFile);
if (logfileContent.length() != logFileLength) {
System.out.println("SimulationDataSpatialHdf5.readLog(), read " + logfileContent.length() + " of " + logFileLength + " bytes of log file");
}
StringTokenizer st = new StringTokenizer(logfileContent);
// so parse into 'dataFilenames' and 'dataTimes' arrays
if (st.countTokens() % 4 != 0) {
throw new DataAccessException("SimulationDataSpatialHdf5.readLog(), tokens in each line should be factor of 4");
}
while (st.hasMoreTokens()) {
int iteration = Integer.parseInt(st.nextToken());
String simFileName = st.nextToken();
String zipFileName = st.nextToken();
double time = Double.parseDouble(st.nextToken());
logfileEntryList.add(new SimLogFileEntry(iteration, simFileName, zipFileName, time));
}
VCMongoMessage.sendTrace("SimulationDataSpatialHdf5.readLog() <<EXIT>>");
}
use of org.vcell.util.DataAccessException in project vcell by virtualcell.
the class ErrorTolerance method readVCML.
/**
* Insert the method's description here.
* Creation date: (10/24/00 3:45:12 PM)
* @return java.lang.String
*/
public void readVCML(CommentStringTokenizer tokens) throws DataAccessException {
//
try {
String token = tokens.nextToken();
if (token.equalsIgnoreCase(VCML.ErrorTolerance)) {
token = tokens.nextToken();
if (!token.equalsIgnoreCase(VCML.BeginBlock)) {
throw new DataAccessException("unexpected token " + token + " expecting " + VCML.BeginBlock);
}
}
while (tokens.hasMoreTokens()) {
token = tokens.nextToken();
if (token.equalsIgnoreCase(VCML.EndBlock)) {
break;
}
if (token.equalsIgnoreCase(VCML.AbsoluteErrorTolerance)) {
token = tokens.nextToken();
fieldAbsoluteErrorTolerance = Double.parseDouble(token);
continue;
}
if (token.equalsIgnoreCase(VCML.RelativeErrorTolerance)) {
token = tokens.nextToken();
fieldRelativeErrorTolerance = Double.parseDouble(token);
continue;
}
throw new DataAccessException("unexpected identifier " + token);
}
} catch (Throwable e) {
throw new DataAccessException("line #" + (tokens.lineIndex() + 1) + " Exception: " + e.getMessage());
}
}
use of org.vcell.util.DataAccessException in project vcell by virtualcell.
the class NonspatialStochHybridOptions method readVCML.
/**
* Read VCML to feed data into the class
*/
public void readVCML(CommentStringTokenizer tokens) throws DataAccessException {
//
try {
String token = tokens.nextToken();
if (token.equalsIgnoreCase(VCML.StochSimOptions)) {
token = tokens.nextToken();
if (!token.equalsIgnoreCase(VCML.BeginBlock)) {
throw new DataAccessException("unexpected token " + token + " expecting " + VCML.BeginBlock);
}
}
while (tokens.hasMoreTokens()) {
token = tokens.nextToken();
if (token.equalsIgnoreCase(VCML.EndBlock)) {
break;
}
if (token.equalsIgnoreCase(VCML.Epsilon)) {
token = tokens.nextToken();
double val3 = Double.parseDouble(token);
if (val3 < 1)
throw new DataAccessException("unexpected token " + token + ", Minimum number of molecue is requied to be greater than or equal to 1. ");
else
epsilon = val3;
continue;
}
if (token.equalsIgnoreCase(VCML.Lambda)) {
token = tokens.nextToken();
double val4 = Double.parseDouble(token);
if (val4 <= 0)
throw new DataAccessException("unexpected token " + token + ", num of trials is requied to be greater than 0. ");
else
lambda = val4;
continue;
}
if (token.equalsIgnoreCase(VCML.MSRTolerance)) {
token = tokens.nextToken();
double val5 = Double.parseDouble(token);
if (val5 <= 0)
throw new DataAccessException("unexpected token " + token + ", Maximum allowed effect of slow reactions is requied to be greater than 0. ");
else
MSRTolerance = val5;
continue;
}
if (token.equalsIgnoreCase(VCML.SDETolerance)) {
token = tokens.nextToken();
double val6 = Double.parseDouble(token);
if (val6 <= 0)
throw new DataAccessException("unexpected token " + token + ", SDE allowed value of drift and diffusion errors is requied to be greater than 0. ");
else
SDETolerance = val6;
continue;
}
throw new DataAccessException("unexpected identifier " + token);
}
} catch (Throwable e) {
throw new DataAccessException("line #" + (tokens.lineIndex() + 1) + " Exception: " + e.getMessage());
}
}
use of org.vcell.util.DataAccessException in project vcell by virtualcell.
the class NonspatialStochSimOptions method readVCML.
/**
* Insert the method's description here.
* Creation date: (12/6/2006 1:03:54 PM)
*/
public void readVCML(CommentStringTokenizer tokens) throws DataAccessException {
//
try {
String token = tokens.nextToken();
if (token.equalsIgnoreCase(VCML.StochSimOptions)) {
token = tokens.nextToken();
if (!token.equalsIgnoreCase(VCML.BeginBlock)) {
throw new DataAccessException("unexpected token " + token + " expecting " + VCML.BeginBlock);
}
}
while (tokens.hasMoreTokens()) {
token = tokens.nextToken();
if (token.equalsIgnoreCase(VCML.EndBlock)) {
break;
}
if (token.equalsIgnoreCase(VCML.UseCustomSeed)) {
token = tokens.nextToken();
useCustomSeed = Boolean.parseBoolean(token);
continue;
}
if (token.equalsIgnoreCase(VCML.CustomSeed)) {
token = tokens.nextToken();
int val1 = Integer.parseInt(token);
if (val1 < 0) {
throw new DataAccessException("unexpected token " + token + ", seed is required to be an unsigned interger. ");
} else {
customSeed = val1;
}
continue;
}
if (token.equalsIgnoreCase(VCML.NumOfTrials)) {
token = tokens.nextToken();
int val2 = Integer.parseInt(token);
if (val2 < 1) {
throw new DataAccessException("unexpected token " + token + ", num of trials is requied to be at least 1. ");
} else {
numOfTrials = val2;
}
continue;
}
throw new DataAccessException("unexpected identifier " + token);
}
} catch (Throwable e) {
throw new DataAccessException("line #" + (tokens.lineIndex() + 1) + " Exception: " + e.getMessage());
}
}
use of org.vcell.util.DataAccessException in project vcell by virtualcell.
the class SimpleReferenceData method fromVCML.
/**
* Insert the method's description here.
* Creation date: (8/3/2005 8:23:18 PM)
* @return cbit.vcell.opt.SimpleConstraintData
* @param tokens cbit.vcell.math.CommentStringTokenizer
*/
@SuppressWarnings("unchecked")
public static SimpleReferenceData fromVCML(CommentStringTokenizer tokens) throws DataAccessException {
String token = tokens.nextToken();
if (!token.equals("SimpleReferenceData")) {
throw new DataAccessException("unexpected identifier '" + token + "', expecting '" + "Data" + "'");
}
token = tokens.nextToken();
if (!token.equals("{")) {
throw new RuntimeException("unexpected symbol '" + token + "', expecting '{'");
}
int numRows = 0;
int numColumns = 0;
try {
numRows = Integer.parseInt(tokens.nextToken());
} catch (NumberFormatException e) {
e.printStackTrace(System.out);
throw new DataAccessException("error reading number of rows: " + e.getMessage());
}
try {
numColumns = Integer.parseInt(tokens.nextToken());
} catch (NumberFormatException e) {
e.printStackTrace(System.out);
throw new DataAccessException("error reading number of columns: " + e.getMessage());
}
String[] names = new String[numColumns];
for (int i = 0; i < numColumns; i++) {
names[i] = tokens.nextToken();
}
double[] weights = new double[numColumns];
for (int i = 0; i < numColumns; i++) {
weights[i] = Double.parseDouble(tokens.nextToken());
}
Vector rowData = new Vector();
for (int i = 0; i < numRows; i++) {
double[] row = new double[numColumns];
for (int j = 0; j < numColumns; j++) {
row[j] = Double.parseDouble(tokens.nextToken());
}
rowData.add(row);
}
SimpleReferenceData simpleReferenceData = new SimpleReferenceData(names, weights, rowData);
// read "}" for Data block
token = tokens.nextToken();
if (!token.equals("}")) {
throw new RuntimeException("unexpected symbol '" + token + "', expecting '}'");
}
return simpleReferenceData;
}
Aggregations