Search in sources :

Example 91 with DataAccessException

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>>");
}
Also used : StringTokenizer(java.util.StringTokenizer) DataAccessException(org.vcell.util.DataAccessException)

Example 92 with DataAccessException

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());
    }
}
Also used : DataAccessException(org.vcell.util.DataAccessException)

Example 93 with DataAccessException

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());
    }
}
Also used : DataAccessException(org.vcell.util.DataAccessException)

Example 94 with DataAccessException

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());
    }
}
Also used : DataAccessException(org.vcell.util.DataAccessException)

Example 95 with DataAccessException

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;
}
Also used : Vector(java.util.Vector) DataAccessException(org.vcell.util.DataAccessException)

Aggregations

DataAccessException (org.vcell.util.DataAccessException)345 KeyValue (org.vcell.util.document.KeyValue)82 XmlParseException (cbit.vcell.xml.XmlParseException)80 ExpressionException (cbit.vcell.parser.ExpressionException)78 ObjectNotFoundException (org.vcell.util.ObjectNotFoundException)71 SQLException (java.sql.SQLException)67 IOException (java.io.IOException)60 MathException (cbit.vcell.math.MathException)59 RemoteProxyException (cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory.RemoteProxyException)46 BigString (org.vcell.util.BigString)45 User (org.vcell.util.document.User)42 FileNotFoundException (java.io.FileNotFoundException)38 ResultSet (java.sql.ResultSet)38 PropertyVetoException (java.beans.PropertyVetoException)37 File (java.io.File)34 PermissionException (org.vcell.util.PermissionException)34 Statement (java.sql.Statement)33 ExpressionBindingException (cbit.vcell.parser.ExpressionBindingException)32 BioModelInfo (org.vcell.util.document.BioModelInfo)29 Vector (java.util.Vector)26