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();
}
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;
}
};
}
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;
}
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;
}
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);
}
Aggregations