Search in sources :

Example 21 with VCUnitDefinition

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

Example 22 with VCUnitDefinition

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

Example 23 with VCUnitDefinition

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;
}
Also used : VCUnitDefinition(cbit.vcell.units.VCUnitDefinition) ISize(org.vcell.util.ISize) Element(org.jdom.Element) VolumeGeometricRegion(cbit.vcell.geometry.surface.VolumeGeometricRegion) SurfaceGeometricRegion(cbit.vcell.geometry.surface.SurfaceGeometricRegion) VolumeGeometricRegion(cbit.vcell.geometry.surface.VolumeGeometricRegion) GeometricRegion(cbit.vcell.geometry.surface.GeometricRegion) SurfaceGeometricRegion(cbit.vcell.geometry.surface.SurfaceGeometricRegion)

Example 24 with VCUnitDefinition

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);
    }
}
Also used : VCUnitDefinition(cbit.vcell.units.VCUnitDefinition) KineticsParameter(cbit.vcell.model.Kinetics.KineticsParameter) Expression(cbit.vcell.parser.Expression) MassActionKinetics(cbit.vcell.model.MassActionKinetics)

Example 25 with VCUnitDefinition

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);
    }
}
Also used : VCUnitDefinition(cbit.vcell.units.VCUnitDefinition) KineticsParameter(cbit.vcell.model.Kinetics.KineticsParameter) Expression(cbit.vcell.parser.Expression) MassActionKinetics(cbit.vcell.model.MassActionKinetics)

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