00001 /* 00002 00003 Copyright (c) 2005-2015, 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 WntCellCycleModel::~WntCellCycleModel() 00056 {} 00057 00058 AbstractCellCycleModel* WntCellCycleModel::CreateCellCycleModel() 00059 { 00060 // Create a new cell-cycle model 00061 WntCellCycleModel* p_model = new WntCellCycleModel(mpOdeSolver); 00062 00063 /* 00064 * Set each member variable of the new cell-cycle model that inherits 00065 * its value from the parent. 00066 * 00067 * Note 1: some of the new cell-cycle model's member variables (namely 00068 * mBirthTime, mCurrentCellCyclePhase, mReadyToDivide, mDt, mpOdeSolver) 00069 * will already have been correctly initialized in its constructor. 00070 * 00071 * Note 2: one or more of the new cell-cycle model's member variables 00072 * may be set/overwritten as soon as InitialiseDaughterCell() is called on 00073 * the new cell-cycle model. 00074 */ 00075 p_model->SetBirthTime(mBirthTime); 00076 p_model->SetDimension(mDimension); 00077 p_model->SetMinimumGapDuration(mMinimumGapDuration); 00078 p_model->SetStemCellG1Duration(mStemCellG1Duration); 00079 p_model->SetTransitCellG1Duration(mTransitCellG1Duration); 00080 p_model->SetSDuration(mSDuration); 00081 p_model->SetG2Duration(mG2Duration); 00082 p_model->SetMDuration(mMDuration); 00083 p_model->SetDivideTime(mDivideTime); 00084 p_model->SetFinishedRunningOdes(mFinishedRunningOdes); 00085 p_model->SetG2PhaseStartTime(mG2PhaseStartTime); 00086 p_model->SetLastTime(mLastTime); 00087 00088 /* 00089 * Create the new cell-cycle model's ODE system and use the current values 00090 * of the state variables in mpOdeSystem as an initial condition. 00091 */ 00092 assert(mpOdeSystem); 00093 double wnt_level = GetWntLevel(); 00094 p_model->SetOdeSystem(new WntCellCycleOdeSystem(wnt_level, mpCell->GetMutationState())); 00095 p_model->SetStateVariables(mpOdeSystem->rGetStateVariables()); 00096 00097 return p_model; 00098 } 00099 00100 void WntCellCycleModel::ChangeCellProliferativeTypeDueToCurrentBetaCateninLevel() 00101 { 00102 assert(mpOdeSystem != NULL); 00103 assert(mpCell != NULL); 00104 00105 double beta_catenin_level = mpOdeSystem->rGetStateVariables()[6] + mpOdeSystem->rGetStateVariables()[7]; 00106 00107 // For mitogenic stimulus of 6x10^-4 in Wnt equations 00108 if (beta_catenin_level < 0.4127) 00109 { 00110 /* 00111 * This method is usually called within a CellBasedSimulation, after the CellPopulation 00112 * has called CellPropertyRegistry::TakeOwnership(). This means that were we to call 00113 * CellPropertyRegistry::Instance() here when setting the CellProliferativeType, we 00114 * would be creating a new CellPropertyRegistry. In this case the cell proliferative 00115 * type counts, as returned by AbstractCellPopulation::GetCellProliferativeTypeCount(), 00116 * would be incorrect. We must therefore access the CellProliferativeType via the cell's 00117 * CellPropertyCollection. 00118 */ 00119 boost::shared_ptr<AbstractCellProperty> p_diff_type = 00120 mpCell->rGetCellPropertyCollection().GetCellPropertyRegistry()->Get<DifferentiatedCellProliferativeType>(); 00121 mpCell->SetCellProliferativeType(p_diff_type); 00122 } 00123 else 00124 { 00125 boost::shared_ptr<AbstractCellProperty> p_transit_type = 00126 mpCell->rGetCellPropertyCollection().GetCellPropertyRegistry()->Get<TransitCellProliferativeType>(); 00127 mpCell->SetCellProliferativeType(p_transit_type); 00128 } 00129 } 00130 00131 void WntCellCycleModel::Initialise() 00132 { 00133 assert(mpOdeSystem == NULL); 00134 assert(mpCell != NULL); 00135 double wnt_level = GetWntLevel(); 00136 00137 mpOdeSystem = new WntCellCycleOdeSystem(wnt_level, mpCell->GetMutationState()); 00138 mpOdeSystem->SetStateVariables(mpOdeSystem->GetInitialConditions()); 00139 00140 ChangeCellProliferativeTypeDueToCurrentBetaCateninLevel(); 00141 } 00142 00143 void WntCellCycleModel::AdjustOdeParameters(double currentTime) 00144 { 00145 double wnt_level = GetWntLevel(); 00146 00147 // Pass this time step's Wnt stimulus into the solver as a constant over this timestep. 00148 mpOdeSystem->rGetStateVariables()[8] = wnt_level; 00149 00150 // Use the cell's current mutation status as another input 00151 static_cast<WntCellCycleOdeSystem*>(mpOdeSystem)->SetMutationState(mpCell->GetMutationState()); 00152 } 00153 00154 void WntCellCycleModel::OutputCellCycleModelParameters(out_stream& rParamsFile) 00155 { 00156 // No new parameters to output 00157 00158 // Call method on direct parent class 00159 AbstractWntOdeBasedCellCycleModel::OutputCellCycleModelParameters(rParamsFile); 00160 } 00161 00162 // Serialization for Boost >= 1.36 00163 #include "SerializationExportWrapperForCpp.hpp" 00164 CHASTE_CLASS_EXPORT(WntCellCycleModel) 00165 #include "CellCycleModelOdeSolverExportWrapper.hpp" 00166 EXPORT_CELL_CYCLE_MODEL_ODE_SOLVER(WntCellCycleModel)