CheckReadyToDivideAndPhaseIsUpdated.hpp

00001 /*
00002 
00003 Copyright (C) University of Oxford, 2005-2009
00004 
00005 University of Oxford means the Chancellor, Masters and Scholars of the
00006 University of Oxford, having an administrative office at Wellington
00007 Square, Oxford OX1 2JD, UK.
00008 
00009 This file is part of Chaste.
00010 
00011 Chaste is free software: you can redistribute it and/or modify it
00012 under the terms of the GNU Lesser General Public License as published
00013 by the Free Software Foundation, either version 2.1 of the License, or
00014 (at your option) any later version.
00015 
00016 Chaste is distributed in the hope that it will be useful, but WITHOUT
00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
00019 License for more details. The offer of Chaste under the terms of the
00020 License is subject to the License being interpreted in accordance with
00021 English Law and subject to any action against the University of Oxford
00022 being under the jurisdiction of the English Courts.
00023 
00024 You should have received a copy of the GNU Lesser General Public License
00025 along with Chaste. If not, see <http://www.gnu.org/licenses/>.
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     // A number of cancer parameters are called in this method,
00053     // so for convenience we create a pointer to the instance
00054     CancerParameters* p_params = CancerParameters::Instance();
00055 
00056     double age = pModel->GetAge();
00057 
00058     const double G1TOL = 1e-5; // how accurate the expected G1 duration is
00059 
00060     // If the G1 duration is incorrect, print out the mismatch
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         // If the cell is differentiated, then it must be in G0 phase and must never divide
00074         TS_ASSERT(!pModel->ReadyToDivide());
00075         TS_ASSERT_EQUALS(pModel->GetCurrentCellCyclePhase(), G_ZERO_PHASE);
00076     }
00077     else if (age < p_params->GetMDuration())
00078     {
00079         // If the cell in M phase, then it must not be ready to divide
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         // The next cell cycle phase after M is G1; cells in G1 phase
00086         // must still not be ready to divide
00087         TS_ASSERT(!pModel->ReadyToDivide());
00088         TS_ASSERT_EQUALS(pModel->GetCurrentCellCyclePhase(), G_ONE_PHASE);
00089 
00090         // If the cell is not in G1 phase when it should be, print out the mismatch
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         // The next cell cycle phase after G1 is S; cells in S phase
00103         // must still not be ready to divide
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         // The next cell cycle phase after S is G2; cells in G2 phase
00110         // must still not be ready to divide
00111         TS_ASSERT(!pModel->ReadyToDivide());
00112         TS_ASSERT_EQUALS(pModel->GetCurrentCellCyclePhase(), G_TWO_PHASE);
00113     }
00114     else
00115     {
00116         // Cells must be ready to divide as soon as they leave G2 phase
00117         TS_ASSERT(pModel->ReadyToDivide());
00118     }
00119 }
00120 
00121 #endif /*CHECKREADYTODIVIDEANDPHASEISUPDATED_HPP_*/

Generated on Wed Mar 18 12:51:49 2009 for Chaste by  doxygen 1.5.5