Search in sources :

Example 1 with NameScope

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();
    }
}
Also used : ModelParameter(cbit.vcell.model.Model.ModelParameter) KineticsParameter(cbit.vcell.model.Kinetics.KineticsParameter) NameScope(cbit.vcell.parser.NameScope) Expression(cbit.vcell.parser.Expression) HMM_IRRKinetics(cbit.vcell.model.HMM_IRRKinetics) ReactionStep(cbit.vcell.model.ReactionStep) Catalyst(cbit.vcell.model.Catalyst) ExpressionException(cbit.vcell.parser.ExpressionException)

Example 2 with NameScope

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);
    }
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) JButton(javax.swing.JButton) JTextField(javax.swing.JTextField) JTabbedPaneEnhanced(org.vcell.util.gui.JTabbedPaneEnhanced) MouseListener(java.awt.event.MouseListener) BorderLayout(java.awt.BorderLayout) Component(java.awt.Component) JComponent(javax.swing.JComponent) MouseEvent(java.awt.event.MouseEvent) NameScope(cbit.vcell.parser.NameScope) MouseAdapter(java.awt.event.MouseAdapter) JLabel(javax.swing.JLabel) JCheckBox(javax.swing.JCheckBox) JTable(javax.swing.JTable) DefaultScrollTableCellRenderer(org.vcell.util.gui.DefaultScrollTableCellRenderer) EditorScrollTable(org.vcell.util.gui.EditorScrollTable)

Example 3 with NameScope

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;
}
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 4 with NameScope

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;
        }
    });
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) NameScope(cbit.vcell.parser.NameScope) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) JTextField(javax.swing.JTextField) JCheckBox(javax.swing.JCheckBox) BorderLayout(java.awt.BorderLayout) JTable(javax.swing.JTable) DefaultScrollTableCellRenderer(org.vcell.util.gui.DefaultScrollTableCellRenderer) WorkflowObject(org.vcell.workflow.WorkflowObject) EditorScrollTable(org.vcell.util.gui.EditorScrollTable) Component(java.awt.Component)

Example 5 with NameScope

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;
}
Also used : VCUnitDefinition(cbit.vcell.units.VCUnitDefinition) SymbolTableEntry(cbit.vcell.parser.SymbolTableEntry) NameScope(cbit.vcell.parser.NameScope) Expression(cbit.vcell.parser.Expression) ModelUnitSystem(cbit.vcell.model.ModelUnitSystem)

Aggregations

NameScope (cbit.vcell.parser.NameScope)8 Expression (cbit.vcell.parser.Expression)4 ExpressionException (cbit.vcell.parser.ExpressionException)3 Catalyst (cbit.vcell.model.Catalyst)2 KineticsParameter (cbit.vcell.model.Kinetics.KineticsParameter)2 ModelParameter (cbit.vcell.model.Model.ModelParameter)2 ReactionStep (cbit.vcell.model.ReactionStep)2 SymbolTableEntry (cbit.vcell.parser.SymbolTableEntry)2 BorderLayout (java.awt.BorderLayout)2 Component (java.awt.Component)2 GridBagConstraints (java.awt.GridBagConstraints)2 GridBagLayout (java.awt.GridBagLayout)2 Insets (java.awt.Insets)2 JButton (javax.swing.JButton)2 JCheckBox (javax.swing.JCheckBox)2 JLabel (javax.swing.JLabel)2 JPanel (javax.swing.JPanel)2 JTable (javax.swing.JTable)2 JTextField (javax.swing.JTextField)2 DefaultScrollTableCellRenderer (org.vcell.util.gui.DefaultScrollTableCellRenderer)2