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