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 
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         // If location indices is given, then it needs to match the number of output cells
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     // Create cells
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     // Create cells
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 /* CELLSGENERATOR_HPP_ */
Generated on Thu Dec 22 13:00:04 2011 for Chaste by  doxygen 1.6.3