23 #include "test_expression_comparison.hpp"
34 void test_expression_comparison::setUp()
39 void test_expression_comparison::tearDown()
44 void test_expression_comparison::test_substrate_activation()
48 std::string infix1(
"V*(substrate/Ksa)^2/(1+substrate/Ksc+substrate/Ksa+(substrate/Ksa)^2)");
51 std::string infix2(
"V*substrate^2/(substrate^2+Ksa*(Ksa*Ksc^(-1)+1)*substrate+Ksa^2)");
54 CPPUNIT_ASSERT(firstTree->
getRoot() != NULL);
56 secondTree->setInfix(infix2);
57 CPPUNIT_ASSERT(secondTree->getRoot() != NULL);
59 CPPUNIT_ASSERT(firstBase != NULL);
61 CPPUNIT_ASSERT(firstFraction != NULL);
63 CPPUNIT_ASSERT(secondBase != NULL);
65 CPPUNIT_ASSERT(secondFraction != NULL);
66 CPPUNIT_ASSERT(*firstFraction == *secondFraction);
73 void test_expression_comparison::test_allosteric_inhibition()
79 std::string infix1(
"V*substrate*(Ks+substrate)^(n-1)/(L*(Ks*(1+Inhibitor/Ki))^n+(Ks+substrate)^n)");
82 std::string infix2(
"(Ks+substrate)^(-1)*(substrate*V)/(1+L*((Ki^(-1)*Ks*Inhibitor+Ks)/(substrate+Ks))^n)");
85 CPPUNIT_ASSERT(firstTree->
getRoot() != NULL);
87 secondTree->setInfix(infix2);
88 CPPUNIT_ASSERT(secondTree->getRoot() != NULL);
91 CPPUNIT_ASSERT(firstBase != NULL);
93 CPPUNIT_ASSERT(firstFraction != NULL);
94 std::string s1 = firstFraction->
toString();
97 CPPUNIT_ASSERT(secondBase != NULL);
99 CPPUNIT_ASSERT(secondFraction != NULL);
100 std::string s2 = secondFraction->
toString();
102 CPPUNIT_ASSERT(*firstFraction == *secondFraction);
110 std::cout <<
"A COPASI exception." << std::endl;
114 void test_expression_comparison::test_hyperbolic_modifier()
118 std::string infix1(
"((Vf*substrate/Kms-Vr*product/Kmp)*(1+b*Modifier/(a*Kd)))/(1+Modifier/Kd+(substrate/Kms+product/Kmp)*(1+Modifier/(a*Kd)))");
122 std::string infix2(
"(Kms^(-1)*Vf*substrate-Kmp^(-1)*Vr*product+((Vf*b*substrate)/(Kms*a)+(b*(-Vr)*product)/(a*Kmp))*Modifier/Kd)/(1+1/Kmp*product+1/Kms*substrate+(1+1/(a*Kms)*substrate+1/(a*Kmp)*product)*Modifier/Kd)");
125 CPPUNIT_ASSERT(firstTree->
getRoot() != NULL);
127 secondTree->setInfix(infix2);
128 CPPUNIT_ASSERT(secondTree->getRoot() != NULL);
130 CPPUNIT_ASSERT(firstBase != NULL);
132 CPPUNIT_ASSERT(firstFraction != NULL);
133 std::string s1 = firstFraction->
toString();
136 CPPUNIT_ASSERT(secondBase != NULL);
138 CPPUNIT_ASSERT(secondFraction != NULL);
139 std::string s2 = secondFraction->
toString();
141 CPPUNIT_ASSERT(*firstFraction == *secondFraction);
148 void test_expression_comparison::test_specific_activation_reversible()
152 std::string infix1(
"(Vf*substrate/Kms-Vr*product/Kmp)*Activator/(Ka+(1+substrate/Kms+product/Kmp)*Activator)");
155 std::string infix2(
"(Kmp*Vf*substrate-Kms*Vr*product)/(Activator^(-1)*Ka*Kms*Kmp+Kms*Kmp+Kmp*substrate+Kms*product)");
158 CPPUNIT_ASSERT(firstTree->
getRoot() != NULL);
160 secondTree->setInfix(infix2);
161 CPPUNIT_ASSERT(secondTree->getRoot() != NULL);
163 CPPUNIT_ASSERT(firstBase != NULL);
165 CPPUNIT_ASSERT(firstFraction != NULL);
167 CPPUNIT_ASSERT(secondBase != NULL);
169 CPPUNIT_ASSERT(secondFraction != NULL);
170 CPPUNIT_ASSERT(*firstFraction == *secondFraction);
177 void test_expression_comparison::test_ordered_bi_bi()
181 std::string infix1(
"Vf*(substratea*substrateb-productp*productq/Keq)/(substratea*substrateb*(1+productp/Kip)+Kma*substrateb+Kmb*(substratea+Kia)+Vf/(Vr*Keq)*(Kmq*productp*(1+substratea/Kia)+productq*(Kmp*(1+Kia*substrateb/(Kma*Kmb))+productp*(1+substrateb/Kib))))");
184 std::string infix2(
"Vf*(productp^(-1)*productq^(-1)-substratea^(-1)*substrateb^(-1)*Keq^(-1))/(productq^(-1)*(productp^(-1)+Kip^(-1))+Kma*substratea^(-1)*productp^(-1)*productq^(-1)+productp^(-1)*productq^(-1)*Kmb*substrateb^(-1)*(1+Kia*substratea^(-1))+Vf/(Vr*Keq)*(Kmq*productq^(-1)*substrateb^(-1)*(substratea^(-1)+1/Kia)+Kmp*productp^(-1)*substratea^(-1)*(substrateb^(-1)+Kia/(Kma*Kmb))+substratea^(-1)*(substrateb^(-1)+1/Kib)))");
187 CPPUNIT_ASSERT(firstTree->
getRoot() != NULL);
189 secondTree->setInfix(infix2);
190 CPPUNIT_ASSERT(secondTree->getRoot() != NULL);
192 CPPUNIT_ASSERT(firstBase != NULL);
194 CPPUNIT_ASSERT(firstFraction != NULL);
196 CPPUNIT_ASSERT(secondBase != NULL);
198 CPPUNIT_ASSERT(secondFraction != NULL);
199 CPPUNIT_ASSERT(*firstFraction == *secondFraction);
206 void test_expression_comparison::test_reversible_hill()
218 std::string infix_numerator1 =
"Vf*substrate/Shalve*(1-product/(substrate*Keq))*(substrate/Shalve+product/Phalve)^(h-1)";
220 std::string infix_denominator1 =
"(1+(substrate/Shalve+product/Phalve)^h)";
221 std::string infix1(
"Vf*substrate/Shalve*(1-product/(substrate*Keq))*(substrate/Shalve+product/Phalve)^(h-1)/(1+(substrate/Shalve+product/Phalve)^h)");
225 std::string infix_numerator2 =
"((substrate*Phalve+product*Shalve)^(h-1)*Vf/Shalve*(substrate-Keq^(-1)*product))";
226 std::string infix_denominator2 =
"(Phalve^(h-1)*Shalve^(h-1)+(substrate*Phalve+product*Shalve)^h/(Shalve*Phalve))";
227 std::string infix2(
"((substrate*Phalve+product*Shalve)^(h-1)*Vf/Shalve*(substrate-Keq^(-1)*product))/(Phalve^(h-1)*Shalve^(h-1)+(substrate*Phalve+product*Shalve)^h/(Shalve*Phalve))");
234 firstTree->
setInfix(infix_numerator1);
235 CPPUNIT_ASSERT(firstTree->
getRoot() != NULL);
237 secondTree->setInfix(infix_numerator2);
238 CPPUNIT_ASSERT(secondTree->getRoot() != NULL);
241 CPPUNIT_ASSERT(firstBase != NULL);
243 CPPUNIT_ASSERT(firstFraction != NULL);
244 std::string s1 = firstFraction->
toString();
250 CPPUNIT_ASSERT(secondBase != NULL);
252 CPPUNIT_ASSERT(secondFraction != NULL);
253 std::string s2 = secondFraction->
toString();
263 firstTree->
setInfix(infix_denominator1);
264 CPPUNIT_ASSERT(firstTree->
getRoot() != NULL);
267 secondTree->setInfix(infix_denominator2);
268 CPPUNIT_ASSERT(secondTree->getRoot() != NULL);
271 CPPUNIT_ASSERT(firstBase != NULL);
273 CPPUNIT_ASSERT(firstFraction != NULL);
280 CPPUNIT_ASSERT(secondBase != NULL);
282 CPPUNIT_ASSERT(secondFraction != NULL);
294 CPPUNIT_ASSERT(firstTree->
getRoot() != NULL);
297 secondTree->setInfix(infix2);
298 CPPUNIT_ASSERT(secondTree->getRoot() != NULL);
301 CPPUNIT_ASSERT(firstBase != NULL);
303 CPPUNIT_ASSERT(firstFraction != NULL);
308 CPPUNIT_ASSERT(secondBase != NULL);
310 CPPUNIT_ASSERT(secondFraction != NULL);
330 std::cout <<
"CopasiException " << std::endl;
334 void test_expression_comparison::test_reversible_hill_one_modifier()
338 std::string infix1(
"Vf*substrate/Shalve*(1-product/(substrate*Keq))*(substrate/Shalve+product/Phalve)^(h-1)/((1+(Modifier/Mhalve)^h)/(1+alpha*(Modifier/Mhalve)^h)+(substrate/Shalve+product/Phalve)^h)");
341 std::string infix2(
"(Vf*Shalve^(-1)*(substrate-Keq^(-1)*product)*(Shalve^(-1)*substrate+Phalve^(-1)*product)^(h-1))/((Modifier^h+Mhalve^h)/(alpha*Modifier^h+Mhalve^h)+(Shalve^(-1)*substrate+Phalve^(-1)*product)^h)");
344 CPPUNIT_ASSERT(firstTree->
getRoot() != NULL);
346 secondTree->setInfix(infix2);
347 CPPUNIT_ASSERT(secondTree->getRoot() != NULL);
349 CPPUNIT_ASSERT(firstBase != NULL);
351 CPPUNIT_ASSERT(firstFraction != NULL);
353 CPPUNIT_ASSERT(secondBase != NULL);
355 CPPUNIT_ASSERT(secondFraction != NULL);
363 void test_expression_comparison::test_reversible_hill_two_modifiers()
367 std::string infix1(
"Vf*substrate/Shalve*(1-product/(substrate*Keq))*(substrate/Shalve+product/Phalve)^(h-1)/((1+(ModifierA/MAhalve)^h+(ModifierB/MBhalve)^h)/(1+alphaA*(ModifierA/MAhalve)^h+alphaB*(ModifierB/MBhalve)^h+alphaA*alphaB*alphaAB*(ModifierA/MAhalve)^h*(ModifierB/MBhalve)^h)+(substrate/Shalve+product/Phalve)^h)");
370 std::string infix2(
"Shalve^(-1)*Vf*(substrate-Keq^(-1)*product)*(Shalve^(-1)*substrate+Phalve^(-1)*product)^(h-1)/((MAhalve^h*MBhalve^h+ModifierA^h*MBhalve^h+ModifierB^h*MAhalve^h)/(MAhalve^h*MBhalve^h+alphaA*ModifierA^h*MBhalve^h+alphaB*ModifierB^h*MAhalve^h+alphaA*alphaB*alphaAB*ModifierA^h*ModifierB^h)+(Shalve^(-1)*substrate+Phalve^(-1)*product)^h)");
373 CPPUNIT_ASSERT(firstTree->
getRoot() != NULL);
375 secondTree->setInfix(infix2);
376 CPPUNIT_ASSERT(secondTree->getRoot() != NULL);
378 CPPUNIT_ASSERT(firstBase != NULL);
380 CPPUNIT_ASSERT(firstFraction != NULL);
381 std::string s1 = firstFraction->
toString();
383 CPPUNIT_ASSERT(secondBase != NULL);
385 CPPUNIT_ASSERT(secondFraction != NULL);
386 std::string s2 = secondFraction->
toString();
394 bool test_expression_comparison::are_expressions_equal(
const std::string& expr1,
const std::string& expr2,
const std::string& ,
bool oldStyle)
411 CPPUNIT_ASSERT(firstTree->
getRoot() != NULL);
413 secondTree->setInfix(expr2);
414 CPPUNIT_ASSERT(secondTree->getRoot() != NULL);
418 if (oldStyle ==
true)
427 CPPUNIT_ASSERT(firstBase != NULL);
429 CPPUNIT_ASSERT(firstFraction != NULL);
433 if (oldStyle ==
true)
442 CPPUNIT_ASSERT(secondBase != NULL);
444 CPPUNIT_ASSERT(secondFraction != NULL);
450 result = (*firstFraction == *secondFraction);
458 std::cout <<
"CopasiException " << std::endl;
466 void test_expression_comparison::test_fraction_to_a_power()
468 std::string expr1(
"(A/B+C/D)^E");
469 std::string expr2(
"(C/D+A/B)^E");
470 bool result = are_expressions_equal(expr1, expr2,
"are_expressions_equal.xhtml",
false);
471 CPPUNIT_ASSERT(result ==
true);
static CNormalFraction * normAndSimplifyReptdly(const CEvaluationTree *tree0, unsigned int depth=0)
virtual std::string toString() const
static void init(int argc, char *argv[], const bool &withGui=false)
CEvaluationNode * getRoot()
virtual bool setInfix(const std::string &infix)