-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpandora.cpp
2750 lines (2326 loc) · 118 KB
/
pandora.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
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "pandora.h"
#include "atlas.h"
#include <QFile>
#include <QFileInfo>
#include <QTextStream>
#include <QString>
#include <QStringList>
#include <QMessageBox>
#include <qmath.h>
#include <QDateTime>
#include <QDebug>
/*
**********************************************************************************************************
Notes
**********************************************************************************************************
The purpose of the Pandora Class is to be a polyglot of chemical data. There are numerous formats for data files
that include coordinates, charge, velocity of atoms, unit cell dimensions, etc... and that is just for Molecular Dynamics.
Prometheus includes an interface of advanced eFF and Quantum methods, which requires
specialized treatments for electrons and density functionals.
Pandora runs the gamut of file types by housing the processing wrappers within its functions, and then delivering
those inputs (outputs) to (from) the Atlas framework.
Each wrapper function is independent, so this class is easily extended and maintained.
***********************************************************************************************************
*/
extern Atlas prometheusModel;
Pandora::Pandora(QObject *parent) :
QObject(parent)
{
setupLookupTables();
activeModel = 0;
}
// Empty Destructor
Pandora::~Pandora() {}
void Pandora::setupLookupTables()
{
// Setup the atomic number lookup table for data manipulation.
elementLookup.resize(119);
elementLookup[0] = "Ez"; // Element Zero... It's a space holder for this array and an opportunity to honor Mass Effect.
elementLookup[1] = "H";
elementLookup[2] = "He";
elementLookup[3] = "Li";
elementLookup[4] = "Be";
elementLookup[5] = "B";
elementLookup[6] = "C";
elementLookup[7] = "N";
elementLookup[8] = "O";
elementLookup[9] = "F";
elementLookup[10] = "Ne";
elementLookup[11] = "Na";
elementLookup[12] = "Mg";
elementLookup[13] = "Al";
elementLookup[14] = "Si";
elementLookup[15] = "P";
elementLookup[16] = "S";
elementLookup[17] = "Cl";
elementLookup[18] = "Ar";
elementLookup[19] = "K";
elementLookup[20] = "Ca";
elementLookup[21] = "Ti";
elementLookup[22] = "Sc";
elementLookup[23] = "V";
elementLookup[24] = "Cr";
elementLookup[25] = "Mn";
elementLookup[26] = "Fe";
elementLookup[27] = "Co";
elementLookup[28] = "Ni";
elementLookup[29] = "Cu";
elementLookup[30] = "Zn";
elementLookup[31] = "Ga";
elementLookup[32] = "Ge";
elementLookup[33] = "As";
elementLookup[34] = "Se";
elementLookup[35] = "Br";
elementLookup[36] = "Kr";
elementLookup[37] = "Rb";
elementLookup[38] = "Sr";
elementLookup[39] = "Y";
elementLookup[40] = "Zr";
elementLookup[41] = "Nb";
elementLookup[42] = "Mo";
elementLookup[43] = "Tc";
elementLookup[44] = "Ru";
elementLookup[45] = "Rh";
elementLookup[46] = "Pd";
elementLookup[47] = "Ag";
elementLookup[48] = "Cd";
elementLookup[49] = "In";
elementLookup[50] = "Sn";
elementLookup[51] = "Sb";
elementLookup[52] = "Te";
elementLookup[53] = "I";
elementLookup[54] = "Xe";
elementLookup[55] = "Cs";
elementLookup[56] = "Ba";
elementLookup[57] = "La";
elementLookup[58] = "Ce";
elementLookup[59] = "Pr";
elementLookup[60] = "Nd";
elementLookup[61] = "Pm";
elementLookup[62] = "Sm";
elementLookup[63] = "Eu";
elementLookup[64] = "Gd";
elementLookup[65] = "Tb";
elementLookup[66] = "Dy";
elementLookup[67] = "Ho";
elementLookup[68] = "Er";
elementLookup[69] = "Tm";
elementLookup[70] = "Yb";
elementLookup[71] = "Lu";
elementLookup[72] = "Hf";
elementLookup[73] = "Ta";
elementLookup[74] = "W";
elementLookup[75] = "Re";
elementLookup[76] = "Os";
elementLookup[77] = "Ir";
elementLookup[78] = "Pt";
elementLookup[79] = "Au";
elementLookup[80] = "Hg";
elementLookup[81] = "Tl";
elementLookup[82] = "Pb";
elementLookup[83] = "Bi";
elementLookup[84] = "Po";
elementLookup[85] = "At";
elementLookup[86] = "Rn";
elementLookup[87] = "Fr";
elementLookup[88] = "Ra";
elementLookup[89] = "Ac";
elementLookup[90] = "Th";
elementLookup[91] = "Pa";
elementLookup[92] = "U";
elementLookup[93] = "Np";
elementLookup[94] = "Pu";
elementLookup[95] = "Am";
elementLookup[96] = "Cm";
elementLookup[97] = "Bk";
elementLookup[98] = "Cf";
elementLookup[99] = "Es";
elementLookup[100] = "Fm";
elementLookup[101] = "Md";
elementLookup[102] = "No";
elementLookup[103] = "Lr";
elementLookup[104] = "Rf";
elementLookup[105] = "Db";
elementLookup[106] = "Sg";
elementLookup[107] = "Bh";
elementLookup[108] = "Hs";
elementLookup[109] = "Mt";
elementLookup[110] = "Ds";
elementLookup[111] = "Rg";
elementLookup[112] = "Cn";
elementLookup[113] = "Uut";
elementLookup[114] = "Fl";
elementLookup[115] = "Uup";
elementLookup[116] = "Lv";
elementLookup[117] = "Uus";
elementLookup[118] = "Uuo";
// Setup the van der Waals radius lookup table for data manipulation. Atomic Radii are given in Angstroms.
vanderWaalsLookup.resize(119);
vanderWaalsLookup[0] = 0.5;
vanderWaalsLookup[1] = 1.1;
vanderWaalsLookup[2] = 1.4;
vanderWaalsLookup[3] = 1.81;
vanderWaalsLookup[4] = 1.53;
vanderWaalsLookup[5] = 1.92;
vanderWaalsLookup[6] = 1.70;
vanderWaalsLookup[7] = 1.55;
vanderWaalsLookup[8] = 1.52;
vanderWaalsLookup[9] = 1.47;
vanderWaalsLookup[10] = 1.54;
vanderWaalsLookup[11] = 2.27;
vanderWaalsLookup[12] = 1.73;
vanderWaalsLookup[13] = 1.84;
vanderWaalsLookup[14] = 2.10;
vanderWaalsLookup[15] = 1.80;
vanderWaalsLookup[16] = 1.80;
vanderWaalsLookup[17] = 1.75;
vanderWaalsLookup[18] = 1.88;
vanderWaalsLookup[19] = 2.75;
vanderWaalsLookup[20] = 2.31;
vanderWaalsLookup[21] = 2.16;
vanderWaalsLookup[22] = 1.87;
vanderWaalsLookup[23] = 1.79;
vanderWaalsLookup[24] = 1.89;
vanderWaalsLookup[25] = 1.97;
vanderWaalsLookup[26] = 1.94;
vanderWaalsLookup[27] = 1.92;
vanderWaalsLookup[28] = 1.84;
vanderWaalsLookup[29] = 1.86;
vanderWaalsLookup[30] = 2.10;
vanderWaalsLookup[31] = 1.87;
vanderWaalsLookup[32] = 2.11;
vanderWaalsLookup[33] = 1.85;
vanderWaalsLookup[34] = 1.90;
vanderWaalsLookup[35] = 1.83;
vanderWaalsLookup[36] = 2.02;
vanderWaalsLookup[37] = 3.03;
vanderWaalsLookup[38] = 2.49;
vanderWaalsLookup[39] = 2.19;
vanderWaalsLookup[40] = 1.86;
vanderWaalsLookup[41] = 2.07;
vanderWaalsLookup[42] = 2.09;
vanderWaalsLookup[43] = 2.09;
vanderWaalsLookup[44] = 2.07;
vanderWaalsLookup[45] = 1.95;
vanderWaalsLookup[46] = 2.02;
vanderWaalsLookup[47] = 2.03;
vanderWaalsLookup[48] = 2.30;
vanderWaalsLookup[49] = 1.93;
vanderWaalsLookup[50] = 2.17;
vanderWaalsLookup[51] = 2.06;
vanderWaalsLookup[52] = 2.06;
vanderWaalsLookup[53] = 1.98;
vanderWaalsLookup[54] = 2.16;
vanderWaalsLookup[55] = 3.43;
vanderWaalsLookup[56] = 2.68;
vanderWaalsLookup[57] = 2.40;
vanderWaalsLookup[58] = 2.35;
vanderWaalsLookup[59] = 2.39;
vanderWaalsLookup[60] = 2.29;
vanderWaalsLookup[61] = 2.36;
vanderWaalsLookup[62] = 2.29;
vanderWaalsLookup[63] = 2.33;
vanderWaalsLookup[64] = 2.37;
vanderWaalsLookup[65] = 2.21;
vanderWaalsLookup[66] = 2.29;
vanderWaalsLookup[67] = 2.16;
vanderWaalsLookup[68] = 2.35;
vanderWaalsLookup[69] = 2.27;
vanderWaalsLookup[70] = 2.42;
vanderWaalsLookup[71] = 2.21;
vanderWaalsLookup[72] = 2.12;
vanderWaalsLookup[73] = 2.17;
vanderWaalsLookup[74] = 2.10;
vanderWaalsLookup[75] = 2.17;
vanderWaalsLookup[76] = 2.16;
vanderWaalsLookup[77] = 2.02;
vanderWaalsLookup[78] = 2.09;
vanderWaalsLookup[79] = 2.17;
vanderWaalsLookup[80] = 2.09;
vanderWaalsLookup[81] = 1.96;
vanderWaalsLookup[82] = 2.02;
vanderWaalsLookup[83] = 2.07;
vanderWaalsLookup[84] = 1.97;
vanderWaalsLookup[85] = 2.02;
vanderWaalsLookup[86] = 2.20;
vanderWaalsLookup[87] = 3.48;
vanderWaalsLookup[88] = 2.83;
vanderWaalsLookup[89] = 2.60;
vanderWaalsLookup[90] = 2.37;
vanderWaalsLookup[91] = 2.43;
vanderWaalsLookup[92] = 2.40;
vanderWaalsLookup[93] = 2.21;
vanderWaalsLookup[94] = 2.43;
vanderWaalsLookup[95] = 2.44;
vanderWaalsLookup[96] = 2.45;
vanderWaalsLookup[97] = 2.44;
vanderWaalsLookup[98] = 2.45;
vanderWaalsLookup[99] = 2.45;
vanderWaalsLookup[100] = 2.45;
vanderWaalsLookup[101] = 2.46;
vanderWaalsLookup[102] = 2.46;
vanderWaalsLookup[103] = 2.46;
// Data for elements beyond this are not really available... the value of 2.45 A is a somewhat reasonable placeholder.
vanderWaalsLookup[104] = 2.45;
vanderWaalsLookup[105] = 2.45;
vanderWaalsLookup[106] = 2.45;
vanderWaalsLookup[107] = 2.45;
vanderWaalsLookup[108] = 2.45;
vanderWaalsLookup[109] = 2.45;
vanderWaalsLookup[110] = 2.45;
vanderWaalsLookup[111] = 2.45;
vanderWaalsLookup[112] = 2.45;
vanderWaalsLookup[113] = 2.45;
vanderWaalsLookup[114] = 2.45;
vanderWaalsLookup[115] = 2.45;
vanderWaalsLookup[116] = 2.45;
vanderWaalsLookup[117] = 2.45;
vanderWaalsLookup[118] = 2.45;
// Setup the color lookup table for data manipulation. (CPK Color Scheme). Colors given here correspond to a RGB color vector with each element having a
// range of [0,1].
colorLookup.resize(119);
for (int i = 0; i < 119; i++)
{
colorLookup[i].resize(3);
}
// CPK Coloring... Colors beyond the original come from Jmol.
colorLookup[0][0] = 77; colorLookup[0][1] = 234; colorLookup[0][2] = 255;
colorLookup[1][0] = 255; colorLookup[1][1] = 255; colorLookup[1][2] = 255;
colorLookup[2][0] = 217; colorLookup[2][1] = 255; colorLookup[2][2] = 255;
colorLookup[3][0] = 204; colorLookup[3][1] = 128; colorLookup[3][2] = 255;
colorLookup[4][0] = 194; colorLookup[4][1] = 255; colorLookup[4][2] = 0;
colorLookup[5][0] = 255; colorLookup[5][1] = 181; colorLookup[5][2] = 181;
colorLookup[6][0] = 135; colorLookup[6][1] = 135; colorLookup[6][2] = 135;
colorLookup[7][0] = 48; colorLookup[7][1] = 80; colorLookup[7][2] = 248;
colorLookup[8][0] = 255; colorLookup[8][1] = 13; colorLookup[8][2] = 13;
colorLookup[9][0] = 144; colorLookup[9][1] = 224; colorLookup[9][2] = 80;
colorLookup[10][0] = 179; colorLookup[10][1] = 227; colorLookup[10][2] = 245;
colorLookup[11][0] = 171; colorLookup[11][1] = 92; colorLookup[11][2] = 242;
colorLookup[12][0] = 138; colorLookup[12][1] = 255; colorLookup[12][2] = 0;
colorLookup[13][0] = 191; colorLookup[13][1] = 166; colorLookup[13][2] = 166;
colorLookup[14][0] = 240; colorLookup[14][1] = 200; colorLookup[14][2] = 160;
colorLookup[15][0] = 255; colorLookup[15][1] = 128; colorLookup[15][2] = 0;
colorLookup[16][0] = 255; colorLookup[16][1] = 255; colorLookup[16][2] = 48;
colorLookup[17][0] = 31; colorLookup[17][1] = 240; colorLookup[17][2] = 31;
colorLookup[18][0] = 128; colorLookup[18][1] = 209; colorLookup[18][2] = 227;
colorLookup[19][0] = 143; colorLookup[19][1] = 64; colorLookup[19][2] = 212;
colorLookup[20][0] = 61; colorLookup[20][1] = 255; colorLookup[20][2] = 0;
colorLookup[21][0] = 230; colorLookup[21][1] = 230; colorLookup[21][2] = 230;
colorLookup[22][0] = 191; colorLookup[22][1] = 194; colorLookup[22][2] = 199;
colorLookup[23][0] = 166; colorLookup[23][1] = 166; colorLookup[23][2] = 171;
colorLookup[24][0] = 138; colorLookup[24][1] = 153; colorLookup[24][2] = 199;
colorLookup[25][0] = 156; colorLookup[25][1] = 122; colorLookup[25][2] = 199;
colorLookup[26][0] = 224; colorLookup[26][1] = 102; colorLookup[26][2] = 51;
colorLookup[27][0] = 240; colorLookup[27][1] = 144; colorLookup[27][2] = 160;
colorLookup[28][0] = 80; colorLookup[28][1] = 208; colorLookup[28][2] = 80;
colorLookup[29][0] = 200; colorLookup[29][1] = 128; colorLookup[29][2] = 51;
colorLookup[30][0] = 125; colorLookup[30][1] = 128; colorLookup[30][2] = 176;
colorLookup[31][0] = 194; colorLookup[31][1] = 143; colorLookup[31][2] = 143;
colorLookup[32][0] = 102; colorLookup[32][1] = 143; colorLookup[32][2] = 143;
colorLookup[33][0] = 189; colorLookup[33][1] = 128; colorLookup[33][2] = 227;
colorLookup[34][0] = 255; colorLookup[34][1] = 161; colorLookup[34][2] = 0;
colorLookup[35][0] = 166; colorLookup[35][1] = 41; colorLookup[35][2] = 41;
colorLookup[36][0] = 92; colorLookup[36][1] = 184; colorLookup[36][2] = 209;
colorLookup[37][0] = 112; colorLookup[37][1] = 46; colorLookup[37][2] = 176;
colorLookup[38][0] = 0; colorLookup[38][1] = 255; colorLookup[38][2] = 0;
colorLookup[39][0] = 148; colorLookup[39][1] = 255; colorLookup[39][2] = 255;
colorLookup[40][0] = 148; colorLookup[40][1] = 224; colorLookup[40][2] = 224;
colorLookup[41][0] = 115; colorLookup[41][1] = 194; colorLookup[41][2] = 201;
colorLookup[42][0] = 84; colorLookup[42][1] = 181; colorLookup[42][2] = 181;
colorLookup[43][0] = 59; colorLookup[43][1] = 158; colorLookup[43][2] = 158;
colorLookup[44][0] = 36; colorLookup[44][1] = 143; colorLookup[44][2] = 143;
colorLookup[45][0] = 10; colorLookup[45][1] = 125; colorLookup[45][2] = 140;
colorLookup[46][0] = 0; colorLookup[46][1] = 105; colorLookup[46][2] = 133;
colorLookup[47][0] = 192; colorLookup[47][1] = 192; colorLookup[47][2] = 192;
colorLookup[48][0] = 255; colorLookup[48][1] = 217; colorLookup[48][2] = 143;
colorLookup[49][0] = 166; colorLookup[49][1] = 117; colorLookup[49][2] = 115;
colorLookup[50][0] = 102; colorLookup[50][1] = 128; colorLookup[50][2] = 128;
colorLookup[51][0] = 158; colorLookup[51][1] = 99; colorLookup[51][2] = 181;
colorLookup[52][0] = 212; colorLookup[52][1] = 122; colorLookup[52][2] = 0;
colorLookup[53][0] = 148; colorLookup[53][1] = 0; colorLookup[53][2] = 148;
colorLookup[54][0] = 66; colorLookup[54][1] = 158; colorLookup[54][2] = 176;
colorLookup[55][0] = 87; colorLookup[55][1] = 23; colorLookup[55][2] = 143;
colorLookup[56][0] = 0; colorLookup[56][1] = 201; colorLookup[56][2] = 0;
colorLookup[57][0] = 112; colorLookup[57][1] = 212; colorLookup[57][2] = 255;
colorLookup[58][0] = 255; colorLookup[58][1] = 255; colorLookup[58][2] = 199;
colorLookup[59][0] = 217; colorLookup[59][1] = 255; colorLookup[59][2] = 199;
colorLookup[60][0] = 199; colorLookup[60][1] = 255; colorLookup[60][2] = 199;
colorLookup[61][0] = 163; colorLookup[61][1] = 255; colorLookup[61][2] = 199;
colorLookup[62][0] = 143; colorLookup[62][1] = 255; colorLookup[62][2] = 199;
colorLookup[63][0] = 97; colorLookup[63][1] = 255; colorLookup[63][2] = 199;
colorLookup[64][0] = 69; colorLookup[64][1] = 255; colorLookup[64][2] = 199;
colorLookup[65][0] = 48; colorLookup[65][1] = 255; colorLookup[65][2] = 199;
colorLookup[66][0] = 31; colorLookup[66][1] = 255; colorLookup[66][2] = 199;
colorLookup[67][0] = 0; colorLookup[67][1] = 255; colorLookup[67][2] = 156;
colorLookup[68][0] = 0; colorLookup[68][1] = 230; colorLookup[68][2] = 117;
colorLookup[69][0] = 0; colorLookup[69][1] = 212; colorLookup[69][2] = 82;
colorLookup[70][0] = 0; colorLookup[70][1] = 191; colorLookup[70][2] = 56;
colorLookup[71][0] = 0; colorLookup[71][1] = 171; colorLookup[71][2] = 36;
colorLookup[72][0] = 77; colorLookup[72][1] = 194; colorLookup[72][2] = 255;
colorLookup[73][0] = 77; colorLookup[73][1] = 166; colorLookup[73][2] = 255;
colorLookup[74][0] = 33; colorLookup[74][1] = 148; colorLookup[74][2] = 214;
colorLookup[75][0] = 38; colorLookup[75][1] = 125; colorLookup[75][2] = 171;
colorLookup[76][0] = 38; colorLookup[76][1] = 102; colorLookup[76][2] = 150;
colorLookup[77][0] = 23; colorLookup[77][1] = 84; colorLookup[77][2] = 135;
colorLookup[78][0] = 208; colorLookup[78][1] = 208; colorLookup[78][2] = 224;
colorLookup[79][0] = 255; colorLookup[79][1] = 209; colorLookup[79][2] = 35;
colorLookup[80][0] = 184; colorLookup[80][1] = 184; colorLookup[80][2] = 208;
colorLookup[81][0] = 166; colorLookup[81][1] = 84; colorLookup[81][2] = 77;
colorLookup[82][0] = 87; colorLookup[82][1] = 89; colorLookup[82][2] = 97;
colorLookup[83][0] = 158; colorLookup[83][1] = 79; colorLookup[83][2] = 181;
colorLookup[84][0] = 171; colorLookup[84][1] = 92; colorLookup[84][2] = 0;
colorLookup[85][0] = 117; colorLookup[85][1] = 79; colorLookup[85][2] = 69;
colorLookup[86][0] = 66; colorLookup[86][1] = 130; colorLookup[86][2] = 150;
colorLookup[87][0] = 66; colorLookup[87][1] = 0; colorLookup[87][2] = 102;
colorLookup[88][0] = 0; colorLookup[88][1] = 125; colorLookup[88][2] = 0;
colorLookup[89][0] = 112; colorLookup[89][1] = 171; colorLookup[89][2] = 250;
colorLookup[90][0] = 0; colorLookup[90][1] = 186; colorLookup[90][2] = 255;
colorLookup[91][0] = 0; colorLookup[91][1] = 161; colorLookup[91][2] = 255;
colorLookup[92][0] = 0; colorLookup[92][1] = 143; colorLookup[92][2] = 255;
colorLookup[93][0] = 0; colorLookup[93][1] = 128; colorLookup[93][2] = 255;
colorLookup[94][0] = 0; colorLookup[94][1] = 107; colorLookup[94][2] = 255;
colorLookup[95][0] = 84; colorLookup[95][1] = 92; colorLookup[95][2] = 242;
colorLookup[96][0] = 120; colorLookup[96][1] = 92; colorLookup[96][2] = 227;
colorLookup[97][0] = 138; colorLookup[97][1] = 79; colorLookup[97][2] = 227;
colorLookup[98][0] = 161; colorLookup[98][1] = 54; colorLookup[98][2] = 212;
colorLookup[99][0] = 179; colorLookup[99][1] = 31; colorLookup[99][2] = 212;
colorLookup[100][0] = 179; colorLookup[100][1] = 31; colorLookup[100][2] = 186;
colorLookup[101][0] = 179; colorLookup[101][1] = 13; colorLookup[101][2] = 166;
colorLookup[102][0] = 189; colorLookup[102][1] = 13; colorLookup[102][2] = 135;
colorLookup[103][0] = 199; colorLookup[103][1] = 0; colorLookup[103][2] = 102;
colorLookup[104][0] = 204; colorLookup[104][1] = 0; colorLookup[104][2] = 89;
colorLookup[105][0] = 209; colorLookup[105][1] = 0; colorLookup[105][2] = 79;
colorLookup[106][0] = 217; colorLookup[106][1] = 0; colorLookup[106][2] = 69;
colorLookup[107][0] = 224; colorLookup[107][1] = 0; colorLookup[107][2] = 56;
colorLookup[108][0] = 230; colorLookup[108][1] = 0; colorLookup[108][2] = 46;
colorLookup[109][0] = 235; colorLookup[109][1] = 0; colorLookup[109][2] = 38;
colorLookup[110][0] = 255; colorLookup[110][1] = 0; colorLookup[110][2] = 0;
colorLookup[111][0] = 255; colorLookup[111][1] = 0; colorLookup[111][2] = 0;
colorLookup[112][0] = 255; colorLookup[112][1] = 0; colorLookup[112][2] = 0;
colorLookup[113][0] = 255; colorLookup[113][1] = 0; colorLookup[113][2] = 0;
colorLookup[114][0] = 255; colorLookup[114][1] = 0; colorLookup[114][2] = 0;
colorLookup[115][0] = 255; colorLookup[115][1] = 0; colorLookup[115][2] = 0;
colorLookup[116][0] = 255; colorLookup[116][1] = 0; colorLookup[116][2] = 0;
colorLookup[117][0] = 255; colorLookup[117][1] = 0; colorLookup[117][2] = 0;
colorLookup[118][0] = 255; colorLookup[118][1] = 0; colorLookup[118][2] = 0;
}
void Pandora::parseDataFile(QString fileType, QString fileName)
{
// This function takes the file extension and assigns a function capable
// of parsing the text file. If it finds none, it sends a signal back to "MainWindow"
// so it can display the appropriate warning.
if (fileType == "All File Types (*.*)")
{
QFileInfo file(fileName);
fileType = file.suffix();
}
if (fileType == "bgf" | fileType == "BIOGRF File (*.bgf)")
{
parseBGF(fileName);
}
// else if (fileType == "cif")
// {
// }
// else if (fileType == "cml")
// {
// }
else if (fileType == "lammps")
{
parseLammpsInput(fileName);
}
// else if (fileType == "lmpstrj")
// {
// parseLammpsTracjectory(fileName);
// }
// else if (fileType == "mol")
// {
// }
// else if (fileType == "mol2")
// {
// }
// else if (fileType == "msi")
// {
// }
// else if (fileType == "pdb")
// {
// }
// else if (fileType == "xyz")
// {
// }
else
{
// The file is either unknown or is currently unsupported. Warn the user.
QString message = "Apologies. The selected data file format *." + fileType + " is currently unsupported.";
pandoraError(message);
}
}
void Pandora::writeDataFile(QString fileType, QString fileName)
{
// This function takes the file extension and assigns a function capable
// of writing the text file containing the chemical data. If it finds none, it sends a signal back to "MainWindow"
// so it can display the appropriate warning.
//Pandora input; // create an instance of Pandora so we can call the specific function we need.
if (fileType == "BIOGRF File (*.bgf)")
{
writeBGF(fileName);
}
// else if (fileType == "cif")
// {
// }
// else if (fileType == "cml")
// {
// }
else if (fileType == "LAMMPS Input File (*.lammps)")
{
writeLammpsInput(fileName);
}
// else if (fileType == "mol")
// {
// }
// else if (fileType == "mol2")
// {
// }
// else if (fileType == "msi")
// {
// }
// else if (fileType == "pdb")
// {
// }
// else if (fileType == "xyz")
// {
// }
else
{
// The filetype is either unknown or is currently unsupported. Warn the user.
QString message = "Apologies. The selected data file format " + fileType + " is currently unsupported.";
pandoraError(message);
}
}
void Pandora::pandoraError(QString message)
{
QMessageBox error;
error.setIcon(QMessageBox::Critical);
error.setText(message);
error.exec();
}
void Pandora::pandoraInfo(QString message)
{
QMessageBox info;
info.setIcon(QMessageBox::Information);
info.setText(message);
info.exec();
}
/******************************************************************************************************************
* File Parsing Functions
******************************************************************************************************************/
void Pandora::parseBGF(QString fileName)
{
//**************************************************************************************
// Purpose: This function is able to parse chemical data files adhering to BIOGRAF (.bgf)
// formatting. The format is detailed, storing atom position, atom type, force field type,
// partial charge, chain and residue identity, and bond connectivity. The format is also
// self-referencing, with headers that describe the function of each line, as well as the
// fixed-width of each column.
//**************************************************************************************
QFile file (fileName);
QTextStream inputFile (&file);
QStringList lineArray;
QString line, line2, widthCatcher, fieldCatcher, fieldCatcher2;
QMessageBox cout;
bool periodicity;
QVector<int> atomColumnWidths, bondColumnWidths, bondLoader;
QString::Iterator iter;
QVector<QVector<int> > bondDuplicateTally;
int atomCount, atomicNumber, atomID, bondOrder, bookmark, corrector, primaryAtom, secondaryAtom;
bool whiteSpaceFound, widthStart, valueFound;
atomColumnWidths.resize(21);
bondColumnWidths.resize(3);
// Throughout the file, the first item on each line indicates the data contained on that line.
// So, we need only grab that first keyword, and we can assign that data into the Prometheus framework.
// But first, we must count the number of atoms within the file and allocate memory appropriately.
atomCount = 0;
file.open(QIODevice::ReadOnly|QIODevice::Text);
while(!inputFile.atEnd())
{
line = inputFile.readLine(); // String that holds the whole line
lineArray = line.split(" "); // StringList breaks the string along white spaces... this lets us look at the keyword.
// The label associated with atomic data is either "HETATM" or "ATOM". Count these.
if (lineArray[0] == "HETATM" || lineArray[0] == "ATOM")
{
++atomCount;
}
}
//close the file and allocate memory for the model.
file.close();
periodicity = false; // take this out when we improve file reading.
prometheusModel.createModel(atomCount, periodicity);
bondDuplicateTally.resize(atomCount);
for (int i = 0; i < atomCount; ++i)
{
bondDuplicateTally[i].clear();
}
// Re-open the file for a proper read that parses the data and loads it into the model.
file.open(QIODevice::ReadOnly | QIODevice::Text);
while (!inputFile.atEnd())
{
line = inputFile.readLine(); // String that holds the whole line.
lineArray = line.split(" ",QString::SkipEmptyParts); // StringList breaks the string along white spaces... this lets us look at the keyword.
if (lineArray[0] == "FORMAT")
{
// This line indicates that it contains the legend for reading the fixed-column format for this file.
// The following code is vulnerable... it breaks if there is even a single white-space in the format definition section. First, we heal
// any whitespaces, by placing the pieces into the same element.
if (lineArray.size() > 3)
{
line.clear();
for(int i = 2; i < lineArray.size(); i++)
{
line.append(lineArray[i]);
}
lineArray[2] = line;
}
if (lineArray[1] == "ATOM" | lineArray[1] == "HETATM")
{
// This line contains the formatting for the data under the HETATM or ATOM headers (position, charge, etc)
// The formatting information is (ironically) formatted somewhat obtusely to save space. Isolate the string that contains
// relevant data and split it using commas as delimiters.
line = lineArray[2];
lineArray = line.split(",");
// The general format is:
// [Multiplier - (optional) states the number of times the following is about to occur]
// followed by [Identifier - states what this field's type is: a = string, i = integer, f = float (see below), x = whitespace]
// followed by [Field Width - states the number of characters this field occupies]
// followed by [Decimal Place - (optional) for float representation, the number of places after the decimal is given after a period]
// Example: to show a representation of three position components, represented as float numbers, and with no spaces between columns
// that are 10 characters wide each, and with a precision of 5 digits after the decimal ----> use 3f10.5
// Very concise, but kinda annoying.
// The multiplier only applies to coordinate data. Only coordinate and partial charge data require float type values, so only they
// will use the decimal precision flag.
// Iterate over the fields... 21 in total.
// 0) BGF Keyword ID [string] 2) Atom Number[int] 4) Atom Label[string] 6) Residue Name[string]
// 8) Chain Designation [int] 10) Residue Number[int] 12) Atom Position Coordinates in Angstrom[float]
// 14) Atom Type from Force Field[string] 16) Max Number of Bonds [int] 18) Number of Lone Electron Pairs [int]
// 20) Partial Charge [float]
// The missing fields designate the width of whitespace between the above fields. They are optional, but must be accounted for.
// If we come accross a missing whitespace flag, we need to not get ahead of ourselves reading the
// line, so "corrector" will keep track and allow us to read the correct field if we've discovered a missing
// whitespace flag field.
corrector = 0;
for (int i = 0; i < 21; i = i + 2)
{
widthCatcher.clear();
if (i != 12 && i != 20)
{
// Most fields will use this section.
// Iterate over the characters in this field.
for (iter = lineArray[i - corrector].begin(); iter != lineArray[i - corrector].end(); ++iter)
{
// Ignore parentheses and letters to grab the any numeral characters...
if (*iter != '(' && *iter != ')' && *iter != 'a' && *iter != 'f' && *iter != 'i' && *iter != 'x')
{
// pile these characters together into a string for conversion.
widthCatcher.append(*iter);
}
}
// Store the field width as an integer.
atomColumnWidths[i] = widthCatcher.toInt();
}
else
{
// We must take more care in the fields that give formatting for position and partial charge data.
widthStart = false;
// Iterate over the characters in this field.
for (iter = lineArray[i - corrector].begin(); iter != lineArray[i - corrector].end(); ++iter)
{
if (widthStart && *iter != '.')
{
// pile the characters between the 'f' and the '.' into a string for conversion.
widthCatcher.append(*iter);
}
// These functions will control the switches that pile the characters into their proper strings for conversion.
if (*iter == 'f')
{
widthStart = true;
}
if (*iter == '.')
{
widthStart = false;
}
}
// Store the field width as an integer.
atomColumnWidths[i] = widthCatcher.toInt();
}
// Move on the the next field. This should contain the width of the whitespace between fields.
// However, its existance is optional. To make matters worse, it doesn't start with an identifier, but
// rather the width of the whitespace. The identifer 'x' comes after the number. Generally, the width should be 1.
// Also, skip this section if we've made it to the partial charge field (i = 20)
widthCatcher.clear();
if (i != 20)
{
// Iterate over the characters in this field.
for (iter = lineArray[i+1 - corrector].begin(); iter != lineArray[i+1 - corrector].end(); ++iter)
{
// Ignore parentheses and letters for now to grab the any numeral characters...
if (*iter != ')' && *iter != 'a' && *iter != 'f' && *iter != 'i' && *iter != 'x')
{
// pile these characters together into a string for conversion.
widthCatcher.append(*iter);
}
else if (*iter == 'a' || *iter == 'f' || *iter == 'i')
{
// This field does not describe a whitespace.
whiteSpaceFound = false;
}
else if (*iter == 'x')
{
// This field describes a whitespace.
whiteSpaceFound = true;
}
}
// Store the field width as an integer.
if (whiteSpaceFound)
{
// Store the width that we found (generally 1)
atomColumnWidths[i+1] = widthCatcher.toInt();
}
else
{
// There is no whitespace, and we need to know to not include any when we are counting
// characters below. Also, we were searching for whitespace field information, so we
// must make sure we re-read this field and store its width in the appropriate location.
// the corrector will adjust the iterator so we do not read out of range of the "lineArray".
atomColumnWidths[i+1] = 0;
++corrector;
}
}
}
}
else if (lineArray[1] == "CONECT")
{
// This line contains the formmating for the data under the "CONECT" header (atom connectivity)
// Once more, the line is formatted in a way that is difficult to parse. However, there is much less to deal with, so this is pretty easy.
// Isolate the string that contains relevant data and split it using commas as delimiters.
line = lineArray[2];
lineArray = line.split(",");
// The first field denotes a text field that contains the label "CONECT". The second specifies which atom is being described, as identified by
// its atom number (integer). All other fields identify atoms that are connected to the first one. In general, there are no spaces between the
// fields, and the width of each field (besides the label CONECT) can be specfied with the multiplier 12.
// iterate over the characters in the first field.
widthCatcher.clear();
for (iter = lineArray[0].begin(); iter != lineArray[0].end(); ++iter)
{
// Grab only numeral characters.
if (*iter != '(' && *iter != 'a' && *iter != ' ')
{
// Pile these together into a string for conversion.
widthCatcher.append(*iter);
}
}
// Store the field width as an integer.
bondColumnWidths[0] = widthCatcher.toInt();
// Now move onto the second field. We'll need to grab the multiplier first (usually 12).
// Iterate over the characters of the second field.
widthCatcher.clear();
for (iter = lineArray[1].begin(); iter != lineArray[1].end(); ++iter)
{
if (*iter == 'i') break; // exit once we hit the integer identifer. We have captured the multiplier fully.
widthCatcher.append(*iter);
}
// Store the multiplier as an integer.
bondColumnWidths[1] = widthCatcher.toInt();
// Now get the width of the fields that hold these atom numbers.
widthCatcher.clear();
widthStart = false;
for (iter = lineArray[1].begin(); iter != lineArray[1].end(); ++iter)
{
// Grab only the numeral character(s).
if (widthStart && *iter != ')')
{
// Pile the characters together in a string for conversion.
widthCatcher.append(*iter);
}
// watch for the identifier that will denote the width information.
if (*iter == 'i') widthStart = true;
}
// Store the width as an integer.
bondColumnWidths[2] = widthCatcher.toInt();
}
}
else if (lineArray[0] == "HETATM" || lineArray[0] == "ATOM")
{
// These lines contain the actual data related to the atoms themselves. We established the column widths earlier, so we
// can just chop these lines up accordingly and grab what we find. We use an integer variable to keep a running count
// of where we are reading in the string... remember we cannot rely on whitespaces to give us each token.
bookmark = 0; // our placeholder in this string.
// BGF Label field... basically just skip over this and the optional whitespace that follows it.
bookmark += atomColumnWidths[0] + atomColumnWidths[1];
// Atom ID number... assumes that the atomID numbers are presented in order. We'll need this for the set functions of the Atlas Class.
fieldCatcher.clear();
for (int i = bookmark; i < bookmark + atomColumnWidths[2]; ++i)
{
fieldCatcher.append(line[i]);
}
// This value is used to order all other atom properties.
atomID = fieldCatcher.toInt();
bookmark += atomColumnWidths[2] + atomColumnWidths[3];
// Atom Name... This is a string, usually an atomic symbol followed by number.
fieldCatcher.clear();
for (int i = bookmark; i < bookmark + atomColumnWidths[4]; ++i)
{
fieldCatcher.append(line[i]);
}
prometheusModel.setAtomName(atomID, fieldCatcher);
bookmark += atomColumnWidths[4] + atomColumnWidths[5];
// Residue Name... This is a string, generally 3 letters that identifies a structural element of a model (monomer, amino acid, etc)
fieldCatcher.clear();
for (int i = bookmark; i < bookmark + atomColumnWidths[6]; ++i)
{
fieldCatcher.append(line[i]);
}
prometheusModel.setAtomResidueName(atomID, fieldCatcher);
bookmark += atomColumnWidths[6] + atomColumnWidths[7];
// Chain Identifier... This is a string, all captial letters, that identifies a chain to which the atom belongs.
fieldCatcher.clear();
for (int i = bookmark; i < bookmark + atomColumnWidths[8]; ++i)
{
fieldCatcher.append(line[i]);
}
prometheusModel.setAtomChainName(atomID, fieldCatcher);
bookmark += atomColumnWidths[8] + atomColumnWidths[9];
// Residue Number... This is an integer. Beyond identifying struture types, we also give them a number to ID that specific subunit.
fieldCatcher.clear();
for (int i = bookmark; i < bookmark + atomColumnWidths[10]; ++i)
{
fieldCatcher.append(line[i]);
}
prometheusModel.setAtomResidueNumber(atomID, fieldCatcher.toInt());
bookmark += atomColumnWidths[10] + atomColumnWidths[11];
// Atomic Position in Cartesian coordinates. Here, we cover fields for X, Y, and Z components given in float format.
// We take the width of the field multiplied by three to capture each component. We assume there are no whitespaces here.
fieldCatcher.clear();
for (int i = bookmark; i < bookmark + atomColumnWidths[12]; ++i)
{
fieldCatcher.append(line[i]);
}
prometheusModel.setAtomPositionX(atomID, fieldCatcher.toFloat());
bookmark += atomColumnWidths[12];
fieldCatcher.clear();
for (int i = bookmark; i < bookmark + atomColumnWidths[12]; ++i)
{
fieldCatcher.append(line[i]);
}
prometheusModel.setAtomPositionY(atomID, fieldCatcher.toFloat());
bookmark += atomColumnWidths[12];
fieldCatcher.clear();
for (int i = bookmark; i < bookmark + atomColumnWidths[12]; ++i)
{
fieldCatcher.append(line[i]);
}
prometheusModel.setAtomPositionZ(atomID, fieldCatcher.toFloat());
bookmark += atomColumnWidths[12] + atomColumnWidths[13];
// Force Field Type... This is a string. This indicates the type of atom as labeled by a particular force field.
// Therefore, this assigns the parameters used in later calcuations.
fieldCatcher.clear();
for (int i = bookmark; i < bookmark + atomColumnWidths[14]; ++i)
{
fieldCatcher.append(line[i]);
}
prometheusModel.setAtomForceFieldType(atomID, fieldCatcher);
bookmark += atomColumnWidths[14] + atomColumnWidths[15];
// Determine the element this atom represents from the force field type provided.
atomicNumber = findAtomicNumber(fieldCatcher);
prometheusModel.setAtomAtomicNumber(atomID, atomicNumber);
// Maximum Number of Covalent Bonds... This is an integer. It is possible this number could be useful adjusting hydrogens in the model.
fieldCatcher.clear();
for (int i = bookmark; i < bookmark + atomColumnWidths[16]; ++i)
{
fieldCatcher.append(line[i]);
}
prometheusModel.setAtomMaxCovalentBonds(atomID, fieldCatcher.toInt());
bookmark += atomColumnWidths[16] + atomColumnWidths[17];
// Number of Electron Lone Pairs... This is an integer.
fieldCatcher.clear();
for (int i = bookmark; i < bookmark + atomColumnWidths[18]; ++i)
{
fieldCatcher.append(line[i]);
}
prometheusModel.setAtomNumberOfLonePairs(atomID, fieldCatcher.toInt());
bookmark += atomColumnWidths[18] + atomColumnWidths[19];
// Partial Charge... This is a float type number.
fieldCatcher.clear();
for (int i = bookmark; i < bookmark + atomColumnWidths[20]; ++i)
{
fieldCatcher.append(line[i]);
}
prometheusModel.setAtomPartialCharge(atomID, fieldCatcher.toFloat());
}
else if (lineArray[0] == "CONECT")
{
// Lines under this header contain atoms that are bonded. The first field indicates the primary atom of interest.
// The following fields indicate atoms bonded to the primary atom. This representation results in redundancies, specifically,
// each bond is noted in two places.
// Also, each line is paired with a second line just after this one, containing bond order information. Under each bond entry, there
// is a number 1, 2, or 3, signifying a single, double, or triple bond, respectively. Though the header is ORDER, the format is identical to
// CONECT... so when we read in the bond information, but we must check each entry for duplication against a tally we maintain, and when we find a
// unique entry, we also grab its corresponding bond order.
// grab the ORDER line.
line2 = inputFile.readLine(); // String that holds the whole line... the ORDER line.
bookmark = bondColumnWidths[0]; // our placeholder in this string. Ignore the CONECT/ORDER header since we are already aware of it.