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