use of cbit.vcell.parser.SymbolTableEntry in project vcell by virtualcell.
the class ReactionStep method getAutoCompleteSymbolFilter.
public AutoCompleteSymbolFilter getAutoCompleteSymbolFilter() {
AutoCompleteSymbolFilter stef = new AutoCompleteSymbolFilter() {
public boolean accept(SymbolTableEntry ste) {
if (ste instanceof StructureSize) {
if (((StructureSize) ste).getStructure() != structure) {
return false;
}
} else {
if (structure instanceof Membrane) {
Membrane membrane = (Membrane) structure;
StructureTopology structTopology = getModel().getStructureTopology();
if (ste instanceof SpeciesContext) {
Structure entryStructure = ((SpeciesContext) ste).getStructure();
if (entryStructure != membrane && entryStructure != structTopology.getInsideFeature(membrane) && entryStructure != structTopology.getOutsideFeature(membrane)) {
return false;
}
} else if (ste instanceof MembraneVoltage) {
if (((MembraneVoltage) ste).getMembrane() != membrane) {
return false;
}
}
} else {
if (ste instanceof SpeciesContext) {
Structure entryStructure = ((SpeciesContext) ste).getStructure();
if (entryStructure != structure) {
return false;
}
} else if (ste instanceof MembraneVoltage) {
return false;
}
}
}
return true;
}
public boolean acceptFunction(String funcName) {
return true;
}
};
return stef;
}
use of cbit.vcell.parser.SymbolTableEntry in project vcell by virtualcell.
the class ReactionStep method getLocalEntry.
public SymbolTableEntry getLocalEntry(String identifier) {
//
// if resolved parameter exists, then return it
//
SymbolTableEntry ste = getKinetics().getKineticsParameter(identifier);
if (ste != null) {
return ste;
}
//
// if unnresolved parameter exists, then return it
//
ste = getKinetics().getUnresolvedParameter(identifier);
if (ste != null) {
return ste;
}
//
// if proxy parameter exists, then return it
//
ste = getKinetics().getProxyParameter(identifier);
if (ste != null) {
return ste;
}
return null;
}
use of cbit.vcell.parser.SymbolTableEntry in project vcell by virtualcell.
the class ModelOptimizationMapping method getRemappedReferenceData.
/**
* Gets the constraintData property (cbit.vcell.opt.ConstraintData) value.
* @return The constraintData property value.
* @see #setConstraintData
*/
private ReferenceData getRemappedReferenceData(MathMapping mathMapping) throws MappingException {
if (modelOptimizationSpec.getReferenceData() == null) {
return null;
}
//
// make sure time is mapped
//
ReferenceData refData = modelOptimizationSpec.getReferenceData();
ReferenceDataMappingSpec[] refDataMappingSpecs = modelOptimizationSpec.getReferenceDataMappingSpecs();
RowColumnResultSet rowColResultSet = new RowColumnResultSet();
Vector<SymbolTableEntry> modelObjectList = new Vector<SymbolTableEntry>();
Vector<double[]> dataList = new Vector<double[]>();
//
// find bound columns, (time is always mapped to the first column)
//
int mappedColumnCount = 0;
for (int i = 0; i < refDataMappingSpecs.length; i++) {
SymbolTableEntry modelObject = refDataMappingSpecs[i].getModelObject();
if (modelObject != null) {
int mappedColumnIndex = mappedColumnCount;
if (modelObject instanceof Model.ReservedSymbol && ((ReservedSymbol) modelObject).isTime()) {
mappedColumnIndex = 0;
}
String origRefDataColumnName = refDataMappingSpecs[i].getReferenceDataColumnName();
int origRefDataColumnIndex = refData.findColumn(origRefDataColumnName);
if (origRefDataColumnIndex < 0) {
throw new RuntimeException("reference data column named '" + origRefDataColumnName + "' not found");
}
double[] columnData = refData.getDataByColumn(origRefDataColumnIndex);
if (modelObjectList.contains(modelObject)) {
throw new RuntimeException("multiple reference data columns mapped to same model object '" + modelObject.getName() + "'");
}
modelObjectList.insertElementAt(modelObject, mappedColumnIndex);
dataList.insertElementAt(columnData, mappedColumnIndex);
mappedColumnCount++;
}
}
//
if (modelObjectList.size() == 0) {
throw new RuntimeException("reference data was not associated with model");
}
if (modelObjectList.size() == 1) {
throw new RuntimeException("reference data was not associated with model, must map time and at least one other column");
}
boolean bFoundTimeVar = false;
for (SymbolTableEntry ste : modelObjectList) {
if (ste instanceof Model.ReservedSymbol && ((ReservedSymbol) ste).isTime()) {
bFoundTimeVar = true;
break;
}
}
if (!bFoundTimeVar) {
throw new RuntimeException("must map time column of reference data to model");
}
//
for (int i = 0; i < modelObjectList.size(); i++) {
SymbolTableEntry modelObject = (SymbolTableEntry) modelObjectList.elementAt(i);
try {
// Find by name because MathSybolMapping has different 'objects' than refDataMapping 'objects'
Variable variable = mathMapping.getMathSymbolMapping().findVariableByName(modelObject.getName());
if (variable != null) {
String symbol = variable.getName();
rowColResultSet.addDataColumn(new ODESolverResultSetColumnDescription(symbol));
} else if (modelObject instanceof Model.ReservedSymbol && ((Model.ReservedSymbol) modelObject).isTime()) {
Model.ReservedSymbol time = (Model.ReservedSymbol) modelObject;
String symbol = time.getName();
rowColResultSet.addDataColumn(new ODESolverResultSetColumnDescription(symbol));
}
} catch (MathException | MatrixException | ExpressionException | ModelException e) {
e.printStackTrace();
throw new MappingException(e.getMessage(), e);
}
}
//
// populate data columns (time and rest)
//
double[] weights = new double[rowColResultSet.getColumnDescriptionsCount()];
weights[0] = 1.0;
int numRows = ((double[]) dataList.elementAt(0)).length;
int numColumns = modelObjectList.size();
for (int j = 0; j < numRows; j++) {
double[] row = new double[numColumns];
for (int i = 0; i < numColumns; i++) {
row[i] = ((double[]) dataList.elementAt(i))[j];
if (i > 0) {
weights[i] += row[i] * row[i];
}
}
rowColResultSet.addRow(row);
}
for (int i = 0; i < numColumns; i++) {
if (weights[i] == 0) {
weights[i] = 1;
} else {
weights[i] = 1 / weights[i];
}
}
SimpleReferenceData remappedRefData = new SimpleReferenceData(rowColResultSet, weights);
return remappedRefData;
}
use of cbit.vcell.parser.SymbolTableEntry in project vcell by virtualcell.
the class ReactionRulePropertiesTableModel method isCellEditable.
/**
* Insert the method's description here.
* Creation date: (2/24/01 12:27:46 AM)
* @return boolean
* @param rowIndex int
* @param columnIndex int
*/
public boolean isCellEditable(int rowIndex, int columnIndex) {
if (!bEditable) {
return false;
}
Object o = getValueAt(rowIndex);
if (!(o instanceof Parameter)) {
return false;
}
Parameter parameter = (Parameter) o;
if (reactionRule != null && reactionRule.getKineticLaw().getLocalParameter(RbmKineticLawParameterType.MassActionReverseRate) == parameter) {
if (!reactionRule.isReversible()) {
// disable Kr if rule is not reversible
return false;
}
}
switch(columnIndex) {
case COLUMN_NAME:
return parameter.isNameEditable();
case COLUMN_DESCRIPTION:
return false;
case COLUMN_IS_GLOBAL:
// if the parameter is reaction rate param or a ReservedSymbol in the model, it should not be editable
if ((parameter instanceof LocalParameter) && (((LocalParameter) parameter).getRole() != RbmKineticLaw.RbmKineticLawParameterType.UserDefined)) {
return false;
}
if (parameter instanceof UnresolvedParameter) {
return false;
}
if (parameter instanceof LocalProxyParameter) {
LocalProxyParameter kpp = (LocalProxyParameter) parameter;
SymbolTableEntry ste = kpp.getTarget();
if ((ste instanceof Model.ReservedSymbol) || (ste instanceof SpeciesContext) || (ste instanceof ModelQuantity)) {
return false;
}
}
return true;
case COLUMN_VALUE:
return parameter.isExpressionEditable();
case COLUMN_UNITS:
return parameter.isUnitEditable();
}
return false;
}
use of cbit.vcell.parser.SymbolTableEntry in project vcell by virtualcell.
the class GeometrySubVolumeTableModel method setGeometry.
/**
* Sets the geometry property (cbit.vcell.geometry.Geometry) value.
* @param geometry The new value for the property.
* @see #getGeometry
*/
public void setGeometry(Geometry geometry) {
if (fieldGeometry == geometry) {
return;
}
Geometry oldValue = fieldGeometry;
if (oldValue != null) {
oldValue.getGeometrySpec().removePropertyChangeListener(this);
for (SubVolume sv : oldValue.getGeometrySpec().getSubVolumes()) {
sv.removePropertyChangeListener(this);
}
}
fieldGeometry = geometry;
if (fieldGeometry != null) {
fieldGeometry.getGeometrySpec().addPropertyChangeListener(this);
for (SubVolume sv : fieldGeometry.getGeometrySpec().getSubVolumes()) {
sv.addPropertyChangeListener(this);
}
autoCompleteSymbolFilter = new AutoCompleteSymbolFilter() {
public boolean accept(SymbolTableEntry ste) {
int dimension = fieldGeometry.getDimension();
if (ste.equals(ReservedVariable.X) || dimension > 1 && ste.equals(ReservedVariable.Y) || dimension > 2 && ste.equals(ReservedVariable.Z)) {
return true;
}
return false;
}
public boolean acceptFunction(String funcName) {
return true;
}
};
}
firePropertyChange("geometry", oldValue, fieldGeometry);
}
Aggregations