CellsGenerator.hpp

00001 /*
00002 
00003 Copyright (C) University of Oxford, 2005-2011
00004 
00005 University of Oxford means the Chancellor, Masters and Scholars of the
00006 University of Oxford, having an administrative office at Wellington
00007 Square, Oxford OX1 2JD, UK.
00008 
00009 This file is part of Chaste.
00010 
00011 Chaste is free software: you can redistribute it and/or modify it
00012 under the terms of the GNU Lesser General Public License as published
00013 by the Free Software Foundation, either version 2.1 of the License, or
00014 (at your option) any later version.
00015 
00016 Chaste is distributed in the hope that it will be useful, but WITHOUT
00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
00019 License for more details. The offer of Chaste under the terms of the
00020 License is subject to the License being interpreted in accordance with
00021 English Law and subject to any action against the University of Oxford
00022 being under the jurisdiction of the English Courts.
00023 
00024 You should have received a copy of the GNU Lesser General Public License
00025 along with Chaste. If not, see <http://www.gnu.org/licenses/>.
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         // If location indices is given, then it needs to match the number of output cells
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     // Create cells
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     // Create cells
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 /* CELLSGENERATOR_HPP_ */

Generated on Mon Apr 18 11:35:27 2011 for Chaste by  doxygen 1.5.5