use of cbit.vcell.parser.NameScope in project vcell by virtualcell.
the class SBPAXHMMIrrevLawBuilder method addKinetics.
public void addKinetics(KineticContext context) {
try {
ReactionStep reaction = context.getReaction();
HMM_IRRKinetics kinetics = new HMM_IRRKinetics((SimpleReaction) reaction);
NameScope modelScope = reaction.getModel().getNameScope();
ModelParameter kMichaelis = context.getParameter(SBOList.MICHAELIS_CONST_FORW);
if (kMichaelis != null) {
KineticsParameter kmParameter = kinetics.getKmParameter();
kmParameter.setExpression(new Expression(kMichaelis, modelScope));
kmParameter.setUnitDefinition(kMichaelis.getUnitDefinition());
}
ModelParameter kcat = context.getParameter(SBOList.CATALYTIC_RATE_CONST_FORW);
if (kcat != null && context.getCatalysts().size() == 1) {
KineticsParameter vmaxParameter = kinetics.getVmaxParameter();
Catalyst catalyst = context.getCatalysts().iterator().next();
vmaxParameter.setExpression(Expression.mult(new Expression(kcat, modelScope), new Expression(catalyst.getSpeciesContext(), modelScope)));
// vmaxParameter.setUnitDefinition(vMax.getUnitDefinition());
} else {
ModelParameter vMax = context.getParameter(SBOList.MAXIMAL_VELOCITY_FORW);
if (vMax != null) {
KineticsParameter vmaxParameter = kinetics.getVmaxParameter();
vmaxParameter.setExpression(new Expression(vMax, modelScope));
vmaxParameter.setUnitDefinition(vMax.getUnitDefinition());
}
}
} catch (ExpressionException e) {
e.printStackTrace();
}
}
use of cbit.vcell.parser.NameScope in project vcell by virtualcell.
the class BioModelParametersPanel method initialize.
private void initialize() {
addNewButton = new JButton("New Global Parameter");
addNewButton.addActionListener(eventHandler);
addNewButton2 = new JButton("New Application Parameter");
// addNewButton2.setIcon(downArrow);
addNewButton2.setHorizontalTextPosition(SwingConstants.LEFT);
addNewButton2.addActionListener(eventHandler);
deleteButton = new JButton("Delete");
deleteButton.setEnabled(false);
deleteButton.addActionListener(eventHandler);
changeUnitsButton = new JButton("Change Unit System");
changeUnitsButton.addActionListener(eventHandler);
textFieldSearch = new JTextField(10);
textFieldSearch.getDocument().addDocumentListener(eventHandler);
textFieldSearch.putClientProperty("JTextField.variant", "search");
parametersFunctionsTable = new EditorScrollTable();
parametersFunctionsTableModel = new BioModelParametersTableModel(parametersFunctionsTable);
parametersFunctionsTable.setModel(parametersFunctionsTableModel);
globalParametersCheckBox = new JCheckBox("Global");
globalParametersCheckBox.setSelected(true);
globalParametersCheckBox.addActionListener(eventHandler);
reactionsCheckBox = new JCheckBox("Reactions and Rules");
reactionsCheckBox.setSelected(true);
reactionsCheckBox.addActionListener(eventHandler);
applicationsCheckBox = new JCheckBox("Applications");
applicationsCheckBox.setSelected(true);
applicationsCheckBox.addActionListener(eventHandler);
applicationComboBox = new JComboBox<ApplicationSelection>();
applicationComboBox.setSelectedItem("All");
applicationComboBox.addActionListener(eventHandler);
applicationComboBox.setModel(applicationComboBoxModel);
applicationComboBox.setRenderer(new ApplicationComboBoxRenderer());
constantsCheckBox = new JCheckBox("Parameters");
constantsCheckBox.setSelected(true);
constantsCheckBox.addActionListener(eventHandler);
functionsCheckBox = new JCheckBox("Functions");
functionsCheckBox.setSelected(true);
functionsCheckBox.addActionListener(eventHandler);
predefinedSymbolsTable = new EditorScrollTable();
predefinedSymbolsTableModel = new PredefinedSymbolsTableModel(predefinedSymbolsTable);
predefinedSymbolsTable.setModel(predefinedSymbolsTableModel);
GuiUtils.flexResizeTableColumns(predefinedSymbolsTable);
modelUnitSystemTable = new EditorScrollTable();
modelUnitSystemTableModel = new ModelUnitSystemTableModel(modelUnitSystemTable);
modelUnitSystemTable.setModel(modelUnitSystemTableModel);
GuiUtils.flexResizeTableColumns(modelUnitSystemTable);
tabbedPane = new JTabbedPaneEnhanced();
tabbedPane.addChangeListener(eventHandler);
ParametersPanelTab[] parametersPanelTabs = new ParametersPanelTab[ParametersPanelTabID.values().length];
parametersPanelTabs[ParametersPanelTabID.parameters_functions.ordinal()] = new ParametersPanelTab(ParametersPanelTabID.parameters_functions, getParametersFunctionsPanel(), null);
parametersPanelTabs[ParametersPanelTabID.predefined.ordinal()] = new ParametersPanelTab(ParametersPanelTabID.predefined, getPredefinedSymbolsPanel(), null);
parametersPanelTabs[ParametersPanelTabID.modelUnitSystem.ordinal()] = new ParametersPanelTab(ParametersPanelTabID.modelUnitSystem, getModelUnitSystemPanel(), null);
for (ParametersPanelTab tab : parametersPanelTabs) {
tab.component.setBorder(GuiConstants.TAB_PANEL_BORDER);
tabbedPane.addTab(tab.id.title, tab.icon, tab.component);
}
JPanel buttonPanel = new JPanel(new GridBagLayout());
int gridy = 0;
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.insets = new Insets(4, 4, 4, 4);
gbc.anchor = GridBagConstraints.LINE_END;
buttonPanel.add(addNewButton, gbc);
gbc = new GridBagConstraints();
gbc.gridx = GridBagConstraints.RELATIVE;
gbc.insets = new Insets(4, 4, 4, 4);
gbc.gridy = gridy;
gbc.anchor = GridBagConstraints.LINE_END;
buttonPanel.add(addNewButton2, gbc);
gbc = new GridBagConstraints();
gbc.gridx = GridBagConstraints.RELATIVE;
gbc.insets = new Insets(4, 4, 4, 4);
gbc.gridy = gridy;
gbc.anchor = GridBagConstraints.LINE_END;
buttonPanel.add(deleteButton, gbc);
gbc = new GridBagConstraints();
gbc.gridx = GridBagConstraints.RELATIVE;
gbc.insets = new Insets(4, 4, 4, 4);
gbc.gridy = gridy;
gbc.anchor = GridBagConstraints.LINE_END;
buttonPanel.add(changeUnitsButton, gbc);
gbc = new GridBagConstraints();
gbc.gridx = GridBagConstraints.RELATIVE;
gbc.gridy = gridy;
gbc.anchor = GridBagConstraints.LINE_END;
gbc.insets = new Insets(4, 50, 4, 4);
buttonPanel.add(new JLabel("Search"), gbc);
gbc = new GridBagConstraints();
gbc.gridx = GridBagConstraints.RELATIVE;
gbc.gridy = gridy;
gbc.weightx = 1.0;
gbc.gridwidth = 2;
gbc.anchor = GridBagConstraints.LINE_START;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(4, 4, 4, 4);
buttonPanel.add(textFieldSearch, gbc);
setLayout(new BorderLayout());
add(tabbedPane, BorderLayout.CENTER);
add(buttonPanel, BorderLayout.SOUTH);
parametersFunctionsTable.getSelectionModel().addListSelectionListener(eventHandler);
parametersFunctionsTable.setDefaultRenderer(NameScope.class, new DefaultScrollTableCellRenderer() {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if (value instanceof NameScope) {
NameScope nameScope = (NameScope) value;
setText(nameScope.getPathDescription());
}
return this;
}
});
{
// make double click on units panel bring up editing box
JPanel p = getModelUnitSystemPanel();
VCAssert.assertValid(p);
EditorScrollTable est = GuiUtils.findFirstChild(p, EditorScrollTable.class);
VCAssert.assertValid(est);
MouseListener ml = new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2) {
changeUnitsButtonPressed();
}
}
};
est.addMouseListener(ml);
}
}
use of cbit.vcell.parser.NameScope 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.NameScope in project vcell by virtualcell.
the class WorkflowObjectsPanel method initialize.
private void initialize() {
showButton = new JButton("show data");
showButton.addActionListener(eventHandler);
deleteButton = new JButton("Delete Task(s)");
deleteButton.setEnabled(false);
deleteButton.addActionListener(eventHandler);
runButton = new JButton("Run");
runButton.addActionListener(eventHandler);
textFieldSearch = new JTextField(10);
textFieldSearch.getDocument().addDocumentListener(eventHandler);
textFieldSearch.putClientProperty("JTextField.variant", "search");
parametersFunctionsTable = new EditorScrollTable();
parametersFunctionsTableModel = new WorkflowObjectsTableModel(parametersFunctionsTable);
parametersFunctionsTable.setModel(parametersFunctionsTableModel);
tasksCheckBox = new JCheckBox("Tasks");
tasksCheckBox.setSelected(true);
tasksCheckBox.addActionListener(eventHandler);
parametersCheckBox = new JCheckBox("parameters");
parametersCheckBox.setSelected(true);
parametersCheckBox.addActionListener(eventHandler);
taskInputsCheckBox = new JCheckBox("Task inputs");
taskInputsCheckBox.setSelected(true);
taskInputsCheckBox.addActionListener(eventHandler);
taskOutputsCheckBox = new JCheckBox("Task outputs");
taskOutputsCheckBox.setSelected(true);
taskOutputsCheckBox.addActionListener(eventHandler);
JPanel buttonPanel = new JPanel(new GridBagLayout());
int gridy = 0;
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.insets = new Insets(4, 4, 4, 4);
gbc.anchor = GridBagConstraints.LINE_END;
buttonPanel.add(showButton, gbc);
gbc = new GridBagConstraints();
gbc.gridx = GridBagConstraints.RELATIVE;
gbc.insets = new Insets(4, 4, 4, 4);
gbc.gridy = gridy;
gbc.anchor = GridBagConstraints.LINE_END;
buttonPanel.add(deleteButton, gbc);
gbc = new GridBagConstraints();
gbc.gridx = GridBagConstraints.RELATIVE;
gbc.insets = new Insets(4, 4, 4, 4);
gbc.gridy = gridy;
gbc.anchor = GridBagConstraints.LINE_END;
buttonPanel.add(runButton, gbc);
gbc = new GridBagConstraints();
gbc.gridx = GridBagConstraints.RELATIVE;
gbc.gridy = gridy;
gbc.anchor = GridBagConstraints.LINE_END;
gbc.insets = new Insets(4, 50, 4, 4);
buttonPanel.add(new JLabel("Search"), gbc);
gbc = new GridBagConstraints();
gbc.gridx = GridBagConstraints.RELATIVE;
gbc.gridy = gridy;
gbc.weightx = 1.0;
gbc.gridwidth = 2;
gbc.anchor = GridBagConstraints.LINE_START;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(4, 4, 4, 4);
buttonPanel.add(textFieldSearch, gbc);
setLayout(new BorderLayout());
add(getParametersFunctionsPanel(), BorderLayout.CENTER);
add(buttonPanel, BorderLayout.SOUTH);
parametersFunctionsTable.getSelectionModel().addListSelectionListener(eventHandler);
parametersFunctionsTable.setDefaultRenderer(NameScope.class, new DefaultScrollTableCellRenderer() {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if (value instanceof NameScope) {
NameScope nameScope = (NameScope) value;
setText(nameScope.getPathDescription());
}
return this;
}
});
}
use of cbit.vcell.parser.NameScope in project vcell by virtualcell.
the class PotentialMapping method getOdeRHS.
/**
* Insert the method's description here.
* Creation date: (4/24/2002 10:45:35 AM)
* @return cbit.vcell.parser.Expression
* @param capacitiveDevice cbit.vcell.mapping.potential.ElectricalDevice
*/
public Expression getOdeRHS(MembraneElectricalDevice capacitiveDevice, AbstractMathMapping mathMapping) throws ExpressionException, MappingException {
NameScope nameScope = mathMapping.getNameScope();
Expression transMembraneCurrent = capacitiveDevice.getParameterFromRole(ElectricalDevice.ROLE_TransmembraneCurrent).getExpression().renameBoundSymbols(nameScope);
Expression totalCapacitance = new Expression(capacitiveDevice.getCapacitanceParameter(), nameScope);
Expression totalCurrent = new Expression(capacitiveDevice.getTotalCurrentSymbol(), nameScope);
ModelUnitSystem modelUnitSystem = fieldMathMapping.getSimulationContext().getModel().getUnitSystem();
VCUnitDefinition potentialUnit = modelUnitSystem.getVoltageUnit();
VCUnitDefinition timeUnit = modelUnitSystem.getTimeUnit();
SymbolTableEntry capacitanceParameter = capacitiveDevice.getCapacitanceParameter();
VCUnitDefinition unitFactor = potentialUnit.divideBy(timeUnit).multiplyBy(capacitanceParameter.getUnitDefinition()).divideBy(capacitiveDevice.getTotalCurrentSymbol().getUnitDefinition());
Expression unitFactorExp = fieldMathMapping.getUnitFactor(unitFactor);
Expression exp = Expression.mult(Expression.div(unitFactorExp, totalCapacitance), Expression.add(totalCurrent, Expression.negate(transMembraneCurrent)));
// exp.bindExpression(mathMapping);
return exp;
}
Aggregations