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 #ifndef CELLSGENERATOR_HPP_
00030 #define CELLSGENERATOR_HPP_
00031
00032
00033 #include <vector>
00034 #include "Cell.hpp"
00035 #include "WildTypeCellMutationState.hpp"
00036 #include "RandomNumberGenerator.hpp"
00037
00043 template<class CELL_CYCLE_MODEL, unsigned DIM>
00044 class CellsGenerator
00045 {
00046 public:
00047
00059 void GenerateBasic(std::vector<CellPtr>& rCells,
00060 unsigned numCells,
00061 const std::vector<unsigned> locationIndices=std::vector<unsigned>(),
00062 CellProliferativeType cellProliferativeType=STEM);
00063
00073 void GenerateBasicRandom(std::vector<CellPtr>& rCells,
00074 unsigned numCells,
00075 CellProliferativeType cellProliferativeType=STEM);
00076
00084 void GenerateGivenLocationIndices(std::vector<CellPtr>& rCells,
00085 const std::vector<unsigned> locationIndices,
00086 CellProliferativeType cellProliferativeType=STEM);
00087 };
00088
00089 template<class CELL_CYCLE_MODEL, unsigned DIM>
00090 void CellsGenerator<CELL_CYCLE_MODEL,DIM>::GenerateBasic(std::vector<CellPtr>& rCells,
00091 unsigned numCells,
00092 const std::vector<unsigned> locationIndices,
00093 CellProliferativeType cellProliferativeType)
00094 {
00095 CellPropertyRegistry::Instance()->Clear();
00096 rCells.clear();
00097 if (!locationIndices.empty())
00098 {
00099
00100 if (numCells != locationIndices.size())
00101 {
00102 EXCEPTION("The size of the locationIndices vector must match the required number of output cells");
00103 }
00104 }
00105 rCells.reserve(numCells);
00106
00107
00108 for (unsigned i=0; i<numCells; i++)
00109 {
00110 CELL_CYCLE_MODEL* p_cell_cycle_model = new CELL_CYCLE_MODEL;
00111 p_cell_cycle_model->SetDimension(DIM);
00112 p_cell_cycle_model->SetCellProliferativeType(cellProliferativeType);
00113
00114 boost::shared_ptr<AbstractCellProperty> p_state(CellPropertyRegistry::Instance()->Get<WildTypeCellMutationState>());
00115 CellPtr p_cell(new Cell(p_state, p_cell_cycle_model));
00116
00117 double birth_time;
00118 if (!locationIndices.empty())
00119 {
00120 birth_time = 0.0 - locationIndices[i];
00121 }
00122 else
00123 {
00124 birth_time = 0.0 - i;
00125 }
00126
00127 p_cell->SetBirthTime(birth_time);
00128 rCells.push_back(p_cell);
00129 }
00130 }
00131
00132 template<class CELL_CYCLE_MODEL, unsigned DIM>
00133 void CellsGenerator<CELL_CYCLE_MODEL,DIM>::GenerateBasicRandom(std::vector<CellPtr>& rCells,
00134 unsigned numCells,
00135 CellProliferativeType cellProliferativeType)
00136 {
00137 CellPropertyRegistry::Instance()->Clear();
00138 rCells.clear();
00139 rCells.reserve(numCells);
00140
00141
00142 for (unsigned i=0; i<numCells; i++)
00143 {
00144 CELL_CYCLE_MODEL* p_cell_cycle_model = new CELL_CYCLE_MODEL;
00145 p_cell_cycle_model->SetDimension(DIM);
00146 p_cell_cycle_model->SetCellProliferativeType(cellProliferativeType);
00147
00148 boost::shared_ptr<AbstractCellProperty> p_state(CellPropertyRegistry::Instance()->Get<WildTypeCellMutationState>());
00149 CellPtr p_cell(new Cell(p_state, p_cell_cycle_model));
00150
00151 double birth_time = -p_cell_cycle_model->GetAverageStemCellCycleTime()*RandomNumberGenerator::Instance()->ranf();
00152
00153 if (cellProliferativeType == TRANSIT)
00154 {
00155 birth_time = -p_cell_cycle_model->GetAverageTransitCellCycleTime()*RandomNumberGenerator::Instance()->ranf();
00156 }
00157
00158 p_cell->SetBirthTime(birth_time);
00159 rCells.push_back(p_cell);
00160 }
00161 }
00162
00163 template<class CELL_CYCLE_MODEL, unsigned DIM>
00164 void CellsGenerator<CELL_CYCLE_MODEL,DIM>::GenerateGivenLocationIndices(std::vector<CellPtr>& rCells,
00165 const std::vector<unsigned> locationIndices,
00166 CellProliferativeType cellProliferativeType)
00167 {
00168 assert(!locationIndices.empty());
00169
00170 unsigned num_cells = locationIndices.size();
00171
00172 rCells.clear();
00173 rCells.reserve(num_cells);
00174 CellPropertyRegistry::Instance()->Clear();
00175
00176 for (unsigned i=0; i<num_cells; i++)
00177 {
00178 CELL_CYCLE_MODEL* p_cell_cycle_model = new CELL_CYCLE_MODEL;
00179 p_cell_cycle_model->SetDimension(DIM);
00180 p_cell_cycle_model->SetCellProliferativeType(cellProliferativeType);
00181
00182 boost::shared_ptr<AbstractCellProperty> p_state(CellPropertyRegistry::Instance()->Get<WildTypeCellMutationState>());
00183
00184 CellPtr p_cell(new Cell(p_state, p_cell_cycle_model));
00185
00186 double birth_time = 0.0 - locationIndices[i];
00187 p_cell->SetBirthTime(birth_time);
00188 rCells.push_back(p_cell);
00189 }
00190 }
00191
00192 #endif