CheckReadyToDivideAndPhaseIsUpdated.hpp

00001 /*
00002 
00003 Copyright (C) University of Oxford, 2005-2011
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=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; // how accurate the expected G1 duration is
00061 
00062     // If the G1 duration is incorrect, print out the mismatch
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         // If the cell is differentiated, then it must be in G0 phase and must never divide
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         // If the cell in M phase, then it must not be ready to divide
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         // The next cell cycle phase after M is G1; cells in G1 phase
00088         // must still not be ready to divide
00089         TS_ASSERT_EQUALS(pModel->ReadyToDivide(), false);
00090         TS_ASSERT_EQUALS(pModel->GetCurrentCellCyclePhase(), G_ONE_PHASE);
00091 
00092         // If the cell is not in G1 phase when it should be, print out the mismatch
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         // The next cell cycle phase after G1 is S; cells in S phase
00105         // must still not be ready to divide
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         // The next cell cycle phase after S is G2; cells in G2 phase
00112         // must still not be ready to divide
00113         TS_ASSERT_EQUALS(pModel->ReadyToDivide(), false);
00114         TS_ASSERT_EQUALS(pModel->GetCurrentCellCyclePhase(), G_TWO_PHASE);
00115     }
00116     else
00117     {
00118         // Cells must be ready to divide as soon as they leave G2 phase
00119         TS_ASSERT_EQUALS(pModel->ReadyToDivide(), true);
00120     }
00121 }
00122 
00123 #endif /*CHECKREADYTODIVIDEANDPHASEISUPDATED_HPP_*/

Generated on Tue May 31 14:31:40 2011 for Chaste by  doxygen 1.5.5