00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef CHECKREADYTODIVIDEANDPHASEISUPDATED_HPP_
00029 #define CHECKREADYTODIVIDEANDPHASEISUPDATED_HPP_
00030
00031 #include <cxxtest/TestSuite.h>
00032
00033 #include <cmath>
00034
00035 #include "AbstractCellCycleModel.hpp"
00036
00048 void CheckReadyToDivideAndPhaseIsUpdated(AbstractCellCycleModel* pModel,
00049 double g1Duration,
00050 double g2Duration=DBL_MAX)
00051 {
00052 if (g2Duration==DBL_MAX)
00053 {
00054 g2Duration = pModel->GetG2Duration();
00055 }
00056
00057
00058 double age = pModel->GetAge();
00059
00060 const double G1TOL = 1e-5;
00061
00062
00063 if ((pModel->GetCellProliferativeType() != DIFFERENTIATED) &&
00064 (age >= pModel->GetMDuration()) &&
00065 (pModel->GetG1Duration() != DOUBLE_UNSET) &&
00066 (fabs(pModel->GetG1Duration() - g1Duration) > G1TOL))
00067 {
00068 std::cout << "G1 duration mismatch: actual = " << pModel->GetG1Duration()
00069 << ", expected = " << g1Duration
00070 << std::endl;
00071 }
00072
00073 if (pModel->GetCellProliferativeType()==DIFFERENTIATED)
00074 {
00075
00076 TS_ASSERT_EQUALS(pModel->ReadyToDivide(), false);
00077 TS_ASSERT_EQUALS(pModel->GetCurrentCellCyclePhase(), G_ZERO_PHASE);
00078 }
00079 else if (age < pModel->GetMDuration())
00080 {
00081
00082 TS_ASSERT_EQUALS(pModel->ReadyToDivide(), false);
00083 TS_ASSERT_EQUALS(pModel->GetCurrentCellCyclePhase(), M_PHASE);
00084 }
00085 else if (age < pModel->GetMDuration() + g1Duration - G1TOL)
00086 {
00087
00088
00089 TS_ASSERT_EQUALS(pModel->ReadyToDivide(), false);
00090 TS_ASSERT_EQUALS(pModel->GetCurrentCellCyclePhase(), G_ONE_PHASE);
00091
00092
00093 if (pModel->GetCurrentCellCyclePhase() != G_ONE_PHASE)
00094 {
00095 std::cout << "Expected G1: " << g1Duration
00096 << "; actual: " << pModel->GetG1Duration()
00097 << "; age = " << age
00098 << "; G1-S transition = " << pModel->GetMDuration() + g1Duration
00099 << std::endl;
00100 }
00101 }
00102 else if (age < pModel->GetMDuration() + g1Duration + pModel->GetSDuration() - G1TOL)
00103 {
00104
00105
00106 TS_ASSERT_EQUALS(pModel->ReadyToDivide(), false);
00107 TS_ASSERT_EQUALS(pModel->GetCurrentCellCyclePhase(), S_PHASE);
00108 }
00109 else if (age < pModel->GetMDuration() + g1Duration + pModel->GetSDuration() + g2Duration - G1TOL)
00110 {
00111
00112
00113 TS_ASSERT_EQUALS(pModel->ReadyToDivide(), false);
00114 TS_ASSERT_EQUALS(pModel->GetCurrentCellCyclePhase(), G_TWO_PHASE);
00115 }
00116 else
00117 {
00118
00119 TS_ASSERT_EQUALS(pModel->ReadyToDivide(), true);
00120 }
00121 }
00122
00123 #endif