Skip to content

Commit a8b914a

Browse files
committed
- import supported distributions
- when the distrib package is enabled on libsbml, convert distrib to annotations and import the supported ones: normal / gamma / uniform / poisson
1 parent bb4c223 commit a8b914a

1 file changed

Lines changed: 76 additions & 0 deletions

File tree

copasi/sbml/SBMLImporter.cpp

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,6 +1152,17 @@ bool addToKnownFunctionToMap(std::map<std::string, std::string>& map, const Func
11521152
return true;
11531153
}
11541154

1155+
id = isKnownCustomFunctionDefinition(sbmlFunction,
1156+
"http://sbml.org/annotations/distribution",
1157+
"distribution",
1158+
"http://en.wikipedia.org/wiki/Normal_distribution");
1159+
1160+
if (!id.empty())
1161+
{
1162+
map[id] = "RNORMAL";
1163+
return true;
1164+
}
1165+
11551166
id = isKnownCustomFunctionDefinition(sbmlFunction,
11561167
"http://sbml.org/annotations/distribution",
11571168
"distribution",
@@ -1163,6 +1174,28 @@ bool addToKnownFunctionToMap(std::map<std::string, std::string>& map, const Func
11631174
return true;
11641175
}
11651176

1177+
id = isKnownCustomFunctionDefinition(sbmlFunction,
1178+
"http://sbml.org/annotations/distribution",
1179+
"distribution",
1180+
"http://en.wikipedia.org/wiki/Uniform_distribution_(continuous)");
1181+
1182+
if (!id.empty())
1183+
{
1184+
map[id] = "RUNIFORM";
1185+
return true;
1186+
}
1187+
1188+
id = isKnownCustomFunctionDefinition(sbmlFunction,
1189+
"http://sbml.org/annotations/distribution",
1190+
"distribution",
1191+
"http://en.wikipedia.org/wiki/Uniform_distribution");
1192+
1193+
if (!id.empty())
1194+
{
1195+
map[id] = "RUNIFORM";
1196+
return true;
1197+
}
1198+
11661199
id = isKnownCustomFunctionDefinition(sbmlFunction,
11671200
"http://sbml.org/annotations/distribution",
11681201
"distribution",
@@ -1174,6 +1207,17 @@ bool addToKnownFunctionToMap(std::map<std::string, std::string>& map, const Func
11741207
return true;
11751208
}
11761209

1210+
id = isKnownCustomFunctionDefinition(sbmlFunction,
1211+
"http://sbml.org/annotations/distribution",
1212+
"distribution",
1213+
"http://en.wikipedia.org/wiki/Gamma_distribution");
1214+
1215+
if (!id.empty())
1216+
{
1217+
map[id] = "RGAMMA";
1218+
return true;
1219+
}
1220+
11771221
id = isKnownCustomFunctionDefinition(sbmlFunction,
11781222
"http://sbml.org/annotations/distribution",
11791223
"distribution",
@@ -1185,6 +1229,17 @@ bool addToKnownFunctionToMap(std::map<std::string, std::string>& map, const Func
11851229
return true;
11861230
}
11871231

1232+
id = isKnownCustomFunctionDefinition(sbmlFunction,
1233+
"http://sbml.org/annotations/distribution",
1234+
"distribution",
1235+
"http://en.wikipedia.org/wiki/Poisson_distribution");
1236+
1237+
if (!id.empty())
1238+
{
1239+
map[id] = "RPOISSON";
1240+
return true;
1241+
}
1242+
11881243
return false;
11891244
}
11901245

@@ -3074,6 +3129,27 @@ bool SBMLImporter::checkValidityOfSourceDocument(SBMLDocument* sbmlDoc)
30743129
}
30753130
}
30763131

3132+
if (sbmlDoc->getPlugin("distrib") != NULL && sbmlDoc->isSetPackageRequired("distrib"))
3133+
{
3134+
ConversionProperties props;
3135+
props.addOption("convert distrib to annotations", true, "convert distrib to annotations");
3136+
props.addOption("writeMeans", true, "Created functions return means of distributions instead of NaN");
3137+
3138+
if (sbmlDoc->convert(props) != LIBSBML_OPERATION_SUCCESS)
3139+
{
3140+
std::string message =
3141+
"The SBML model you are trying to import uses the Distrib extension. "
3142+
"In order to import this model in COPASI, it has to be converted, however conversion failed";
3143+
3144+
if (sbmlDoc->getNumErrors() == 0)
3145+
message += ".";
3146+
else
3147+
message += " with the following errors:\n" + sbmlDoc->getErrorLog()->toString();
3148+
3149+
CCopasiMessage(CCopasiMessage::ERROR, message.c_str());
3150+
}
3151+
}
3152+
30773153
if (sbmlDoc->getPlugin("comp") != NULL && sbmlDoc->isSetPackageRequired("comp"))
30783154
{
30793155

0 commit comments

Comments
 (0)