Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3792,6 +3792,11 @@ public void updateAll(boolean bForceUpgrade) throws MappingException {
double structSize = 1.0;
StructureSizeSolver.updateAbsoluteStructureSizes_symbolic(this, struct, structSize, struct.getStructureSize().getUnitDefinition());
}
if (getGeometry().getDimension() > 0 && !gc.isAllUnitSizeParameterSetForSpatial()) {
for (GeometryClass geometryClass : getGeometry().getGeometryClasses()) {
StructureSizeSolver.updateUnitStructureSizes(this, geometryClass);
}
}
}

//
Expand Down
14 changes: 12 additions & 2 deletions vcell-core/src/main/java/org/vcell/sbml/vcell/SBMLExporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,8 @@ private static boolean validSpatial(SimulationContext ctx) {
private void addCompartments() throws XMLStreamException, SbmlException {
Model vcModel = vcBioModel.getModel();
try {
// old vcell spatial application, with only relative compartment sizes (SBML wants absolute sizes for nonspatial ... easier to understand anyway)
if (!getSelectedSimContext().getGeometryContext().isAllSizeSpecifiedPositive() && getSelectedSimContext().getGeometry().getDimension() == 0) {
// old vcell nonspatial application, with only relative compartment sizes (SBML wants absolute sizes for nonspatial ... easier to understand anyway)
if (getSelectedSimContext().getGeometry().getDimension() == 0 && !getSelectedSimContext().getGeometryContext().isAllSizeSpecifiedPositive()) {
Structure structure = getSelectedSimContext().getModel().getStructure(0);
double structureSize = 1.0;
StructureMapping structMapping = getSelectedSimContext().getGeometryContext().getStructureMapping(structure);
Expand All @@ -281,6 +281,16 @@ private void addCompartments() throws XMLStreamException, SbmlException {
}catch (Exception e) {
throw new RuntimeException("Failed to solve for absolute compartment sizes for nonspatial application: "+e.getMessage(), e);
}
try {
// old vcell spatial application, with only relative compartment sizes (SBML wants absolute sizes for nonspatial ... easier to understand anyway)
if (getSelectedSimContext().getGeometry().getDimension() > 0 && !getSelectedSimContext().getGeometryContext().isAllUnitSizeParameterSetForSpatial()) {
for (GeometryClass geometryClass : getSelectedSimContext().getGeometry().getGeometryClasses()) {
StructureSizeSolver.updateUnitStructureSizes(getSelectedSimContext(), geometryClass);
}
}
}catch (Exception e) {
throw new RuntimeException("Failed to solve for unit sizes for spatial application: "+e.getMessage(), e);
}
cbit.vcell.model.Structure[] vcStructures = vcModel.getStructures();
for (int i = 0; i < vcStructures.length; i++) { // first we populate compartment vcell name to sbml id map
Compartment sbmlCompartment = sbmlModel.createCompartment();
Expand Down
21 changes: 16 additions & 5 deletions vcell-core/src/main/java/org/vcell/sbml/vcell/SBMLImporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -4152,26 +4152,37 @@ private static void addGeometry(org.sbml.jsbml.Model sbmlModel, BioModel vcBioMo
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));
if (compMapping.isSetUnitSize()) {
double unitSize = compMapping.getUnitSize();
featureMapping.getVolumePerUnitVolumeParameter().setExpression(new Expression(unitSize));
}
sbmlSymbolMapping.putInitial(compMapping, featureMapping.getVolumePerUnitVolumeParameter());
} else if (geometryClass instanceof SurfaceClass) {
featureMapping.getVolumePerUnitAreaParameter().setExpression(new Expression(unitSize));
if (compMapping.isSetUnitSize()) {
double unitSize = compMapping.getUnitSize();
featureMapping.getVolumePerUnitAreaParameter().setExpression(new Expression(unitSize));
}
sbmlSymbolMapping.putInitial(compMapping, featureMapping.getVolumePerUnitAreaParameter());
}
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));
if (compMapping.isSetUnitSize()) {
double unitSize = compMapping.getUnitSize();
membraneMapping.getAreaPerUnitVolumeParameter().setExpression(new Expression(unitSize));
}
sbmlSymbolMapping.putInitial(compMapping, membraneMapping.getAreaPerUnitVolumeParameter());
} else if (geometryClass instanceof SurfaceClass) {
membraneMapping.getAreaPerUnitAreaParameter().setExpression(new Expression(unitSize));
if (compMapping.isSetUnitSize()) {
double unitSize = compMapping.getUnitSize();
membraneMapping.getAreaPerUnitAreaParameter().setExpression(new Expression(unitSize));
}
sbmlSymbolMapping.putInitial(compMapping, membraneMapping.getAreaPerUnitAreaParameter());
}
structMappingsVector.add(membraneMapping);
Expand Down