Search in sources :

Example 31 with SymbolTableEntry

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

the class ParameterEstimationPanel method initialize.

@Override
protected void initialize() {
    super.initialize();
    setName("Parameter Estimation");
    setLayout(new java.awt.BorderLayout());
    referenceDataPanel = new ReferenceDataPanel();
    runTaskPanel = new ParameterEstimationRunTaskPanel();
    getparameterMappingPanel().setBorder(GuiConstants.TAB_PANEL_BORDER);
    referenceDataPanel.setBorder(GuiConstants.TAB_PANEL_BORDER);
    getDataMappingPanel().setBorder(GuiConstants.TAB_PANEL_BORDER);
    runTaskPanel.setBorder(GuiConstants.TAB_PANEL_BORDER);
    tabbedPane.addTab(ParameterEstimationPanelTabID.parameters.title, getparameterMappingPanel());
    tabbedPane.addTab(ParameterEstimationPanelTabID.experimental_data_import.title, referenceDataPanel);
    tabbedPane.addTab(ParameterEstimationPanelTabID.experimental_data_mapping.title, getDataMappingPanel());
    tabbedPane.addTab(ParameterEstimationPanelTabID.run_task.title, runTaskPanel);
    add(tabbedPane, BorderLayout.CENTER);
    add(getButtonPanel(), BorderLayout.NORTH);
    getNewAnalysisTaskButton().addActionListener(eventHandler);
    getDeleteAnalysisTaskButton().addActionListener(eventHandler);
    getCopyButton().addActionListener(eventHandler);
    getAnalysisTaskComboBox().addActionListener(eventHandler);
    getMapButton().addActionListener(eventHandler);
    getEvaluateConfidenceIntervalButton().addActionListener(eventHandler);
    getDataModelMappingTable().getSelectionModel().addListSelectionListener(eventHandler);
    dataModelMappingTable.addMouseListener(eventHandler);
    getDataModelMappingTable().setDefaultRenderer(SymbolTableEntry.class, new DefaultScrollTableCellRenderer() {

        public java.awt.Component getTableCellRendererComponent(javax.swing.JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
            super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
            if (value == null) {
                setText("unmapped");
                return this;
            }
            SymbolTableEntry ste = (SymbolTableEntry) value;
            if (ste instanceof Model.ReservedSymbol) {
                setText(ste.getName());
            } else if (ste instanceof SpeciesContext) {
                setText("[" + ste.getName() + "]");
            } else if (ste instanceof KineticsParameter) {
                setText(ste.getNameScope().getName() + ":" + ste.getName());
            } else if (ste instanceof ModelParameter) {
                setText(ste.getName());
            } else if (ste instanceof ReservedVariable) {
                setText(ste.getName());
            } else {
                setText(ste.getNameScope().getAbsoluteScopePrefix() + ste.getName());
            }
            return this;
        }
    });
    getDataModelMappingTable().setModel(getreferenceDataMappingSpecTableModel());
    getDataModelMappingTable().createDefaultColumnsFromModel();
}
Also used : SpeciesContext(cbit.vcell.model.SpeciesContext) ParameterEstimationRunTaskPanel(org.vcell.optimization.gui.ParameterEstimationRunTaskPanel) ModelParameter(cbit.vcell.model.Model.ModelParameter) SymbolTableEntry(cbit.vcell.parser.SymbolTableEntry) ReservedVariable(cbit.vcell.math.ReservedVariable) KineticsParameter(cbit.vcell.model.Kinetics.KineticsParameter) ReferenceDataMappingSpecTableModel(org.vcell.optimization.gui.ReferenceDataMappingSpecTableModel) AnalysisTaskComboBoxModel(org.vcell.optimization.gui.AnalysisTaskComboBoxModel) Model(cbit.vcell.model.Model) DefaultScrollTableCellRenderer(org.vcell.util.gui.DefaultScrollTableCellRenderer) BorderLayout(java.awt.BorderLayout) ReferenceDataPanel(org.vcell.optimization.gui.ReferenceDataPanel)

Example 32 with SymbolTableEntry

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

the class PredefinedSymbolsTableModel method getComparator.

@Override
protected Comparator<SymbolTableEntry> getComparator(final int col, final boolean ascending) {
    return new Comparator<SymbolTableEntry>() {

        public int compare(SymbolTableEntry o1, SymbolTableEntry o2) {
            int scale = ascending ? 1 : -1;
            switch(col) {
                case COLUMN_NAME:
                    return scale * getName(o1).compareToIgnoreCase(getName(o2));
                case COLUMN_DESCRIPTION:
                    return scale * getDescription(o1).compareToIgnoreCase(getDescription(o2));
                case COLUMN_EXPRESSION:
                    Expression e1 = null;
                    Expression e2 = null;
                    if (o1 instanceof Model.ReservedSymbol) {
                        e1 = ((Model.ReservedSymbol) o1).getExpression();
                    }
                    if (o2 instanceof Model.ReservedSymbol) {
                        e2 = ((Model.ReservedSymbol) o2).getExpression();
                    }
                    return TableUtil.expressionCompare(e1, e2, ascending);
                case COLUMN_UNIT:
                    String u1 = o1.getUnitDefinition() == null ? "" : o1.getUnitDefinition().getSymbol();
                    String u2 = o2.getUnitDefinition() == null ? "" : o2.getUnitDefinition().getSymbol();
                    return scale * u1.compareToIgnoreCase(u2);
            }
            return 0;
        }
    };
}
Also used : SymbolTableEntry(cbit.vcell.parser.SymbolTableEntry) Expression(cbit.vcell.parser.Expression) Model(cbit.vcell.model.Model) Comparator(java.util.Comparator)

Example 33 with SymbolTableEntry

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

the class PredefinedSymbolsTableModel method computeData.

@Override
protected List<SymbolTableEntry> computeData() {
    List<SymbolTableEntry> predefinedSymbolList = new ArrayList<SymbolTableEntry>();
    if (getModel() != null) {
        predefinedSymbolList.addAll(Arrays.asList(getModel().getReservedSymbols()));
        predefinedSymbolList.addAll(Arrays.asList(getModel().getModelFunctions()));
    }
    predefinedSymbolList.addAll(Arrays.asList(ASTFuncNode.predefinedSymbolTableFunctionEntries));
    List<SymbolTableEntry> searchList = null;
    if (searchText == null || searchText.length() == 0) {
        searchList = predefinedSymbolList;
    } else {
        String lowerCaseSearchText = searchText.toLowerCase();
        searchList = new ArrayList<SymbolTableEntry>();
        for (SymbolTableEntry ste : predefinedSymbolList) {
            String expression = getExpression(ste);
            if (getName(ste).toLowerCase().contains(lowerCaseSearchText) || getDescription(ste).toLowerCase().contains(lowerCaseSearchText) || expression != null && expression.toLowerCase().contains(lowerCaseSearchText) || ste.getUnitDefinition() != null && ste.getUnitDefinition().getSymbol().toLowerCase().contains(lowerCaseSearchText)) {
                searchList.add(ste);
            }
        }
    }
    return searchList;
}
Also used : SymbolTableEntry(cbit.vcell.parser.SymbolTableEntry) ArrayList(java.util.ArrayList)

Example 34 with SymbolTableEntry

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

the class BioModel method findReferences.

public List<SymbolTableEntry> findReferences(SymbolTableEntry symbolTableEntry) {
    ArrayList<SymbolTableEntry> references = new ArrayList<SymbolTableEntry>();
    HashSet<NameScope> visited = new HashSet<NameScope>();
    fieldModel.getNameScope().findReferences(symbolTableEntry, references, visited);
    for (SimulationContext simContext : fieldSimulationContexts) {
        simContext.getNameScope().findReferences(symbolTableEntry, references, visited);
    }
    return references;
}
Also used : SymbolTableEntry(cbit.vcell.parser.SymbolTableEntry) NameScope(cbit.vcell.parser.NameScope) ArrayList(java.util.ArrayList) SimulationContext(cbit.vcell.mapping.SimulationContext) HashSet(java.util.HashSet)

Example 35 with SymbolTableEntry

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

the class ModelUnitConverter method convertExprWithUnitFactors.

private static void convertExprWithUnitFactors(SymbolTable oldSymbolTable, SymbolTable newSymbolTable, VCUnitDefinition oldExprUnit, VCUnitDefinition newExprUnit, Expression expr) throws ExpressionException {
    if (expr == null) {
        return;
    }
    String[] symbols = expr.getSymbols();
    if (symbols != null) {
        for (String s : symbols) {
            SymbolTableEntry boundSTE = expr.getSymbolBinding(s);
            SymbolTableEntry newSTE = newSymbolTable.getEntry(s);
            SymbolTableEntry oldSTE = oldSymbolTable.getEntry(s);
            if (boundSTE == null) {
                System.err.println("symbol '" + s + "' in expression " + expr.infix() + " was not bound to the model");
                continue;
            }
            if (oldSTE == null) {
                System.err.println("symbol '" + s + "' in expression " + expr.infix() + " was not found in the new symbol table");
                continue;
            }
            if (newSTE == null) {
                System.err.println("symbol '" + s + "' in expression " + expr.infix() + " was not bound to the old symbol table");
                continue;
            }
            if (newSTE != boundSTE) {
                System.err.println("symbol '" + s + "' in expression " + expr.infix() + " is not bound properly (binding doesn't match new symbol table)");
                continue;
            }
            if (oldSTE.getUnitDefinition() == null) {
                System.err.println("symbol '" + s + "' in expression " + expr.infix() + " is has a null unit in old model, can't convert");
                continue;
            }
            if (newSTE.getUnitDefinition() == null) {
                System.err.println("symbol '" + s + "' in expression " + expr.infix() + " is has a null unit in new model, can't convert");
                continue;
            }
            if (oldSTE.getUnitDefinition().isTBD()) {
                continue;
            }
            if (newSTE.getUnitDefinition().isTBD()) {
                continue;
            }
            VCUnitDefinition oldToNewConversionUnit = oldSTE.getUnitDefinition().divideBy(newSTE.getUnitDefinition());
            RationalNumber conversionFactor = oldToNewConversionUnit.getDimensionlessScale();
            if (conversionFactor.doubleValue() != 1.0) {
                Expression spcSymbol = new Expression(newSTE, newSTE.getNameScope());
                expr.substituteInPlace(spcSymbol, Expression.mult(spcSymbol, new Expression(conversionFactor)));
            }
        }
    }
    if (oldExprUnit == null || oldExprUnit.isTBD() || newExprUnit == null || newExprUnit.isTBD()) {
        Expression flattened = expr.flatten();
        Expression origExp = new Expression(expr);
        expr.substituteInPlace(origExp, flattened);
        return;
    }
    VCUnitDefinition oldToNewConversionUnit = newExprUnit.divideBy(oldExprUnit);
    RationalNumber conversionFactor = oldToNewConversionUnit.getDimensionlessScale();
    if (conversionFactor.doubleValue() != 1.0) {
        Expression oldExp = new Expression(expr);
        expr.substituteInPlace(oldExp, Expression.mult(oldExp, new Expression(conversionFactor)));
    }
    Expression flattened = expr.flatten();
    Expression origExp = new Expression(expr);
    expr.substituteInPlace(origExp, flattened);
}
Also used : SymbolTableEntry(cbit.vcell.parser.SymbolTableEntry) VCUnitDefinition(cbit.vcell.units.VCUnitDefinition) Expression(cbit.vcell.parser.Expression) RationalNumber(cbit.vcell.matrix.RationalNumber)

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