CellsGenerator.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 CELLSGENERATOR_HPP_
00037 #define CELLSGENERATOR_HPP_
00038
00039 #include <vector>
00040 #include "Cell.hpp"
00041 #include "WildTypeCellMutationState.hpp"
00042 #include "StemCellProliferativeType.hpp"
00043 #include "TransitCellProliferativeType.hpp"
00044 #include "RandomNumberGenerator.hpp"
00045
00051 template<class CELL_CYCLE_MODEL, unsigned DIM>
00052 class CellsGenerator
00053 {
00054 public:
00055
00067 void GenerateBasic(std::vector<CellPtr>& rCells,
00068 unsigned numCells,
00069 const std::vector<unsigned> locationIndices=std::vector<unsigned>(),
00070 boost::shared_ptr<AbstractCellProperty> pCellProliferativeType=boost::shared_ptr<AbstractCellProperty>());
00071
00081 void GenerateBasicRandom(std::vector<CellPtr>& rCells,
00082 unsigned numCells,
00083 boost::shared_ptr<AbstractCellProperty> pCellProliferativeType=boost::shared_ptr<AbstractCellProperty>());
00084
00092 void GenerateGivenLocationIndices(std::vector<CellPtr>& rCells,
00093 const std::vector<unsigned> locationIndices,
00094 boost::shared_ptr<AbstractCellProperty> pCellProliferativeType=boost::shared_ptr<AbstractCellProperty>());
00095 };
00096
00097 template<class CELL_CYCLE_MODEL, unsigned DIM>
00098 void CellsGenerator<CELL_CYCLE_MODEL,DIM>::GenerateBasic(std::vector<CellPtr>& rCells,
00099 unsigned numCells,
00100 const std::vector<unsigned> locationIndices,
00101 boost::shared_ptr<AbstractCellProperty> pCellProliferativeType)
00102 {
00103 rCells.clear();
00104
00105 if (!locationIndices.empty())
00106 {
00107
00108 if (numCells != locationIndices.size())
00109 {
00110 EXCEPTION("The size of the locationIndices vector must match the required number of output cells");
00111 }
00112 }
00113 rCells.reserve(numCells);
00114
00115
00116 for (unsigned i=0; i<numCells; i++)
00117 {
00118 CELL_CYCLE_MODEL* p_cell_cycle_model = new CELL_CYCLE_MODEL;
00119 p_cell_cycle_model->SetDimension(DIM);
00120
00121 boost::shared_ptr<AbstractCellProperty> p_state(CellPropertyRegistry::Instance()->Get<WildTypeCellMutationState>());
00122 CellPtr p_cell(new Cell(p_state, p_cell_cycle_model));
00123
00124 if (!pCellProliferativeType)
00125 {
00126 p_cell->SetCellProliferativeType(CellPropertyRegistry::Instance()->Get<StemCellProliferativeType>());
00127 }
00128 else
00129 {
00130 p_cell->SetCellProliferativeType(pCellProliferativeType);
00131 }
00132
00133 double birth_time;
00134 if (!locationIndices.empty())
00135 {
00136 birth_time = 0.0 - locationIndices[i];
00137 }
00138 else
00139 {
00140 birth_time = 0.0 - i;
00141 }
00142
00143 p_cell->SetBirthTime(birth_time);
00144 rCells.push_back(p_cell);
00145 }
00146 }
00147
00148 template<class CELL_CYCLE_MODEL, unsigned DIM>
00149 void CellsGenerator<CELL_CYCLE_MODEL,DIM>::GenerateBasicRandom(std::vector<CellPtr>& rCells,
00150 unsigned numCells,
00151 boost::shared_ptr<AbstractCellProperty> pCellProliferativeType)
00152 {
00153 rCells.clear();
00154
00155 rCells.reserve(numCells);
00156
00157
00158 for (unsigned i=0; i<numCells; i++)
00159 {
00160 CELL_CYCLE_MODEL* p_cell_cycle_model = new CELL_CYCLE_MODEL;
00161 p_cell_cycle_model->SetDimension(DIM);
00162
00163 boost::shared_ptr<AbstractCellProperty> p_state(CellPropertyRegistry::Instance()->Get<WildTypeCellMutationState>());
00164 CellPtr p_cell(new Cell(p_state, p_cell_cycle_model));
00165
00166 if (!pCellProliferativeType)
00167 {
00168 p_cell->SetCellProliferativeType(CellPropertyRegistry::Instance()->Get<StemCellProliferativeType>());
00169 }
00170 else
00171 {
00172 p_cell->SetCellProliferativeType(pCellProliferativeType);
00173 }
00174
00175 double birth_time = -p_cell_cycle_model->GetAverageStemCellCycleTime()*RandomNumberGenerator::Instance()->ranf();
00176
00177 if (p_cell->GetCellProliferativeType()->IsType<TransitCellProliferativeType>())
00178 {
00179 birth_time = -p_cell_cycle_model->GetAverageTransitCellCycleTime()*RandomNumberGenerator::Instance()->ranf();
00180 }
00181
00182 p_cell->SetBirthTime(birth_time);
00183 rCells.push_back(p_cell);
00184 }
00185 }
00186
00187 template<class CELL_CYCLE_MODEL, unsigned DIM>
00188 void CellsGenerator<CELL_CYCLE_MODEL,DIM>::GenerateGivenLocationIndices(std::vector<CellPtr>& rCells,
00189 const std::vector<unsigned> locationIndices,
00190 boost::shared_ptr<AbstractCellProperty> pCellProliferativeType)
00191 {
00192 assert(!locationIndices.empty());
00193
00194 unsigned num_cells = locationIndices.size();
00195
00196 rCells.clear();
00197 rCells.reserve(num_cells);
00198 CellPropertyRegistry::Instance()->Clear();
00199
00200 for (unsigned i=0; i<num_cells; i++)
00201 {
00202 CELL_CYCLE_MODEL* p_cell_cycle_model = new CELL_CYCLE_MODEL;
00203 p_cell_cycle_model->SetDimension(DIM);
00204
00205 boost::shared_ptr<AbstractCellProperty> p_state(CellPropertyRegistry::Instance()->Get<WildTypeCellMutationState>());
00206
00207 CellPtr p_cell(new Cell(p_state, p_cell_cycle_model));
00208
00209 if (!pCellProliferativeType)
00210 {
00211 p_cell->SetCellProliferativeType(CellPropertyRegistry::Instance()->Get<StemCellProliferativeType>());
00212 }
00213 else
00214 {
00215 p_cell->SetCellProliferativeType(pCellProliferativeType);
00216 }
00217
00218 double birth_time = 0.0 - locationIndices[i];
00219 p_cell->SetBirthTime(birth_time);
00220 rCells.push_back(p_cell);
00221 }
00222 }
00223
00224 #endif