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 "UblasIncludes.hpp"
00029 #include "IngeWntSwatCellCycleModel.hpp"
00030 
00031 
00032 IngeWntSwatCellCycleModel::IngeWntSwatCellCycleModel(unsigned hypothesis, unsigned dimension)
00033    : AbstractWntOdeBasedCellCycleModel(dimension),
00034      mHypothesis(hypothesis)
00035 {
00036     if ( !(mHypothesis==1u || mHypothesis==2u) )
00037     {
00038         EXCEPTION("Model must be set up with argument(hypothesis) = 1u or 2u");
00039     }
00040 }
00041 
00042 
00043 IngeWntSwatCellCycleModel::IngeWntSwatCellCycleModel(const IngeWntSwatCellCycleModel& rOtherModel)
00044     : AbstractWntOdeBasedCellCycleModel(rOtherModel),
00045       mHypothesis(rOtherModel.mHypothesis)
00046 {
00047     if (rOtherModel.mpOdeSystem != NULL)
00048     {
00049         mpOdeSystem = new IngeWntSwatCellCycleOdeSystem(*static_cast<IngeWntSwatCellCycleOdeSystem*>(rOtherModel.mpOdeSystem));
00050     }
00051 }
00052 
00053 
00054 IngeWntSwatCellCycleModel::IngeWntSwatCellCycleModel(const unsigned& rHypothesis,
00055                                                      const std::vector<double>& rParentProteinConcentrations,
00056                                                      const CellMutationState& rMutationState,
00057                                                      const unsigned& rDimension)
00058     : AbstractWntOdeBasedCellCycleModel(rDimension)
00059 {
00060     mHypothesis = rHypothesis;
00061     mpOdeSystem = new IngeWntSwatCellCycleOdeSystem(rHypothesis, rParentProteinConcentrations[21], rMutationState);// Wnt pathway is reset in a couple of lines.
00062 
00063     // Set the model to be the same as the parent cell
00064     mpOdeSystem->rGetStateVariables() = rParentProteinConcentrations;
00065 }
00066 
00067 
00068 AbstractCellCycleModel* IngeWntSwatCellCycleModel::CreateCellCycleModel()
00069 {
00070     return new IngeWntSwatCellCycleModel(*this);
00071 }
00072 
00073 
00074 void IngeWntSwatCellCycleModel::ChangeCellTypeDueToCurrentBetaCateninLevel()
00075 {
00076     assert(mpOdeSystem!=NULL);
00077     assert(mpCell!=NULL);
00078     double beta_catenin_level = mpOdeSystem->rGetStateVariables()[16]
00079                                 + mpOdeSystem->rGetStateVariables()[17]
00080                                 + mpOdeSystem->rGetStateVariables()[18]
00081                                 + mpOdeSystem->rGetStateVariables()[19];
00082 
00083     CellType cell_type = TRANSIT;
00084 
00085     // For mitogenic stimulus of 1/25.0 in Wnt equations
00086     if (beta_catenin_level < 10.188)
00087     {
00088         cell_type = DIFFERENTIATED;
00089     }
00090 
00091     mpCell->SetCellType(cell_type);
00092 }
00093 
00094 
00095 void IngeWntSwatCellCycleModel::Initialise()
00096 {
00097     assert(mpOdeSystem==NULL);
00098     assert(mpCell!=NULL);
00099 
00100     double wnt_level = GetWntLevel();
00101 
00102     mpOdeSystem = new IngeWntSwatCellCycleOdeSystem(mHypothesis, wnt_level, mpCell->GetMutationState());
00103     mpOdeSystem->SetStateVariables(mpOdeSystem->GetInitialConditions());
00104 
00105     ChangeCellTypeDueToCurrentBetaCateninLevel();
00106 }
00107 
00108 
00109 bool IngeWntSwatCellCycleModel::SolveOdeToTime(double currentTime)
00110 {
00111     // We are in G0 or G1 phase - running cell cycle ODEs
00112 #ifdef CHASTE_CVODE
00113     const double dt = SimulationTime::Instance()->GetTimeStep();
00114 #else
00115     double dt = 0.00005; // Needs to be this precise to stop crazy errors whilst we are still using rk4.
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()[21] = GetWntLevel();
00120 
00121     // Use the cell's current mutation status as another input
00122     static_cast<IngeWntSwatCellCycleOdeSystem*>(mpOdeSystem)->SetMutationState(mpCell->GetMutationState());
00123 
00124     msSolver.SolveAndUpdateStateVariable(mpOdeSystem, mLastTime, currentTime, dt);
00125 
00126     mLastTime = currentTime; // normally done in Abstract class, but no harm in doing it here to prevent following line throwing an error.
00127     UpdateCellType();
00128     return msSolver.StoppingEventOccurred();
00129 }
00130 
00131 
00132 double IngeWntSwatCellCycleModel::GetMembraneBoundBetaCateninLevel()
00133 {
00134     return mpOdeSystem->rGetStateVariables()[13] + mpOdeSystem->rGetStateVariables()[14];
00135 }
00136 
00137 
00138 double IngeWntSwatCellCycleModel::GetCytoplasmicBetaCateninLevel()
00139 {
00140     return mpOdeSystem->rGetStateVariables()[7] + mpOdeSystem->rGetStateVariables()[8]
00141         + mpOdeSystem->rGetStateVariables()[9] + mpOdeSystem->rGetStateVariables()[10]
00142         + mpOdeSystem->rGetStateVariables()[11];
00143 }
00144 
00145 
00146 double IngeWntSwatCellCycleModel::GetNuclearBetaCateninLevel()
00147 {
00148     return mpOdeSystem->rGetStateVariables()[16] +
00149            mpOdeSystem->rGetStateVariables()[17] +
00150            mpOdeSystem->rGetStateVariables()[18] +
00151            mpOdeSystem->rGetStateVariables()[19];
00152 }
00153 
00154 
00155 unsigned IngeWntSwatCellCycleModel::GetHypothesis() const
00156 {
00157     return mHypothesis;
00158 }

Generated on Tue Aug 4 16:10:21 2009 for Chaste by  doxygen 1.5.5