Skip to content

Commit 7b71250

Browse files
committed
- allow to bypass suitability tests
1 parent 151acfd commit 7b71250

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

src/sbml/conversion/SBMLRateRuleConverter.cpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,9 @@ SBMLRateRuleConverter::getDefaultProperties() const
238238
prop.addOption("useStoichiometryFromMath", true,
239239
"If a number appears in the math use it as the stoichiometry");
240240

241+
prop.addOption("performSanityCheck", true,
242+
"Whether the model should be checked for suitability first");
243+
241244
init = true;
242245
return prop;
243246
}
@@ -300,7 +303,7 @@ SBMLRateRuleConverter::convert()
300303
{
301304
// if we cannot do the conversion - dont try
302305
OperationReturnValues_t returnValue;
303-
if (!isDocumentAppropriate(returnValue))
306+
if (performSanityCheck() && !isDocumentAppropriate(returnValue))
304307
{
305308
return returnValue;
306309
}
@@ -1137,6 +1140,21 @@ bool SBMLRateRuleConverter::useStoichiometryFromMath()
11371140
return value;
11381141
}
11391142

1143+
bool SBMLRateRuleConverter::performSanityCheck()
1144+
{
1145+
bool value = true;
1146+
if (getProperties() == NULL || getProperties()->hasOption("performSanityCheck") == false)
1147+
{
1148+
return value;
1149+
}
1150+
else
1151+
{
1152+
value = getProperties()->getBoolValue("performSanityCheck");
1153+
}
1154+
return value;
1155+
}
1156+
1157+
11401158
void
11411159
SBMLRateRuleConverter::analyseCoefficient(std::vector<double> coeffs, unsigned int term_index)
11421160
{

src/sbml/conversion/SBMLRateRuleConverter.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,8 @@ class LIBSBML_EXTERN SBMLRateRuleConverter : public SBMLConverter
229229

230230
bool useStoichiometryFromMath();
231231

232+
bool performSanityCheck();
233+
232234
// functions to deal with multiple compartments
233235
bool speciesFromMultipleCompartmentsInSameRateRule();
234236

src/sbml/conversion/test/TestSBMLRateRuleConverter.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,18 @@ START_TEST(test_conversion_raterule_converter_invalid)
254254

255255
fail_unless(rule_rn_converter->convert() == LIBSBML_OPERATION_FAILED);
256256

257+
// now override the check for suitability to force an invalid document through
258+
// assuming the user knows what they are doing
259+
rule_rn_props.addOption("performSanityCheck", false);
260+
rule_rn_converter->setProperties(&rule_rn_props);
261+
262+
fail_unless(rule_rn_converter->convert() == LIBSBML_OPERATION_SUCCESS);
263+
264+
// reset to default
265+
rule_rn_props.setBoolValue("performSanityCheck", true);
266+
rule_rn_converter->setProperties(&rule_rn_props);
267+
268+
257269
delete doc;
258270
}
259271
END_TEST

0 commit comments

Comments
 (0)