forked from mikahlbk/SpatialYeastModel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
219 lines (198 loc) · 6.3 KB
/
main.cpp
File metadata and controls
219 lines (198 loc) · 6.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
// Main.cpp
//***********************************
// Include Dependencies
#include <iostream>
#include <math.h>
#include <cstring>
#include <vector>
#include <fstream>
#include <ctime>
#include <cstdio>
#include <memory>
#include <random>
#include <stdio.h>
#include "colony.h"
#include "parameters.h"
#include "coord.h"
#include "cell.h"
#include "mesh.h"
#include "mesh_pt.h"
//****************************************
using namespace std;
//*****************************************
//buddding (1) vs. non-budding (0)
int Budding_On = 1;
int Nutrient_On = 0;
int Start_from_four = 0;
//Axial = 0, Bipolar = 1, Random = 2;
int Division_Pattern = 1;
//Adhesion between all cells
double SINGLE_BOND_BIND_ENERGY = 25;
//Parameters for logistic equation governing
//prion dynamics
double P_0 = 50;
double r_LOGISTIC = 1;
double A_LOGISTIC = 35;
//Carrying capacity for logistic equation
//governing nutrient concentration in each bucket
double K_MASS = 18*M_PI*pow(3.1,2);
double NUTRIENT_DECAY = .003;
int main(int argc, char* argv[]) {
//cout << "Starting" << endl;
//reads in name of folder to store output for visualization
string anim_folder = argv[1];
for(int i = 1; i < argc; i++){
if(!strcmp(argv[i], "-Budding")){
Budding_On = stod(argv[i+1]);
}else if(!strcmp(argv[i],"-HERTZ_ADH")){
SINGLE_BOND_BIND_ENERGY = stod(argv[i+1]);
}else if(!strcmp(argv[i],"-Initial_Protein")){
P_0 = stod(argv[i+1]);
}else if(!strcmp(argv[i],"-growth_rate")){
r_LOGISTIC = stod(argv[i+1]);
}else if(!strcmp(argv[i],"-competition_term")){
A_LOGISTIC = stod(argv[i+1]);
}else if(!strcmp(argv[i],"-division")){
Division_Pattern = stod(argv[i+1]);
}else if(!strcmp(argv[i],"-nutrient_mass")){
K_MASS = stod(argv[i+1]);
}else if(!strcmp(argv[i],"-nutrient_decay")){
NUTRIENT_DECAY = stod(argv[i+1]);
}else if(!strcmp(argv[i],"-nutrient_depletion")){
Nutrient_On = stod(argv[i+1]);
}else if(!strcmp(argv[i],"-start_from_four")){
Start_from_four = stod(argv[i+1]);
}
}
//keeps track of simulation time
int start = clock();
//cout << "clock" << endl;
string init_colony = "mixed_initial.csv";
//cout << "read in colony text file" << endl;
//initialize seed for generating random numbers
//is fed to colony constructor so that colony holds
//the same seed and can give to other classes
std::random_device seed;
std::mt19937 gen(seed());
//make mesh for bucketing
//cout << "make mesh" << endl;
auto mesh_for_bins = make_shared<Mesh>();
//leftmost point for mesh
int start_1 = -400;
//rightmost point for mesh
int start_2 = 400;
//each square unit on mesh will be this many units
double increment = 25.0;
int num_buckets = 2*ceil(start_2/increment);
//cout << " make bins " << endl;
mesh_for_bins->make_mesh_pts(start_1,start_2,num_buckets,increment);
//cout << "make neighbors" << endl;
mesh_for_bins->assign_neighbors();
//make colony object
//gen is the seed for random numbers
auto growing_Colony = make_shared<Colony>(mesh_for_bins,gen);
//cout << "Made Colony" << endl;
//make founder cell
//growing_Colony->make_founder_cell(init_colony);
//growing_Colony->match_up();
//cout << "Match up" << endl;
growing_Colony->make_founder_cell();
//cout << "Made Founder Cell" << endl;
//variables for writing output files
string format = ".txt";
string initial = "/locations";
int out = 1;
ofstream myfile;
string Number;
string Filename;
//not in use********************************
//some variables for writing vtk files
/*int digits;
string format = ".vtk";
string Number;
string initial = "/Spatial_Model_Yeast_";
string Filename;
ofstream ofs_anim;
int out = 0;*/
//*****************************************
//loop for time steps
for (int Ti = 0; Ti < NUM_STEPS; Ti++) {
//write data to txt file
//change OUTPUT_FREQ to smaller number in parameters.h
//if want to see more timesteps
//cout << "In time loop" << endl;
if(Ti%OUTPUT_FREQ == 0){
//open txt file for writing cell data
Number = to_string(out);
Filename = anim_folder + initial + Number + format;
myfile.open(Filename.c_str());
growing_Colony->write_data(myfile);
myfile.close();
out++;
}
//cout << "Time: " << Ti << endl;
//assign each cell to closest bin
//for computing forces
if(Ti%1000 == 0){
growing_Colony->find_bin();
//cout << "bins" << endl;
}
if(Nutrient_On){
growing_Colony->update_growth_rates();
//growth rate changes according to nutrient conc in bin
}
//growth
//cout << "grow" << endl;
growing_Colony->grow_cells();
//cell cyle
//cout << "cell cycle" << endl;
growing_Colony->update_cell_cycles(Ti);
//budding
//cout<< "budding" << endl;
growing_Colony->perform_budding(Ti);
//remove buds that are big enough
//cout << "mitosis" << endl;
growing_Colony->perform_mitosis(Ti);
//pulling test for mother-bud adhesion
//growing_Colony->pull_daughter();
//spatial rearrangment
//cout << "rearrange" << endl;
growing_Colony->update_locations();
//cout << "rearranged" << endl;
//compute protein concentration
//cout << "Protein Conc" << endl;
growing_Colony->update_protein_concentration();
//cout << "protein end" << endl;
//not in use********************************
//make vtk files
/*if(Ti%100 == 0){digits = ceil(log10(out +1));
if(digits == 1 || digits == 0){
Number = "0000" + to_string(out);
}
else if(digits == 2){
Number = "000" + to_string(out);
}
else if(digits == 3){
Number = "00" + to_string(out);
}
else if(digits == 4){
Number = "0" + to_string(out);
}
Filename = anim_folder + initial + Number + format;
ofs_anim.open(Filename.c_str());
growing_Colony->print_vtk_file(ofs_anim);
ofs_anim.close();
out++;
}*/
}
//open txt file for writing cell data
Number = to_string(out);
Filename = anim_folder + initial + Number + format;
myfile.open(Filename.c_str());
growing_Colony->write_data(myfile);
myfile.close();
int stop = clock();
cout << "Time: " << (stop-start) / double(CLOCKS_PER_SEC)*1000 << endl;
//Need to add way to store data over multiple runs
return 0;
}