Search in sources :

Example 16 with VCUnitDefinition

use of cbit.vcell.units.VCUnitDefinition in project vcell by virtualcell.

the class Xmlproducer method getXML.

/**
 * This method returns a XML representation of an Electrode.
 * Creation date: (6/6/2002 2:32:56 PM)
 * @return Element
 * @param param cbit.vcell.mapping.Electrode
 */
private Element getXML(ElectricalStimulus param) {
    String electricalStimulusType = null;
    if (param instanceof VoltageClampStimulus) {
        // process a VoltageClampStimulus object
        electricalStimulusType = XMLTags.VoltageClampTag;
    } else if (param instanceof CurrentDensityClampStimulus) {
        // Process a CurrentClampStimulus
        electricalStimulusType = XMLTags.CurrentDensityClampTag;
    } else if (param instanceof TotalCurrentClampStimulus) {
        // Process a CurrentClampStimulus
        electricalStimulusType = XMLTags.TotalCurrentClampTag;
    }
    Element electricalStimulus = new Element(XMLTags.ClampTag);
    // Need to add electrode ??
    Element electrode = getXML(param.getElectrode());
    electricalStimulus.addContent(electrode);
    // Add attributes
    electricalStimulus.setAttribute(XMLTags.TypeAttrTag, electricalStimulusType);
    // 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, ((ElectricalStimulusParameterType) parm.getRole()).roleDescription);
        VCUnitDefinition unit = parm.getUnitDefinition();
        if (unit != null) {
            tempparameter.setAttribute(XMLTags.VCUnitDefinitionAttrTag, unit.getSymbol());
        }
        tempparameter.addContent(mangleExpression(parm.getExpression()));
        // Add the parameter to the general electricalstimulus object
        electricalStimulus.addContent(tempparameter);
    }
    return electricalStimulus;
}
Also used : LocalParameter(cbit.vcell.mapping.ParameterContext.LocalParameter) VCUnitDefinition(cbit.vcell.units.VCUnitDefinition) VoltageClampStimulus(cbit.vcell.mapping.VoltageClampStimulus) Element(org.jdom.Element) CurrentDensityClampStimulus(cbit.vcell.mapping.CurrentDensityClampStimulus) TotalCurrentClampStimulus(cbit.vcell.mapping.TotalCurrentClampStimulus)

Example 17 with VCUnitDefinition

use of cbit.vcell.units.VCUnitDefinition in project vcell by virtualcell.

the class Xmlproducer method getXML.

/**
 * This method returns a XML representation of a Kinetics object type.
 * Creation date: (2/26/2001 7:31:43 PM)
 * @return Element
 * @param param cbit.vcell.model.Kinetics
 */
private Element getXML(Kinetics param) throws XmlParseException {
    String kineticsType = null;
    if (param instanceof GeneralKinetics) {
        // process a GeneralKinetics object
        kineticsType = XMLTags.KineticsTypeGeneralKinetics;
    } else if (param instanceof MassActionKinetics) {
        // Process a MassActionKinetics
        kineticsType = XMLTags.KineticsTypeMassAction;
    } else if (param instanceof NernstKinetics) {
        // Process a NernstKinetics
        kineticsType = XMLTags.KineticsTypeNernst;
    } else if (param instanceof GHKKinetics) {
        // Process a GHKKinetics
        kineticsType = XMLTags.KineticsTypeGHK;
    } else if (param instanceof GeneralCurrentKinetics) {
        // Process a GeneralCurrentKinetics
        kineticsType = XMLTags.KineticsTypeGeneralCurrentKinetics;
    } else if (param instanceof HMM_IRRKinetics) {
        // Process a HenriMichaelasMentenKinetics (irreversible)
        kineticsType = XMLTags.KineticsTypeHMM_Irr;
    } else if (param instanceof HMM_REVKinetics) {
        // Process a HenriMichaelasMentenKinetics (reversible)
        kineticsType = XMLTags.KineticsTypeHMM_Rev;
    } else if (param instanceof GeneralLumpedKinetics) {
        // Process a GeneralLumpedKinetics
        kineticsType = XMLTags.KineticsTypeGeneralLumped;
    } else if (param instanceof GeneralCurrentLumpedKinetics) {
        // Process a GeneralCurrentLumpedKinetics
        kineticsType = XMLTags.KineticsTypeGeneralCurrentLumped;
    } else if (param instanceof GeneralPermeabilityKinetics) {
        // Process a GeneralPermeabilityKinetics
        kineticsType = XMLTags.KineticsTypeGeneralPermeability;
    } else if (param instanceof Macroscopic_IRRKinetics) {
        // Process a Macroscopic_IRRKinetics
        kineticsType = XMLTags.KineticsTypeMacroscopic_Irr;
    } else if (param instanceof Microscopic_IRRKinetics) {
        // Process a Microscopic_IRRKinetics
        kineticsType = XMLTags.KineticsTypeMicroscopic_Irr;
    }
    Element kinetics = new Element(XMLTags.KineticsTag);
    // Add atributes
    kinetics.setAttribute(XMLTags.KineticsTypeAttrTag, kineticsType);
    // Add Kinetics Parameters
    Kinetics.KineticsParameter[] parameters = param.getKineticsParameters();
    for (int i = 0; i < parameters.length; i++) {
        Kinetics.KineticsParameter parm = parameters[i];
        Element tempparameter = new Element(XMLTags.ParameterTag);
        // Get parameter attributes
        tempparameter.setAttribute(XMLTags.NameAttrTag, mangle(parm.getName()));
        tempparameter.setAttribute(XMLTags.ParamRoleAttrTag, param.getDefaultParameterDesc(parm.getRole()));
        VCUnitDefinition unit = parm.getUnitDefinition();
        if (unit != null) {
            tempparameter.setAttribute(XMLTags.VCUnitDefinitionAttrTag, unit.getSymbol());
        }
        tempparameter.addContent(mangleExpression(parm.getExpression()));
        // Add the parameter to the general kinetics object
        kinetics.addContent(tempparameter);
    }
    return kinetics;
}
Also used : HMM_IRRKinetics(cbit.vcell.model.HMM_IRRKinetics) GHKKinetics(cbit.vcell.model.GHKKinetics) Element(org.jdom.Element) NernstKinetics(cbit.vcell.model.NernstKinetics) HMM_REVKinetics(cbit.vcell.model.HMM_REVKinetics) GeneralKinetics(cbit.vcell.model.GeneralKinetics) GeneralLumpedKinetics(cbit.vcell.model.GeneralLumpedKinetics) GeneralCurrentKinetics(cbit.vcell.model.GeneralCurrentKinetics) VCUnitDefinition(cbit.vcell.units.VCUnitDefinition) GeneralCurrentLumpedKinetics(cbit.vcell.model.GeneralCurrentLumpedKinetics) MassActionKinetics(cbit.vcell.model.MassActionKinetics) Macroscopic_IRRKinetics(cbit.vcell.model.Macroscopic_IRRKinetics) Macroscopic_IRRKinetics(cbit.vcell.model.Macroscopic_IRRKinetics) Kinetics(cbit.vcell.model.Kinetics) NernstKinetics(cbit.vcell.model.NernstKinetics) GeneralKinetics(cbit.vcell.model.GeneralKinetics) GeneralLumpedKinetics(cbit.vcell.model.GeneralLumpedKinetics) GeneralPermeabilityKinetics(cbit.vcell.model.GeneralPermeabilityKinetics) GHKKinetics(cbit.vcell.model.GHKKinetics) MassActionKinetics(cbit.vcell.model.MassActionKinetics) Microscopic_IRRKinetics(cbit.vcell.model.Microscopic_IRRKinetics) GeneralCurrentKinetics(cbit.vcell.model.GeneralCurrentKinetics) HMM_REVKinetics(cbit.vcell.model.HMM_REVKinetics) HMM_IRRKinetics(cbit.vcell.model.HMM_IRRKinetics) GeneralCurrentLumpedKinetics(cbit.vcell.model.GeneralCurrentLumpedKinetics) GeneralPermeabilityKinetics(cbit.vcell.model.GeneralPermeabilityKinetics) Microscopic_IRRKinetics(cbit.vcell.model.Microscopic_IRRKinetics)

Example 18 with VCUnitDefinition

use of cbit.vcell.units.VCUnitDefinition in project vcell by virtualcell.

the class Xmlproducer method getXML.

private Element getXML(ModelParameter modelParam) {
    Element glParamElement = new Element(XMLTags.ParameterTag);
    // Get parameter attributes - name, role and unit definition
    glParamElement.setAttribute(XMLTags.NameAttrTag, mangle(modelParam.getName()));
    if (modelParam.getRole() == Model.ROLE_UserDefined) {
        glParamElement.setAttribute(XMLTags.ParamRoleAttrTag, Model.RoleDesc);
    } else {
        throw new RuntimeException("Unknown model parameter role/type");
    }
    // if (modelParam.getRole() == Model.ROLE_UserDefined) {
    // glParamElement.setAttribute(XMLTags.ParamRoleAttrTag, Model.RoleDescs[0]);
    // } else	if (modelParam.getRole() == Model.ROLE_VariableRate) {
    // glParamElement.setAttribute(XMLTags.ParamRoleAttrTag, Model.RoleDescs[1]);
    // } else {
    // throw new RuntimeException("Unknown model parameter role/type");
    // }
    VCUnitDefinition unit = modelParam.getUnitDefinition();
    if (unit != null) {
        glParamElement.setAttribute(XMLTags.VCUnitDefinitionAttrTag, unit.getSymbol());
    }
    // add expression as content
    glParamElement.addContent(mangleExpression(modelParam.getExpression()));
    // add annotation (if there is any)
    if (modelParam.getModelParameterAnnotation() != null && modelParam.getModelParameterAnnotation().length() > 0) {
        Element annotationElement = new Element(XMLTags.AnnotationTag);
        annotationElement.setText(mangle(modelParam.getModelParameterAnnotation()));
        glParamElement.addContent(annotationElement);
    }
    return glParamElement;
}
Also used : VCUnitDefinition(cbit.vcell.units.VCUnitDefinition) Element(org.jdom.Element)

Example 19 with VCUnitDefinition

use of cbit.vcell.units.VCUnitDefinition in project vcell by virtualcell.

the class XmlReader method getDataSymbols.

private ArrayList<DataSymbol> getDataSymbols(Element dataContextElement, DataContext dataContext, ModelUnitSystem modelUnitSystem) {
    ArrayList<DataSymbol> dataSymbolsList = new ArrayList<DataSymbol>();
    // iterate over fieldDatasymbols. When other dataSymbol types are implemented, repeat this loop.
    Iterator dataSymbolsElementIter = dataContextElement.getChildren(XMLTags.FieldDataSymbolTag, vcNamespace).iterator();
    while (dataSymbolsElementIter.hasNext()) {
        Element dataSymbolElement = (Element) dataSymbolsElementIter.next();
        String dataSymbolName = unMangle(dataSymbolElement.getAttributeValue(XMLTags.DataSymbolNameTag));
        DataSymbolType dataSymbolType = DataSymbolType.fromDatabaseName(unMangle(dataSymbolElement.getAttributeValue(XMLTags.DataSymbolTypeTag)));
        String symbol = dataSymbolElement.getAttributeValue(XMLTags.VCUnitDefinitionAttrTag);
        VCUnitDefinition vcUnitDefinition = null;
        if (symbol != null) {
            vcUnitDefinition = modelUnitSystem.getInstance(symbol);
        }
        // ExternalDataIdentifier dataSetID in FieldDataSymbol
        Element dataSetIDElement = dataSymbolElement.getChild(XMLTags.ExternalDataIdentifierTag, vcNamespace);
        String name = unMangle(dataSetIDElement.getAttributeValue(XMLTags.NameAttrTag));
        String key = unMangle(dataSetIDElement.getAttributeValue(XMLTags.KeyValueAttrTag));
        String userID = unMangle(dataSetIDElement.getAttributeValue(XMLTags.OwnerNameAttrTag));
        String userKey = unMangle(dataSetIDElement.getAttributeValue(XMLTags.OwnerKeyAttrTag));
        User owner = new User(userID, new KeyValue(userKey));
        ExternalDataIdentifier edi = new ExternalDataIdentifier(new KeyValue(key), owner, name);
        // ---
        String fieldItemName = unMangle(dataSymbolElement.getAttributeValue(XMLTags.FieldItemNameTag));
        String fieldItemType = unMangle(dataSymbolElement.getAttributeValue(XMLTags.FieldItemTypeTag));
        double fieldItemTime = Double.parseDouble(unMangle(dataSymbolElement.getAttributeValue(XMLTags.FieldItemTimeTag)));
        FieldDataSymbol fds = new FieldDataSymbol(dataSymbolName, dataSymbolType, dataContext, vcUnitDefinition, edi, fieldItemName, fieldItemType, fieldItemTime);
        dataSymbolsList.add(fds);
    }
    return dataSymbolsList;
}
Also used : User(org.vcell.util.document.User) KeyValue(org.vcell.util.document.KeyValue) Element(org.jdom.Element) ArrayList(java.util.ArrayList) FieldDataSymbol(cbit.vcell.data.FieldDataSymbol) DataSymbol(cbit.vcell.data.DataSymbol) VCUnitDefinition(cbit.vcell.units.VCUnitDefinition) Iterator(java.util.Iterator) DataSymbolType(cbit.vcell.data.DataSymbol.DataSymbolType) ExternalDataIdentifier(org.vcell.util.document.ExternalDataIdentifier) FieldDataSymbol(cbit.vcell.data.FieldDataSymbol)

Example 20 with VCUnitDefinition

use of cbit.vcell.units.VCUnitDefinition in project vcell by virtualcell.

the class XmlReader method getSimulationContextParameter.

public SimulationContextParameter getSimulationContextParameter(Element paramElement, SimulationContext simContext) {
    // get its attributes : name, role and unit definition
    String appParamName = unMangle(paramElement.getAttributeValue(XMLTags.NameAttrTag));
    String role = paramElement.getAttributeValue(XMLTags.ParamRoleAttrTag);
    ModelUnitSystem modelUnitSystem = simContext.getModel().getUnitSystem();
    int appParamRole = -1;
    if (role.equals(XMLTags.ParamRoleUserDefinedTag)) {
        appParamRole = SimulationContext.ROLE_UserDefined;
    } else {
        throw new RuntimeException("unknown type of application parameter (not user-defined)");
    }
    String unitSymbol = paramElement.getAttributeValue(XMLTags.VCUnitDefinitionAttrTag);
    VCUnitDefinition appParamUnit = null;
    if (unitSymbol != null) {
        appParamUnit = modelUnitSystem.getInstance(unitSymbol);
    }
    // get parameter contents : expression; annotation, if any.
    String appParamExpStr = paramElement.getText();
    Expression appParamExp = unMangleExpression(appParamExpStr);
    // String appParamAnnotation = null;
    // String annotationText = paramElement.getChildText(XMLTags.AnnotationTag, vcNamespace);
    // if (annotationText != null && annotationText.length() > 0) {
    // appParamAnnotation = unMangle(annotationText);
    // }
    // create new global parameter
    SimulationContextParameter newAppParam = simContext.new SimulationContextParameter(appParamName, appParamExp, appParamRole, appParamUnit);
    return newAppParam;
}
Also used : VCUnitDefinition(cbit.vcell.units.VCUnitDefinition) Expression(cbit.vcell.parser.Expression) SimulationContextParameter(cbit.vcell.mapping.SimulationContext.SimulationContextParameter) ModelUnitSystem(cbit.vcell.model.ModelUnitSystem)

Aggregations

VCUnitDefinition (cbit.vcell.units.VCUnitDefinition)113 Expression (cbit.vcell.parser.Expression)73 ModelUnitSystem (cbit.vcell.model.ModelUnitSystem)36 ExpressionException (cbit.vcell.parser.ExpressionException)26 PropertyVetoException (java.beans.PropertyVetoException)24 LocalParameter (cbit.vcell.mapping.ParameterContext.LocalParameter)21 Element (org.jdom.Element)20 KineticsParameter (cbit.vcell.model.Kinetics.KineticsParameter)19 ArrayList (java.util.ArrayList)17 ModelParameter (cbit.vcell.model.Model.ModelParameter)16 Model (cbit.vcell.model.Model)14 Parameter (cbit.vcell.model.Parameter)14 SpeciesContext (cbit.vcell.model.SpeciesContext)13 SymbolTableEntry (cbit.vcell.parser.SymbolTableEntry)13 Membrane (cbit.vcell.model.Membrane)12 Structure (cbit.vcell.model.Structure)12 StructureMapping (cbit.vcell.mapping.StructureMapping)11 MathException (cbit.vcell.math.MathException)10 ReactionStep (cbit.vcell.model.ReactionStep)10 Feature (cbit.vcell.model.Feature)9