use of cbit.vcell.parser.NameScope in project vcell by virtualcell.
the class ParameterContext method renameLocalParameter.
/**
* Insert the method's description here.
* Creation date: (5/24/01 4:05:36 PM)
*/
public void renameLocalParameter(String oldName, String newName) throws ExpressionException, java.beans.PropertyVetoException {
if (oldName == null || newName == null) {
throw new RuntimeException("renameParameter from '" + oldName + "' to '" + newName + "', nulls are not allowed");
}
NameScope nameScope = getNameScope();
String prefix = AbstractNameScope.getPrefix(newName);
String strippedName = AbstractNameScope.getStrippedIdentifier(newName);
if (prefix != null) {
NameScope prefixNameScope = nameScope.getNameScopeFromPrefix(prefix);
if (prefixNameScope != nameScope) {
// from different namescope, then strip any prefix.
throw new ExpressionException("reaction parameter cannot be renamed to '" + newName + "', name is scoped to '" + prefixNameScope.getName() + "'");
}
}
newName = strippedName;
if (oldName.equals(newName)) {
throw new RuntimeException("renameParameter from '" + oldName + "' to '" + newName + "', same name not allowed");
}
LocalParameter existingParameter = getLocalParameterFromName(newName);
if (existingParameter != null) {
throw new RuntimeException("Parameter '" + newName + "' already exists.");
}
LocalParameter parameter = getLocalParameterFromName(oldName);
if (parameter != null) {
//
// must change name in ElectricalStimulusParameter directly
// then change all references to this name in the other parameter's expressions.
//
LocalParameter[] newParameters = (LocalParameter[]) getLocalParameters().clone();
//
// replaces parameter with name 'oldName' with new parameter with name 'newName' and original expression.
//
parameter.fieldParameterName = newName;
//
for (int i = 0; i < newParameters.length; i++) {
if (newParameters[i].getExpression() != null) {
Expression newExp = newParameters[i].getExpression().renameBoundSymbols(getNameScope());
newParameters[i].setExpression(newExp);
}
}
setLocalParameters(newParameters);
//
try {
cleanupParameters();
} catch (Exception e) {
e.printStackTrace(System.out);
throw new RuntimeException(e.getMessage());
}
parameter.firePropertyChange("name", oldName, newName);
}
}
use of cbit.vcell.parser.NameScope in project vcell by virtualcell.
the class ExpressionCanvas method setNameScope.
/**
* Sets the nameScope property (cbit.vcell.parser.NameScope) value.
* @param nameScope The new value for the property.
* @see #getNameScope
*/
public void setNameScope(NameScope nameScope) {
cbit.vcell.parser.NameScope oldValue = fieldNameScope;
fieldNameScope = nameScope;
firePropertyChange("nameScope", oldValue, nameScope);
}
use of cbit.vcell.parser.NameScope in project vcell by virtualcell.
the class SBPAXHMMRevLawBuilder method addKinetics.
public void addKinetics(KineticContext context) {
try {
ReactionStep reaction = context.getReaction();
HMM_REVKinetics kinetics = new HMM_REVKinetics((SimpleReaction) reaction);
NameScope modelScope = reaction.getModel().getNameScope();
ModelParameter kMichaelisFwd = context.getParameter(SBOList.MICHAELIS_CONST_FORW);
if (kMichaelisFwd != null) {
KineticsParameter kmfParameter = kinetics.getKmFwdParameter();
kmfParameter.setExpression(new Expression(kMichaelisFwd, modelScope));
kmfParameter.setUnitDefinition(kMichaelisFwd.getUnitDefinition());
}
ModelParameter kcatf = context.getParameter(SBOList.CATALYTIC_RATE_CONST_FORW);
if (kcatf != null && context.getCatalysts().size() == 1) {
KineticsParameter vmaxfParameter = kinetics.getVmaxFwdParameter();
Catalyst catalyst = context.getCatalysts().iterator().next();
vmaxfParameter.setExpression(Expression.mult(new Expression(kcatf, modelScope), new Expression(catalyst.getSpeciesContext(), modelScope)));
// vmaxParameter.setUnitDefinition(vMax.getUnitDefinition());
} else {
ModelParameter vMaxf = context.getParameter(SBOList.MAXIMAL_VELOCITY_FORW);
if (vMaxf != null) {
KineticsParameter vmaxfParameter = kinetics.getVmaxFwdParameter();
vmaxfParameter.setExpression(new Expression(vMaxf, modelScope));
vmaxfParameter.setUnitDefinition(vMaxf.getUnitDefinition());
}
}
ModelParameter kMichaelisRev = context.getParameter(SBOList.MICHAELIS_CONST_REV);
if (kMichaelisRev != null) {
KineticsParameter kmrParameter = kinetics.getKmRevParameter();
kmrParameter.setExpression(new Expression(kMichaelisRev, modelScope));
kmrParameter.setUnitDefinition(kMichaelisRev.getUnitDefinition());
}
ModelParameter kcatr = context.getParameter(SBOList.CATALYTIC_RATE_CONST_FORW);
if (kcatr != null && context.getCatalysts().size() == 1) {
KineticsParameter vmaxrParameter = kinetics.getVmaxRevParameter();
Catalyst catalyst = context.getCatalysts().iterator().next();
vmaxrParameter.setExpression(Expression.mult(new Expression(kcatr, modelScope), new Expression(catalyst.getSpeciesContext(), modelScope)));
// vmaxParameter.setUnitDefinition(vMax.getUnitDefinition());
} else {
ModelParameter vMaxr = context.getParameter(SBOList.MAXIMAL_VELOCITY_REV);
if (vMaxr != null) {
KineticsParameter vmaxrParameter = kinetics.getVmaxRevParameter();
vmaxrParameter.setExpression(new Expression(vMaxr, modelScope));
vmaxrParameter.setUnitDefinition(vMaxr.getUnitDefinition());
}
}
} catch (ExpressionException e) {
e.printStackTrace();
}
}
Aggregations