Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#275: check that spatial dimensions match before running test #276

Merged
merged 5 commits into from
Oct 28, 2022
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
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