Search in sources :

Example 71 with DataAccessException

use of org.vcell.util.DataAccessException in project vcell by virtualcell.

the class OutputTimeSpec method readVCML.

/**
 * Insert the method's description here.
 * Creation date: (9/7/2005 9:10:09 AM)
 * @return cbit.vcell.solver.OutputTimeSpec
 */
public static OutputTimeSpec readVCML(CommentStringTokenizer tokens) throws DataAccessException {
    // 
    // read format as follows:
    // 
    // OutputOptions {
    // KeepEvery 1
    // KeepAtMost	1000
    // }
    // 
    // OR
    // OutputOptions {
    // OutputTimes 0.1,0.3,0.4,... (no spaces or line feeds between numbers)
    // }
    // 
    // OR
    // OutputOptions {
    // OutputTimeStep 10
    // }
    // 
    OutputTimeSpec ots = null;
    try {
        String token = tokens.nextToken();
        if (token.equalsIgnoreCase(VCML.OutputOptions)) {
            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.KeepEvery)) {
                token = tokens.nextToken();
                int keepEvery = Integer.parseInt(token);
                token = tokens.nextToken();
                if (!token.equalsIgnoreCase(VCML.KeepAtMost)) {
                    throw new DataAccessException("unexpected identifier " + token);
                }
                token = tokens.nextToken();
                int keepAtMost = Integer.parseInt(token);
                ots = new DefaultOutputTimeSpec(keepEvery, keepAtMost);
                continue;
            } else if (token.equalsIgnoreCase(VCML.OutputTimeStep)) {
                token = tokens.nextToken();
                double outputTimeStep = Double.parseDouble(token);
                ots = new UniformOutputTimeSpec(outputTimeStep);
                continue;
            } else if (token.equalsIgnoreCase(VCML.OutputTimes)) {
                token = tokens.nextToken();
                java.util.StringTokenizer st = new java.util.StringTokenizer(token, ",");
                double[] times = new double[st.countTokens()];
                int count = 0;
                while (st.hasMoreTokens()) {
                    token = st.nextToken();
                    times[count++] = Double.parseDouble(token);
                }
                ots = new ExplicitOutputTimeSpec(times);
                continue;
            }
            throw new DataAccessException("unexpected identifier " + token);
        }
    } catch (Throwable e) {
        throw new DataAccessException("line #" + (tokens.lineIndex() + 1) + " Exception: " + e.getMessage());
    }
    return ots;
}
Also used : CommentStringTokenizer(org.vcell.util.CommentStringTokenizer) DataAccessException(org.vcell.util.DataAccessException)

Example 72 with DataAccessException

use of org.vcell.util.DataAccessException in project vcell by virtualcell.

the class SundialsPdeSolverOptions method readVCML.

private void readVCML(CommentStringTokenizer tokens) throws DataAccessException {
    String token = tokens.nextToken();
    if (token.equalsIgnoreCase(VCML.SundialsSolverOptions)) {
        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.SundialsSolverOptions_maxOrderAdvection)) {
            token = tokens.nextToken();
            maxOrderAdvection = Integer.parseInt(token);
        } else if (token.equalsIgnoreCase("maxOrder")) {
            // old way
            token = tokens.nextToken();
        } else {
            throw new DataAccessException("unexpected identifier " + token);
        }
    }
}
Also used : DataAccessException(org.vcell.util.DataAccessException)

Example 73 with DataAccessException

use of org.vcell.util.DataAccessException in project vcell by virtualcell.

the class TimeBounds 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.TimeBounds)) {
            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.StartingTime)) {
                token = tokens.nextToken();
                fieldStartingTime = Double.parseDouble(token);
                continue;
            }
            if (token.equalsIgnoreCase(VCML.EndingTime)) {
                token = tokens.nextToken();
                fieldEndingTime = 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 74 with DataAccessException

use of org.vcell.util.DataAccessException in project vcell by virtualcell.

the class ODESimData method readIDADataFile.

public static ODESimData readIDADataFile(VCDataIdentifier vcdId, File dataFile, int keepMost, File functionsFile) throws DataAccessException {
    // read ida file
    System.out.println("reading ida file : " + dataFile);
    ODESimData odeSimData = new ODESimData();
    odeSimData.formatID = IDA_DATA_FORMAT_ID;
    odeSimData.mathName = vcdId.getID();
    BufferedReader bufferedReader = null;
    try {
        bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(dataFile)));
        // Read header
        String line = bufferedReader.readLine();
        if (line == null) {
            // throw exception
            return null;
        }
        StringTokenizer st = new StringTokenizer(line, ":");
        while (st.hasMoreTokens()) {
            odeSimData.addDataColumn(new ODESolverResultSetColumnDescription(st.nextToken()));
        }
        // Read data
        while ((line = bufferedReader.readLine()) != null) {
            st = new StringTokenizer(line);
            double[] values = new double[odeSimData.getDataColumnCount()];
            int count = 0;
            while (st.hasMoreTokens()) {
                values[count++] = Double.valueOf(st.nextToken()).doubleValue();
            }
            if (count == odeSimData.getDataColumnCount()) {
                odeSimData.addRow(values);
            } else {
                break;
            }
        }
    // 
    } catch (Exception e) {
        e.printStackTrace(System.out);
        return null;
    } finally {
        try {
            if (bufferedReader != null) {
                bufferedReader.close();
            }
        } catch (Exception ex) {
            ex.printStackTrace(System.out);
        }
    }
    if (!odeSimData.getColumnDescriptions(0).getName().equals(SimDataConstants.HISTOGRAM_INDEX_NAME)) {
        Vector<AnnotatedFunction> funcList;
        try {
            funcList = FunctionFileGenerator.readFunctionsFile(functionsFile, vcdId.getID());
            for (AnnotatedFunction func : funcList) {
                try {
                    Expression expression = new Expression(func.getExpression());
                    odeSimData.addFunctionColumn(new FunctionColumnDescription(expression, func.getName(), null, func.getName(), false));
                } catch (ExpressionException e) {
                    throw new RuntimeException("Could not add function " + func.getName() + " to annotatedFunctionList");
                }
            }
        } catch (FileNotFoundException e1) {
            e1.printStackTrace(System.out);
            throw new DataAccessException(e1.getMessage());
        } catch (IOException e1) {
            e1.printStackTrace(System.out);
            throw new DataAccessException(e1.getMessage());
        }
    }
    if (keepMost > 0) {
        odeSimData.trimRows(keepMost);
    }
    return odeSimData;
}
Also used : InputStreamReader(java.io.InputStreamReader) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream) IOException(java.io.IOException) DataAccessException(org.vcell.util.DataAccessException) ExpressionException(cbit.vcell.parser.ExpressionException) ExpressionBindingException(cbit.vcell.parser.ExpressionBindingException) EOFException(java.io.EOFException) FileNotFoundException(java.io.FileNotFoundException) ExpressionException(cbit.vcell.parser.ExpressionException) StringTokenizer(java.util.StringTokenizer) Expression(cbit.vcell.parser.Expression) BufferedReader(java.io.BufferedReader) ODESolverResultSetColumnDescription(cbit.vcell.math.ODESolverResultSetColumnDescription) FunctionColumnDescription(cbit.vcell.math.FunctionColumnDescription) DataAccessException(org.vcell.util.DataAccessException) AnnotatedFunction(cbit.vcell.solver.AnnotatedFunction)

Example 75 with DataAccessException

use of org.vcell.util.DataAccessException in project vcell by virtualcell.

the class ODESimData method readNFSIMDataFile.

public static ODESimData readNFSIMDataFile(VCDataIdentifier vcdId, File dataFile, File functionsFile) throws DataAccessException, IOException {
    System.out.println("reading NetCDF file : " + dataFile);
    ODESimData odeSimData = new ODESimData();
    odeSimData.formatID = NETCDF_DATA_FORMAT_ID;
    odeSimData.mathName = vcdId.getID();
    String file = dataFile.getPath();
    BufferedReader reader = new BufferedReader(new FileReader(file));
    String firstLine = reader.readLine();
    StringTokenizer st = new StringTokenizer(firstLine);
    // #
    st.nextToken();
    // time
    st.nextToken();
    // first column will be time t.
    odeSimData.addDataColumn(new ODESolverResultSetColumnDescription("t"));
    int count = st.countTokens();
    String varName = new String();
    for (int i = 0; i < count; i++) {
        varName = st.nextToken();
        odeSimData.addDataColumn(new ODESolverResultSetColumnDescription(varName));
    }
    // Read data
    // String         ls = System.getProperty("line.separator");
    // StringBuilder  stringBuilder = new StringBuilder();
    String line = null;
    while ((line = reader.readLine()) != null) {
        double[] values = new double[odeSimData.getDataColumnCount()];
        st = new StringTokenizer(line);
        count = st.countTokens();
        String sData = new String();
        for (int i = 0; i < count; i++) {
            sData = st.nextToken();
            double dData = Double.parseDouble(sData);
            values[i] = dData;
        }
        odeSimData.addRow(values);
    }
    if (!odeSimData.getColumnDescriptions(0).getName().equals(SimDataConstants.HISTOGRAM_INDEX_NAME)) {
        Vector<AnnotatedFunction> funcList;
        try {
            funcList = FunctionFileGenerator.readFunctionsFile(functionsFile, vcdId.getID());
            for (AnnotatedFunction func : funcList) {
                try {
                    Expression expression = new Expression(func.getExpression());
                    odeSimData.addFunctionColumn(new FunctionColumnDescription(expression, func.getName(), null, func.getName(), false));
                } catch (ExpressionException e) {
                    throw new RuntimeException("Could not add function " + func.getName() + " to annotatedFunctionList");
                }
            }
        } catch (FileNotFoundException e1) {
            e1.printStackTrace(System.out);
            throw new DataAccessException(e1.getMessage());
        } catch (IOException e1) {
            e1.printStackTrace(System.out);
            throw new DataAccessException(e1.getMessage());
        }
    }
    return odeSimData;
}
Also used : FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) ExpressionException(cbit.vcell.parser.ExpressionException) StringTokenizer(java.util.StringTokenizer) Expression(cbit.vcell.parser.Expression) BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader) ODESolverResultSetColumnDescription(cbit.vcell.math.ODESolverResultSetColumnDescription) FunctionColumnDescription(cbit.vcell.math.FunctionColumnDescription) DataAccessException(org.vcell.util.DataAccessException) AnnotatedFunction(cbit.vcell.solver.AnnotatedFunction)

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