SingleOdeWntCellCycleModel.cpp

00001 /*
00002 
00003 Copyright (C) University of Oxford, 2005-2010
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 "UblasIncludes.hpp"
00029 #include "SingleOdeWntCellCycleModel.hpp"
00030 
00031 #ifdef CHASTE_CVODE
00032 CvodeAdaptor SingleOdeWntCellCycleModel::msSolver;
00033 #else
00034 RungeKutta4IvpOdeSolver SingleOdeWntCellCycleModel::msSolver;
00035 #endif //CHASTE_CVODE
00036 
00037 SingleOdeWntCellCycleModel::~SingleOdeWntCellCycleModel()
00038 {
00039     delete mpOdeSystem;
00040 }
00041 
00042 AbstractCellCycleModel* SingleOdeWntCellCycleModel::CreateCellCycleModel()
00043 {
00044     return new SingleOdeWntCellCycleModel(*this);
00045 }
00046 
00047 SingleOdeWntCellCycleModel::SingleOdeWntCellCycleModel(const SingleOdeWntCellCycleModel& rOtherModel)
00048     : SimpleWntCellCycleModel(rOtherModel),
00049       mpOdeSystem(NULL) // This line is even more unbelievably important than you'd expect.
00050 {
00051     mBetaCateninDivisionThreshold = rOtherModel.mBetaCateninDivisionThreshold;
00052     mLastTime = rOtherModel.mLastTime;
00053     if (rOtherModel.mpOdeSystem != NULL)
00054     {
00055         mpOdeSystem = new Mirams2010WntOdeSystem(*static_cast<Mirams2010WntOdeSystem*>(rOtherModel.mpOdeSystem));
00056     }
00057 }
00058 
00059 void SingleOdeWntCellCycleModel::UpdateCellCyclePhase()
00060 {
00061     assert(SimulationTime::Instance()->IsStartTimeSetUp());
00062     UpdateBetaCateninLevel();
00063     ChangeCellProliferativeTypeDueToCurrentBetaCateninLevel();
00064     AbstractSimpleCellCycleModel::UpdateCellCyclePhase(); 
00065 }
00066 
00067 
00068 SingleOdeWntCellCycleModel::SingleOdeWntCellCycleModel(std::vector<double>& rParentProteinConcentrations,
00069                                      boost::shared_ptr<AbstractCellMutationState> pMutationState,
00070                                      unsigned& rDimension,
00071                                      bool useTypeDependentG1)
00072     : mLastTime(DBL_MAX)
00073 {
00074     SetDimension(rDimension),
00075     SetUseCellProliferativeTypeDependentG1Duration(useTypeDependentG1);
00076 #ifdef CHASTE_CVODE
00077         msSolver.SetMaxSteps(10000);
00078 #endif // CHASTE_CVODE
00079     // Set the other initial conditions to be the same as the parent cell
00080     mpOdeSystem = new Mirams2010WntOdeSystem(rParentProteinConcentrations[2], pMutationState);
00081     mpOdeSystem->rGetStateVariables() = rParentProteinConcentrations;
00082 }
00083 
00084 
00085 void SingleOdeWntCellCycleModel::Initialise()
00086 {
00087     assert(mpOdeSystem == NULL);
00088     assert(mpCell != NULL);
00089 
00090     double wnt_level = this->GetWntLevel();
00091     mpOdeSystem = new Mirams2010WntOdeSystem(wnt_level, mpCell->GetMutationState());
00092     mpOdeSystem->SetStateVariables(mpOdeSystem->GetInitialConditions());
00093 
00094     // MAGIC NUMBER!
00095     mBetaCateninDivisionThreshold = 100.0;
00096 
00097     // This call actually sets up the G1 phase to something sensible (random number generated)
00098     SimpleWntCellCycleModel::Initialise();
00099 
00100     mLastTime = mBirthTime;
00101 
00102     ChangeCellProliferativeTypeDueToCurrentBetaCateninLevel();
00103 }
00104 
00105 void SingleOdeWntCellCycleModel::UpdateBetaCateninLevel()
00106 {
00107     assert(mpOdeSystem!=NULL);
00108     assert(mpCell!=NULL);
00109     assert(mLastTime < DBL_MAX - 1e5);
00110 
00111     // We run the cell cycle ODEs whatever time we are interested in
00112 #ifdef CHASTE_CVODE
00113     const double dt = SimulationTime::Instance()->GetTimeStep(); // Use the mechanics time step as max time step.
00114 #else
00115     double dt = 0.001;
00116 #endif // CHASTE_CVODE
00117 
00118     // Pass this time step's Wnt stimulus into the solver as a constant over this timestep.
00119     mpOdeSystem->rGetStateVariables()[2] = this->GetWntLevel();
00120 
00121     // Use the cell's current mutation status as another input
00122     static_cast<Mirams2010WntOdeSystem*>(mpOdeSystem)->SetMutationState(mpCell->GetMutationState());
00123 
00124     double current_time = SimulationTime::Instance()->GetTime();
00125     if (mLastTime < current_time)
00126     {
00127         msSolver.SolveAndUpdateStateVariable(mpOdeSystem, mLastTime, current_time, dt);
00128         mLastTime = current_time;
00129     }
00130 }
00131 
00132 void SingleOdeWntCellCycleModel::ChangeCellProliferativeTypeDueToCurrentBetaCateninLevel()
00133 {
00134     assert(mpOdeSystem!=NULL);
00135     assert(mpCell!=NULL);
00136 
00137     CellProliferativeType cell_type = TRANSIT;
00138     if (GetBetaCateninConcentration() < GetBetaCateninDivisionThreshold())
00139     {
00140         cell_type = DIFFERENTIATED;
00141     }
00142 
00143     mpCell->SetCellProliferativeType(cell_type);
00144 }
00145 
00146 double SingleOdeWntCellCycleModel::GetBetaCateninConcentration()
00147 {
00148     return mpOdeSystem->rGetStateVariables()[0] + mpOdeSystem->rGetStateVariables()[1];
00149 }
00150 
00151 void SingleOdeWntCellCycleModel::SetBetaCateninDivisionThreshold(double betaCateninDivisionThreshold)
00152 {
00153     mBetaCateninDivisionThreshold = betaCateninDivisionThreshold;
00154 }
00155 
00156 double SingleOdeWntCellCycleModel::GetBetaCateninDivisionThreshold()
00157 {
00158     return mBetaCateninDivisionThreshold;
00159 }
00160 
00161 // Declare identifier for the serializer
00162 #include "SerializationExportWrapperForCpp.hpp"
00163 CHASTE_CLASS_EXPORT(SingleOdeWntCellCycleModel)

Generated by  doxygen 1.6.2