use of cbit.vcell.parser.Expression in project vcell by virtualcell.
the class SBMLImporter method addGeometry.
protected void addGeometry() {
// get a Geometry object via SpatialModelPlugin object.
org.sbml.jsbml.ext.spatial.Geometry sbmlGeometry = getSbmlGeometry();
if (sbmlGeometry == null) {
return;
}
int dimension = 0;
Origin vcOrigin = null;
Extent vcExtent = null;
{
// local code block
// get a CoordComponent object via the Geometry object.
ListOf<CoordinateComponent> listOfCoordComps = sbmlGeometry.getListOfCoordinateComponents();
if (listOfCoordComps == null) {
throw new RuntimeException("Cannot have 0 coordinate compartments in geometry");
}
// coord component
double ox = 0.0;
double oy = 0.0;
double oz = 0.0;
double ex = 1.0;
double ey = 1.0;
double ez = 1.0;
for (CoordinateComponent coordComponent : listOfCoordComps) {
double minValue = coordComponent.getBoundaryMinimum().getValue();
double maxValue = coordComponent.getBoundaryMaximum().getValue();
switch(coordComponent.getType()) {
case cartesianX:
{
ox = minValue;
ex = maxValue - minValue;
break;
}
case cartesianY:
{
oy = minValue;
ey = maxValue - minValue;
break;
}
case cartesianZ:
{
oz = minValue;
ez = maxValue - minValue;
break;
}
}
dimension++;
}
vcOrigin = new Origin(ox, oy, oz);
vcExtent = new Extent(ex, ey, ez);
}
// from geometry definition, find out which type of geometry : image or
// analytic or CSG
AnalyticGeometry analyticGeometryDefinition = null;
CSGeometry csGeometry = null;
SampledFieldGeometry segmentedSampledFieldGeometry = null;
SampledFieldGeometry distanceMapSampledFieldGeometry = null;
ParametricGeometry parametricGeometry = null;
for (int i = 0; i < sbmlGeometry.getListOfGeometryDefinitions().size(); i++) {
GeometryDefinition gd_temp = sbmlGeometry.getListOfGeometryDefinitions().get(i);
if (!gd_temp.isSetIsActive()) {
continue;
}
if (gd_temp instanceof AnalyticGeometry) {
analyticGeometryDefinition = (AnalyticGeometry) gd_temp;
} else if (gd_temp instanceof SampledFieldGeometry) {
SampledFieldGeometry sfg = (SampledFieldGeometry) gd_temp;
String sfn = sfg.getSampledField();
ListOf<SampledField> sampledFields = sbmlGeometry.getListOfSampledFields();
if (sampledFields.size() > 1) {
throw new RuntimeException("only one sampled field supported");
}
InterpolationKind ik = sampledFields.get(0).getInterpolationType();
switch(ik) {
case linear:
distanceMapSampledFieldGeometry = sfg;
break;
case nearestneighbor:
segmentedSampledFieldGeometry = sfg;
break;
default:
lg.warn("Unsupported " + sampledFields.get(0).getName() + " interpolation type " + ik);
}
} else if (gd_temp instanceof CSGeometry) {
csGeometry = (CSGeometry) gd_temp;
} else if (gd_temp instanceof ParametricGeometry) {
parametricGeometry = (ParametricGeometry) gd_temp;
} else {
throw new RuntimeException("unsupported geometry definition type " + gd_temp.getClass().getSimpleName());
}
}
if (analyticGeometryDefinition == null && segmentedSampledFieldGeometry == null && distanceMapSampledFieldGeometry == null && csGeometry == null) {
throw new SBMLImportException("VCell supports only Analytic, Image based (segmentd or distance map) or Constructed Solid Geometry at this time.");
}
GeometryDefinition selectedGeometryDefinition = null;
if (csGeometry != null) {
selectedGeometryDefinition = csGeometry;
} else if (analyticGeometryDefinition != null) {
selectedGeometryDefinition = analyticGeometryDefinition;
} else if (segmentedSampledFieldGeometry != null) {
selectedGeometryDefinition = segmentedSampledFieldGeometry;
} else if (distanceMapSampledFieldGeometry != null) {
selectedGeometryDefinition = distanceMapSampledFieldGeometry;
} else if (parametricGeometry != null) {
selectedGeometryDefinition = parametricGeometry;
} else {
throw new SBMLImportException("no geometry definition found");
}
Geometry vcGeometry = null;
if (selectedGeometryDefinition == analyticGeometryDefinition || selectedGeometryDefinition == csGeometry) {
vcGeometry = new Geometry("spatialGeom", dimension);
} else if (selectedGeometryDefinition == distanceMapSampledFieldGeometry || selectedGeometryDefinition == segmentedSampledFieldGeometry) {
SampledFieldGeometry sfg = (SampledFieldGeometry) selectedGeometryDefinition;
// get image from sampledFieldGeometry
// get a sampledVol object via the listOfSampledVol (from
// SampledGeometry) object.
// gcw gcw gcw
String sfn = sfg.getSampledField();
SampledField sf = null;
for (SampledField sampledField : sbmlGeometry.getListOfSampledFields()) {
if (sampledField.getSpatialId().equals(sfn)) {
sf = sampledField;
}
}
int numX = sf.getNumSamples1();
int numY = sf.getNumSamples2();
int numZ = sf.getNumSamples3();
int[] samples = new int[sf.getSamplesLength()];
StringTokenizer tokens = new StringTokenizer(sf.getSamples(), " ");
int count = 0;
while (tokens.hasMoreTokens()) {
int sample = Integer.parseInt(tokens.nextToken());
samples[count++] = sample;
}
byte[] imageInBytes = new byte[samples.length];
if (selectedGeometryDefinition == distanceMapSampledFieldGeometry) {
//
for (int i = 0; i < imageInBytes.length; i++) {
// if (interpolation(samples[i])<0){
if (samples[i] < 0) {
imageInBytes[i] = -1;
} else {
imageInBytes[i] = 1;
}
}
} else {
for (int i = 0; i < imageInBytes.length; i++) {
imageInBytes[i] = (byte) samples[i];
}
}
try {
// System.out.println("ident " + sf.getId() + " " + sf.getName());
VCImage vcImage = null;
CompressionKind ck = sf.getCompression();
DataKind dk = sf.getDataType();
if (ck == CompressionKind.deflated) {
vcImage = new VCImageCompressed(null, imageInBytes, vcExtent, numX, numY, numZ);
} else {
switch(dk) {
case UINT8:
case UINT16:
case UINT32:
vcImage = new VCImageUncompressed(null, imageInBytes, vcExtent, numX, numY, numZ);
default:
}
}
if (vcImage == null) {
throw new SbmlException("Unsupported type combination " + ck + ", " + dk + " for sampled field " + sf.getName());
}
vcImage.setName(sf.getId());
ListOf<SampledVolume> sampledVolumes = sfg.getListOfSampledVolumes();
final int numSampledVols = sampledVolumes.size();
if (numSampledVols == 0) {
throw new RuntimeException("Cannot have 0 sampled volumes in sampledField (image_based) geometry");
}
// check to see if values are uniquely integer , add set up scaling if necessary
double scaleFactor = checkPixelScaling(sampledVolumes, 1);
if (scaleFactor != 1) {
double checkScaleFactor = checkPixelScaling(sampledVolumes, scaleFactor);
VCAssert.assertTrue(checkScaleFactor != scaleFactor, "Scale factor check failed");
}
VCPixelClass[] vcpixelClasses = new VCPixelClass[numSampledVols];
// get pixel classes for geometry
for (int i = 0; i < numSampledVols; i++) {
SampledVolume sVol = sampledVolumes.get(i);
// from subVolume, get pixelClass?
final int scaled = (int) (scaleFactor * sVol.getSampledValue());
vcpixelClasses[i] = new VCPixelClass(null, sVol.getDomainType(), scaled);
}
vcImage.setPixelClasses(vcpixelClasses);
// now create image geometry
vcGeometry = new Geometry("spatialGeom", vcImage);
} catch (Exception e) {
e.printStackTrace(System.out);
throw new RuntimeException("Unable to create image from SampledFieldGeometry : " + e.getMessage());
}
}
GeometrySpec vcGeometrySpec = vcGeometry.getGeometrySpec();
vcGeometrySpec.setOrigin(vcOrigin);
try {
vcGeometrySpec.setExtent(vcExtent);
} catch (PropertyVetoException e) {
e.printStackTrace(System.out);
throw new SBMLImportException("Unable to set extent on VC geometry : " + e.getMessage(), e);
}
// get listOfDomainTypes via the Geometry object.
ListOf<DomainType> listOfDomainTypes = sbmlGeometry.getListOfDomainTypes();
if (listOfDomainTypes == null || listOfDomainTypes.size() < 1) {
throw new SBMLImportException("Cannot have 0 domainTypes in geometry");
}
// get a listOfDomains via the Geometry object.
ListOf<Domain> listOfDomains = sbmlGeometry.getListOfDomains();
if (listOfDomains == null || listOfDomains.size() < 1) {
throw new SBMLImportException("Cannot have 0 domains in geometry");
}
// ListOfGeometryDefinitions listOfGeomDefns =
// sbmlGeometry.getListOfGeometryDefinitions();
// if ((listOfGeomDefns == null) ||
// (sbmlGeometry.getNumGeometryDefinitions() > 1)) {
// throw new
// RuntimeException("Can have only 1 geometry definition in geometry");
// }
// use the boolean bAnalytic to create the right kind of subvolume.
// First match the somVol=domainTypes for spDim=3. Deal witl spDim=2
// afterwards.
GeometrySurfaceDescription vcGsd = vcGeometry.getGeometrySurfaceDescription();
Vector<DomainType> surfaceClassDomainTypesVector = new Vector<DomainType>();
try {
for (DomainType dt : listOfDomainTypes) {
if (dt.getSpatialDimensions() == 3) {
// subvolume
if (selectedGeometryDefinition == analyticGeometryDefinition) {
// will set expression later - when reading in Analytic
// Volumes in GeometryDefinition
vcGeometrySpec.addSubVolume(new AnalyticSubVolume(dt.getId(), new Expression(1.0)));
} else {
// add SubVolumes later for CSG and Image-based
}
} else if (dt.getSpatialDimensions() == 2) {
surfaceClassDomainTypesVector.add(dt);
}
}
// analytic vol is needed to get the expression for subVols
if (selectedGeometryDefinition == analyticGeometryDefinition) {
// get an analyticVol object via the listOfAnalyticVol (from
// AnalyticGeometry) object.
ListOf<AnalyticVolume> aVolumes = analyticGeometryDefinition.getListOfAnalyticVolumes();
if (aVolumes.size() < 1) {
throw new SBMLImportException("Cannot have 0 Analytic volumes in analytic geometry");
}
for (AnalyticVolume analyticVol : aVolumes) {
// get subVol from VC geometry using analyticVol spatialId;
// set its expr using analyticVol's math.
SubVolume vcSubvolume = vcGeometrySpec.getSubVolume(analyticVol.getDomainType());
CastInfo<AnalyticSubVolume> ci = BeanUtils.attemptCast(AnalyticSubVolume.class, vcSubvolume);
if (!ci.isGood()) {
throw new RuntimeException("analytic volume '" + analyticVol.getId() + "' does not map to any VC subvolume.");
}
AnalyticSubVolume asv = ci.get();
try {
Expression subVolExpr = getExpressionFromFormula(analyticVol.getMath());
asv.setExpression(subVolExpr);
} catch (ExpressionException e) {
e.printStackTrace(System.out);
throw new SBMLImportException("Unable to set expression on subVolume '" + asv.getName() + "'. " + e.getMessage(), e);
}
}
}
SampledFieldGeometry sfg = BeanUtils.downcast(SampledFieldGeometry.class, selectedGeometryDefinition);
if (sfg != null) {
ListOf<SampledVolume> sampledVolumes = sfg.getListOfSampledVolumes();
int numSampledVols = sampledVolumes.size();
if (numSampledVols == 0) {
throw new SBMLImportException("Cannot have 0 sampled volumes in sampledField (image_based) geometry");
}
VCPixelClass[] vcpixelClasses = new VCPixelClass[numSampledVols];
ImageSubVolume[] vcImageSubVols = new ImageSubVolume[numSampledVols];
// get pixel classes for geometry
int idx = 0;
for (SampledVolume sVol : sampledVolumes) {
// from subVolume, get pixelClass?
final String name = sVol.getDomainType();
final int pixelValue = SBMLUtils.ignoreZeroFraction(sVol.getSampledValue());
VCPixelClass pc = new VCPixelClass(null, name, pixelValue);
vcpixelClasses[idx] = pc;
// Create the new Image SubVolume - use index of this for
// loop as 'handle' for ImageSubVol?
ImageSubVolume isv = new ImageSubVolume(null, pc, idx);
isv.setName(name);
vcImageSubVols[idx++] = isv;
}
vcGeometry.getGeometrySpec().setSubVolumes(vcImageSubVols);
}
if (selectedGeometryDefinition == csGeometry) {
ListOf<org.sbml.jsbml.ext.spatial.CSGObject> listOfcsgObjs = csGeometry.getListOfCSGObjects();
ArrayList<org.sbml.jsbml.ext.spatial.CSGObject> sbmlCSGs = new ArrayList<org.sbml.jsbml.ext.spatial.CSGObject>(listOfcsgObjs);
// we want the CSGObj with highest ordinal to be the first
// element in the CSG subvols array.
Collections.sort(sbmlCSGs, new Comparator<org.sbml.jsbml.ext.spatial.CSGObject>() {
@Override
public int compare(org.sbml.jsbml.ext.spatial.CSGObject lhs, org.sbml.jsbml.ext.spatial.CSGObject rhs) {
// minus one to reverse sort
return -1 * Integer.compare(lhs.getOrdinal(), rhs.getOrdinal());
}
});
int n = sbmlCSGs.size();
CSGObject[] vcCSGSubVolumes = new CSGObject[n];
for (int i = 0; i < n; i++) {
org.sbml.jsbml.ext.spatial.CSGObject sbmlCSGObject = sbmlCSGs.get(i);
CSGObject vcellCSGObject = new CSGObject(null, sbmlCSGObject.getDomainType(), i);
vcellCSGObject.setRoot(getVCellCSGNode(sbmlCSGObject.getCSGNode()));
}
vcGeometry.getGeometrySpec().setSubVolumes(vcCSGSubVolumes);
}
// Call geom.geomSurfDesc.updateAll() to automatically generate
// surface classes.
// vcGsd.updateAll();
vcGeometry.precomputeAll(new GeometryThumbnailImageFactoryAWT(), true, true);
} catch (Exception e) {
e.printStackTrace(System.out);
throw new SBMLImportException("Unable to create VC subVolumes from SBML domainTypes : " + e.getMessage(), e);
}
// should now map each SBML domain to right VC geometric region.
GeometricRegion[] vcGeomRegions = vcGsd.getGeometricRegions();
ISize sampleSize = vcGsd.getVolumeSampleSize();
RegionInfo[] regionInfos = vcGsd.getRegionImage().getRegionInfos();
int numX = sampleSize.getX();
int numY = sampleSize.getY();
int numZ = sampleSize.getZ();
double ox = vcOrigin.getX();
double oy = vcOrigin.getY();
double oz = vcOrigin.getZ();
for (Domain domain : listOfDomains) {
String domainType = domain.getDomainType();
InteriorPoint interiorPt = domain.getListOfInteriorPoints().get(0);
if (interiorPt == null) {
DomainType currDomainType = null;
for (DomainType dt : sbmlGeometry.getListOfDomainTypes()) {
if (dt.getSpatialId().equals(domainType)) {
currDomainType = dt;
}
}
if (currDomainType.getSpatialDimensions() == 2) {
continue;
}
}
Coordinate sbmlInteriorPtCoord = new Coordinate(interiorPt.getCoord1(), interiorPt.getCoord2(), interiorPt.getCoord3());
for (int j = 0; j < vcGeomRegions.length; j++) {
if (vcGeomRegions[j] instanceof VolumeGeometricRegion) {
int regionID = ((VolumeGeometricRegion) vcGeomRegions[j]).getRegionID();
for (int k = 0; k < regionInfos.length; k++) {
// (using gemoRegion regionID).
if (regionInfos[k].getRegionIndex() == regionID) {
int volIndx = 0;
Coordinate nearestPtCoord = null;
double minDistance = Double.MAX_VALUE;
// represented by SBML 'domain[i]'.
for (int z = 0; z < numZ; z++) {
for (int y = 0; y < numY; y++) {
for (int x = 0; x < numX; x++) {
if (regionInfos[k].isIndexInRegion(volIndx)) {
double unit_z = (numZ > 1) ? ((double) z) / (numZ - 1) : 0.5;
double coordZ = oz + vcExtent.getZ() * unit_z;
double unit_y = (numY > 1) ? ((double) y) / (numY - 1) : 0.5;
double coordY = oy + vcExtent.getY() * unit_y;
double unit_x = (numX > 1) ? ((double) x) / (numX - 1) : 0.5;
double coordX = ox + vcExtent.getX() * unit_x;
// for now, find the shortest dist
// coord. Can refine algo later.
Coordinate vcCoord = new Coordinate(coordX, coordY, coordZ);
double distance = sbmlInteriorPtCoord.distanceTo(vcCoord);
if (distance < minDistance) {
minDistance = distance;
nearestPtCoord = vcCoord;
}
}
volIndx++;
}
// end - for x
}
// end - for y
}
// with domain name
if (nearestPtCoord != null) {
GeometryClass geomClassSBML = vcGeometry.getGeometryClass(domainType);
// we know vcGeometryReg[j] is a VolGeomRegion
GeometryClass geomClassVC = ((VolumeGeometricRegion) vcGeomRegions[j]).getSubVolume();
if (geomClassSBML.compareEqual(geomClassVC)) {
vcGeomRegions[j].setName(domain.getId());
}
}
}
// end if (regInfoIndx = regId)
}
// end - for regInfo
}
}
// end for - vcGeomRegions
}
// deal with surfaceClass:spDim2-domainTypes
for (int i = 0; i < surfaceClassDomainTypesVector.size(); i++) {
DomainType surfaceClassDomainType = surfaceClassDomainTypesVector.elementAt(i);
// 'surfaceClassDomainType'
for (Domain d : listOfDomains) {
if (d.getDomainType().equals(surfaceClassDomainType.getId())) {
// get the adjacent domains of this 'surface' domain
// (surface domain + its 2 adj vol domains)
Set<Domain> adjacentDomainsSet = getAssociatedAdjacentDomains(sbmlGeometry, d);
// get the domain types of the adjacent domains in SBML and
// store the corresponding subVol counterparts from VC for
// adj vol domains
Vector<SubVolume> adjacentSubVolumesVector = new Vector<SubVolume>();
Vector<VolumeGeometricRegion> adjVolGeomRegionsVector = new Vector<VolumeGeometricRegion>();
Iterator<Domain> iterator = adjacentDomainsSet.iterator();
while (iterator.hasNext()) {
Domain dom = iterator.next();
DomainType dt = getBySpatialID(sbmlGeometry.getListOfDomainTypes(), dom.getDomainType());
if (dt.getSpatialDimensions() == 3) {
// for domain type with sp. dim = 3, get
// correspoinding subVol from VC geometry.
GeometryClass gc = vcGeometry.getGeometryClass(dt.getId());
adjacentSubVolumesVector.add((SubVolume) gc);
// store volGeomRegions corresponding to this (vol)
// geomClass in adjVolGeomRegionsVector : this
// should return ONLY 1 region for subVol.
GeometricRegion[] geomRegion = vcGsd.getGeometricRegions(gc);
adjVolGeomRegionsVector.add((VolumeGeometricRegion) geomRegion[0]);
}
}
// there should be only 2 subVols in this vector
if (adjacentSubVolumesVector.size() != 2) {
throw new RuntimeException("Cannot have more or less than 2 subvolumes that are adjacent to surface (membrane) '" + d.getId() + "'");
}
// get the surface class with these 2 adj subVols. Set its
// name to that of 'surfaceClassDomainType'
SurfaceClass surfacClass = vcGsd.getSurfaceClass(adjacentSubVolumesVector.get(0), adjacentSubVolumesVector.get(1));
surfacClass.setName(surfaceClassDomainType.getSpatialId());
// get surfaceGeometricRegion that has adjVolGeomRegions as
// its adjacent vol geom regions and set its name from
// domain 'd'
SurfaceGeometricRegion surfaceGeomRegion = getAssociatedSurfaceGeometricRegion(vcGsd, adjVolGeomRegionsVector);
if (surfaceGeomRegion != null) {
surfaceGeomRegion.setName(d.getId());
}
}
// end if - domain.domainType == surfaceClassDomainType
}
// end for - numDomains
}
// structureMappings in VC from compartmentMappings in SBML
try {
// set geometry first and then set structureMappings?
vcBioModel.getSimulationContext(0).setGeometry(vcGeometry);
// update simContextName ...
vcBioModel.getSimulationContext(0).setName(vcBioModel.getSimulationContext(0).getName() + "_" + vcGeometry.getName());
Model vcModel = vcBioModel.getSimulationContext(0).getModel();
ModelUnitSystem vcModelUnitSystem = vcModel.getUnitSystem();
Vector<StructureMapping> structMappingsVector = new Vector<StructureMapping>();
SpatialCompartmentPlugin cplugin = null;
for (int i = 0; i < sbmlModel.getNumCompartments(); i++) {
Compartment c = sbmlModel.getCompartment(i);
String cname = c.getName();
cplugin = (SpatialCompartmentPlugin) c.getPlugin(SBMLUtils.SBML_SPATIAL_NS_PREFIX);
CompartmentMapping compMapping = cplugin.getCompartmentMapping();
if (compMapping != null) {
// final String id = compMapping.getId();
// final String name = compMapping.getName();
CastInfo<Structure> ci = SBMLHelper.getTypedStructure(Structure.class, vcModel, cname);
if (ci.isGood()) {
Structure struct = ci.get();
String domainType = compMapping.getDomainType();
GeometryClass geometryClass = vcGeometry.getGeometryClass(domainType);
double unitSize = compMapping.getUnitSize();
Feature feat = BeanUtils.downcast(Feature.class, struct);
if (feat != null) {
FeatureMapping featureMapping = new FeatureMapping(feat, vcBioModel.getSimulationContext(0), vcModelUnitSystem);
featureMapping.setGeometryClass(geometryClass);
if (geometryClass instanceof SubVolume) {
featureMapping.getVolumePerUnitVolumeParameter().setExpression(new Expression(unitSize));
} else if (geometryClass instanceof SurfaceClass) {
featureMapping.getVolumePerUnitAreaParameter().setExpression(new Expression(unitSize));
}
structMappingsVector.add(featureMapping);
} else if (struct instanceof Membrane) {
MembraneMapping membraneMapping = new MembraneMapping((Membrane) struct, vcBioModel.getSimulationContext(0), vcModelUnitSystem);
membraneMapping.setGeometryClass(geometryClass);
if (geometryClass instanceof SubVolume) {
membraneMapping.getAreaPerUnitVolumeParameter().setExpression(new Expression(unitSize));
} else if (geometryClass instanceof SurfaceClass) {
membraneMapping.getAreaPerUnitAreaParameter().setExpression(new Expression(unitSize));
}
structMappingsVector.add(membraneMapping);
}
}
}
}
StructureMapping[] structMappings = structMappingsVector.toArray(new StructureMapping[0]);
vcBioModel.getSimulationContext(0).getGeometryContext().setStructureMappings(structMappings);
// if type from SBML parameter Boundary Condn is not the same as the
// boundary type of the
// structureMapping of structure of paramSpContext, set the boundary
// condn type of the structureMapping
// to the value of 'type' from SBML parameter Boundary Condn.
ListOf<Parameter> listOfGlobalParams = sbmlModel.getListOfParameters();
for (Parameter sbmlGlobalParam : sbmlModel.getListOfParameters()) {
SpatialParameterPlugin spplugin = (SpatialParameterPlugin) sbmlGlobalParam.getPlugin(SBMLUtils.SBML_SPATIAL_NS_PREFIX);
ParameterType paramType = spplugin.getParamType();
if (!(paramType instanceof BoundaryCondition)) {
continue;
}
BoundaryCondition bCondn = (BoundaryCondition) paramType;
if (bCondn.isSetVariable()) {
// get the var of boundaryCondn; find appropriate spContext
// in vcell;
SpeciesContext paramSpContext = vcBioModel.getSimulationContext(0).getModel().getSpeciesContext(bCondn.getVariable());
if (paramSpContext != null) {
Structure s = paramSpContext.getStructure();
StructureMapping sm = vcBioModel.getSimulationContext(0).getGeometryContext().getStructureMapping(s);
if (sm != null) {
BoundaryConditionType bct = null;
switch(bCondn.getType()) {
case Dirichlet:
{
bct = BoundaryConditionType.DIRICHLET;
break;
}
case Neumann:
{
bct = BoundaryConditionType.NEUMANN;
break;
}
case Robin_inwardNormalGradientCoefficient:
case Robin_sum:
case Robin_valueCoefficient:
default:
throw new RuntimeException("boundary condition type " + bCondn.getType().name() + " not supported");
}
for (CoordinateComponent coordComp : getSbmlGeometry().getListOfCoordinateComponents()) {
if (bCondn.getSpatialRef().equals(coordComp.getBoundaryMinimum().getSpatialId())) {
switch(coordComp.getType()) {
case cartesianX:
{
sm.setBoundaryConditionTypeXm(bct);
}
case cartesianY:
{
sm.setBoundaryConditionTypeYm(bct);
}
case cartesianZ:
{
sm.setBoundaryConditionTypeZm(bct);
}
}
}
if (bCondn.getSpatialRef().equals(coordComp.getBoundaryMaximum().getSpatialId())) {
switch(coordComp.getType()) {
case cartesianX:
{
sm.setBoundaryConditionTypeXm(bct);
}
case cartesianY:
{
sm.setBoundaryConditionTypeYm(bct);
}
case cartesianZ:
{
sm.setBoundaryConditionTypeZm(bct);
}
}
}
}
} else // sm != null
{
logger.sendMessage(VCLogger.Priority.MediumPriority, VCLogger.ErrorType.OverallWarning, "No structure " + s.getName() + " requested by species context " + paramSpContext.getName());
}
}
// end if (paramSpContext != null)
}
// end if (bCondn.isSetVar())
}
// end for (sbmlModel.numParams)
vcBioModel.getSimulationContext(0).getGeometryContext().refreshStructureMappings();
vcBioModel.getSimulationContext(0).refreshSpatialObjects();
} catch (Exception e) {
e.printStackTrace(System.out);
throw new SBMLImportException("Unable to create VC structureMappings from SBML compartment mappings : " + e.getMessage(), e);
}
}
use of cbit.vcell.parser.Expression in project vcell by virtualcell.
the class RationalExp method getTermExpression.
private cbit.vcell.parser.Expression getTermExpression(Term term) throws ExpressionException {
cbit.vcell.parser.Expression exp = new cbit.vcell.parser.Expression(term.getCoefficient().doubleValue());
while (!term.symbolList.isEmpty()) {
String symbol = term.symbolList.remove(0);
int count = 1;
while (term.symbolList.remove(symbol)) {
count++;
}
cbit.vcell.parser.Expression tempExp = null;
if (count == 1) {
exp = cbit.vcell.parser.Expression.mult(exp, new cbit.vcell.parser.Expression(symbol));
} else {
exp = cbit.vcell.parser.Expression.mult(exp, cbit.vcell.parser.Expression.power(new Expression(symbol), count));
}
}
return exp;
}
use of cbit.vcell.parser.Expression in project vcell by virtualcell.
the class ModelTest method getExample_Bound.
/**
* This method was created by a SmartGuide.
*/
public static Model getExample_Bound() throws Exception {
double FRACTIONAL_VOLUME_ER = 0.15;
double SURFACE_TO_VOLUME_ER = 6;
double FRACTIONAL_VOLUME_CYTOSOL = 0.15;
double SURFACE_TO_VOLUME_CYTOSOL = 0.25;
org.vcell.util.document.Version version = new org.vcell.util.document.Version("boundModel", new org.vcell.util.document.User("frm", new org.vcell.util.document.KeyValue("227")));
Model model = new Model(version);
FormalSpeciesInfo fsi = null;
DBFormalSpecies dbfs = null;
DBSpecies dbs = null;
String[] names1 = new String[1];
names1[0] = "IP3";
fsi = new CompoundInfo(names1[0] + "_KeggID", names1, names1[0] + "_Formula", names1[0] + "_casID", null);
dbfs = new FormalCompound(new org.vcell.util.document.KeyValue("0"), (CompoundInfo) fsi);
dbs = new BoundCompound(new org.vcell.util.document.KeyValue("1"), (FormalCompound) dbfs);
model.addSpecies(new Species(names1[0], null, dbs));
String[] names2 = new String[1];
names2[0] = "Calcium";
fsi = new CompoundInfo(names2[0] + "_KeggID", names2, names2[0] + "_Formula", names2[0] + "_casID", null);
dbfs = new FormalCompound(new org.vcell.util.document.KeyValue("2"), (CompoundInfo) fsi);
dbs = new BoundCompound(new org.vcell.util.document.KeyValue("3"), (FormalCompound) dbfs);
model.addSpecies(new Species(names2[0], null, dbs));
String keywords = "keword1,keyword2";
String descr = "Decription Text";
String[] names3 = new String[1];
names3[0] = "IP3_Receptor";
fsi = new ProteinInfo(names3[0] + "_SwissProtID", names3, names3[0] + "_Organism", names3[0] + "_Accession", keywords, descr);
dbfs = new FormalProtein(new org.vcell.util.document.KeyValue("4"), (ProteinInfo) fsi);
dbs = new BoundProtein(new org.vcell.util.document.KeyValue("5"), (FormalProtein) dbfs);
model.addSpecies(new Species(names3[0], null, dbs));
// names[0] = "IP3_Receptor_Activated";
// fsi = new ProteinInfo(names[0]+"_SwissProtID",names,names[0]+"_Organism",names[0]+"_Accession",keywords,descr);
// dbfs = new FormalProtein(new cbit.sql.KeyValue("6"),(ProteinInfo)fsi);
// dbs = new BoundProtein(new cbit.sql.KeyValue("7"),(FormalProtein)dbfs);
// make 1 unbound
model.addSpecies(new Species("IP3_Receptor_Activated", null));
model.addFeature("Extracellular");
Feature extracellular = (Feature) model.getStructure("Extracellular");
model.addFeature("Cytosol");
Feature cytosol = (Feature) model.getStructure("Cytosol");
Membrane plasmaMembrane = (Membrane) model.getStructure("PlasmaMembrane");
model.addFeature("ER");
Feature er = (Feature) model.getStructure("ER");
Membrane erMembrane = (Membrane) model.getStructure("ER_Membrane");
Species calcium = model.getSpecies("Calcium");
Species ip3 = model.getSpecies("IP3");
Species r = model.getSpecies("IP3_Receptor");
Species ri = model.getSpecies("IP3_Receptor_Activated");
model.addSpeciesContext(calcium, er);
model.addSpeciesContext(calcium, cytosol);
model.addSpeciesContext(calcium, extracellular);
model.addSpeciesContext(ip3, cytosol);
model.addSpeciesContext(ip3, extracellular);
model.addSpeciesContext(r, erMembrane);
model.addSpeciesContext(ri, erMembrane);
SpeciesContext ip3_cytosol = model.getSpeciesContext(ip3, cytosol);
SpeciesContext ip3_extracellular = model.getSpeciesContext(ip3, extracellular);
SpeciesContext calcium_cytosol = model.getSpeciesContext(calcium, cytosol);
SpeciesContext calcium_extracellular = model.getSpeciesContext(calcium, extracellular);
SpeciesContext calcium_er = model.getSpeciesContext(calcium, er);
SpeciesContext r_erMembrane = model.getSpeciesContext(r, erMembrane);
SpeciesContext ri_erMembrane = model.getSpeciesContext(ri, erMembrane);
SimpleReaction sr;
SimpleReaction sr1;
FluxReaction fr;
//
// CYTOSOL REACTIONS
//
// 1.0/12.0;
double IP3_DEGRADATION = 0.5;
double IP3_DESIRED_INITIAL = 0.01;
double IP3_DESIRED_FINAL = 0.03;
double PLASMA_MEM_SURFACE_TO_VOLUME_ER = 0.25;
double IP3_FLUX_TIME_CONSTANT = 0.050;
double IP3_FLUX_FINAL = IP3_DEGRADATION * (IP3_DESIRED_FINAL - IP3_DESIRED_INITIAL) * (1 - FRACTIONAL_VOLUME_ER) / PLASMA_MEM_SURFACE_TO_VOLUME_ER;
//
// IP3_DEGRADATION
// IP3 ----------------->
//
//
// source(IP3) = IP3_DEGRADATION * IP3_DESIRED_INITIAL
//
// model.addReaction("IP3_Volume");
// reaction = model.getReaction("IP3_Volume");
sr = new SimpleReaction(model, cytosol, "IP3_DEGRADATION", true);
sr.addReactant(ip3_cytosol, 1);
sr.setKinetics(new MassActionKinetics(sr));
MassActionKinetics massAct = (MassActionKinetics) sr.getKinetics();
massAct.setParameterValue(massAct.getForwardRateParameter(), new Expression("Kdegr1;"));
massAct.setParameterValue(massAct.getKineticsParameter("Kdegr1"), new Expression(IP3_DEGRADATION));
model.addReactionStep(sr);
sr = new SimpleReaction(model, cytosol, "IP3_BASAL_CREATION", true);
sr.addProduct(ip3_cytosol, 1);
massAct = new MassActionKinetics(sr);
sr.setKinetics(massAct);
massAct.setParameterValue(massAct.getForwardRateParameter(), new Expression("Kdegr2 * IP3i;"));
massAct.setParameterValue(massAct.getKineticsParameter("Kdegr2"), new Expression(IP3_DEGRADATION));
massAct.setParameterValue(massAct.getKineticsParameter("IP3i"), new Expression(IP3_DESIRED_INITIAL));
model.addReactionStep(sr);
sr1 = new SimpleReaction(model, cytosol, "IP3_DEGRADATION2", true);
sr1.addReactant(ip3_cytosol, 1);
sr1.setKinetics(new HMM_IRRKinetics(sr1));
HMM_IRRKinetics hmmKinetics = (HMM_IRRKinetics) sr1.getKinetics();
hmmKinetics.setParameterValue(hmmKinetics.getVmaxParameter(), new Expression("10.0"));
hmmKinetics.setParameterValue(hmmKinetics.getKmParameter(), new Expression("12.0"));
model.addReactionStep(sr1);
//
// flux(IP3) = IP3_FLUX_FINAL * (1 - exp(-t/IP3_FLUX_TIME_CONSTANT))
//
// model.addReaction("IP3_generation");
// reaction = model.getReaction("IP3_generation");
fr = new FluxReaction(model, plasmaMembrane, null, "IP3_FLUX", true);
GeneralKinetics genKinetics = new GeneralKinetics(fr);
fr.setKinetics(genKinetics);
genKinetics.setParameterValue(genKinetics.getReactionRateParameter(), new Expression("Jfinal * (1 - exp(-t/TAU));"));
genKinetics.setParameterValue(genKinetics.getKineticsParameter("Jfinal"), new Expression(0.034));
genKinetics.setParameterValue(genKinetics.getKineticsParameter("TAU"), new Expression(IP3_FLUX_TIME_CONSTANT));
model.addReactionStep(fr);
//
// ER REACTIONS
//
//
// IP3 Receptor
//
double I1 = 3.33333333;
double ii1 = 100;
double i1 = ii1 / I1;
double channel_density = 25;
// channel_density / (1 + IP3_DESIRED_INITIAL * I1);
double R = 19.35;
// channel_density * IP3_DESIRED_INITIAL * I1 * R;
double RI = 0.65;
double TOTAL_CHANNEL = R + RI;
double channel_flux = 143.7;
double CALCIUM_DIFFUSION = 180.0;
double IP3_DIFFUSION = 250;
double CALCIUM_CYTOSOL = 0.050;
double CALCIUM_ER = 2500.0;
double CALCIUM_EXTRACELLULAR_INITIAL = 1000;
double IP3_EXTRACELLULAR_INITIAL = 10;
// model.addReaction("IP3_Receptor");
// reaction = model.getReaction("IP3_Receptor");
sr = new SimpleReaction(model, erMembrane, "IP3_BINDING", true);
sr.addReactant(r_erMembrane, 2);
sr.addReactant(ip3_cytosol, 3);
sr.addProduct(ri_erMembrane, 1);
massAct = new MassActionKinetics(sr);
sr.setKinetics(massAct);
massAct.setParameterValue(massAct.getForwardRateParameter(), new Expression("ii1;"));
massAct.setParameterValue(massAct.getReverseRateParameter(), new Expression("i1;"));
massAct.setParameterValue(massAct.getKineticsParameter("ii1"), new Expression(ii1));
massAct.setParameterValue(massAct.getKineticsParameter("i1"), new Expression("ii1/I1"));
massAct.setParameterValue(massAct.getKineticsParameter("I1"), new Expression(I1));
model.addReactionStep(sr);
fr = new FluxReaction(model, erMembrane, null, "IP3R_FLUX", true);
fr.addCatalyst(ri_erMembrane);
// fr.addCatalyst(calcium_cytosol);
// fr.addCatalyst(calcium_er);
// fr.setInwardFlux(-channel_flux+" * "+ (4/(channel_density*channel_density))+" * pow(RI,3);");
genKinetics = (GeneralKinetics) fr.getKinetics();
genKinetics.setParameterValue(genKinetics.getReactionRateParameter(), new Expression("Jchan * (" + calcium_cytosol.getName() + " - " + calcium_er.getName() + ") * pow(" + ri_erMembrane.getName() + "/Rtotal,3);"));
genKinetics.setParameterValue(genKinetics.getKineticsParameter("Rtotal"), new Expression(TOTAL_CHANNEL));
genKinetics.setParameterValue(genKinetics.getKineticsParameter("Jchan"), new Expression(4.6));
model.addReactionStep(fr);
//
// SERCA pump
//
double K_serca = 0.270;
double pump_coef = (K_serca * K_serca + CALCIUM_CYTOSOL * CALCIUM_CYTOSOL) * channel_flux * 4 * RI * RI * RI / (channel_density * channel_density * CALCIUM_CYTOSOL * CALCIUM_CYTOSOL);
// model.addReaction("Serca_Pump");
// reaction = model.getReaction("Serca_Pump");
fr = new FluxReaction(model, erMembrane, null, "SERCA_FLUX", true);
genKinetics = (GeneralKinetics) fr.getKinetics();
genKinetics.setParameterValue(genKinetics.getReactionRateParameter(), new Expression("Vmax * pow(" + calcium_cytosol.getName() + ",2) / (pow(Kd,2) + pow(" + calcium_er.getName() + ",2));"));
genKinetics.setParameterValue(genKinetics.getKineticsParameter("Kd"), new Expression(0.7));
genKinetics.setParameterValue(genKinetics.getKineticsParameter("Vmax"), new Expression(77.77));
model.addReactionStep(fr);
SpeciesContext sc = model.getSpeciesContext(r, erMembrane);
// sc.setInitialValue(R);
sc = model.getSpeciesContext(ri, erMembrane);
// sc.setInitialValue(RI);
sc = model.getSpeciesContext(calcium, er);
// sc.setInitialValue(CALCIUM_ER);
sc = model.getSpeciesContext(calcium, cytosol);
// sc.setInitialValue(CALCIUM_CYTOSOL);
// sc.setDiffusionRate(CALCIUM_DIFFUSION);
sc = model.getSpeciesContext(calcium, extracellular);
// sc.setDiffusionRate(CALCIUM_DIFFUSION);
// sc.setInitialValue(CALCIUM_EXTRACELLULAR_INITIAL);
sc = model.getSpeciesContext(ip3, cytosol);
// sc.setInitialValue(IP3_DESIRED_INITIAL);
// sc.setDiffusionRate(IP3_DIFFUSION);
sc = model.getSpeciesContext(ip3, extracellular);
return model;
}
use of cbit.vcell.parser.Expression in project vcell by virtualcell.
the class ModelTest method getExample2_Fast.
/**
* This method was created by a SmartGuide.
*/
public static Model getExample2_Fast() throws Exception {
double A_init = 10.0;
double B_init = 20.0;
double C_init = 30.0;
double D_init = 40.0;
double E_init = 50.0;
double F_init = 60.0;
double A_diff = 11.0;
double B_diff = 22.0;
double C_diff = 33.0;
double D_diff = 44.0;
double E_diff = 55.0;
double F_diff = 66.0;
Model model = new Model("model1");
model.addSpecies(new Species("A", "A"));
Species A = model.getSpecies("A");
model.addSpecies(new Species("B", "B"));
Species B = model.getSpecies("B");
model.addSpecies(new Species("C", "C"));
Species C = model.getSpecies("C");
model.addSpecies(new Species("D", "D"));
Species D = model.getSpecies("D");
model.addSpecies(new Species("E", "E"));
Species E = model.getSpecies("E");
model.addSpecies(new Species("F", "F"));
Species F = model.getSpecies("F");
model.addFeature("Cytosol");
Feature cytosol = (Feature) model.getStructure("Cytosol");
model.addSpeciesContext(F, cytosol);
SpeciesContext F_cyt = model.getSpeciesContext(F, cytosol);
// F_cyt.setInitialValue(F_init);
// F_cyt.setDiffusionRate(F_diff);
model.addSpeciesContext(A, cytosol);
SpeciesContext A_cyt = model.getSpeciesContext(A, cytosol);
// A_cyt.setInitialValue(A_init);
// A_cyt.setDiffusionRate(A_diff);
model.addSpeciesContext(B, cytosol);
SpeciesContext B_cyt = model.getSpeciesContext(B, cytosol);
// B_cyt.setInitialValue(B_init);
// B_cyt.setDiffusionRate(B_diff);
model.addSpeciesContext(D, cytosol);
SpeciesContext D_cyt = model.getSpeciesContext(D, cytosol);
// D_cyt.setInitialValue(D_init);
// D_cyt.setDiffusionRate(D_diff);
model.addSpeciesContext(E, cytosol);
SpeciesContext E_cyt = model.getSpeciesContext(E, cytosol);
// E_cyt.setInitialValue(E_init);
// E_cyt.setDiffusionRate(E_diff);
model.addSpeciesContext(C, cytosol);
SpeciesContext C_cyt = model.getSpeciesContext(C, cytosol);
// C_cyt.setInitialValue(C_init);
// C_cyt.setDiffusionRate(C_diff);
SimpleReaction sr;
//
// CYTOSOL REACTIONS
//
double K1f = 1.0;
double K1r = 1.0;
double K2f = 200.0;
double K2r = 300.0;
double K3f = 4.0;
double K3r = 4.0;
sr = new SimpleReaction(model, cytosol, "SIMPLE_REACTION_ABC", true);
sr.addReactant(A_cyt, 1);
sr.addReactant(B_cyt, 1);
sr.addProduct(C_cyt, 1);
MassActionKinetics massAct = new MassActionKinetics(sr);
massAct.setParameterValue(massAct.getForwardRateParameter(), new Expression(K1f));
massAct.setParameterValue(massAct.getReverseRateParameter(), new Expression(K1r));
massAct.getForwardRateParameter().setName("K1f");
massAct.getReverseRateParameter().setName("K1r");
// massAct.setFast(false);
sr.setKinetics(massAct);
model.addReactionStep(sr);
sr = new SimpleReaction(model, cytosol, "SIMPLE_REACTION_CDE", true);
sr.addReactant(C_cyt, 1);
sr.addReactant(D_cyt, 1);
sr.addProduct(E_cyt, 1);
massAct = new MassActionKinetics(sr);
massAct.setParameterValue(massAct.getForwardRateParameter(), new Expression(K2f));
massAct.setParameterValue(massAct.getReverseRateParameter(), new Expression(K2r));
massAct.getForwardRateParameter().setName("K2f");
massAct.getReverseRateParameter().setName("K2r");
// massAct.setFast(true);
sr.setKinetics(massAct);
model.addReactionStep(sr);
sr = new SimpleReaction(model, cytosol, "SIMPLE_REACTION_EAF", true);
sr.addReactant(E_cyt, 1);
sr.addReactant(A_cyt, 1);
sr.addProduct(F_cyt, 1);
massAct = new MassActionKinetics(sr);
massAct.setParameterValue(massAct.getForwardRateParameter(), new Expression(K3f));
massAct.setParameterValue(massAct.getReverseRateParameter(), new Expression(K3r));
massAct.getForwardRateParameter().setName("K3f");
massAct.getReverseRateParameter().setName("K3r");
// massAct.setFast(false);
sr.setKinetics(massAct);
model.addReactionStep(sr);
return model;
}
use of cbit.vcell.parser.Expression in project vcell by virtualcell.
the class ModelTest method getExample.
/**
* This method was created by a SmartGuide.
*/
public static Model getExample() throws Exception {
double FRACTIONAL_VOLUME_ER = 0.15;
double SURFACE_TO_VOLUME_ER = 6;
double FRACTIONAL_VOLUME_CYTOSOL = 0.15;
double SURFACE_TO_VOLUME_CYTOSOL = 0.25;
Model model = new Model("model1");
model.addSpecies(new Species("IP3", "Inositol-trisphosphate(1,4,5)"));
model.addSpecies(new Species("Ca", "Calcium"));
model.addSpecies(new Species("R", "IP3-Receptor"));
model.addSpecies(new Species("RI", "IP3-Receptor-Activated"));
model.addFeature("Extracellular");
Feature extracellular = (Feature) model.getStructure("Extracellular");
model.addFeature("Cytosol");
Feature cytosol = (Feature) model.getStructure("Cytosol");
Membrane plasmaMembrane = (Membrane) model.getStructure("PlasmaMembrane");
model.addFeature("ER");
Feature er = (Feature) model.getStructure("ER");
Membrane erMembrane = (Membrane) model.getStructure("ER_Membrane");
Species calcium = model.getSpecies("Ca");
Species ip3 = model.getSpecies("IP3");
Species r = model.getSpecies("R");
Species ri = model.getSpecies("RI");
model.addSpeciesContext(calcium, er);
model.addSpeciesContext(calcium, cytosol);
model.addSpeciesContext(calcium, extracellular);
model.addSpeciesContext(ip3, cytosol);
model.addSpeciesContext(ip3, extracellular);
model.addSpeciesContext(r, erMembrane);
model.addSpeciesContext(ri, erMembrane);
SpeciesContext ip3_cytosol = model.getSpeciesContext(ip3, cytosol);
SpeciesContext ip3_extracellular = model.getSpeciesContext(ip3, extracellular);
SpeciesContext calcium_cytosol = model.getSpeciesContext(calcium, cytosol);
SpeciesContext calcium_extracellular = model.getSpeciesContext(calcium, extracellular);
SpeciesContext calcium_er = model.getSpeciesContext(calcium, er);
SpeciesContext r_erMembrane = model.getSpeciesContext(r, erMembrane);
SpeciesContext ri_erMembrane = model.getSpeciesContext(ri, erMembrane);
SimpleReaction sr;
SimpleReaction sr1;
FluxReaction fr;
//
// CYTOSOL REACTIONS
//
// 1.0/12.0;
double IP3_DEGRADATION = 0.5;
double IP3_DESIRED_INITIAL = 0.01;
double IP3_DESIRED_FINAL = 0.03;
double PLASMA_MEM_SURFACE_TO_VOLUME_ER = 0.25;
double IP3_FLUX_TIME_CONSTANT = 0.050;
double IP3_FLUX_FINAL = IP3_DEGRADATION * (IP3_DESIRED_FINAL - IP3_DESIRED_INITIAL) * (1 - FRACTIONAL_VOLUME_ER) / PLASMA_MEM_SURFACE_TO_VOLUME_ER;
//
// IP3_DEGRADATION
// IP3 ----------------->
//
//
// source(IP3) = IP3_DEGRADATION * IP3_DESIRED_INITIAL
//
// model.addReaction("IP3_Volume");
// reaction = model.getReaction("IP3_Volume");
sr = new SimpleReaction(model, cytosol, "IP3_DEGRADATION", true);
sr.setModel(model);
sr.addReactant(ip3_cytosol, 1);
sr.setKinetics(new MassActionKinetics(sr));
MassActionKinetics massAct = (MassActionKinetics) sr.getKinetics();
massAct.setParameterValue(massAct.getForwardRateParameter(), new Expression("Kdegr1;"));
massAct.setParameterValue(massAct.getKineticsParameter("Kdegr1"), new Expression(IP3_DEGRADATION));
model.addReactionStep(sr);
sr = new SimpleReaction(model, cytosol, "IP3_BASAL_CREATION", true);
sr.setModel(model);
sr.addProduct(ip3_cytosol, 1);
massAct = new MassActionKinetics(sr);
sr.setKinetics(massAct);
massAct.setParameterValue(massAct.getForwardRateParameter(), new Expression("Kdegr2 * IP3i;"));
massAct.setParameterValue(massAct.getKineticsParameter("Kdegr2"), new Expression(IP3_DEGRADATION));
massAct.setParameterValue(massAct.getKineticsParameter("IP3i"), new Expression(IP3_DESIRED_INITIAL));
model.addReactionStep(sr);
sr1 = new SimpleReaction(model, cytosol, "IP3_DEGRADATION1", true);
sr1.setModel(model);
sr1.addReactant(ip3_cytosol, 1);
sr1.setKinetics(new HMM_IRRKinetics(sr1));
HMM_IRRKinetics hmmKinetics = (HMM_IRRKinetics) sr1.getKinetics();
hmmKinetics.setParameterValue(hmmKinetics.getVmaxParameter(), new Expression("10.0"));
hmmKinetics.setParameterValue(hmmKinetics.getKmParameter(), new Expression("12.0"));
model.addReactionStep(sr1);
//
// flux(IP3) = IP3_FLUX_FINAL * (1 - exp(-t/IP3_FLUX_TIME_CONSTANT))
//
// model.addReaction("IP3_generation");
// reaction = model.getReaction("IP3_generation");
fr = new FluxReaction(model, plasmaMembrane, null, "IP3_FLUX", true);
fr.setModel(model);
GeneralKinetics genKinetics = new GeneralKinetics(fr);
fr.setKinetics(genKinetics);
genKinetics.setParameterValue(genKinetics.getReactionRateParameter(), new Expression("Jfinal * (1 - exp(-t/TAU));"));
genKinetics.setParameterValue(massAct.getKineticsParameter("Jfinal"), new Expression(0.034));
genKinetics.setParameterValue(massAct.getKineticsParameter("TAU"), new Expression(IP3_FLUX_TIME_CONSTANT));
model.addReactionStep(fr);
//
// ER REACTIONS
//
//
// IP3 Receptor
//
double I1 = 3.33333333;
double ii1 = 100;
double i1 = ii1 / I1;
double channel_density = 25;
// channel_density / (1 + IP3_DESIRED_INITIAL * I1);
double R = 19.35;
// channel_density * IP3_DESIRED_INITIAL * I1 * R;
double RI = 0.65;
double TOTAL_CHANNEL = R + RI;
double channel_flux = 143.7;
double CALCIUM_DIFFUSION = 180.0;
double IP3_DIFFUSION = 250;
double CALCIUM_CYTOSOL = 0.050;
double CALCIUM_ER = 2500.0;
double CALCIUM_EXTRACELLULAR_INITIAL = 1000;
double IP3_EXTRACELLULAR_INITIAL = 10;
// model.addReaction("IP3_Receptor");
// reaction = model.getReaction("IP3_Receptor");
sr = new SimpleReaction(model, erMembrane, "IP3_BINDING", true);
sr.setModel(model);
sr.addReactant(r_erMembrane, 2);
sr.addReactant(ip3_cytosol, 3);
sr.addProduct(ri_erMembrane, 1);
massAct = new MassActionKinetics(sr);
sr.setKinetics(massAct);
massAct.setParameterValue(massAct.getForwardRateParameter(), new Expression("ii1;"));
massAct.setParameterValue(massAct.getReverseRateParameter(), new Expression("i1;"));
massAct.setParameterValue(massAct.getKineticsParameter("ii1"), new Expression(ii1));
massAct.setParameterValue(massAct.getKineticsParameter("i1"), new Expression("ii1/I1"));
massAct.setParameterValue(massAct.getKineticsParameter("I1"), new Expression(I1));
model.addReactionStep(sr);
fr = new FluxReaction(model, erMembrane, null, "IP3R_FLUX", true);
fr.setModel(model);
fr.addCatalyst(ri_erMembrane);
// fr.addCatalyst(calcium_cytosol);
// fr.addCatalyst(calcium_er);
// fr.setInwardFlux(-channel_flux+" * "+ (4/(channel_density*channel_density))+" * pow(RI,3);");
genKinetics = (GeneralKinetics) fr.getKinetics();
genKinetics.setParameterValue(genKinetics.getReactionRateParameter(), new Expression("Jchan * (" + calcium_cytosol.getName() + " - " + calcium_er.getName() + ") * pow(" + ri_erMembrane.getName() + "/Rtotal,3);"));
genKinetics.setParameterValue(genKinetics.getKineticsParameter("Rtotal"), new Expression(TOTAL_CHANNEL));
genKinetics.setParameterValue(genKinetics.getKineticsParameter("Jchan"), new Expression(4.6));
model.addReactionStep(fr);
//
// SERCA pump
//
double K_serca = 0.270;
double pump_coef = (K_serca * K_serca + CALCIUM_CYTOSOL * CALCIUM_CYTOSOL) * channel_flux * 4 * RI * RI * RI / (channel_density * channel_density * CALCIUM_CYTOSOL * CALCIUM_CYTOSOL);
// model.addReaction("Serca_Pump");
// reaction = model.getReaction("Serca_Pump");
fr = new FluxReaction(model, erMembrane, null, "SERCA_FLUX", true);
fr.setModel(model);
genKinetics = (GeneralKinetics) fr.getKinetics();
genKinetics.setParameterValue(genKinetics.getReactionRateParameter(), new Expression("Vmax * pow(" + calcium_cytosol.getName() + ",2) / (pow(Kd,2) + pow(" + calcium_er.getName() + ",2));"));
genKinetics.setParameterValue(genKinetics.getKineticsParameter("Kd"), new Expression(0.7));
genKinetics.setParameterValue(genKinetics.getKineticsParameter("Vmax"), new Expression(77.77));
model.addReactionStep(fr);
SpeciesContext sc = model.getSpeciesContext(r, erMembrane);
// sc.setInitialValue(R);
sc = model.getSpeciesContext(ri, erMembrane);
// sc.setInitialValue(RI);
sc = model.getSpeciesContext(calcium, er);
// sc.setInitialValue(CALCIUM_ER);
sc = model.getSpeciesContext(calcium, cytosol);
// sc.setInitialValue(CALCIUM_CYTOSOL);
// sc.setDiffusionRate(CALCIUM_DIFFUSION);
sc = model.getSpeciesContext(calcium, extracellular);
// sc.setDiffusionRate(CALCIUM_DIFFUSION);
// sc.setInitialValue(CALCIUM_EXTRACELLULAR_INITIAL);
sc = model.getSpeciesContext(ip3, cytosol);
// sc.setInitialValue(IP3_DESIRED_INITIAL);
// sc.setDiffusionRate(IP3_DIFFUSION);
sc = model.getSpeciesContext(ip3, extracellular);
return model;
}
Aggregations