WntCellCycleModel.cpp

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 #include "WntCellCycleModel.hpp"
00029 
00030 
00031 WntCellCycleModel::WntCellCycleModel(AbstractOdeSystem* pParentOdeSystem,
00032                                      const CellMutationState& rMutationState,
00033                                      double birthTime,
00034                                      double lastTime,
00035                                      bool inSG2MPhase,
00036                                      bool readyToDivide,
00037                                      double divideTime)
00038    : AbstractWntOdeBasedCellCycleModel(lastTime)
00039 {
00040     if (pParentOdeSystem != NULL)
00041     {
00042         std::vector<double> parent_protein_concs = pParentOdeSystem->rGetStateVariables();
00043         mpOdeSystem = new WntCellCycleOdeSystem(parent_protein_concs[8], rMutationState);// Wnt pathway is reset in a couple of lines.
00044 
00045         // Set the initial conditions to be the same as the parent cell
00046         mpOdeSystem->rGetStateVariables() = parent_protein_concs;
00047     }
00048     else
00049     {
00050         mpOdeSystem = NULL;
00051     }
00052 
00053     if (SimulationTime::Instance()->IsStartTimeSetUp()==false)
00054     {
00055         #define COVERAGE_IGNORE
00056         EXCEPTION("WntCellCycleModel is being created but SimulationTime has not been set up");
00057         #undef COVERAGE_IGNORE
00058     }
00059     mBirthTime = birthTime;
00060     mFinishedRunningOdes = inSG2MPhase;
00061     mReadyToDivide = readyToDivide;
00062     mDivideTime = divideTime;
00063 }
00064 
00065 
00066 WntCellCycleModel::WntCellCycleModel(const std::vector<double>& rParentProteinConcentrations,
00067                                      const CellMutationState& rMutationState)
00068 {
00069     mpOdeSystem = new WntCellCycleOdeSystem(rParentProteinConcentrations[8], rMutationState); // Wnt pathway is reset in a couple of lines
00070     
00071     // Set the initial conditions to be the same as the parent cell
00072     mpOdeSystem->rGetStateVariables() = rParentProteinConcentrations;
00073 }
00074 
00075 
00076 AbstractCellCycleModel* WntCellCycleModel::CreateDaughterCellCycleModel()
00077 {
00078     assert(mpCell!=NULL);
00079     
00080     /*
00081      * We call a cheeky version of the constructor which makes the new cell 
00082      * cycle model the same as the old one - not a dividing copy at this time,
00083      * unless the parent cell has just divided.
00084      */
00085     return new WntCellCycleModel(mpOdeSystem,
00086                                  mpCell->GetMutationState(), 
00087                                  mBirthTime,
00088                                  mLastTime,
00089                                  mFinishedRunningOdes,
00090                                  mReadyToDivide,
00091                                  mDivideTime);
00092 }
00093 
00094 
00095 void WntCellCycleModel::ChangeCellTypeDueToCurrentBetaCateninLevel()
00096 {
00097     assert(mpOdeSystem!=NULL);
00098     assert(mpCell!=NULL);
00099     double beta_catenin_level = mpOdeSystem->rGetStateVariables()[6] + mpOdeSystem->rGetStateVariables()[7];
00100 
00101     CellType cell_type=TRANSIT;
00102 
00103     // For mitogenic stimulus of 6x10^-4 in Wnt equations
00104     if (beta_catenin_level < 0.4127)
00105     {
00106         cell_type = DIFFERENTIATED;
00107     }
00108 
00109     mpCell->SetCellType(cell_type);
00110 }
00111 
00112 
00113 void WntCellCycleModel::Initialise()
00114 {
00115     assert(mpOdeSystem==NULL);
00116     assert(mpCell!=NULL);
00117     mpOdeSystem = new WntCellCycleOdeSystem(WntConcentration::Instance()->GetWntLevel(mpCell), mpCell->GetMutationState());
00118     mpOdeSystem->SetStateVariables(mpOdeSystem->GetInitialConditions());
00119     ChangeCellTypeDueToCurrentBetaCateninLevel();
00120 }
00121 
00122 
00123 bool WntCellCycleModel::SolveOdeToTime(double currentTime)
00124 {
00125     // We are in G0 or G1 phase - running cell cycle ODEs
00126 #ifdef CHASTE_CVODE
00127     const double dt = SimulationTime::Instance()->GetTimeStep();
00128 #else
00129     double dt = 0.0001; // Needs to be this precise to stop crazy errors whilst we are still using rk4.
00130 #endif // CHASTE_CVODE
00131 
00132     // Pass this time step's Wnt stimulus into the solver as a constant over this timestep.
00133     mpOdeSystem->rGetStateVariables()[8] = WntConcentration::Instance()->GetWntLevel(mpCell);
00134 
00135     // Use the cell's current mutation status as another input
00136     static_cast<WntCellCycleOdeSystem*>(mpOdeSystem)->SetMutationState(mpCell->GetMutationState());
00137 
00138     msSolver.SolveAndUpdateStateVariable(mpOdeSystem, mLastTime, currentTime, dt);
00139 
00140     mLastTime = currentTime;// normally done in Abstract class, but no harm in doing it here to prevent following line throwing an error.
00141     UpdateCellType();
00142     return msSolver.StoppingEventOccurred();
00143 }

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