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 #include "VertexCryptSimulation2d.hpp"
00030 #include "WntConcentration.hpp"
00031 #include "VanLeeuwen2009WntSwatCellCycleModelHypothesisOne.hpp"
00032 #include "VanLeeuwen2009WntSwatCellCycleModelHypothesisTwo.hpp"
00033
00034 VertexCryptSimulation2d::VertexCryptSimulation2d(AbstractCellPopulation<2>& rCellPopulation,
00035 bool deleteCellPopulationAndForceCollection,
00036 bool initialiseCells)
00037 : CellBasedSimulation<2>(rCellPopulation,
00038 deleteCellPopulationAndForceCollection,
00039 initialiseCells),
00040 mUseJiggledBottomCells(false),
00041 mWriteBetaCatenin(false)
00042 {
00043
00044
00045
00046
00047
00048
00049 if (dynamic_cast<AbstractVanLeeuwen2009WntSwatCellCycleModel*>(mrCellPopulation.Begin()->GetCellCycleModel()))
00050 {
00051 mWriteBetaCatenin = true;
00052 }
00053 }
00054
00055 c_vector<double, 2> VertexCryptSimulation2d::CalculateCellDivisionVector(CellPtr pParentCell)
00056 {
00057 c_vector<double, 2> axis_of_division = zero_vector<double>(2);
00058
00059
00060 bool is_wnt_included = WntConcentration<2>::Instance()->IsWntSetUp();
00061 if (!is_wnt_included)
00062 {
00063 WntConcentration<2>::Destroy();
00064 if (pParentCell->GetCellCycleModel()->GetCellProliferativeType() == STEM)
00065 {
00066 axis_of_division(0) = 1.0;
00067 axis_of_division(1) = 0.0;
00068 }
00069 }
00070 return axis_of_division;
00071 }
00072
00073 void VertexCryptSimulation2d::WriteVisualizerSetupFile()
00074 {
00075 *mpVizSetupFile << "MeshWidth\t" << mrCellPopulation.GetWidth(0) << "\n";
00076 }
00077
00078 void VertexCryptSimulation2d::SetupWriteBetaCatenin()
00079 {
00080 OutputFileHandler output_file_handler(this->mSimulationOutputDirectory + "/", false);
00081 mVizBetaCateninResultsFile = output_file_handler.OpenOutputFile("results.vizbetacatenin");
00082 *mpVizSetupFile << "BetaCatenin\n";
00083 }
00084
00085 void VertexCryptSimulation2d::WriteBetaCatenin(double time)
00086 {
00087 *mVizBetaCateninResultsFile << time << "\t";
00088
00089 unsigned global_index;
00090 double x;
00091 double y;
00092 double b_cat_membrane;
00093 double b_cat_cytoplasm;
00094 double b_cat_nuclear;
00095
00096 for (AbstractCellPopulation<2>::Iterator cell_iter = mrCellPopulation.Begin();
00097 cell_iter != mrCellPopulation.End();
00098 ++cell_iter)
00099 {
00100 global_index = mrCellPopulation.GetLocationIndexUsingCell(*cell_iter);
00101 x = mrCellPopulation.GetLocationOfCellCentre(*cell_iter)[0];
00102 y = mrCellPopulation.GetLocationOfCellCentre(*cell_iter)[1];
00103
00104
00105 assert(mWriteBetaCatenin);
00106
00107 AbstractVanLeeuwen2009WntSwatCellCycleModel* p_model = dynamic_cast<AbstractVanLeeuwen2009WntSwatCellCycleModel*>(cell_iter->GetCellCycleModel());
00108 b_cat_membrane = p_model->GetMembraneBoundBetaCateninLevel();
00109 b_cat_cytoplasm = p_model->GetCytoplasmicBetaCateninLevel();
00110 b_cat_nuclear = p_model->GetNuclearBetaCateninLevel();
00111
00112 *mVizBetaCateninResultsFile << global_index << " " << x << " " << y << " " << b_cat_membrane << " " << b_cat_cytoplasm << " " << b_cat_nuclear << " ";
00113 }
00114
00115 *mVizBetaCateninResultsFile << "\n";
00116 }
00117
00118 void VertexCryptSimulation2d::SetupSolve()
00119 {
00120
00121
00122
00123
00124 bool any_cells_present = (mrCellPopulation.Begin() != mrCellPopulation.End());
00125 if (any_cells_present && mWriteBetaCatenin)
00126 {
00127 SetupWriteBetaCatenin();
00128 double current_time = SimulationTime::Instance()->GetTime();
00129 WriteBetaCatenin(current_time);
00130 }
00131 }
00132
00133 void VertexCryptSimulation2d::PostSolve()
00134 {
00135 SimulationTime* p_time = SimulationTime::Instance();
00136
00137 if ((p_time->GetTimeStepsElapsed()+1)%mSamplingTimestepMultiple == 0)
00138 {
00139
00140
00141
00142
00143
00144 bool any_cells_present = (mrCellPopulation.Begin() != mrCellPopulation.End());
00145 if (any_cells_present && mWriteBetaCatenin)
00146 {
00147 double time_next_step = p_time->GetTime() + p_time->GetTimeStep();
00148 WriteBetaCatenin(time_next_step);
00149 }
00150 }
00151 }
00152
00153 void VertexCryptSimulation2d::AfterSolve()
00154 {
00155
00156
00157
00158
00159 bool any_cells_present = (mrCellPopulation.Begin() != mrCellPopulation.End());
00160 if (any_cells_present && mWriteBetaCatenin)
00161 {
00162 mVizBetaCateninResultsFile->close();
00163 }
00164 }
00165
00166 void VertexCryptSimulation2d::UseJiggledBottomCells()
00167 {
00168 mUseJiggledBottomCells = true;
00169 }
00170
00171 void VertexCryptSimulation2d::ApplyCellPopulationBoundaryConditions(const std::vector< c_vector<double, 2> >& rOldLocations)
00172 {
00173 bool is_wnt_included = WntConcentration<2>::Instance()->IsWntSetUp();
00174 if (!is_wnt_included)
00175 {
00176 WntConcentration<2>::Destroy();
00177 }
00178
00179
00180 unsigned num_nodes = mrCellPopulation.GetNumNodes();
00181 for (unsigned node_index=0; node_index<num_nodes; node_index++)
00182 {
00183 Node<2>* p_node = mrCellPopulation.GetNode(node_index);
00184 c_vector<double, 2> old_location = rOldLocations[node_index];
00185
00186 if (!is_wnt_included)
00187 {
00193 if (rOldLocations[node_index][1] < DBL_EPSILON)
00194 {
00195
00196 p_node->rGetModifiableLocation()[1] = rOldLocations[node_index][1];
00197 }
00198 }
00199
00200
00201 if (p_node->rGetLocation()[1] < 0.0)
00202 {
00203 p_node->rGetModifiableLocation()[1] = 0.0;
00204 if (this->mUseJiggledBottomCells)
00205 {
00206
00207 p_node->rGetModifiableLocation()[1] = 0.05*mpRandomGenerator->ranf();
00208 }
00209 }
00210 assert(p_node->rGetLocation()[1] >= 0.0);
00211 }
00212 }
00213
00214 void VertexCryptSimulation2d::SetBottomCellAncestors()
00215 {
00216 unsigned index = 0;
00217 for (AbstractCellPopulation<2>::Iterator cell_iter = mrCellPopulation.Begin();
00218 cell_iter != mrCellPopulation.End();
00219 ++cell_iter)
00220 {
00221 if (mrCellPopulation.GetLocationOfCellCentre(*cell_iter)[1] < 1.0)
00222 {
00223 cell_iter->SetAncestor(index++);
00224 }
00225 }
00226 }
00227
00228 void VertexCryptSimulation2d::OutputSimulationParameters(out_stream& rParamsFile)
00229 {
00230 *rParamsFile << "\t\t<CryptCircumference>" << mrCellPopulation.GetWidth(0) << "</CryptCircumference>\n";
00231 *rParamsFile << "\t\t<UseJiggledBottomCells>" << mUseJiggledBottomCells << "</UseJiggledBottomCells>\n";
00232
00233
00234 CellBasedSimulation<2>::OutputSimulationParameters(rParamsFile);
00235 }
00236
00237
00238 #include "SerializationExportWrapperForCpp.hpp"
00239 CHASTE_CLASS_EXPORT(VertexCryptSimulation2d)