Chaste Commit::ca8ccdedf819b6e02855bc0e8e6f50bdecbc5208
CellsGenerator.hpp
1/*
2
3Copyright (c) 2005-2024, University of Oxford.
4All rights reserved.
5
6University of Oxford means the Chancellor, Masters and Scholars of the
7University of Oxford, having an administrative office at Wellington
8Square, Oxford OX1 2JD, UK.
9
10This file is part of Chaste.
11
12Redistribution and use in source and binary forms, with or without
13modification, are permitted provided that the following conditions are met:
14 * Redistributions of source code must retain the above copyright notice,
15 this list of conditions and the following disclaimer.
16 * Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19 * Neither the name of the University of Oxford nor the names of its
20 contributors may be used to endorse or promote products derived from this
21 software without specific prior written permission.
22
23THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
29GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
32OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33
34*/
35
36#ifndef CELLSGENERATOR_HPP_
37#define CELLSGENERATOR_HPP_
38
39#include <vector>
40#include "Cell.hpp"
41#include "WildTypeCellMutationState.hpp"
42#include "StemCellProliferativeType.hpp"
43#include "TransitCellProliferativeType.hpp"
44#include "RandomNumberGenerator.hpp"
45
51template<class CELL_CYCLE_MODEL, unsigned DIM>
53{
54public:
55
67 void GenerateBasic(std::vector<CellPtr>& rCells,
68 unsigned numCells,
69 const std::vector<unsigned> locationIndices=std::vector<unsigned>(),
70 boost::shared_ptr<AbstractCellProperty> pCellProliferativeType=boost::shared_ptr<AbstractCellProperty>());
71
81 void GenerateBasicRandom(std::vector<CellPtr>& rCells,
82 unsigned numCells,
83 boost::shared_ptr<AbstractCellProperty> pCellProliferativeType=boost::shared_ptr<AbstractCellProperty>());
84
92 void GenerateGivenLocationIndices(std::vector<CellPtr>& rCells,
93 const std::vector<unsigned> locationIndices,
94 boost::shared_ptr<AbstractCellProperty> pCellProliferativeType=boost::shared_ptr<AbstractCellProperty>());
95};
96
97template<class CELL_CYCLE_MODEL, unsigned DIM>
99 unsigned numCells,
100 const std::vector<unsigned> locationIndices,
101 boost::shared_ptr<AbstractCellProperty> pCellProliferativeType)
102{
103 rCells.clear();
104
105 if (!locationIndices.empty())
106 {
107 // If location indices is given, then it needs to match the number of output cells
108 if (numCells != locationIndices.size())
109 {
110 EXCEPTION("The size of the locationIndices vector must match the required number of output cells");
111 }
112 }
113 rCells.reserve(numCells);
114
115 // Create cells
116 for (unsigned i=0; i<numCells; i++)
117 {
118 CELL_CYCLE_MODEL* p_cell_cycle_model = new CELL_CYCLE_MODEL;
119 p_cell_cycle_model->SetDimension(DIM);
120
121 boost::shared_ptr<AbstractCellProperty> p_state(CellPropertyRegistry::Instance()->Get<WildTypeCellMutationState>());
122 CellPtr p_cell(new Cell(p_state, p_cell_cycle_model));
123
124 if (!pCellProliferativeType)
125 {
126 p_cell->SetCellProliferativeType(CellPropertyRegistry::Instance()->Get<StemCellProliferativeType>());
127 }
128 else
129 {
130 p_cell->SetCellProliferativeType(pCellProliferativeType);
131 }
132
133 double birth_time;
134 if (!locationIndices.empty())
135 {
136 birth_time = 0.0 - locationIndices[i];
137 }
138 else
139 {
140 birth_time = 0.0 - i;
141 }
142
143 p_cell->SetBirthTime(birth_time);
144 rCells.push_back(p_cell);
145 }
146}
147
148template<class CELL_CYCLE_MODEL, unsigned DIM>
150 unsigned numCells,
151 boost::shared_ptr<AbstractCellProperty> pCellProliferativeType)
152{
153 rCells.clear();
154
155 rCells.reserve(numCells);
156
157 // Create cells
158 for (unsigned i=0; i<numCells; i++)
159 {
160 CELL_CYCLE_MODEL* p_cell_cycle_model = new CELL_CYCLE_MODEL;
161 p_cell_cycle_model->SetDimension(DIM);
162
163 boost::shared_ptr<AbstractCellProperty> p_state(CellPropertyRegistry::Instance()->Get<WildTypeCellMutationState>());
164 CellPtr p_cell(new Cell(p_state, p_cell_cycle_model));
165
166 if (!pCellProliferativeType)
167 {
168 p_cell->SetCellProliferativeType(CellPropertyRegistry::Instance()->Get<StemCellProliferativeType>());
169 }
170 else
171 {
172 p_cell->SetCellProliferativeType(pCellProliferativeType);
173 }
174
175 double birth_time = -p_cell_cycle_model->GetAverageStemCellCycleTime()*RandomNumberGenerator::Instance()->ranf();
176
177 if (p_cell->GetCellProliferativeType()->IsType<TransitCellProliferativeType>())
178 {
179 birth_time = -p_cell_cycle_model->GetAverageTransitCellCycleTime()*RandomNumberGenerator::Instance()->ranf();
180 }
181
182 p_cell->SetBirthTime(birth_time);
183 rCells.push_back(p_cell);
184 }
185}
186
187template<class CELL_CYCLE_MODEL, unsigned DIM>
189 const std::vector<unsigned> locationIndices,
190 boost::shared_ptr<AbstractCellProperty> pCellProliferativeType)
191{
192 assert(!locationIndices.empty());
193
194 unsigned num_cells = locationIndices.size();
195
196 rCells.clear();
197 rCells.reserve(num_cells);
199
200 for (unsigned i=0; i<num_cells; i++)
201 {
202 CELL_CYCLE_MODEL* p_cell_cycle_model = new CELL_CYCLE_MODEL;
203 p_cell_cycle_model->SetDimension(DIM);
204
205 boost::shared_ptr<AbstractCellProperty> p_state(CellPropertyRegistry::Instance()->Get<WildTypeCellMutationState>());
206
207 CellPtr p_cell(new Cell(p_state, p_cell_cycle_model));
208
209 if (!pCellProliferativeType)
210 {
211 p_cell->SetCellProliferativeType(CellPropertyRegistry::Instance()->Get<StemCellProliferativeType>());
212 }
213 else
214 {
215 p_cell->SetCellProliferativeType(pCellProliferativeType);
216 }
217
218 double birth_time = 0.0 - locationIndices[i];
219 p_cell->SetBirthTime(birth_time);
220 rCells.push_back(p_cell);
221 }
222}
223
224#endif /* CELLSGENERATOR_HPP_ */
#define EXCEPTION(message)
static CellPropertyRegistry * Instance()
Definition Cell.hpp:92
void GenerateBasicRandom(std::vector< CellPtr > &rCells, unsigned numCells, boost::shared_ptr< AbstractCellProperty > pCellProliferativeType=boost::shared_ptr< AbstractCellProperty >())
void GenerateBasic(std::vector< CellPtr > &rCells, unsigned numCells, const std::vector< unsigned > locationIndices=std::vector< unsigned >(), boost::shared_ptr< AbstractCellProperty > pCellProliferativeType=boost::shared_ptr< AbstractCellProperty >())
void GenerateGivenLocationIndices(std::vector< CellPtr > &rCells, const std::vector< unsigned > locationIndices, boost::shared_ptr< AbstractCellProperty > pCellProliferativeType=boost::shared_ptr< AbstractCellProperty >())
static RandomNumberGenerator * Instance()