use of cbit.vcell.parser.Expression in project vcell by virtualcell.
the class XmlReader method getExplicitDataGenerator.
private ExplicitDataGenerator getExplicitDataGenerator(Element element) {
String name = unMangle(element.getAttributeValue(XMLTags.NameAttrTag));
String domainStr = unMangle(element.getAttributeValue(XMLTags.DomainAttrTag));
Domain domain = null;
if (domainStr != null) {
domain = new Domain(domainStr);
}
String temp = element.getText();
Expression exp = unMangleExpression(temp);
ExplicitDataGenerator explicitDataGenerator = new ExplicitDataGenerator(name, domain, exp);
return explicitDataGenerator;
}
use of cbit.vcell.parser.Expression in project vcell by virtualcell.
the class XmlReader method getGaussianDistribution.
private GaussianDistribution getGaussianDistribution(Element distElement) {
Element element = distElement.getChild(XMLTags.GaussianDistributionMeanTag, vcNamespace);
Expression mu = unMangleExpression(element.getText());
element = distElement.getChild(XMLTags.GaussianDistributionStandardDeviationTag, vcNamespace);
Expression sigma = unMangleExpression(element.getText());
return new GaussianDistribution(mu, sigma);
}
use of cbit.vcell.parser.Expression in project vcell by virtualcell.
the class XmlReader method getFunction.
/**
* This method returns a Function variable object from a XML Element.
* Creation date: (5/16/2001 3:45:21 PM)
* @return cbit.vcell.math.Function
* @param param org.jdom.Element
* @exception cbit.vcell.xml.XmlParseException The exception description.
*/
private Function getFunction(Element param) throws XmlParseException {
// get attributes
String name = unMangle(param.getAttributeValue(XMLTags.NameAttrTag));
/**
* ---------------------------------------------------------------
* ATTENTATION: this is a quick fix for a specific user to load his model
* with a function name as "ATP/ADP". This syntax is not allowed.
*-----------------------------------------------------------------------
*/
if (name.equals("ATP/ADP")) {
name = "ATP_ADP_renamed";
System.err.print("Applying species function name change ATP/ADP to ATP_ADP for a specific user (key=2288008)");
Thread.dumpStack();
}
String domainStr = unMangle(param.getAttributeValue(XMLTags.DomainAttrTag));
Domain domain = null;
if (domainStr != null) {
domain = new Domain(domainStr);
}
String temp = param.getText();
Expression exp = unMangleExpression(temp);
// -- create new Function --
Function function = new Function(name, exp, domain);
transcribeComments(param, function);
return function;
}
use of cbit.vcell.parser.Expression in project vcell by virtualcell.
the class Xmlproducer method getXML.
/**
* This method returns a XML representation of a OdeEquation object.
* Creation date: (3/2/2001 2:52:14 PM)
* @return Element
* @param param cbit.vcell.math.OdeEquation
*/
private Element getXML(OdeEquation param) throws XmlParseException {
Element ode = new Element(XMLTags.OdeEquationTag);
// Add atribute
ode.setAttribute(XMLTags.NameAttrTag, mangle(param.getVariable().getName()));
// Add Rate subelement
Element rate = new Element(XMLTags.RateTag);
if (param.getRateExpression() != null) {
rate.addContent(mangleExpression(param.getRateExpression()));
} else {
rate.addContent("0.0");
}
ode.addContent(rate);
// Add Initial
Element initial = new Element(XMLTags.InitialTag);
if (param.getInitialExpression() != null) {
initial.addContent(mangleExpression(param.getInitialExpression()));
ode.addContent(initial);
}
// add solution expression
switch(param.getSolutionType()) {
case Equation.UNKNOWN_SOLUTION:
{
ode.setAttribute(XMLTags.SolutionTypeTag, XMLTags.UnknownTypeTag);
if (param.getInitialExpression() == null) {
initial.setText(mangleExpression(new cbit.vcell.parser.Expression(0.0)));
ode.addContent(initial);
}
break;
}
case Equation.EXACT_SOLUTION:
{
ode.setAttribute(XMLTags.SolutionTypeTag, XMLTags.ExactTypeTag);
Element solution = new Element(XMLTags.SolutionExpressionTag);
solution.setText(mangle(param.getExactSolution().infix()));
ode.addContent(solution);
break;
}
default:
{
throw new XmlParseException("Unknown solution type:" + param.getSolutionType());
}
}
return ode;
}
use of cbit.vcell.parser.Expression in project vcell by virtualcell.
the class Xmlproducer method getXML.
private Element getXML(RbmKineticLaw param) {
Element kinetics = new Element(XMLTags.KineticsTag);
switch(param.getRateLawType()) {
case MassAction:
{
kinetics.setAttribute(XMLTags.KineticsTypeAttrTag, XMLTags.RbmKineticTypeMassAction);
break;
}
case MichaelisMenten:
{
kinetics.setAttribute(XMLTags.KineticsTypeAttrTag, XMLTags.RbmKineticTypeMichaelisMenten);
break;
}
case Saturable:
{
kinetics.setAttribute(XMLTags.KineticsTypeAttrTag, XMLTags.RbmKineticTypeSaturable);
break;
}
}
HashMap<ParameterRoleEnum, String> roleHash = new HashMap<ParameterRoleEnum, String>();
roleHash.put(RbmKineticLawParameterType.MassActionForwardRate, XMLTags.RbmMassActionKfRole);
roleHash.put(RbmKineticLawParameterType.MassActionReverseRate, XMLTags.RbmMassActionKrRole);
roleHash.put(RbmKineticLawParameterType.MichaelisMentenKcat, XMLTags.RbmMichaelisMentenKcatRole);
roleHash.put(RbmKineticLawParameterType.MichaelisMentenKm, XMLTags.RbmMichaelisMentenKmRole);
roleHash.put(RbmKineticLawParameterType.SaturableVmax, XMLTags.RbmSaturableVmaxRole);
roleHash.put(RbmKineticLawParameterType.SaturableKs, XMLTags.RbmSaturableKsRole);
roleHash.put(RbmKineticLawParameterType.RuleRate, XMLTags.RbmRuleRateRole);
roleHash.put(RbmKineticLawParameterType.UserDefined, XMLTags.RbmUserDefinedRole);
// Add Kinetics Parameters
LocalParameter[] parameters = param.getLocalParameters();
for (int i = 0; i < parameters.length; i++) {
LocalParameter parm = parameters[i];
Element tempparameter = new Element(XMLTags.ParameterTag);
// Get parameter attributes
tempparameter.setAttribute(XMLTags.NameAttrTag, mangle(parm.getName()));
tempparameter.setAttribute(XMLTags.ParamRoleAttrTag, roleHash.get(parm.getRole()));
VCUnitDefinition unit = parm.getUnitDefinition();
if (unit != null) {
tempparameter.setAttribute(XMLTags.VCUnitDefinitionAttrTag, unit.getSymbol());
}
Expression expression = parm.getExpression();
if (expression != null) {
tempparameter.addContent(mangleExpression(expression));
}
// Add the parameter to the general kinetics object
kinetics.addContent(tempparameter);
}
return kinetics;
}
Aggregations