Search in sources :

Example 26 with SymbolTableEntry

use of cbit.vcell.parser.SymbolTableEntry in project vcell by virtualcell.

the class PdeTimePlotMultipleVariablesPanel method showTimePlot.

public void showTimePlot() {
    if ((plotChangeTimer = ClientTaskDispatcher.getBlockingTimer(this, multiTimePlotHelper.getPdeDatacontext(), null, plotChangeTimer, new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e2) {
            showTimePlot();
        }
    }, "PdeTimePlotMultipleVariablesPanel update...")) != null) {
        return;
    }
    VariableType varType = multiTimePlotHelper.getVariableType();
    Object[] selectedValues = variableJList.getSelectedValues();
    DataIdentifier[] selectedDataIdentifiers = new DataIdentifier[selectedValues.length];
    System.arraycopy(selectedValues, 0, selectedDataIdentifiers, 0, selectedValues.length);
    if (selectedDataIdentifiers.length > 1) {
        for (DataIdentifier selectedDataIdentifier : selectedDataIdentifiers) {
            if (!selectedDataIdentifier.getVariableType().getVariableDomain().equals(varType.getVariableDomain())) {
                PopupGenerator.showErrorDialog(this, "Please choose VOLUME variables or MEMBRANE variables only");
                variableJList.clearSelection();
                variableJList.setSelectedValue(multiTimePlotHelper.getPdeDatacontext().getVariableName(), true);
                return;
            }
        }
    }
    try {
        final int numSelectedVariables = selectedDataIdentifiers.length;
        final int numSelectedSpatialPoints = pointVector.size();
        int[][] indices = new int[numSelectedVariables][numSelectedSpatialPoints];
        // 
        for (int i = 0; i < numSelectedSpatialPoints; i++) {
            for (int v = 0; v < numSelectedVariables; v++) {
                if (selectedDataIdentifiers[v].getVariableType().equals(varType)) {
                    if (varType.equals(VariableType.VOLUME) || varType.equals(VariableType.VOLUME_REGION) || varType.equals(VariableType.POSTPROCESSING)) {
                        SpatialSelectionVolume ssv = (SpatialSelectionVolume) pointVector.get(i);
                        indices[v][i] = ssv.getIndex(0);
                    } else if (varType.equals(VariableType.MEMBRANE) || varType.equals(VariableType.MEMBRANE_REGION)) {
                        SpatialSelectionMembrane ssm = (SpatialSelectionMembrane) pointVector.get(i);
                        indices[v][i] = ssm.getIndex(0);
                    }
                } else {
                    if (varType.equals(VariableType.VOLUME) || varType.equals(VariableType.VOLUME_REGION) || varType.equals(VariableType.POSTPROCESSING)) {
                        SpatialSelectionVolume ssv = (SpatialSelectionVolume) pointVector2.get(i);
                        indices[v][i] = ssv.getIndex(0);
                    } else if (varType.equals(VariableType.MEMBRANE) || varType.equals(VariableType.MEMBRANE_REGION)) {
                        SpatialSelectionMembrane ssm = (SpatialSelectionMembrane) pointVector2.get(i);
                        indices[v][i] = ssm.getIndex(0);
                    }
                }
            }
        }
        final String[] selectedVarNames = new String[numSelectedVariables];
        for (int i = 0; i < selectedVarNames.length; i++) {
            selectedVarNames[i] = selectedDataIdentifiers[i].getName();
        }
        final double[] timePoints = multiTimePlotHelper.getPdeDatacontext().getTimePoints();
        TimeSeriesJobSpec tsjs = new TimeSeriesJobSpec(selectedVarNames, indices, null, timePoints[0], 1, timePoints[timePoints.length - 1], VCDataJobID.createVCDataJobID(multiTimePlotHelper.getUser(), true));
        if (!tsjs.getVcDataJobID().isBackgroundTask()) {
            throw new RuntimeException("Use getTimeSeries(...) if not a background job");
        }
        Hashtable<String, Object> hash = new Hashtable<String, Object>();
        hash.put(PDEDataViewer.StringKey_timeSeriesJobSpec, tsjs);
        AsynchClientTask task1 = new PDEDataViewer.TimeSeriesDataRetrievalTask("Retrieving Data", multiTimePlotHelper, multiTimePlotHelper.getPdeDatacontext());
        AsynchClientTask task2 = new AsynchClientTask("showing time plot", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {

            @Override
            public void run(Hashtable<String, Object> hashTable) throws Exception {
                TSJobResultsNoStats tsJobResultsNoStats = (TSJobResultsNoStats) hashTable.get(PDEDataViewer.StringKey_timeSeriesJobResults);
                int plotCount = numSelectedVariables * numSelectedSpatialPoints;
                SymbolTableEntry[] symbolTableEntries = new SymbolTableEntry[plotCount];
                String[] plotNames = new String[plotCount];
                double[][] plotDatas = new double[1 + plotCount][];
                plotDatas[0] = timePoints;
                int plotIndex = 0;
                for (int v = 0; v < numSelectedVariables; v++) {
                    String varName = selectedVarNames[v];
                    double[][] data = tsJobResultsNoStats.getTimesAndValuesForVariable(varName);
                    for (int i = 1; i < data.length; i++) {
                        symbolTableEntries[plotIndex] = multiTimePlotHelper.getsimulation().getMathDescription().getEntry(varName);
                        plotNames[plotIndex] = varName + " at P[" + (i - 1) + "]";
                        plotDatas[plotIndex + 1] = data[i];
                        plotIndex++;
                    }
                }
                Plot2D plot2D = new SingleXPlot2D(symbolTableEntries, multiTimePlotHelper.getDataSymbolMetadataResolver(), ReservedVariable.TIME.getName(), plotNames, plotDatas, new String[] { "Time Plot", ReservedVariable.TIME.getName(), "" });
                plotPane.setPlot2D(plot2D);
            }
        };
        ClientTaskDispatcher.dispatch(this, hash, new AsynchClientTask[] { task1, task2 }, false, true, true, null, false);
    } catch (Exception e) {
        e.printStackTrace(System.out);
    }
}
Also used : AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) DataIdentifier(cbit.vcell.simdata.DataIdentifier) TimeSeriesJobSpec(org.vcell.util.document.TimeSeriesJobSpec) ActionEvent(java.awt.event.ActionEvent) SpatialSelectionMembrane(cbit.vcell.simdata.SpatialSelectionMembrane) SymbolTableEntry(cbit.vcell.parser.SymbolTableEntry) VariableType(cbit.vcell.math.VariableType) Hashtable(java.util.Hashtable) SingleXPlot2D(cbit.plot.SingleXPlot2D) ActionListener(java.awt.event.ActionListener) SpatialSelectionVolume(cbit.vcell.simdata.SpatialSelectionVolume) SingleXPlot2D(cbit.plot.SingleXPlot2D) Plot2D(cbit.plot.Plot2D) TSJobResultsNoStats(org.vcell.util.document.TSJobResultsNoStats)

Example 27 with SymbolTableEntry

use of cbit.vcell.parser.SymbolTableEntry in project vcell by virtualcell.

the class ODESolverPlotSpecificationPanel method regeneratePlot2D.

/**
 * Comment
 */
private void regeneratePlot2D() throws ExpressionException, ObjectNotFoundException {
    if (getMyDataInterface() == null) {
        return;
    }
    if (!getMyDataInterface().isMultiTrialData()) {
        if (getXAxisComboBox_frm().getSelectedIndex() < 0) {
            return;
        } else {
            // double[] xData = getOdeSolverResultSet().extractColumn(getPlottableColumnIndices()[getXIndex()]);
            // getUnfilteredSortedXAxisNames
            double[] xData = getMyDataInterface().extractColumn((String) getXAxisComboBox_frm().getSelectedItem());
            double[][] allData = new double[((DefaultListModel) getYAxisChoice().getModel()).size() + 1][xData.length];
            String[] yNames = new String[((DefaultListModel) getYAxisChoice().getModel()).size()];
            allData[0] = xData;
            double[] yData = new double[xData.length];
            double currParamValue = 0.0;
            double deltaParamValue = 0.0;
            // Extrapolation calculations!
            if (getSensitivityParameter() != null) {
                int val = getSensitivityParameterSlider().getValue();
                double nominalParamValue = getSensitivityParameter().getConstantValue();
                double pMax = nominalParamValue * 1.1;
                double pMin = nominalParamValue * 0.9;
                int iMax = getSensitivityParameterSlider().getMaximum();
                int iMin = getSensitivityParameterSlider().getMinimum();
                double slope = (pMax - pMin) / (iMax - iMin);
                currParamValue = slope * val + pMin;
                deltaParamValue = currParamValue - nominalParamValue;
                getMaxLabel().setText(Double.toString(pMax));
                getMinLabel().setText(Double.toString(pMin));
                getCurLabel().setText(Double.toString(currParamValue));
            }
            if (!getLogSensCheckbox().getModel().isSelected()) {
                // When log sensitivity check box is not selected.
                for (int i = 0; i < allData.length - 1; i++) {
                    // If sensitivity analysis is enabled, extrapolate values for State vars and non-sensitivity functions
                    if (getSensitivityParameter() != null) {
                        ColumnDescription cd = getMyDataInterface().getColumnDescription((String) ((DefaultListModel) getYAxisChoice().getModel()).elementAt(i));
                        double[] sens = getSensValues(cd);
                        yData = getMyDataInterface().extractColumn(cd.getName());
                        // sens array != null for non-sensitivity state vars and functions, so extrapolate
                        if (sens != null) {
                            for (int j = 0; j < sens.length; j++) {
                                if (Math.abs(yData[j]) > 1e-6) {
                                    // away from zero, exponential extrapolation
                                    allData[i + 1][j] = yData[j] * Math.exp(deltaParamValue * sens[j] / yData[j]);
                                } else {
                                    // around zero - linear extrapolation
                                    allData[i + 1][j] = yData[j] + sens[j] * deltaParamValue;
                                }
                            }
                        // sens array == null for sensitivity state vars and functions, so don't change their original values
                        } else {
                            allData[i + 1] = getMyDataInterface().extractColumn((String) ((DefaultListModel) getYAxisChoice().getModel()).elementAt(i));
                        }
                    } else {
                        // No sensitivity analysis case, so do not alter the original values for any variable or function
                        allData[i + 1] = getMyDataInterface().extractColumn((String) ((DefaultListModel) getYAxisChoice().getModel()).elementAt(i));
                    }
                    yNames[i] = (String) ((DefaultListModel) getYAxisChoice().getModel()).elementAt(i);
                }
            } else {
                // When log sensitivity checkbox is selected.
                // Get sensitivity parameter and its value to compute log sensitivity
                Constant sensParam = getSensitivityParameter();
                double sensParamValue = sensParam.getConstantValue();
                getJLabelSensitivityParameter().setText("Sensitivity wrt Parameter " + sensParam.getName());
                // 
                for (int i = 0; i < allData.length - 1; i++) {
                    // Finding sensitivity var column for each column in result set.
                    ColumnDescription cd = getMyDataInterface().getColumnDescription((String) ((DefaultListModel) getYAxisChoice().getModel()).elementAt(i));
                    String sensVarName = null;
                    ColumnDescription[] allColumnDescriptions = getMyDataInterface().getAllColumnDescriptions();
                    for (int j = 0; j < allColumnDescriptions.length; j++) {
                        String obj = "sens_" + cd.getName() + "_wrt_" + sensParam.getName();
                        if (allColumnDescriptions[j].getName().equals(obj)) {
                            sensVarName = obj;
                            break;
                        }
                    }
                    int sensIndex = -1;
                    if (sensVarName != null) {
                        for (int j = 0; j < ((DefaultListModel) getYAxisChoice().getModel()).getSize(); j++) {
                            if (((String) ((DefaultListModel) getYAxisChoice().getModel()).get(j)).equals(sensVarName)) {
                                sensIndex = j;
                                break;
                            }
                        }
                    }
                    yData = getMyDataInterface().extractColumn(cd.getName());
                    // If sensitivity var exists, compute log sensitivity
                    if (sensVarName != null) {
                        double[] sens = getMyDataInterface().extractColumn(sensVarName);
                        for (int k = 0; k < yData.length; k++) {
                            // Extrapolated statevars and functions
                            if (Math.abs(yData[k]) > 1e-6) {
                                // away from zero, exponential extrapolation
                                allData[i + 1][k] = yData[k] * Math.exp(deltaParamValue * sens[k] / yData[k]);
                            } else {
                                // around zero - linear extrapolation
                                allData[i + 1][k] = yData[k] + sens[k] * deltaParamValue;
                            }
                            // Log sensitivity for the state variables and functions
                            // default if floating point problems
                            double logSens = 0.0;
                            if (Math.abs(yData[k]) > 0) {
                                double tempLogSens = sens[k] * sensParamValue / yData[k];
                                if (tempLogSens != Double.NEGATIVE_INFINITY && tempLogSens != Double.POSITIVE_INFINITY && tempLogSens != Double.NaN) {
                                    logSens = tempLogSens;
                                }
                            }
                            if (sensIndex > -1) {
                                allData[sensIndex + 1][k] = logSens;
                            }
                        }
                    // If sensitivity var does not exist, retain  original value of column (var or function).
                    } else {
                        if (!cd.getName().startsWith("sens_")) {
                            allData[i + 1] = yData;
                        }
                    }
                    yNames[i] = (String) ((DefaultListModel) getYAxisChoice().getModel()).elementAt(i);
                }
            }
            String title = "";
            String xLabel = (String) getXAxisComboBox_frm().getSelectedItem();
            String yLabel = "";
            if (yNames.length == 1) {
                yLabel = yNames[0];
            }
            // Update Sensitivity parameter label depending on whether Log sensitivity check box is checked or not.
            if (!getLogSensCheckbox().getModel().isSelected()) {
                getJLabelSensitivityParameter().setText("");
            }
            SymbolTableEntry[] symbolTableEntries = null;
            if (getSymbolTable() != null && yNames != null && yNames.length > 0) {
                symbolTableEntries = new SymbolTableEntry[yNames.length];
                for (int i = 0; i < yNames.length; i += 1) {
                    SymbolTableEntry ste = getSymbolTable().getEntry(yNames[i]);
                    symbolTableEntries[i] = ste;
                }
            }
            SingleXPlot2D plot2D = new SingleXPlot2D(symbolTableEntries, getMyDataInterface().getDataSymbolMetadataResolver(), xLabel, yNames, allData, new String[] { title, xLabel, yLabel });
            refreshVisiblePlots(plot2D);
            // here fire "singleXPlot2D" event, ODEDataViewer's event handler listens to it.
            setPlot2D(plot2D);
        }
    } else // end of none MultitrialData
    // multitrial data
    {
        // a column of data get from ODESolverRestultSet, which is actually the results for a specific variable during multiple trials
        double[] rowData = new double[getMyDataInterface().getRowCount()];
        PlotData[] plotData = new PlotData[((DefaultListModel) getYAxisChoice().getModel()).size()];
        for (int i = 0; i < plotData.length; i++) {
            ColumnDescription cd = getMyDataInterface().getColumnDescription((String) ((DefaultListModel) getYAxisChoice().getModel()).elementAt(i));
            rowData = getMyDataInterface().extractColumn(cd.getName());
            Point2D[] histogram = generateHistogram(rowData);
            double[] x = new double[histogram.length];
            double[] y = new double[histogram.length];
            for (int j = 0; j < histogram.length; j++) {
                x[j] = histogram[j].getX();
                y[j] = histogram[j].getY();
            }
            plotData[i] = new PlotData(x, y);
        }
        SymbolTableEntry[] symbolTableEntries = null;
        if (getSymbolTable() != null && ((DefaultListModel) getYAxisChoice().getModel()).size() > 0) {
            symbolTableEntries = new SymbolTableEntry[((DefaultListModel) getYAxisChoice().getModel()).size()];
            for (int i = 0; i < symbolTableEntries.length; i += 1) {
                symbolTableEntries[i] = getSymbolTable().getEntry((String) ((DefaultListModel) getYAxisChoice().getModel()).elementAt(i));
            }
        }
        String title = "Probability Distribution of Species";
        String xLabel = "Number of Particles";
        String yLabel = "";
        String[] yNames = new String[((DefaultListModel) getYAxisChoice().getModel()).size()];
        ((DefaultListModel) getYAxisChoice().getModel()).copyInto(yNames);
        Plot2D plot2D = new Plot2D(symbolTableEntries, getMyDataInterface().getDataSymbolMetadataResolver(), yNames, plotData, new String[] { title, xLabel, yLabel });
        refreshVisiblePlots(plot2D);
        setPlot2D(plot2D);
    }
}
Also used : PlotData(cbit.plot.PlotData) ColumnDescription(cbit.vcell.util.ColumnDescription) FunctionColumnDescription(cbit.vcell.math.FunctionColumnDescription) Constant(cbit.vcell.math.Constant) DefaultListModel(javax.swing.DefaultListModel) SingleXPlot2D(cbit.plot.SingleXPlot2D) SymbolTableEntry(cbit.vcell.parser.SymbolTableEntry) Point2D(java.awt.geom.Point2D) SingleXPlot2D(cbit.plot.SingleXPlot2D) Plot2D(cbit.plot.Plot2D)

Example 28 with SymbolTableEntry

use of cbit.vcell.parser.SymbolTableEntry in project vcell by virtualcell.

the class ParameterTableModel method isCellEditable.

/**
 * Insert the method's description here.
 * Creation date: (2/24/01 12:27:46 AM)
 * @return boolean
 * @param rowIndex int
 * @param columnIndex int
 */
public boolean isCellEditable(int rowIndex, int columnIndex) {
    if (!bEditable) {
        return false;
    }
    Parameter parameter = getValueAt(rowIndex);
    if (reactionStep != null && parameter instanceof KineticsParameter) {
        KineticsParameter kp = (KineticsParameter) parameter;
        if (kp.getRole() == Kinetics.ROLE_KReverse) {
            if (!reactionStep.isReversible()) {
                // disable Kr if rule is not reversible
                return false;
            }
        }
    }
    switch(columnIndex) {
        case COLUMN_NAME:
            return parameter.isNameEditable();
        case COLUMN_DESCRIPTION:
            return false;
        case COLUMN_IS_GLOBAL:
            // if the parameter is reaction rate param or a ReservedSymbol in the model, it should not be editable
            if ((parameter instanceof KineticsParameter) && (((KineticsParameter) parameter).getRole() != Kinetics.ROLE_UserDefined)) {
                return false;
            }
            if (parameter instanceof UnresolvedParameter) {
                return false;
            }
            if (parameter instanceof KineticsProxyParameter) {
                KineticsProxyParameter kpp = (KineticsProxyParameter) parameter;
                SymbolTableEntry ste = kpp.getTarget();
                if ((ste instanceof Model.ReservedSymbol) || (ste instanceof SpeciesContext) || (ste instanceof ModelQuantity)) {
                    return false;
                }
            }
            return true;
        case COLUMN_VALUE:
            return parameter.isExpressionEditable();
        case COLUMN_UNITS:
            return parameter.isUnitEditable();
    }
    return false;
}
Also used : SymbolTableEntry(cbit.vcell.parser.SymbolTableEntry) KineticsProxyParameter(cbit.vcell.model.Kinetics.KineticsProxyParameter) KineticsParameter(cbit.vcell.model.Kinetics.KineticsParameter) ModelQuantity(cbit.vcell.model.ModelQuantity) VCellSortTableModel(cbit.vcell.client.desktop.biomodel.VCellSortTableModel) Model(cbit.vcell.model.Model) ModelParameter(cbit.vcell.model.Model.ModelParameter) KineticsProxyParameter(cbit.vcell.model.Kinetics.KineticsProxyParameter) Parameter(cbit.vcell.model.Parameter) KineticsParameter(cbit.vcell.model.Kinetics.KineticsParameter) UnresolvedParameter(cbit.vcell.model.Kinetics.UnresolvedParameter) UnresolvedParameter(cbit.vcell.model.Kinetics.UnresolvedParameter) SpeciesContext(cbit.vcell.model.SpeciesContext)

Example 29 with SymbolTableEntry

use of cbit.vcell.parser.SymbolTableEntry in project vcell by virtualcell.

the class IssueTableModel method getSourceObjectPathDescription.

private String getSourceObjectPathDescription(VCDocument vcDocument, Issue issue) {
    VCAssert.assertValid(issue);
    Object source = issue.getSource();
    {
        IssueOrigin io = BeanUtils.downcast(IssueOrigin.class, source);
        if (io != null) {
            return io.getDescription();
        }
    }
    if (vcDocument instanceof BioModel) {
        BioModel bioModel = (BioModel) vcDocument;
        String description = "";
        if (source instanceof SymbolTableEntry) {
            if (source instanceof SpeciesContext) {
                description = "Model / Species";
            } else if (source instanceof RbmObservable) {
                description = "Model / Observables";
            } else {
                description = ((SymbolTableEntry) source).getNameScope().getPathDescription();
            }
        } else if (source instanceof MolecularType) {
            description = "Model / Molecules";
        } else if (source instanceof ReactionStep) {
            ReactionStep reactionStep = (ReactionStep) source;
            description = ((ReactionNameScope) reactionStep.getNameScope()).getPathDescription();
        } else if (source instanceof ReactionRule) {
            ReactionRule reactionRule = (ReactionRule) source;
            description = ((ReactionRuleNameScope) reactionRule.getNameScope()).getPathDescription();
        } else if (source instanceof SpeciesPattern) {
            // if (issue.getIssueContext().hasContextType(ContextType.SpeciesContext)){
            // description = "Model / Species";
            // }else if(issue.getIssueContext().hasContextType(ContextType.ReactionRule)) {
            // ReactionRule thing = (ReactionRule)issue.getIssueContext().getContextObject(ContextType.ReactionRule);
            // description = ((ReactionRuleNameScope)thing.getNameScope()).getPathDescription();
            // }else if(issue.getIssueContext().hasContextType(ContextType.RbmObservable)) {
            // description = "Model / Observables";
            // } else {
            System.err.println("Bad issue context for " + ((SpeciesPattern) source).toString());
            description = ((SpeciesPattern) source).toString();
        // }
        } else if (source instanceof Structure) {
            Structure structure = (Structure) source;
            description = "Model / " + structure.getTypeName() + "(" + structure.getName() + ")";
        } else if (source instanceof StructureMapping) {
            StructureMapping structureMapping = (StructureMapping) source;
            description = ((StructureMappingNameScope) structureMapping.getNameScope()).getPathDescription();
        } else if (source instanceof OutputFunctionIssueSource) {
            SimulationContext simulationContext = (SimulationContext) ((OutputFunctionIssueSource) source).getOutputFunctionContext().getSimulationOwner();
            description = "App(" + simulationContext.getName() + ") / " + "Simulations" + " / " + "Output Functions";
        } else if (source instanceof Simulation) {
            Simulation simulation = (Simulation) source;
            try {
                SimulationContext simulationContext = bioModel.getSimulationContext(simulation);
                description = "App(" + simulationContext.getName() + ") / Simulations";
            } catch (ObjectNotFoundException e) {
                e.printStackTrace();
                description = "App(" + "unknown" + ") / Simulations";
            }
        } else if (source instanceof UnmappedGeometryClass) {
            UnmappedGeometryClass unmappedGC = (UnmappedGeometryClass) source;
            description = "App(" + unmappedGC.getSimulationContext().getName() + ") / Subdomain(" + unmappedGC.getGeometryClass().getName() + ")";
        } else if (source instanceof GeometryContext) {
            description = "App(" + ((GeometryContext) source).getSimulationContext().getName() + ")";
        } else if (source instanceof ModelOptimizationSpec) {
            description = "App(" + ((ModelOptimizationSpec) source).getSimulationContext().getName() + ") / Parameter Estimation";
        } else if (source instanceof MicroscopeMeasurement) {
            description = "App(" + ((MicroscopeMeasurement) source).getSimulationContext().getName() + ") / Microscope Measurements";
        } else if (source instanceof SpatialObject) {
            description = "App(" + ((SpatialObject) source).getSimulationContext().getName() + ") / Spatial Objects";
        } else if (source instanceof SpatialProcess) {
            description = "App(" + ((SpatialProcess) source).getSimulationContext().getName() + ") / Spatial Processes";
        } else if (source instanceof SpeciesContextSpec) {
            SpeciesContextSpec scs = (SpeciesContextSpec) source;
            description = "App(" + scs.getSimulationContext().getName() + ") / Specifications / Species";
        } else if (source instanceof ReactionCombo) {
            ReactionCombo rc = (ReactionCombo) source;
            description = "App(" + rc.getReactionContext().getSimulationContext().getName() + ") / Specifications / Reactions";
        } else if (source instanceof RbmModelContainer) {
            IssueCategory ic = issue.getCategory();
            switch(ic) {
                case RbmMolecularTypesTableBad:
                    description = "Model / " + MolecularType.typeName + "s";
                    break;
                case RbmReactionRulesTableBad:
                    description = "Model / Reactions";
                    break;
                case RbmObservablesTableBad:
                    description = "Model / Observables";
                    break;
                case RbmNetworkConstraintsBad:
                    description = "Network Constrains";
                    break;
                default:
                    description = "Model";
                    break;
            }
        } else if (source instanceof SimulationContext) {
            SimulationContext sc = (SimulationContext) source;
            IssueCategory ic = issue.getCategory();
            switch(ic) {
                case RbmNetworkConstraintsBad:
                    description = "Specifications / Network";
                    break;
                default:
                    description = "Application";
                    break;
            }
        } else if (source instanceof Model) {
            description = "Model";
        } else if (source instanceof BioEvent) {
            return "Protocols / Events";
        } else if (source instanceof MathDescription) {
            return "Math Description";
        } else {
            System.err.println("unknown source type in IssueTableModel.getSourceObjectPathDescription(): " + source.getClass());
        }
        return description;
    } else if (vcDocument instanceof MathModel) {
        if (source instanceof Geometry) {
            return GuiConstants.DOCUMENT_EDITOR_FOLDERNAME_MATH_GEOMETRY;
        } else if (source instanceof OutputFunctionIssueSource) {
            return GuiConstants.DOCUMENT_EDITOR_FOLDERNAME_MATH_OUTPUTFUNCTIONS;
        } else if (source instanceof Simulation) {
            return "Simulation(" + ((Simulation) source).getName() + ")";
        } else {
            return GuiConstants.DOCUMENT_EDITOR_FOLDERNAME_MATH_VCML;
        }
    } else {
        System.err.println("unknown document type in IssueTableModel.getSourceObjectPathDescription()");
        return "";
    }
}
Also used : MathModel(cbit.vcell.mathmodel.MathModel) IssueCategory(org.vcell.util.Issue.IssueCategory) MathDescription(cbit.vcell.math.MathDescription) IssueOrigin(org.vcell.util.Issue.IssueOrigin) SpeciesContext(cbit.vcell.model.SpeciesContext) SpeciesContextSpec(cbit.vcell.mapping.SpeciesContextSpec) StructureMapping(cbit.vcell.mapping.StructureMapping) SpeciesPattern(org.vcell.model.rbm.SpeciesPattern) SpatialObject(cbit.vcell.mapping.spatial.SpatialObject) SymbolTableEntry(cbit.vcell.parser.SymbolTableEntry) OutputFunctionIssueSource(cbit.vcell.solver.OutputFunctionContext.OutputFunctionIssueSource) RbmModelContainer(cbit.vcell.model.Model.RbmModelContainer) ModelOptimizationSpec(cbit.vcell.modelopt.ModelOptimizationSpec) SpatialProcess(cbit.vcell.mapping.spatial.processes.SpatialProcess) UnmappedGeometryClass(cbit.vcell.mapping.GeometryContext.UnmappedGeometryClass) MicroscopeMeasurement(cbit.vcell.mapping.MicroscopeMeasurement) GeometryContext(cbit.vcell.mapping.GeometryContext) ReactionRuleNameScope(cbit.vcell.model.ReactionRule.ReactionRuleNameScope) Structure(cbit.vcell.model.Structure) ReactionCombo(cbit.vcell.mapping.ReactionSpec.ReactionCombo) ReactionRule(cbit.vcell.model.ReactionRule) RbmObservable(cbit.vcell.model.RbmObservable) SimulationContext(cbit.vcell.mapping.SimulationContext) MolecularType(org.vcell.model.rbm.MolecularType) Geometry(cbit.vcell.geometry.Geometry) Simulation(cbit.vcell.solver.Simulation) BioModel(cbit.vcell.biomodel.BioModel) ReactionStep(cbit.vcell.model.ReactionStep) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) MathModel(cbit.vcell.mathmodel.MathModel) Model(cbit.vcell.model.Model) BioModel(cbit.vcell.biomodel.BioModel) SpatialObject(cbit.vcell.mapping.spatial.SpatialObject) BioEvent(cbit.vcell.mapping.BioEvent)

Example 30 with SymbolTableEntry

use of cbit.vcell.parser.SymbolTableEntry in project vcell by virtualcell.

the class IssueTableModel method getSourceObjectDescription.

private String getSourceObjectDescription(VCDocument vcDocument, Issue issue) {
    if (vcDocument instanceof BioModel) {
        Object object = issue.getSource();
        {
            DecoratedIssueSource dis = BeanUtils.downcast(DecoratedIssueSource.class, object);
            if (dis != null) {
                return dis.getSourcePath();
            }
        }
        String description = "";
        if (object instanceof SymbolTableEntry) {
            description = ((SymbolTableEntry) object).getName();
        } else if (object instanceof ReactionStep) {
            description = ((ReactionStep) object).getName();
        } else if (object instanceof ReactionRule) {
            description = ((ReactionRule) object).getName();
        } else if (object instanceof SpeciesPattern) {
            // Object parent = issue.getIssueContext().getContextObject();
            // if (parent instanceof SpeciesContext){
            // description = ((SpeciesContext)parent).getName();
            // }
            // if (issue.getIssueContext().hasContextType(ContextType.SpeciesContext)){
            // SpeciesContext thing = (SpeciesContext)issue.getIssueContext().getContextObject(ContextType.SpeciesContext);
            // description = thing.getName();
            // }else if(issue.getIssueContext().hasContextType(ContextType.ReactionRule)) {
            // ReactionRule thing = (ReactionRule)issue.getIssueContext().getContextObject(ContextType.ReactionRule);
            // description = thing.getName();
            // }else if(issue.getIssueContext().hasContextType(ContextType.RbmObservable)) {
            // RbmObservable thing = (RbmObservable)issue.getIssueContext().getContextObject(ContextType.RbmObservable);
            // description = thing.getName();
            // } else {
            System.err.println("Bad issue context for " + ((SpeciesPattern) object).toString());
            description = ((SpeciesPattern) object).toString();
        // }
        } else if (object instanceof MolecularType) {
            description = ((MolecularType) object).getName();
        } else if (object instanceof MolecularComponent) {
            description = ((MolecularComponent) object).getName();
        } else if (object instanceof ComponentStateDefinition) {
            description = ((ComponentStateDefinition) object).getName();
        } else if (object instanceof Structure) {
            description = ((Structure) object).getName();
        } else if (object instanceof SubDomain) {
            description = ((SubDomain) object).getName();
        } else if (object instanceof Geometry) {
            description = ((Geometry) object).getName();
        } else if (object instanceof StructureMapping) {
            description = ((StructureMapping) object).getStructure().getName();
        } else if (object instanceof OutputFunctionIssueSource) {
            description = ((OutputFunctionIssueSource) object).getAnnotatedFunction().getName();
        } else if (object instanceof UnmappedGeometryClass) {
            description = ((UnmappedGeometryClass) object).getGeometryClass().getName();
        } else if (object instanceof MicroscopeMeasurement) {
            description = ((MicroscopeMeasurement) object).getName();
        } else if (object instanceof SpatialObject) {
            description = ((SpatialObject) object).getName();
        } else if (object instanceof SpatialProcess) {
            description = ((SpatialProcess) object).getName();
        } else if (object instanceof GeometryContext) {
            description = "Geometry";
        } else if (object instanceof ModelOptimizationSpec) {
            description = ((ModelOptimizationSpec) object).getParameterEstimationTask().getName();
        } else if (object instanceof Simulation) {
            description = ((Simulation) object).getName();
        } else if (object instanceof SpeciesContextSpec) {
            SpeciesContextSpec scs = (SpeciesContextSpec) object;
            description = scs.getSpeciesContext().getName();
        } else if (object instanceof ReactionCombo) {
            ReactionSpec rs = ((ReactionCombo) object).getReactionSpec();
            description = rs.getReactionStep().getName();
        } else if (object instanceof RbmModelContainer) {
            // RbmModelContainer mc = (RbmModelContainer)object;
            description = "Rules validator";
        } else if (object instanceof SimulationContext) {
            SimulationContext sc = (SimulationContext) object;
            description = sc.getName();
        } else if (object instanceof Model) {
            Model m = (Model) object;
            description = m.getName();
        } else if (object instanceof BioEvent) {
            return ((BioEvent) object).getName() + "";
        } else if (object instanceof MathDescription) {
            return ((MathDescription) object).getName() + "";
        } else {
            System.err.println("unknown object type in IssueTableModel.getSourceObjectDescription(): " + object.getClass());
        }
        return description;
    } else if (vcDocument instanceof MathModel) {
        Object object = issue.getSource();
        String description = "";
        if (object instanceof Variable) {
            description = ((Variable) object).getName();
        } else if (object instanceof SubDomain) {
            description = ((SubDomain) object).getName();
        } else if (object instanceof Geometry) {
            description = "Geometry";
        } else if (object instanceof OutputFunctionIssueSource) {
            description = ((OutputFunctionIssueSource) object).getAnnotatedFunction().getName();
        } else if (object instanceof MathDescription) {
            return "math";
        } else if (object instanceof Simulation) {
            return "Simulation " + ((Simulation) object).getName() + "";
        }
        return description;
    } else {
        System.err.println("unknown document type in IssueTableModel.getSourceObjectDescription()");
        return "";
    }
}
Also used : MathModel(cbit.vcell.mathmodel.MathModel) Variable(cbit.vcell.math.Variable) MathDescription(cbit.vcell.math.MathDescription) SpeciesContextSpec(cbit.vcell.mapping.SpeciesContextSpec) StructureMapping(cbit.vcell.mapping.StructureMapping) SpeciesPattern(org.vcell.model.rbm.SpeciesPattern) ComponentStateDefinition(org.vcell.model.rbm.ComponentStateDefinition) SpatialObject(cbit.vcell.mapping.spatial.SpatialObject) SubDomain(cbit.vcell.math.SubDomain) SymbolTableEntry(cbit.vcell.parser.SymbolTableEntry) OutputFunctionIssueSource(cbit.vcell.solver.OutputFunctionContext.OutputFunctionIssueSource) MolecularComponent(org.vcell.model.rbm.MolecularComponent) RbmModelContainer(cbit.vcell.model.Model.RbmModelContainer) SpatialProcess(cbit.vcell.mapping.spatial.processes.SpatialProcess) ModelOptimizationSpec(cbit.vcell.modelopt.ModelOptimizationSpec) UnmappedGeometryClass(cbit.vcell.mapping.GeometryContext.UnmappedGeometryClass) MicroscopeMeasurement(cbit.vcell.mapping.MicroscopeMeasurement) GeometryContext(cbit.vcell.mapping.GeometryContext) Structure(cbit.vcell.model.Structure) ReactionCombo(cbit.vcell.mapping.ReactionSpec.ReactionCombo) ReactionRule(cbit.vcell.model.ReactionRule) DecoratedIssueSource(cbit.vcell.client.desktop.DecoratedIssueSource) ReactionSpec(cbit.vcell.mapping.ReactionSpec) SimulationContext(cbit.vcell.mapping.SimulationContext) MolecularType(org.vcell.model.rbm.MolecularType) Geometry(cbit.vcell.geometry.Geometry) Simulation(cbit.vcell.solver.Simulation) BioModel(cbit.vcell.biomodel.BioModel) ReactionStep(cbit.vcell.model.ReactionStep) MathModel(cbit.vcell.mathmodel.MathModel) Model(cbit.vcell.model.Model) BioModel(cbit.vcell.biomodel.BioModel) SpatialObject(cbit.vcell.mapping.spatial.SpatialObject) BioEvent(cbit.vcell.mapping.BioEvent)

Aggregations

SymbolTableEntry (cbit.vcell.parser.SymbolTableEntry)115 Expression (cbit.vcell.parser.Expression)50 ExpressionException (cbit.vcell.parser.ExpressionException)20 Vector (java.util.Vector)20 ArrayList (java.util.ArrayList)19 SpeciesContext (cbit.vcell.model.SpeciesContext)18 ModelParameter (cbit.vcell.model.Model.ModelParameter)14 PropertyVetoException (java.beans.PropertyVetoException)14 VCUnitDefinition (cbit.vcell.units.VCUnitDefinition)13 Model (cbit.vcell.model.Model)12 KineticsParameter (cbit.vcell.model.Kinetics.KineticsParameter)11 HashMap (java.util.HashMap)11 SimulationContext (cbit.vcell.mapping.SimulationContext)10 Variable (cbit.vcell.math.Variable)10 LocalParameter (cbit.vcell.mapping.ParameterContext.LocalParameter)9 SpeciesContextSpec (cbit.vcell.mapping.SpeciesContextSpec)9 Parameter (cbit.vcell.model.Parameter)9 SingleXPlot2D (cbit.plot.SingleXPlot2D)8 MathException (cbit.vcell.math.MathException)8 ReservedVariable (cbit.vcell.math.ReservedVariable)8