CryptCellsGenerator.hpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #ifndef CRYPTCELLSGENERATOR_HPP_
00037 #define CRYPTCELLSGENERATOR_HPP_
00038
00039 #include <boost/mpl/integral_c.hpp>
00040 #include <boost/type_traits/is_same.hpp>
00041 #include <boost/mpl/if.hpp>
00042
00043 #include "CellsGenerator.hpp"
00044
00045 #include "CellPropertyRegistry.hpp"
00046 #include "TetrahedralMesh.hpp"
00047 #include "VertexMesh.hpp"
00048 #include "PottsMesh.hpp"
00049
00050 #include "StochasticDurationGenerationBasedCellCycleModel.hpp"
00051 #include "FixedDurationGenerationBasedCellCycleModel.hpp"
00052 #include "TysonNovakCellCycleModel.hpp"
00053 #include "WntCellCycleModel.hpp"
00054 #include "SimpleWntCellCycleModel.hpp"
00055 #include "StochasticWntCellCycleModel.hpp"
00056 #include "VanLeeuwen2009WntSwatCellCycleModelHypothesisOne.hpp"
00057 #include "VanLeeuwen2009WntSwatCellCycleModelHypothesisTwo.hpp"
00058 #include "Exception.hpp"
00059 #include "StemCellProliferativeType.hpp"
00060 #include "TransitCellProliferativeType.hpp"
00061 #include "DifferentiatedCellProliferativeType.hpp"
00062
00063
00068 template<class T1, class T2>
00069 bool ClassesAreSame()
00070 {
00071 using namespace boost::mpl;
00072 using namespace boost;
00073 typedef typename if_< is_same<T1, T2>, integral_c<unsigned, 1>, integral_c<unsigned, 0> >::type selector_t;
00074 return (selector_t()==1);
00075 }
00076
00082 template<class CELL_CYCLE_MODEL>
00083 class CryptCellsGenerator : public CellsGenerator<CELL_CYCLE_MODEL,2>
00084 {
00085 public:
00086
00104 void Generate(std::vector<CellPtr>& rCells,
00105 AbstractMesh<2,2>* pMesh,
00106 const std::vector<unsigned> locationIndices,
00107 bool randomBirthTimes,
00108 double y0 = 0.3,
00109 double y1 = 2.0,
00110 double y2 = 3.0,
00111 double y3 = 4.0,
00112 bool initialiseCells = false);
00113 };
00114
00115 template<class CELL_CYCLE_MODEL>
00116 void CryptCellsGenerator<CELL_CYCLE_MODEL>::Generate(
00117 std::vector<CellPtr>& rCells,
00118 AbstractMesh<2,2>* pMesh,
00119 const std::vector<unsigned> locationIndices,
00120 bool randomBirthTimes,
00121 double y0,
00122 double y1,
00123 double y2,
00124 double y3,
00125 bool initialiseCells)
00126 {
00127 rCells.clear();
00128
00129 RandomNumberGenerator* p_random_num_gen = RandomNumberGenerator::Instance();
00130
00131 unsigned mesh_size;
00132 if (dynamic_cast<TetrahedralMesh<2,2>*>(pMesh))
00133 {
00134 mesh_size = pMesh->GetNumNodes();
00135 unsigned num_cells = locationIndices.empty() ? pMesh->GetNumNodes() : locationIndices.size();
00136 rCells.reserve(num_cells);
00137 }
00138 else if (dynamic_cast<PottsMesh<2>*>(pMesh))
00139 {
00140 mesh_size = static_cast<PottsMesh<2>*>(pMesh)->GetNumElements();
00141 rCells.reserve(mesh_size);
00142 }
00143 else
00144 {
00145
00146 assert((dynamic_cast<VertexMesh<2,2>*>(pMesh)));
00147 mesh_size = static_cast<VertexMesh<2,2>*>(pMesh)->GetNumElements();
00148 rCells.reserve(mesh_size);
00149 }
00150
00151 boost::shared_ptr<AbstractCellProperty> p_state(CellPropertyRegistry::Instance()->Get<WildTypeCellMutationState>());
00152
00153
00154 for (unsigned i=0; i<mesh_size; i++)
00155 {
00156
00157 double y = 0.0;
00158 if (dynamic_cast<TetrahedralMesh<2,2>*>(pMesh))
00159 {
00160 if (locationIndices.empty())
00161 {
00162 y = pMesh->GetNode(i)->GetPoint().rGetLocation()[1];
00163
00164 }
00165 else if (std::find(locationIndices.begin(), locationIndices.end(), i) != locationIndices.end())
00166 {
00167 y = pMesh->GetNode(i)->GetPoint().rGetLocation()[1];
00168 }
00169 }
00170 else if (dynamic_cast<PottsMesh<2>*>(pMesh))
00171 {
00172 y = static_cast<PottsMesh<2>*>(pMesh)->GetCentroidOfElement(i)[1];
00173 }
00174 else
00175 {
00176
00177 assert((dynamic_cast<VertexMesh<2,2>*>(pMesh)));
00178 y = static_cast<VertexMesh<2,2>*>(pMesh)->GetCentroidOfElement(i)[1];
00179 }
00180
00181
00182 CELL_CYCLE_MODEL* p_cell_cycle_model = new CELL_CYCLE_MODEL;
00183 p_cell_cycle_model->SetDimension(2);
00184
00185 double typical_transit_cycle_time = p_cell_cycle_model->GetAverageTransitCellCycleTime();
00186 double typical_stem_cycle_time = p_cell_cycle_model->GetAverageStemCellCycleTime();
00187
00188 double birth_time = 0.0;
00189 if (randomBirthTimes)
00190 {
00191 birth_time = -p_random_num_gen->ranf();
00192 }
00193
00194
00195 unsigned generation = 4;
00196 if (y <= y0)
00197 {
00198 generation = 0;
00199 }
00200 else if (y < y1)
00201 {
00202 generation = 1;
00203 }
00204 else if (y < y2)
00205 {
00206 generation = 2;
00207 }
00208 else if (y < y3)
00209 {
00210 generation = 3;
00211 }
00212 if (dynamic_cast<AbstractSimpleGenerationBasedCellCycleModel*>(p_cell_cycle_model))
00213 {
00214 dynamic_cast<AbstractSimpleGenerationBasedCellCycleModel*>(p_cell_cycle_model)->SetGeneration(generation);
00215 }
00216
00217
00218 CellPtr p_cell(new Cell(p_state, p_cell_cycle_model));
00219
00220
00221 if (y <= y0)
00222 {
00223 p_cell->SetCellProliferativeType(CellPropertyRegistry::Instance()->Get<StemCellProliferativeType>());
00224 }
00225 else
00226 {
00227 p_cell->SetCellProliferativeType(CellPropertyRegistry::Instance()->Get<TransitCellProliferativeType>());
00228 if (y >= y3 && p_cell_cycle_model->CanCellTerminallyDifferentiate())
00229 {
00230 p_cell->SetCellProliferativeType(CellPropertyRegistry::Instance()->Get<DifferentiatedCellProliferativeType>());
00231 }
00232 }
00233
00234
00235 if (initialiseCells)
00236 {
00237 p_cell->InitialiseCellCycleModel();
00238 }
00239
00240
00241 if (y <= y0)
00242 {
00243 birth_time *= typical_stem_cycle_time;
00244 }
00245 else
00246 {
00247 birth_time *= typical_transit_cycle_time;
00248 }
00249 p_cell->SetBirthTime(birth_time);
00250
00251 if (locationIndices.empty())
00252 {
00253 rCells.push_back(p_cell);
00254 }
00255 else if (std::find(locationIndices.begin(), locationIndices.end(), i) != locationIndices.end())
00256 {
00257 rCells.push_back(p_cell);
00258 }
00259 }
00260 }
00261
00262 #endif