Skip to content

Commit

Permalink
Merge pull request #276 from sbmlteam/spatial-validation-issue
Browse files Browse the repository at this point in the history
#275: check that spatial dimensions match before running test
  • Loading branch information
skeating committed Oct 28, 2022
2 parents 6135015 + 4733698 commit efc1992
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/sbml/packages/spatial/validator/SpatialSBMLErrorTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -882,9 +882,9 @@ static const packageErrorTableEntry spatialErrorTable[] =
{ SpatialCompartmentMappingUnitSizeMustBeFraction,
"The 'unitSize' attribute must be between 0 and 1.",
LIBSBML_CAT_GENERAL_CONSISTENCY,
LIBSBML_SEV_ERROR,
"The attribute 'spatial:unitSize' on a <compartmentMapping> must have a value "
"between 0 and 1, inclusive.",
LIBSBML_SEV_WARNING,
"The attribute 'spatial:unitSize' on a <compartmentMapping> should have a value "
"between 0 and 1, inclusive, when the dimensions of the referenced compartments are the same.",
{ "L3V1 Spatial V1 Section"
}
},
Expand All @@ -894,7 +894,7 @@ static const packageErrorTableEntry spatialErrorTable[] =
"The 'unitSize' attributes should sum to 1.",
LIBSBML_CAT_GENERAL_CONSISTENCY,
LIBSBML_SEV_WARNING,
"The values of the 'spatial:unitSize' attributes of every <compartmentMapping> with the same 'spatial:domainType' should sum to 1.",
"The values of the 'spatial:unitSize' attributes of every <compartmentMapping> with the same 'spatial:domainType' should sum to 1, when the dimensions of the referenced compartments are the same.",
{ "L3V1 Spatial V1 Section"
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,30 @@ END_CONSTRAINT
// 1221350
START_CONSTRAINT(SpatialCompartmentMappingUnitSizeMustBeFraction, CompartmentMapping, cmap)
{
SpatialModelPlugin *plug = (SpatialModelPlugin*)(m.getPlugin("spatial"));
pre(plug != NULL);
const Compartment *pComp = dynamic_cast<const Compartment*>(cmap.getParentSBMLObject());
pre(pComp != NULL);
pre(plug->isSetGeometry());
const Compartment* pOtherComp = NULL;
for (unsigned int i = 0; i < m.getNumCompartments(); ++i)
{
const Compartment* comp = m.getCompartment(i);
if (!comp) continue;
const SpatialCompartmentPlugin *compPlugin = dynamic_cast<const SpatialCompartmentPlugin *>(comp->getPlugin("spatial"));
if (!compPlugin) continue;
const CompartmentMapping* otherMapping = compPlugin->getCompartmentMapping();
if (!otherMapping) continue;
if (otherMapping->getDomainType() != cmap.getDomainType()) continue;
pOtherComp = comp;
break;
}
pre(pOtherComp != NULL);

// this constraint should only apply when
// the domainType's compartment has the same dimension as the mapped compartment
pre(pComp->getSpatialDimensions() == pOtherComp->getSpatialDimensions());

bool fail = false;
if (cmap.isSetUnitSize() && (cmap.getUnitSize() > 1 || cmap.getUnitSize() < 0)) {
fail = true;
Expand Down

0 comments on commit efc1992

Please sign in to comment.