-
Notifications
You must be signed in to change notification settings - Fork 1
/
output.h
executable file
·161 lines (136 loc) · 3.33 KB
/
output.h
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
#ifndef OUTPUT_H
#define OUTPUT_H
//#include "observer.h"
#include "vector3d.h"
#include <iostream>
#include <time.h>
#include <stdlib.h>
#include <math.h>
#include <sstream>
#include <vector>
#include "cell.h"
#include "SHM.h"
#include "events.h"
#ifdef _WIN32
#include <windows.h>
#endif
#ifdef __linux__
#include <sys/stat.h>
#endif
#ifdef __APPLE__
#include <sys/param.h>
#include <sys/stat.h>
#endif
using namespace std;
class simulation;
class parameters;
class cell;
class output
{
public:
string parfname;
output(string _parfname = string());
~output();
void record_output_time_step(double currentTime, simulation& currentSim, parameters &p);
void recordEvent(double currentTime , double value);
short Output_ID;
void initialize_fileds();
void clear_fileds();
void clear_Pfields();
void write2file_time(double currentTime, simulation& currentSim, parameters&p);
void write_event( cell* Cellx, stringstream &sim_output);
void close_event(B_cell* Cellx, stringstream &sim_output,double time);
void write_event_2file(stringstream &sim_output);
void Plasma_output(double currentTime, simulation& currentSim, parameters&p);
void Memory_output(double currentTime, simulation& currentSim, parameters&p);
void createFolder(string folderName,parameters &p);
void createFolder(string folderName);
string output_path;
string currentDateTime();
vector<string> storage;
};
struct ministat
{
ministat()
{
clear_ministat();
}
void clear_ministat()
{
N=0;
sum=0;
sumsq=0;
values.clear();
}
void add(double v)
{
if(not(isnan(v))){
sum += v;
sumsq += v*v;
N++;}
else {
cout<<"NAN value in output!";
}
values.push_back(v);
}
int N;
vector<double> values;
double sum;
double sumsq;
double average()
{
// if(N==NAN){return 0;}
if (N<=0){return 0;}
if(isnan(sum)){return 0;} //ELENA
else{return double(sum / (double) N);}
}
double stddev()
{
if (N<=1){return 0;}
if(sum == 0){return 0;} //ELENA
if (isnan(sum)) {return 0;}
else
{ if (N>1)
{
double std = (double) sqrt( (double) (sumsq / (double) N) - (sum / (double) N) * (sum / (double) double (N - 1)));
if (isnan(std))
{return 0.0;}
return std;
}
else {
return 0;
}
}
}
string print()
{
stringstream res;
res << "[" << N << "]";
for(int i = 0; i < N; ++i)
{
res << "\t" << values[i];
}
return res.str();
}
};
extern std::string fasta_path;
extern std::string base_Path;
//ministats
extern vector<ministat> Bcell_counts; //number of Bcells
extern vector<ministat> Plasma_counts;
//Mutations
extern ministat Bcell_mutation;
extern ministat Plasma_mutations;
//Affinities
extern ministat Bcell_affinity;
extern ministat Plasma_affinity;
//Antigens
extern vector<ministat> Bcell_Antigen;
//Antibodies
extern ministat Antibody;
//CentroBlasts cycle and divisions
extern ministat Bcell_cycle;
extern ministat Bcell_divisions;
extern ministat Plasma_antigen;
extern ministat Plasma_divisions;
#endif // OUTPUT_H