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=CancerParameters::Instance()->GetG2Duration())
00051 {
00052
00053
00054 CancerParameters* p_params = CancerParameters::Instance();
00055
00056 double age = pModel->GetAge();
00057
00058 const double G1TOL = 1e-5;
00059
00060
00061 if ((pModel->GetCell()->GetCellType() != DIFFERENTIATED) &&
00062 (age >= p_params->GetMDuration()) &&
00063 (pModel->GetG1Duration() != DOUBLE_UNSET) &&
00064 (fabs(pModel->GetG1Duration() - g1Duration) > G1TOL))
00065 {
00066 std::cout << "G1 duration mismatch: actual = " << pModel->GetG1Duration()
00067 << ", expected = " << g1Duration
00068 << std::endl;
00069 }
00070
00071 if (pModel->GetCell()->GetCellType()==DIFFERENTIATED)
00072 {
00073
00074 TS_ASSERT(!pModel->ReadyToDivide());
00075 TS_ASSERT_EQUALS(pModel->GetCurrentCellCyclePhase(), G_ZERO_PHASE);
00076 }
00077 else if (age < p_params->GetMDuration())
00078 {
00079
00080 TS_ASSERT(!pModel->ReadyToDivide());
00081 TS_ASSERT_EQUALS(pModel->GetCurrentCellCyclePhase(), M_PHASE);
00082 }
00083 else if (age < p_params->GetMDuration() + g1Duration - G1TOL)
00084 {
00085
00086
00087 TS_ASSERT(!pModel->ReadyToDivide());
00088 TS_ASSERT_EQUALS(pModel->GetCurrentCellCyclePhase(), G_ONE_PHASE);
00089
00090
00091 if (pModel->GetCurrentCellCyclePhase() != G_ONE_PHASE)
00092 {
00093 std::cout << "Expected G1: " << g1Duration
00094 << "; actual: " << pModel->GetG1Duration()
00095 << "; age = " << age
00096 << "; G1-S transition = " << p_params->GetMDuration() + g1Duration
00097 << std::endl;
00098 }
00099 }
00100 else if (age < p_params->GetMDuration() + g1Duration + p_params->GetSDuration() - G1TOL)
00101 {
00102
00103
00104 TS_ASSERT(!pModel->ReadyToDivide());
00105 TS_ASSERT_EQUALS(pModel->GetCurrentCellCyclePhase(), S_PHASE);
00106 }
00107 else if (age < p_params->GetMDuration() + g1Duration + p_params->GetSDuration() + g2Duration - G1TOL)
00108 {
00109
00110
00111 TS_ASSERT(!pModel->ReadyToDivide());
00112 TS_ASSERT_EQUALS(pModel->GetCurrentCellCyclePhase(), G_TWO_PHASE);
00113 }
00114 else
00115 {
00116
00117 TS_ASSERT(pModel->ReadyToDivide());
00118 }
00119 }
00120
00121 #endif