Chaste Release::3.1
WntCellCycleModel.cpp
00001 /*
00002 
00003 Copyright (c) 2005-2012, University of Oxford.
00004 All rights reserved.
00005 
00006 University of Oxford means the Chancellor, Masters and Scholars of the
00007 University of Oxford, having an administrative office at Wellington
00008 Square, Oxford OX1 2JD, UK.
00009 
00010 This file is part of Chaste.
00011 
00012 Redistribution and use in source and binary forms, with or without
00013 modification, are permitted provided that the following conditions are met:
00014  * Redistributions of source code must retain the above copyright notice,
00015    this list of conditions and the following disclaimer.
00016  * Redistributions in binary form must reproduce the above copyright notice,
00017    this list of conditions and the following disclaimer in the documentation
00018    and/or other materials provided with the distribution.
00019  * Neither the name of the University of Oxford nor the names of its
00020    contributors may be used to endorse or promote products derived from this
00021    software without specific prior written permission.
00022 
00023 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00024 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00025 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00026 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
00027 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00028 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
00029 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00030 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00031 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
00032 OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00033 
00034 */
00035 #include "WntCellCycleModel.hpp"
00036 
00037 WntCellCycleModel::WntCellCycleModel(boost::shared_ptr<AbstractCellCycleModelOdeSolver> pOdeSolver)
00038     : AbstractWntOdeBasedCellCycleModel(pOdeSolver)
00039 {
00040     if (!mpOdeSolver)
00041     {
00042 #ifdef CHASTE_CVODE
00043         mpOdeSolver = CellCycleModelOdeSolver<WntCellCycleModel, CvodeAdaptor>::Instance();
00044         mpOdeSolver->Initialise();
00045         // Chaste solvers always check for stopping events, CVODE needs to be instructed to do so
00046         mpOdeSolver->CheckForStoppingEvents();
00047         mpOdeSolver->SetMaxSteps(10000);
00048 #else
00049         mpOdeSolver = CellCycleModelOdeSolver<WntCellCycleModel, RungeKutta4IvpOdeSolver>::Instance();
00050         mpOdeSolver->Initialise();
00051 #endif //CHASTE_CVODE
00052     }
00053 }
00054 
00055 AbstractCellCycleModel* WntCellCycleModel::CreateCellCycleModel()
00056 {
00057     // Create a new cell-cycle model
00058     WntCellCycleModel* p_model = new WntCellCycleModel(mpOdeSolver);
00059 
00060     /*
00061      * Set each member variable of the new cell-cycle model that inherits
00062      * its value from the parent.
00063      *
00064      * Note 1: some of the new cell-cycle model's member variables (namely
00065      * mBirthTime, mCurrentCellCyclePhase, mReadyToDivide, mDt, mpOdeSolver)
00066      * will already have been correctly initialized in its constructor.
00067      *
00068      * Note 2: one or more of the new cell-cycle model's member variables
00069      * may be set/overwritten as soon as InitialiseDaughterCell() is called on
00070      * the new cell-cycle model.
00071      */
00072     p_model->SetBirthTime(mBirthTime);
00073     p_model->SetDimension(mDimension);
00074     p_model->SetMinimumGapDuration(mMinimumGapDuration);
00075     p_model->SetStemCellG1Duration(mStemCellG1Duration);
00076     p_model->SetTransitCellG1Duration(mTransitCellG1Duration);
00077     p_model->SetSDuration(mSDuration);
00078     p_model->SetG2Duration(mG2Duration);
00079     p_model->SetMDuration(mMDuration);
00080     p_model->SetDivideTime(mDivideTime);
00081     p_model->SetFinishedRunningOdes(mFinishedRunningOdes);
00082     p_model->SetG2PhaseStartTime(mG2PhaseStartTime);
00083     p_model->SetLastTime(mLastTime);
00084 
00085     /*
00086      * Create the new cell-cycle model's ODE system and use the current values
00087      * of the state variables in mpOdeSystem as an initial condition.
00088      */
00089     assert(mpOdeSystem);
00090     double wnt_level = GetWntLevel();
00091     p_model->SetOdeSystem(new WntCellCycleOdeSystem(wnt_level, mpCell->GetMutationState()));
00092     p_model->SetStateVariables(mpOdeSystem->rGetStateVariables());
00093 
00094     return p_model;
00095 }
00096 
00097 void WntCellCycleModel::ChangeCellProliferativeTypeDueToCurrentBetaCateninLevel()
00098 {
00099     assert(mpOdeSystem != NULL);
00100     assert(mpCell != NULL);
00101     double beta_catenin_level = mpOdeSystem->rGetStateVariables()[6] + mpOdeSystem->rGetStateVariables()[7];
00102 
00103     CellProliferativeType cell_type = TRANSIT;
00104 
00105     // For mitogenic stimulus of 6x10^-4 in Wnt equations
00106     if (beta_catenin_level < 0.4127)
00107     {
00108         cell_type = DIFFERENTIATED;
00109     }
00110 
00111     mpCell->SetCellProliferativeType(cell_type);
00112 }
00113 
00114 void WntCellCycleModel::Initialise()
00115 {
00116     assert(mpOdeSystem == NULL);
00117     assert(mpCell != NULL);
00118     double wnt_level = GetWntLevel();
00119 
00120     mpOdeSystem = new WntCellCycleOdeSystem(wnt_level, mpCell->GetMutationState());
00121     mpOdeSystem->SetStateVariables(mpOdeSystem->GetInitialConditions());
00122 
00123     ChangeCellProliferativeTypeDueToCurrentBetaCateninLevel();
00124 }
00125 
00126 void WntCellCycleModel::AdjustOdeParameters(double currentTime)
00127 {
00128     double wnt_level = GetWntLevel();
00129 
00130     // Pass this time step's Wnt stimulus into the solver as a constant over this timestep.
00131     mpOdeSystem->rGetStateVariables()[8] = wnt_level;
00132 
00133     // Use the cell's current mutation status as another input
00134     static_cast<WntCellCycleOdeSystem*>(mpOdeSystem)->SetMutationState(mpCell->GetMutationState());
00135 }
00136 
00137 void WntCellCycleModel::OutputCellCycleModelParameters(out_stream& rParamsFile)
00138 {
00139     // No new parameters to output
00140 
00141     // Call method on direct parent class
00142     AbstractWntOdeBasedCellCycleModel::OutputCellCycleModelParameters(rParamsFile);
00143 }
00144 
00145 // Serialization for Boost >= 1.36
00146 #include "SerializationExportWrapperForCpp.hpp"
00147 CHASTE_CLASS_EXPORT(WntCellCycleModel)
00148 #include "CellCycleModelOdeSolverExportWrapper.hpp"
00149 EXPORT_CELL_CYCLE_MODEL_ODE_SOLVER(WntCellCycleModel)