Search in sources :

Example 56 with Expression

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;
}
Also used : Expression(cbit.vcell.parser.Expression) ExplicitDataGenerator(cbit.vcell.math.ExplicitDataGenerator) MembraneSubDomain(cbit.vcell.math.MembraneSubDomain) CompartmentSubDomain(cbit.vcell.math.CompartmentSubDomain) FilamentSubDomain(cbit.vcell.math.FilamentSubDomain) PointSubDomain(cbit.vcell.math.PointSubDomain) Domain(cbit.vcell.math.Variable.Domain)

Example 57 with Expression

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);
}
Also used : GaussianDistribution(cbit.vcell.math.GaussianDistribution) Expression(cbit.vcell.parser.Expression) Element(org.jdom.Element)

Example 58 with Expression

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;
}
Also used : AnnotatedFunction(cbit.vcell.solver.AnnotatedFunction) Function(cbit.vcell.math.Function) Expression(cbit.vcell.parser.Expression) MembraneSubDomain(cbit.vcell.math.MembraneSubDomain) CompartmentSubDomain(cbit.vcell.math.CompartmentSubDomain) FilamentSubDomain(cbit.vcell.math.FilamentSubDomain) PointSubDomain(cbit.vcell.math.PointSubDomain) Domain(cbit.vcell.math.Variable.Domain)

Example 59 with Expression

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;
}
Also used : Element(org.jdom.Element) Expression(cbit.vcell.parser.Expression)

Example 60 with Expression

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;
}
Also used : LocalParameter(cbit.vcell.mapping.ParameterContext.LocalParameter) VCUnitDefinition(cbit.vcell.units.VCUnitDefinition) HashMap(java.util.HashMap) Expression(cbit.vcell.parser.Expression) Element(org.jdom.Element) ParameterRoleEnum(cbit.vcell.mapping.ParameterContext.ParameterRoleEnum)

Aggregations

Expression (cbit.vcell.parser.Expression)549 ExpressionException (cbit.vcell.parser.ExpressionException)163 VCUnitDefinition (cbit.vcell.units.VCUnitDefinition)76 PropertyVetoException (java.beans.PropertyVetoException)73 Variable (cbit.vcell.math.Variable)69 ArrayList (java.util.ArrayList)58 Vector (java.util.Vector)56 MathException (cbit.vcell.math.MathException)55 VolVariable (cbit.vcell.math.VolVariable)53 SymbolTableEntry (cbit.vcell.parser.SymbolTableEntry)51 SpeciesContext (cbit.vcell.model.SpeciesContext)50 Element (org.jdom.Element)47 KineticsParameter (cbit.vcell.model.Kinetics.KineticsParameter)45 ExpressionBindingException (cbit.vcell.parser.ExpressionBindingException)45 Model (cbit.vcell.model.Model)43 Function (cbit.vcell.math.Function)42 Constant (cbit.vcell.math.Constant)41 ModelParameter (cbit.vcell.model.Model.ModelParameter)41 ModelUnitSystem (cbit.vcell.model.ModelUnitSystem)41 LocalParameter (cbit.vcell.mapping.ParameterContext.LocalParameter)38