IngeWntSwatCellCycleModel.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 "IngeWntSwatCellCycleModel.hpp"
00029 #include "WntConcentration.hpp"
00030 
00031 
00032 IngeWntSwatCellCycleModel::IngeWntSwatCellCycleModel(const unsigned& rHypothesis,
00033                                                      AbstractOdeSystem* pParentOdeSystem,
00034                                                      const CellMutationState& rMutationState,
00035                                                      double birthTime,
00036                                                      double lastTime,
00037                                                      bool inSG2MPhase,
00038                                                      bool readyToDivide,
00039                                                      double divideTime)
00040    : AbstractWntOdeBasedCellCycleModel(lastTime)
00041 {
00042     if (pParentOdeSystem !=NULL)
00043     {
00044         std::vector<double> parent_protein_concs = pParentOdeSystem->rGetStateVariables();
00045         mpOdeSystem = new IngeWntSwatCellCycleOdeSystem(rHypothesis, parent_protein_concs[8], rMutationState);// Wnt pathway is reset in a couple of lines
00046         
00047         // Set the model to be the same as the parent cell
00048         mpOdeSystem->rGetStateVariables() = parent_protein_concs;
00049     }
00050     else
00051     {
00052         mpOdeSystem = NULL;
00053     }
00054 
00055     if (SimulationTime::Instance()->IsStartTimeSetUp()==false)
00056     {
00057         #define COVERAGE_IGNORE
00058         EXCEPTION("IngeWntSwatCellCycleModel is being created but SimulationTime has not been set up");
00059         #undef COVERAGE_IGNORE
00060     }
00061     mBirthTime = birthTime;
00062     mFinishedRunningOdes = inSG2MPhase;
00063     mReadyToDivide = readyToDivide;
00064     mDivideTime = divideTime;
00065     mHypothesis = rHypothesis;
00066 }
00067 
00068 
00069 IngeWntSwatCellCycleModel::IngeWntSwatCellCycleModel(const unsigned& rHypothesis,
00070                                                      const std::vector<double>& rParentProteinConcentrations,
00071                                                      const CellMutationState& rMutationState)
00072 {
00073     mHypothesis = rHypothesis;
00074     mpOdeSystem = new IngeWntSwatCellCycleOdeSystem(rHypothesis, rParentProteinConcentrations[21], rMutationState);// Wnt pathway is reset in a couple of lines.
00075 
00076     // Set the model to be the same as the parent cell
00077     mpOdeSystem->rGetStateVariables() = rParentProteinConcentrations;
00078 }
00079 
00080 
00081 AbstractCellCycleModel* IngeWntSwatCellCycleModel::CreateDaughterCellCycleModel()
00082 {
00083     assert(mpCell!=NULL);
00084 
00090     return new IngeWntSwatCellCycleModel(mHypothesis,
00091                                          mpOdeSystem,
00092                                          mpCell->GetMutationState(),
00093                                          mBirthTime,
00094                                          mLastTime,
00095                                          mFinishedRunningOdes,
00096                                          mReadyToDivide,
00097                                          mDivideTime);
00098 }
00099 
00100 
00101 void IngeWntSwatCellCycleModel::ChangeCellTypeDueToCurrentBetaCateninLevel()
00102 {
00103     assert(mpOdeSystem!=NULL);
00104     assert(mpCell!=NULL);
00105     double beta_catenin_level = mpOdeSystem->rGetStateVariables()[16]
00106                                 + mpOdeSystem->rGetStateVariables()[17]
00107                                 + mpOdeSystem->rGetStateVariables()[18]
00108                                 + mpOdeSystem->rGetStateVariables()[19];
00109 
00110     CellType cell_type = TRANSIT;
00111 
00112     // For mitogenic stimulus of 1/25.0 in Wnt equations
00113     if (beta_catenin_level < 10.188)
00114     {
00115         cell_type = DIFFERENTIATED;
00116     }
00117 
00118     mpCell->SetCellType(cell_type);
00119 }
00120 
00121 
00122 void IngeWntSwatCellCycleModel::Initialise()
00123 {
00124     assert(mpOdeSystem==NULL);
00125     assert(mpCell!=NULL);
00126 
00127     mpOdeSystem = new IngeWntSwatCellCycleOdeSystem(mHypothesis, WntConcentration::Instance()->GetWntLevel(mpCell), mpCell->GetMutationState());
00128     mpOdeSystem->SetStateVariables(mpOdeSystem->GetInitialConditions());
00129     ChangeCellTypeDueToCurrentBetaCateninLevel();
00130 }
00131 
00132 
00133 bool IngeWntSwatCellCycleModel::SolveOdeToTime(double currentTime)
00134 {
00135     // We are in G0 or G1 phase - running cell cycle ODEs
00136 #ifdef CHASTE_CVODE
00137     const double dt = SimulationTime::Instance()->GetTimeStep();
00138 #else
00139     double dt = 0.00005; // Needs to be this precise to stop crazy errors whilst we are still using rk4.
00140 #endif // CHASTE_CVODE
00141 
00142     // Pass this time step's Wnt stimulus into the solver as a constant over this timestep.
00143     mpOdeSystem->rGetStateVariables()[21] = WntConcentration::Instance()->GetWntLevel(mpCell);
00144 
00145     // Use the cell's current mutation status as another input
00146     static_cast<IngeWntSwatCellCycleOdeSystem*>(mpOdeSystem)->SetMutationState(mpCell->GetMutationState());
00147 
00148     msSolver.SolveAndUpdateStateVariable(mpOdeSystem, mLastTime, currentTime, dt);
00149 
00150     mLastTime = currentTime; // normally done in Abstract class, but no harm in doing it here to prevent following line throwing an error.
00151     UpdateCellType();
00152     return msSolver.StoppingEventOccurred();
00153 }
00154 
00155 
00156 double IngeWntSwatCellCycleModel::GetMembraneBoundBetaCateninLevel()
00157 {
00158     return mpOdeSystem->rGetStateVariables()[13] + mpOdeSystem->rGetStateVariables()[14];
00159 }
00160 
00161 
00162 double IngeWntSwatCellCycleModel::GetCytoplasmicBetaCateninLevel()
00163 {
00164     return mpOdeSystem->rGetStateVariables()[7] + mpOdeSystem->rGetStateVariables()[8]
00165         + mpOdeSystem->rGetStateVariables()[9] + mpOdeSystem->rGetStateVariables()[10]
00166         + mpOdeSystem->rGetStateVariables()[11];
00167 }
00168 
00169 
00170 double IngeWntSwatCellCycleModel::GetNuclearBetaCateninLevel()
00171 {
00172     return mpOdeSystem->rGetStateVariables()[16] + 
00173            mpOdeSystem->rGetStateVariables()[17] +  
00174            mpOdeSystem->rGetStateVariables()[18] + 
00175            mpOdeSystem->rGetStateVariables()[19];
00176 }
00177 
00178 
00179 unsigned IngeWntSwatCellCycleModel::GetHypothesis() const
00180 {
00181     return mHypothesis;
00182 }

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