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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations