use of cbit.vcell.units.VCUnitDefinition 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;
}
use of cbit.vcell.units.VCUnitDefinition in project vcell by virtualcell.
the class Xmlproducer method getXML.
private Element getXML(SimulationContextParameter appParam) {
Element appParamElement = new Element(XMLTags.ParameterTag);
// Get parameter attributes - name, role and unit definition
appParamElement.setAttribute(XMLTags.NameAttrTag, mangle(appParam.getName()));
if (appParam.getRole() == SimulationContext.ROLE_UserDefined) {
appParamElement.setAttribute(XMLTags.ParamRoleAttrTag, SimulationContext.RoleDesc);
} else {
throw new RuntimeException("Unknown application parameter role/type");
}
VCUnitDefinition unit = appParam.getUnitDefinition();
if (unit != null) {
appParamElement.setAttribute(XMLTags.VCUnitDefinitionAttrTag, unit.getSymbol());
}
// add expression as content
appParamElement.addContent(mangleExpression(appParam.getExpression()));
// }
return appParamElement;
}
use of cbit.vcell.units.VCUnitDefinition in project vcell by virtualcell.
the class Xmlproducer method getXML.
private Element getXML(GeometrySurfaceDescription param) throws XmlParseException {
Element gsd = new Element(XMLTags.SurfaceDescriptionTag);
// add attributes
ISize isize = param.getVolumeSampleSize();
if (isize == null) {
throw new XmlParseException("Unable to retrieve dimensions for surface descriptions for Geometry: " + param.getGeometry().getName());
}
gsd.setAttribute(XMLTags.NumSamplesXAttrTag, String.valueOf(isize.getX()));
gsd.setAttribute(XMLTags.NumSamplesYAttrTag, String.valueOf(isize.getY()));
gsd.setAttribute(XMLTags.NumSamplesZAttrTag, String.valueOf(isize.getZ()));
Double coFrequency = param.getFilterCutoffFrequency();
if (coFrequency == null) {
throw new XmlParseException("Unable to retrieve cutoff frequency for surface descriptions for Geometry: " + param.getGeometry().getName());
}
double cutoffFrequency = coFrequency.doubleValue();
gsd.setAttribute(XMLTags.CutoffFrequencyAttrTag, String.valueOf(cutoffFrequency));
// add subelements
GeometricRegion[] geomRegions = param.getGeometricRegions();
if (geomRegions != null) {
for (int i = 0; i < geomRegions.length; i++) {
if (geomRegions[i] instanceof SurfaceGeometricRegion) {
SurfaceGeometricRegion sgr = (SurfaceGeometricRegion) geomRegions[i];
Element membraneRegion = new Element(XMLTags.MembraneRegionTag);
membraneRegion.setAttribute(XMLTags.NameAttrTag, sgr.getName());
GeometricRegion[] adjacents = sgr.getAdjacentGeometricRegions();
if (adjacents == null || adjacents.length != 2) {
throw new XmlParseException("Wrong number of adjacent regions for surface descriptions for location: " + sgr.getName() + " in Geometry: " + param.getGeometry().getName());
}
membraneRegion.setAttribute(XMLTags.VolumeRegion_1AttrTag, adjacents[0].getName());
membraneRegion.setAttribute(XMLTags.VolumeRegion_2AttrTag, adjacents[1].getName());
double size = sgr.getSize();
if (size != -1) {
membraneRegion.setAttribute(XMLTags.SizeAttrTag, String.valueOf(size));
VCUnitDefinition unit = sgr.getSizeUnit();
if (unit != null) {
membraneRegion.setAttribute(XMLTags.VCUnitDefinitionAttrTag, unit.getSymbol());
}
}
gsd.addContent(membraneRegion);
} else if (geomRegions[i] instanceof VolumeGeometricRegion) {
VolumeGeometricRegion vgr = (VolumeGeometricRegion) geomRegions[i];
Element volumeRegion = new Element(XMLTags.VolumeRegionTag);
volumeRegion.setAttribute(XMLTags.NameAttrTag, vgr.getName());
volumeRegion.setAttribute(XMLTags.RegionIDAttrTag, String.valueOf(vgr.getRegionID()));
volumeRegion.setAttribute(XMLTags.SubVolumeAttrTag, vgr.getSubVolume().getName());
double size = vgr.getSize();
if (size != -1) {
volumeRegion.setAttribute(XMLTags.SizeAttrTag, String.valueOf(size));
VCUnitDefinition unit = vgr.getSizeUnit();
if (unit != null) {
volumeRegion.setAttribute(XMLTags.VCUnitDefinitionAttrTag, unit.getSymbol());
}
}
gsd.addContent(volumeRegion);
}
}
}
return gsd;
}
use of cbit.vcell.units.VCUnitDefinition in project vcell by virtualcell.
the class SBPAXKineticsExtractor method setKForwardParam.
private static void setKForwardParam(ReactionStep reaction, SBOParam kForward, Kinetics kinetics) throws ExpressionException, PropertyVetoException {
if (kForward != null) {
KineticsParameter fwdParam = ((MassActionKinetics) kinetics).getForwardRateParameter();
kinetics.setParameterValue(fwdParam, new Expression(kForward.getNumber()));
String unitF = SBOParam.formatUnit(kForward.getUnit());
VCUnitDefinition fwdUnit = reaction.getModel().getUnitSystem().getInstance(unitF);
fwdParam.setUnitDefinition(fwdUnit);
}
}
use of cbit.vcell.units.VCUnitDefinition in project vcell by virtualcell.
the class SBPAXKineticsExtractor method setKReverseParam.
private static void setKReverseParam(ReactionStep reaction, SBOParam kReverse, Kinetics kinetics) throws ExpressionException, PropertyVetoException {
if (kReverse != null) {
KineticsParameter revParam = ((MassActionKinetics) kinetics).getReverseRateParameter();
kinetics.setParameterValue(revParam, new Expression(kReverse.getNumber()));
String unitR = SBOParam.formatUnit(kReverse.getUnit());
VCUnitDefinition revUnit = reaction.getModel().getUnitSystem().getInstance(unitR);
revParam.setUnitDefinition(revUnit);
}
}
Aggregations