-
Notifications
You must be signed in to change notification settings - Fork 1
/
output.cpp
executable file
·627 lines (499 loc) · 20.4 KB
/
output.cpp
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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
#include "output.h"
#include <set>
#include <numeric>
#include "mafalda.h"
#include "cell.h"
#include <experimental/filesystem> ///RRR
#include "SHM.h"
#include <boost/algorithm/string/join.hpp>
using namespace std;
// ministats
vector<ministat> Bcell_counts; // number of Bcells
vector<ministat> Plasma_counts;
// Affinities
// This is for recording (average) affinities of B cells versus time, for plasma
// cells there is a different file of records
ministat Bcell_affinity;
output::output(string _parfname) : parfname(_parfname) { initialize_fileds(); }
output::~output() {}
string output::currentDateTime() {
time_t now = time(0);
struct tm tstruct;
char buf[80];
tstruct = *localtime(&now);
strftime(buf, sizeof(buf), "%y-%m-%d_%H-%M-%S", &tstruct);
return buf;
}
void output::createFolder(string folderName) {
#ifdef __WIN32__
const char *p = tmp.str();
const WCHAR *pwcsName;
int nChars = MultiByteToWideChar(CP_ACP, 0, p, -1, NULL, 0);
pwcsName = new WCHAR[nChars];
MultiByteToWideChar(CP_ACP, 0, p, -1, (LPWSTR)pwcsName, nChars);
CreateDirectory(pwcsName, NULL);
delete[] pwcsName;
#endif
//#Recheck
#ifdef __linux__
//#Danial: Fully changed
stringstream tmp;
tmp <<"/" << "sim_" << Output_ID << "_" << currentDateTime();
folderName = folderName + tmp.str();
output_path = folderName;
if (!(std::experimental::filesystem::create_directory(output_path))) { ///RRR tmp.str() Y otracosa
std::cerr << "Error creating directory " << std::endl; ///RRR
}
#endif
#ifdef __APPLE__
stringstream tmp;
tmp <<"/" << "sim_" << Output_ID << "_" << currentDateTime();
folderName = folderName + tmp.str();
output_path = folderName;
if (!(std::experimental::filesystem::create_directory(output_path))) { ///RRR tmp.str() Y otracosa
std::cerr << "Error creating directory " << std::endl; ///RRR
}
char cstr [folderName.size()+1];
strcpy(cstr,folderName.c_str());
mkdir(cstr, 0777);
#endif
}
void output::createFolder(string folderName, parameters &p) {
//#Recheck
// Output folder
stringstream tmp;
tmp << "/home/rgarcia/Escritorio/NGly_network" << "/" << p.parameter_file_name << "sim_" << Output_ID
<< "_" << currentDateTime();
output_path = tmp.str();
//#Recheck
#ifdef _WIN32
const char *p = tmp.str();
const WCHAR *pwcsName;
int nChars = MultiByteToWideChar(CP_ACP, 0, p, -1, NULL, 0);
pwcsName = new WCHAR[nChars];
MultiByteToWideChar(CP_ACP, 0, p, -1, (LPWSTR)pwcsName, nChars);
CreateDirectory(pwcsName, NULL);
delete[] pwcsName;
#endif
//#Recheck
#ifdef __linux__
if (!(std::experimental::filesystem::create_directory(tmp.str()))) { ///RRR tmp.str() Y otracosa
std::cerr << "Error creating directory " << std::endl; ///RRR
}
#endif
#ifdef __APPLE__
char cstr[tmp.str().size() + 1];
strcpy(cstr, tmp.str().c_str());
mkdir(cstr, 0777);
#endif
}
void output::initialize_fileds() {
// 0-9 -> CC states (7) + CB (2)
for (int i = 0; i < 8; i++) {
Bcell_counts.push_back(ministat()); // number of Bcells
}
}
void output::clear_fileds() {
for (int i = 0; i < 8; i++) {
Bcell_counts.clear(); //.at(i).clear_ministat(); //number of Bcells
}
for (int i = 0; i < 8; i++) {
Bcell_counts.push_back(ministat()); // number of Bcells
}
// Affinities
Bcell_affinity.clear_ministat();
}
// Take fields from simulation into master observer variable to create file.
void output::record_output_time_step(double currentTime, simulation ¤tSim,
parameters &p) {
// This function records data about B cells population and affinity versus
// time, this does not include Plasma cells.
// Bcell data
int CB = 0;
int CC = 0;
int apop =0;
vector<int> CC_IDs;
for (int i = 0; i < currentSim.ListB_cell.size(); i++) {
B_cell *Bcell = currentSim.ListB_cell.at(i);
// Check integrity of the list
if (Bcell->cell_state > 7) {
cout << "Error, wrong cell in BC list," << Bcell->cell_state << endl;
exit(1);
}
Bcell_counts[Bcell->cell_state].add(1);
if (Bcell->cell_state == 7) {
apop = apop +1;
} else if ( Bcell->cell_type == 4) {
CB = CB +1;
} else if ( Bcell->cell_type == 5) {
CC = CC +1;
CC_IDs.push_back(Bcell->ID);
}
// Bcell Affinity
Bcell->setMyAffinity(p);
Bcell_affinity.add(Bcell->MyAffinity);
}
FILE *Bcell_time_data;
string folder1 = output_path + "/Bcell_time.csv";
char *s1 = const_cast<char *>(folder1.c_str());
;
Bcell_time_data = fopen(s1, "a");
static bool tmp = true;
if (tmp) {
tmp = false;
fprintf(Bcell_time_data, "%s",
"time,founder,unselected,contact_FDC,FDC_selected,contact_TC,TC_"
"Selected_by_TC,recycled,apoptosis,affinity,std_affinity,CC_IDs,CB,CC,Pr,Apoptotic\n");
}
fprintf(Bcell_time_data, "%f,", currentTime);
for (int i = 0; i < 8; i++) {
fprintf(Bcell_time_data, "%f,", Bcell_counts[i].sum);
}
fprintf(Bcell_time_data, "%.16G,%.16G,", Bcell_affinity.average(),
Bcell_affinity.stddev());
fprintf(Bcell_time_data, "%s,",
"Prueba");
fprintf(Bcell_time_data, "%d,%d,%s,%d\n", CB,CC,"Pr",apop);
fclose(Bcell_time_data); //#Recheck take care of bins in gle file
clear_fileds();
std::ostringstream oss;
if (!CC_IDs.empty())
{
// Convert all but the last element to avoid a trailing ","
std::copy(CC_IDs.begin(), CC_IDs.end()-1,
std::ostream_iterator<int>(oss, ";"));
// Now add the last element with no delimiter
oss << CC_IDs.back();
}
std::string oss_s = oss.str();
oss.str(std::string());
FILE *CC_time_data;
string folderCC = output_path + "/CC_time.csv";
char *s1CC = const_cast<char *>(folderCC.c_str());
;
CC_time_data = fopen(s1CC, "a");
static bool tmpCC = true;
if (tmpCC) {
tmpCC = false;
fprintf(CC_time_data, "%s",
"time,CC_IDs\n");
}
fprintf(CC_time_data, "%f,", currentTime);
fprintf(CC_time_data, "%s\n", oss_s.c_str());
fclose(CC_time_data); //#Recheck take care of bins in gle file
// Bcell seq data
vector<string> fastas_totales;
for (const auto & entry : std::experimental::filesystem::directory_iterator("/home/rgarcia/Escritorio/NGly_scripts/Control_VJ_GC_model")) { ///RRR5k "/home/rgarcia/Escritorio/NGly_scripts/MariaGC_1000_processed_fastas/Fastas_ABM/Fastas_r"
if (!entry.path().extension().compare(".fasta")) {
fastas_totales.push_back(entry.path());
}
}
string sequence;
for (int indiv = 0; indiv < fastas_totales.size(); indiv++) {
sequence= std::experimental::filesystem::path(fastas_totales[indiv]).filename();
CB = 0;
CC = 0;
apop =0;
for (int i = 0; i < currentSim.ListB_cell.size(); i++) {
B_cell *Bcell2 = currentSim.ListB_cell.at(i);
// Check integrity of the list
if ((sequence.compare(Bcell2->germline_name)) == 0 ) {
if (Bcell2->cell_state > 7) {
cout << "Error, wrong cell in BC list," << Bcell2->cell_state << endl;
exit(1);
}
Bcell_counts[Bcell2->cell_state].add(1);
if (Bcell2->cell_state == 7) {
apop = apop +1;
} else if ( Bcell2->cell_type == 4) {
CB = CB +1;
} else if ( Bcell2->cell_type == 5) {
CC = CC +1;
}
// Bcell Affinity
Bcell2->setMyAffinity(p);
Bcell_affinity.add(Bcell2->MyAffinity);
}
}
FILE *Bcell_seq_time_data;
string folder2 = output_path + "/Bcell_time_seq.csv";
char *s2 = const_cast<char *>(folder2.c_str());
Bcell_seq_time_data = fopen(s2, "a");
static bool tmp2 = true;
if (tmp2) {
tmp2 = false;
fprintf(Bcell_seq_time_data, "%s",
"Fasta, time,founder,unselected,contact_FDC,FDC_selected,contact_TC,TC_"
"Selected_by_TC,recycled,apoptosis,affinity,std_affinity,Prueba,CB,CC,Pr,Apoptotic\n");
}
fprintf(Bcell_seq_time_data, "%s,", sequence.c_str());
fprintf(Bcell_seq_time_data, "%f,", currentTime);
for (int i = 0; i < 8; i++) {
fprintf(Bcell_seq_time_data, "%f,", Bcell_counts[i].sum);
}
fprintf(Bcell_seq_time_data, "%.16G,%.16G,", Bcell_affinity.average(),
Bcell_affinity.stddev());
fprintf(Bcell_seq_time_data, "%s,",
"Prueba");
fprintf(Bcell_seq_time_data, "%d,%d,%s,%d\n", CB,CC,"Pr",apop);
fclose(Bcell_seq_time_data); //#Recheck take care of bins in gle file
clear_fileds();
}
}
void output::write_event(cell *Cellx, stringstream &sim_output) {
sim_output << Cellx->event.str() << endl;
}
void output::write_event_2file(stringstream &sim_output) {
FILE *event_data;
string folder1 = output_path + "/event_data.csv";
event_data = fopen(folder1.c_str(), "a");
static bool tmp = false;
if (not(tmp)) {
fprintf(event_data, "%s",
"ID,Born_time,MID,States,Affinity,N_of_Ags,N_of_divisions,N_of_"
"Mutations,delta_aff,FDC_interaction_nums,FDC_interaction_time_avg,"
"TC_interaction_time,TC_signaling_time,FDC_selected,Selected_by_TC, Original_fasta, Sequence, Protein sequence, Status, Replacement_mutations, Silent_Mutations, Relevant_NGly_sites, All_NGly_sites, Death_time, AA_regions, NT_REGIONS, Blacklists, BLIMP1, BCL6, IRF4, BLIMP1_0, BCL6_0, IRF4_0,BCR_1,BCR_2,BCR_3,BCR_4,ORF\n");
tmp = true;
}
fprintf(event_data, "%s", sim_output.str().c_str());
fclose(event_data); //#Recheck take care of bins in gle file
}
// for B cells
//cell states: 0-founder,
//1-unselected,
//2-contact_FDC,
//3-FDC_selected,
//4-contact_TC,
//5-TC_selected,
//6-recycled,
//7-apoptosis,
//8-TC_free,
//9-TC_connected,
//10-Plasma_Out,
//11-Plasma_in_GC,
//12-cell_state_counter
void output::close_event(B_cell *Cellx, stringstream &sim_output, double time) {
Cellx->event << Cellx->cell_state << "," << Cellx->MyAffinity << ","
<< Cellx->retained_Ag << "," << Cellx->total_number_of_divisions
<< "," << Cellx->myBCR.nMutFromGermline << ","
<< Cellx->delta_Affinity << ",";
Cellx->event << Cellx->nFDCcontacts << ",";
if (Cellx->nFDCcontacts == 0) {
Cellx->event << Cellx->fdc_interaction_time_history << ",";
} else {
Cellx->event << double(Cellx->fdc_interaction_time_history /
double(Cellx->nFDCcontacts))
<< ",";
}
Cellx->event << Cellx->Tc_interaction_history.first << ","
<< Cellx->Tc_interaction_history.second << ",";
std::stringstream ss;
for(size_t i = 0; i < Cellx->NGly_mutated_sites.size(); ++i)
{
if(i != 0)
ss << "-";
ss << Cellx->NGly_mutated_sites[i];
}
std::string s = ss.str();
ss.str(std::string());
std::stringstream sts;
for(size_t i = 0; i < Cellx->All_NGly_mutated_sites.size(); ++i)
{
if(i != 0)
sts << "-";
sts << Cellx->All_NGly_mutated_sites [i];
}
std::string st = sts.str();
sts.str(std::string());
std::stringstream blk;
for(size_t i = 0; i < Cellx->blacklist_nums.size(); ++i)
{
if(i != 0)
blk << "-";
blk << Cellx->blacklist_nums [i];
}
std::string blks = blk.str();
blk.str(std::string());
Cellx->event << Cellx->Selected_by_FDC << "," << Cellx->Selected_by_TC << ","<< Cellx->germline_name << "," << Cellx->sequence << "," << Cellx->protein_sequence << ","<< cellToString(Cellx->cell_type) << "," << mapToString(Cellx->MUTATIONS) << "," << mapToString(Cellx->SILENT_MUTATIONS) << "," << s << "," << st << ","<< time << ","<< mapToString2(Cellx->AA_REGIONS).c_str() << ","<< mapToString2(Cellx->REGIONS).c_str() << ","<< blks<< ","<< Cellx->BLIMP1 << ","<< Cellx->BCL6<< ","<< Cellx->IRF4<< ","<< Cellx->BLIMP1_0 << ","<< Cellx->BCL6_0<< ","<< Cellx->IRF4_0<< ","<< Cellx->myBCR.BCReceptor[0]<< ","<< Cellx->myBCR.BCReceptor[1]<< ","<< Cellx->myBCR.BCReceptor[2]<< ","<< Cellx->myBCR.BCReceptor[3]<< ","<< Cellx->ORF;
}
void output::Plasma_output(double currentTime, simulation ¤tSim,
parameters &p) {
FILE *Plasma_cells_data;
string folder1 = output_path + "/event_data.csv";
Plasma_cells_data = fopen(folder1.c_str(), "a");
// fprintf(Plasma_cells_data, "%s",
// "ID,Born_time,MID,States,Affinity,N_of_Ags,N_of_divisions,N_of_Mutations,"
// "delta_aff,FDC_interaction_nums,FDC_interaction_time_total,TC_"
// "interaction_time,TC_signaling_time,FDC_selected,Selected_by_TC,Sequence,Protein_Sequence, Status, Mutations, Relevant_NGly_sites, Death_time\n"); ///RRR
// Plasma data
std::stringstream ss;
std::string s;
for (int j = 0; j < currentSim.ListP_cell.size(); j++) {
Plasma_cell *Plasma = currentSim.ListP_cell.at(j);
for(size_t i = 0; i < Plasma->NGly_mutated_sites.size(); ++i)
{
if(i != 0)
ss << "-";
ss << Plasma->NGly_mutated_sites[i];
}
s = ss.str();
ss.str(std::string());
std::stringstream sts;
for(size_t i = 0; i < Plasma->All_NGly_mutated_sites.size(); ++i)
{
if(i != 0)
sts << "-";
sts << Plasma->All_NGly_mutated_sites [i];
}
std::string st = sts.str();
sts.str(std::string());
std::stringstream blk;
for(size_t i = 0; i < Plasma->blacklist_nums.size(); ++i)
{
if(i != 0)
blk << "-";
blk << Plasma->blacklist_nums [i];
}
std::string blks = blk.str();
blk.str(std::string());
fprintf(Plasma_cells_data, "%d,%f,%d,%d,%f,%f,%d,%d,%f,%d,%f,%f,%f,%d,%d,%s,%s,%s,%s,%s,%s,%s,%s,%f,%s,%s,%s,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%d\n",
Plasma->ID, Plasma->birth_time, Plasma->MID,Plasma->cell_state, Plasma->MyAffinity,
Plasma->retained_Ag, Plasma->total_number_of_divisions,
Plasma->myBCR.nMutFromGermline, Plasma->delta_Affinity, Plasma->nFDCcontacts,
Plasma->fdc_interaction_time_history,
Plasma->Tc_interaction_history.first,
Plasma->Tc_interaction_history.second, Plasma->Selected_by_FDC,Plasma->Selected_by_TC,Plasma->germline_name.c_str(), Plasma->sequence.c_str(), Plasma->protein_sequence.c_str(), "Plasma", mapToString(Plasma->MUTATIONS).c_str(), mapToString(Plasma->SILENT_MUTATIONS).c_str(), s.c_str(), st.c_str(),Plasma->depart_time, mapToString2(Plasma->AA_REGIONS).c_str(), mapToString2(Plasma->REGIONS).c_str(), blks.c_str(),Plasma->BLIMP1,Plasma->BCL6,Plasma->IRF4,Plasma->BLIMP1_0,Plasma->BCL6_0,Plasma->IRF4_0,Plasma->myBCR.BCReceptor[0],Plasma->myBCR.BCReceptor[1],Plasma->myBCR.BCReceptor[2],Plasma->myBCR.BCReceptor[3], Plasma->ORF); ///RRR added sequence in fprintf (2 changes)
}
fclose(Plasma_cells_data); //#Recheck take care of bins in gle file
fstream database;
database.open(output_path + "/Sequence_db.csv", fstream::out);
fstream myStream;
for(auto& kv : Seq_affinity) {
database << kv.first << ',' << kv.second[0] << ',' << kv.second[1] << ',' << kv.second[2] << ',' << kv.second[3] << ',' << "\n";
}
database.close();
fstream database2;
database2.open(output_path + "/Restricted_db.csv", fstream::out);
fstream myStream2;
for(auto& kv : Restricted_db) {
for(auto& kv2 : kv.second) {
for(auto& kv3 : kv2.second) {
for(auto& kv4 : kv3.second) {
database2 << kv.first << ',' << kv2.first << ',' << kv3.first << ',' << kv4.first << ',' << kv4.second << ',' << "\n";
////if (kv4.second.compare("")==0) {
////cout << "FALLOnoenEscribir"<<endl;
////}
} }
}
}
database2.close();
fstream databaseCDR;
databaseCDR.open(output_path + "/CDRs_db.csv", fstream::out);
fstream myStreamCDR;
for(auto& kv : CDRs_affinity) {
databaseCDR << kv.first[0] << ',' << kv.first[1] << ',' << kv.first[2] << ',' << kv.second[0] << ',' << kv.second[1] << ',' << kv.second[2] << ',' << kv.second[3] << ',' << "\n";
}
databaseCDR.close();
fstream databaseFWR;
databaseFWR.open(output_path + "/FWRs_db.csv", fstream::out);
fstream myStreamFWR;
for(auto& kv : FWRs_db) {
databaseFWR << kv.first[0] << ',' << kv.first[1] << ',' << kv.second << "\n";
}
databaseFWR.close();
}
///Elena
void output::Memory_output(double currentTime, simulation ¤tSim,
parameters &p) {
// Danial: This function only writes down the data of plasma cells at the end
// of the simulation.
/*The order is
1-Time of production(differetiation)
2-ID
3-ID of mother B-cell
4-Total number of divisions
5-Total amount of Ag
6-Affinity
7-Total number of mutations
*/
FILE *Memory_cells_data;
string folder2 = output_path + "/event_data.csv";
// char *ss1 = const_cast<char*>(folder1.c_str());;
Memory_cells_data = fopen(folder2.c_str(), "a");
std::stringstream ss;
std::string s;
for (int j = 0; j < currentSim.ListM_cell.size(); j++) {
Memory_cell *Memory = currentSim.ListM_cell.at(j);
for(size_t i = 0; i < Memory->NGly_mutated_sites.size(); ++i)
{
if(i != 0)
ss << "-";
ss << Memory->NGly_mutated_sites[i];
}
s = ss.str();
ss.str(std::string());
std::stringstream sts;
for(size_t i = 0; i < Memory->All_NGly_mutated_sites.size(); ++i)
{
if(i != 0)
sts << "-";
sts << Memory->All_NGly_mutated_sites [i];
}
std::string st = sts.str();
sts.str(std::string());
std::stringstream blk;
for(size_t i = 0; i < Memory->blacklist_nums.size(); ++i)
{
if(i != 0)
blk << "-";
blk << Memory->blacklist_nums [i];
}
std::string blks = blk.str();
blk.str(std::string());
fprintf(Memory_cells_data, "%d,%f,%d,%d,%f,%f,%d,%d,%f,%d,%f,%f,%f,%d,%d,%s,%s,%s,%s,%s,%s,%s,%s,%f,%s,%s,%s,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%d\n",
Memory->ID, Memory->birth_time, Memory->MID,Memory->cell_state, Memory->MyAffinity,
Memory->retained_Ag, Memory->total_number_of_divisions,
Memory->myBCR.nMutFromGermline, Memory->delta_Affinity, Memory->nFDCcontacts,
Memory->fdc_interaction_time_history,
Memory->Tc_interaction_history.first,
Memory->Tc_interaction_history.second, Memory->Selected_by_FDC,Memory->Selected_by_TC,Memory->germline_name.c_str(), Memory->sequence.c_str(), Memory->protein_sequence.c_str(), "Memory", mapToString(Memory->MUTATIONS).c_str(), mapToString(Memory->SILENT_MUTATIONS).c_str(), s.c_str(), st.c_str(),Memory->depart_time, mapToString2(Memory->AA_REGIONS).c_str(),mapToString2(Memory->REGIONS).c_str(), blks.c_str(),Memory->BLIMP1,Memory->BCL6,Memory->IRF4,Memory->BLIMP1_0,Memory->BCL6_0,Memory->IRF4_0,Memory->myBCR.BCReceptor[0],Memory->myBCR.BCReceptor[1],Memory->myBCR.BCReceptor[2],Memory->myBCR.BCReceptor[3], Memory->ORF); ///RRR added sequence in fprintf (2 changes)
}
fclose(Memory_cells_data); //#Recheck take care of bins in gle file
fstream database;
database.open(output_path + "/Sequence_db_original.csv", fstream::out);
fstream myStream;
for(auto& kv : Seq_affinity_original) {
database << kv.first << ',' << kv.second[0] << ',' << kv.second[1] << ',' << kv.second[2] << ',' << kv.second[3] << ',' << "\n";
}
database.close();
fstream database2;
database2.open(output_path + "/Restricted_db_original.csv", fstream::out);
fstream myStream2;
for(auto& kv : Restricted_db_original) {
for(auto& kv2 : kv.second) {
for(auto& kv3 : kv2.second) {
for(auto& kv4 : kv3.second) {
database2 << kv.first << ',' << kv2.first << ',' << kv3.first << ',' << kv4.first << ',' << kv4.second << ',' << "\n";
////if (kv4.second.compare("")==0) {
////cout << "FALLOnoenEscribir"<<endl;
////}
} }
}
}
database2.close();
fstream databaseCDR;
databaseCDR.open(output_path +"/CDRs_db_original.csv", fstream::out);
fstream myStreamCDR;
for(auto& kv : CDRs_affinity_original) {
databaseCDR << kv.first[0] << ',' << kv.first[1] << ',' << kv.first[2] << ',' << kv.second[0] << ',' << kv.second[1] << ',' << kv.second[2] << ',' << kv.second[3] << ',' << "\n";
}
databaseCDR.close();
fstream databaseFWR;
databaseFWR.open(output_path +"/FWRs_db_original.csv", fstream::out);
fstream myStreamFWR;
for(auto& kv : FWRs_db_original) {
databaseFWR << kv.first[0] << ',' << kv.first[1] << ',' << kv.second << "\n";
}
databaseFWR.close();
}
///Elena