Search in sources :

Example 51 with RbmObservable

use of cbit.vcell.model.RbmObservable in project vcell by virtualcell.

the class EventPanel method filterEventAssignmentVariables.

public static ArrayList<String> filterEventAssignmentVariables(SimulationContext simContext) {
    // fill comboboxmodel with possible variables from simContext (symboltable entries) list
    Map<String, SymbolTableEntry> entryMap = new HashMap<String, SymbolTableEntry>();
    simContext.getEntries(entryMap);
    ArrayList<String> varNameList = new ArrayList<String>();
    for (String varName : entryMap.keySet()) {
        SymbolTableEntry symbolTableEntry = entryMap.get(varName);
        if (/*bExcludeFuncAndReserved && */
        (symbolTableEntry instanceof SymbolTableFunctionEntry || symbolTableEntry instanceof Structure.StructureSize || symbolTableEntry instanceof Model.ReservedSymbol || symbolTableEntry instanceof RbmObservable)) {
            continue;
        }
        if (simContext.getAssignmentRule(symbolTableEntry) != null) {
            // we don't allow assignment rule variables, they'll become functions in the math
            continue;
        }
        if (symbolTableEntry instanceof Model.ModelParameter) {
            // exclude global parameters that are rate or assignment rule variables
            if (simContext.getRateRule(symbolTableEntry) != null) {
                // it's a rate rule variable, we can use it
                ;
            } else {
                Model.ModelParameter mp = (Model.ModelParameter) symbolTableEntry;
                Expression exp = mp.getExpression();
                try {
                    boolean isConstant = BioEvent.isConstantExpression(simContext, exp);
                    if (!isConstant) {
                        // System.out.println(mp.getName() + " - NO");		// skip this
                        continue;
                    }
                // System.out.println(mp.getName() + " - yes: ");
                } catch (ExpressionException e) {
                    // System.out.println(mp.getName() + " - NO");			// skip this
                    continue;
                }
            }
        }
        varNameList.add(varName);
    }
    Collections.sort(varNameList);
    return varNameList;
}
Also used : HashMap(java.util.HashMap) RbmObservable(cbit.vcell.model.RbmObservable) ArrayList(java.util.ArrayList) ExpressionException(cbit.vcell.parser.ExpressionException) SymbolTableEntry(cbit.vcell.parser.SymbolTableEntry) Expression(cbit.vcell.parser.Expression) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) Model(cbit.vcell.model.Model) ListSelectionModel(javax.swing.ListSelectionModel) SymbolTableFunctionEntry(cbit.vcell.parser.SymbolTableFunctionEntry)

Aggregations

RbmObservable (cbit.vcell.model.RbmObservable)51 SpeciesPattern (org.vcell.model.rbm.SpeciesPattern)22 ReactionRule (cbit.vcell.model.ReactionRule)20 SpeciesContext (cbit.vcell.model.SpeciesContext)18 Structure (cbit.vcell.model.Structure)16 ArrayList (java.util.ArrayList)16 MolecularType (org.vcell.model.rbm.MolecularType)14 Model (cbit.vcell.model.Model)10 MolecularTypePattern (org.vcell.model.rbm.MolecularTypePattern)10 ReactionStep (cbit.vcell.model.ReactionStep)9 SimulationContext (cbit.vcell.mapping.SimulationContext)8 PropertyVetoException (java.beans.PropertyVetoException)8 BioModel (cbit.vcell.biomodel.BioModel)6 ModelException (cbit.vcell.model.ModelException)6 RbmModelContainer (cbit.vcell.model.Model.RbmModelContainer)5 ProductPattern (cbit.vcell.model.ProductPattern)5 ReactantPattern (cbit.vcell.model.ReactantPattern)5 Expression (cbit.vcell.parser.Expression)5 ExpressionException (cbit.vcell.parser.ExpressionException)5 LinkedHashMap (java.util.LinkedHashMap)5