-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgraph_info.py
877 lines (715 loc) · 39.5 KB
/
graph_info.py
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
from operator import index
import networkx as nx
import numpy as np
def metal_index(G):
"""Identify the metal center in the graph by its atomic number. Provide
its node index.
Args:
G (networkx graph class): Graph read by networkx
Returns:
int: metal node index
"""
# metal atomic numbers
period_4 = [i for i in range(21,31)]
period_5 = [i for i in range(39, 49)]
period_6 = [i for i in range(57,58)] + [i for i in range(72, 81)]
period_7 = [i for i in range(89,90)] + [i for i in range(104,109)]
metals = [*period_4, *period_5, *period_6, *period_7]
atomic_numbers = []
for node in G.nodes():
# save the atomic numbers of the graph
atomic_numbers.append(G.nodes[node]["feature_atomic_number"])
# identify the metal atomic number of the graph
metal_number = [atomic_num for atomic_num in atomic_numbers
if atomic_num in metals]
# find the metal node index
idx_metal = atomic_numbers.index(metal_number[0])
return idx_metal
def node_info(G, depth_max, idx):
"""Create a dictionary for each graph where the keys are the depths and,
the values are the nodes in those depths
Args:
G (networkx graph class): Graph read by networkx
depth_max (int): Maximum distance to read the graph
idx (int): Node index set as the starting node
Returns:
dict: per each graph at the selected depth
"""
# save the already read nodes index per iteration
historical_nodes = []
historical_nodes.append(str(idx))
# create a dict at depth = 0
node_dict = dict()
origin = 0
keys = origin
values = [str(idx)]
node_dict[keys] = values
for depth in range(depth_max):
# save the node indexes at depth = 1
if depth == 0:
depth = depth + 1
node_neighbors_idx = [n for n in G.neighbors(str(idx))]
node_dict[depth] = node_neighbors_idx
historical_nodes.extend(node_neighbors_idx)
# save the node indexes at depth > 1
else:
node_neighbors_depth = []
for node in node_dict[depth]:
node_neighbors = [n for n in G.neighbors(node) \
if n not in historical_nodes]
node_neighbors_depth.extend(node_neighbors)
historical_nodes.extend(node_neighbors)
node_dict[depth + 1] = list(set(node_neighbors_depth))
depth = depth + 1
return node_dict
def edge_info(G, depth_max, idx):
"""Create a dictionary for each graph where the keys are the depths and,
the values are the edges in those depths starting from one new defined edge
Args:
G (networkx graph class): Graph read by networkx
depth_max (int): Maximum distance to read the graph
index (int): Node index set as the starting node
Returns:
dict: per each graph at the selected depth
"""
# save the already read node indexes per iteration
historical_nodes = []
historical_nodes.append(str(idx))
edge_dict = dict()
for depth in range(depth_max + 1):
# save the edge index at depth = 0
if depth == 0:
node_neighbors = []
edge_neighbors_idx = [G.edges(str(idx))]
edges_idx = [(node1, node2) for edge in edge_neighbors_idx
for node1, node2 in edge]
edges_format_idx = [(node1, node2, 0) for edge in edge_neighbors_idx
for node1, node2 in edge]
edge_dict[depth] = edges_format_idx
for edge in edges_idx:
# save the node indexes of the edge except the starting node index
node1, node2 = edge
if node1 != str(idx):
node_neighbors.append(node1)
if node2 != str(idx):
node_neighbors.append(node2)
node_neighbors = list(set(node_neighbors))
# save the edge indexes at depth > 0
else:
edges_depth, edges_format_depth = [], []
for node in node_neighbors:
edge_neighbors = [G.edges(node)]
for edge in edge_neighbors:
for node1, node2 in edge:
if node1 not in historical_nodes and node1 != node2:
if node2 not in historical_nodes and node2 != node1:
new_edge = (node1, node2)
new_edge_format = (node1, node2, 0)
edges_depth.append(new_edge)
edges_format_depth.append(new_edge_format)
historical_nodes.append(node)
edge_dict[depth] = edges_format_depth
# save the non-walked node indexes yet
active_nodes = []
for edge in edges_depth:
node1, node2 = edge
if node1 not in historical_nodes:
active_nodes.append(node1)
if node2 not in historical_nodes:
active_nodes.append(node2)
node_neighbors = active_nodes
depth = depth + 1
return edge_dict
def new_edge_info(G, depth_max, idx_edge):
"""Create a dictionary for each graph where the keys are the depths and,
the values are the edges in those depths starting from a specific idx_edge
Args:
G (networkx graph class): Graph read by networkx
depth_max (int): Maximum distance to read the graph
idx_edge (tuple): Edge index set as the starting edge
Returns:
dict: per each graph at the selected depth
"""
# save the starting edge index
(node1_idx, node2_idx) = idx_edge
idx_edge_rev = (node2_idx, node1_idx)
historical_edges = [idx_edge]
historical_edges.append(idx_edge_rev)
historical_nodes = []
# create a dict at depth = 0
edge_dict = dict()
origin = 0
keys = origin
values = (node1_idx, node2_idx, 0)
edge_dict[keys] = values
for depth in range(depth_max):
# save the edge indexes at depth = 1
if depth == 0:
depth = depth + 1
node1_idx, node2_idx = idx_edge
historical_nodes = [node1_idx]
historical_nodes.append(node2_idx)
# save the neighbor edge indexes of the starting edge
edge_neighbors_idx_1 = [n for n in G.edges(node1_idx)]
edge_neighbors_idx_2 = [n for n in G.edges(node2_idx)]
edge_neighbors_idx_sum = edge_neighbors_idx_1 + edge_neighbors_idx_2
edge_neighbors_idx = [edge for edge in edge_neighbors_idx_sum
if edge not in historical_edges]
edges_format_idx = []
node_neighbors = []
for edge in edge_neighbors_idx:
# save the read edge indexes
node1, node2 = edge
edges_format_idx.append((node1, node2, 0))
if node1 not in historical_nodes:
node_neighbors.append(node1)
if node2 not in historical_nodes:
node_neighbors.append(node2)
node_neighbors = list(set(node_neighbors))
edge_rev = (node2, node1)
historical_edges.append(edge)
historical_edges.append(edge_rev)
edge_dict[depth] = edges_format_idx
# save the edges at depth > 1
else:
historical_nodes.extend(node_neighbors)
edge_neighbors = [edge for edge in G.edges(node_neighbors)
if edge not in historical_edges]
edges_format = []
active_nodes = []
for edge in edge_neighbors:
# save the read edge indexes
node1, node2 = edge
edges_format.append((node1, node2, 0))
# save the non-walked node indexes yet
if node1 not in historical_nodes:
active_nodes.append(node1)
if node2 not in historical_nodes:
active_nodes.append(node2)
active_nodes = list(set(active_nodes))
edge_rev = (node2, node1)
historical_edges.append(edge)
historical_edges.append(edge_rev)
edge_dict[depth + 1] = edges_format
node_neighbors = active_nodes
depth = depth + 1
return edge_dict
def gp_new_edge_attribute(G, model_number, node_dict):
"""Define new edge attributes according to the selected model
Args:
G (networkx graph class): Graph read by networkx
model_number (int): Type of new edge attribute
node_dict (dict): Depth as keys and nodes as values
Returns:
list: List of new edge features
"""
# dictionary for new attributes
for edge in G.edges(G):
# sort nodes of in the edges by their depths (in node_dict)
node_i, node_j = edge
depth_a = [k for (k, v) in node_dict.items() if node_i in v]
depth_b = [k for (k, v) in node_dict.items() if node_j in v]
if depth_a < depth_b:
edge = node_i, node_j
if depth_b < depth_a:
edge = node_j, node_i
node1, node2 = edge
# get the new edge features
Z_1 = G.nodes[node1]['feature_atomic_number']
Z_2 = G.nodes[node2]['feature_atomic_number']
T_1 = G.nodes[node1]['feature_node_degree']
T_2 = G.nodes[node2]['feature_node_degree']
S_1 = G.nodes[node1]['feature_covalent_radius']
S_2 = G.nodes[node2]['feature_covalent_radius']
X_1 = G.nodes[node1]['feature_electronegativity']
X_2 = G.nodes[node2]['feature_electronegativity']
# add new edge attributes
if model_number == 1:
new_attributes = {(node1, node2, 0): {"feature_atomic_number_1": Z_1,
"feature_atomic_number_2": Z_2,
"feature_node_degree_1": T_1,
"feature_node_degree_2": T_2,
"feature_electronegativity_1": X_1,
"feature_electronegativity_2": X_2}}
newedge_attribute = ["feature_atomic_number_1",
"feature_atomic_number_2",
"feature_node_degree_1",
"feature_node_degree_2",
"feature_electronegativity_1",
"feature_electronegativity_2",
"feature_bond_distance",
"feature_wiberg_bond_order_int",
"feature_identity"]
if model_number == 2:
new_attributes = {(node1, node2, 0): {"feature_atomic_number_1": Z_1,
"feature_atomic_number_2": Z_2,
"feature_node_degree_1": T_1,
"feature_node_degree_2": T_2,
"feature_electronegativity_12": X_1 - X_2}}
newedge_attribute = ["feature_atomic_number_1",
"feature_atomic_number_2",
"feature_node_degree_1",
"feature_node_degree_2",
"feature_electronegativity_12",
"feature_bond_distance",
"feature_wiberg_bond_order_int",
"feature_identity"]
if model_number == 3:
new_attributes = {(node1, node2, 0): {"feature_atomic_number_1": Z_1,
"feature_atomic_number_2": Z_2,
"feature_node_degree_1": T_1,
"feature_node_degree_2": T_2,
"feature_electronegativity_12": X_1 - X_2,
"feature_covalent_radius_1": S_1,
"feature_covalent_radius_2":S_2}}
newedge_attribute = ["feature_atomic_number_1",
"feature_atomic_number_2",
"feature_node_degree_1",
"feature_node_degree_2",
"feature_electronegativity_12",
"feature_covalent_radius_1",
"feature_covalent_radius_2",
"feature_wiberg_bond_order_int",
"feature_identity"]
# add new edge attributes
nx.set_edge_attributes(G, new_attributes)
return newedge_attribute
def nbo_new_edge_attribute(G, model_number, node_dict):
"""Define new edge attributes according to the selected model for nbo properties
Args:
G (networkx graph class): Graph read by networkx
model_number (int): Type of new edge attribute
node_dict (dict): Depth as keys and nodes as values
Returns:
list: List of new edge features
"""
# dictionary for new attributes
for edge in G.edges(G):
# sort nodes of in the edges by their depths (in node_dict)
node_i, node_j = edge
depth_a = [k for (k, v) in node_dict.items() if node_i in v]
depth_b = [k for (k, v) in node_dict.items() if node_j in v]
if depth_a < depth_b:
edge = node_i, node_j
if depth_b < depth_a:
edge = node_j, node_i
node1, node2 = edge
# get the new edge features
qnat_1 = G.nodes[node1]['feature_natural_atomic_charge']
qnat_2 = G.nodes[node2]['feature_natural_atomic_charge']
Vnat_1 = G.nodes[node1]['feature_natural_electron_population_valence']
Vnat_2 = G.nodes[node2]['feature_natural_electron_population_valence']
Ns_1 = G.nodes[node1]['feature_natural_electron_configuration_0']
Ns_2 = G.nodes[node2]['feature_natural_electron_configuration_0']
Np_1 = G.nodes[node1]['feature_natural_electron_configuration_1']
Np_2 = G.nodes[node2]['feature_natural_electron_configuration_1']
Nd_1 = G.nodes[node1]['feature_natural_electron_configuration_2']
Nd_2 = G.nodes[node2]['feature_natural_electron_configuration_2']
Nlp_1 = G.nodes[node1]['feature_n_lone_pairs']
Nlp_2 = G.nodes[node2]['feature_n_lone_pairs']
LPe_1 = G.nodes[node1]['feature_lone_pair_max_energy']
LPe_2 = G.nodes[node2]['feature_lone_pair_max_energy']
LPde_1 = G.nodes[node1]['feature_lone_pair_energy_min_max_difference']
LPde_2 = G.nodes[node2]['feature_lone_pair_energy_min_max_difference']
Nlv_1 = G.nodes[node1]['feature_n_lone_vacancies']
Nlv_2 = G.nodes[node2]['feature_n_lone_vacancies']
LVde_1 = G.nodes[node1]['feature_lone_vacancy_energy_min_max_difference']
LVde_2 = G.nodes[node2]['feature_lone_vacancy_energy_min_max_difference']
LVe_1 = G.nodes[node1]['feature_lone_vacancy_min_energy']
LVe_2 = G.nodes[node2]['feature_lone_vacancy_min_energy']
# add new edge attributes
if model_number == 1:
new_attributes = {(node1, node2, 0): {"feature_natural_atomic_charge_1": qnat_1,
"feature_natural_atomic_charge_2": qnat_2,
"feature_natural_electron_configuration_0_1": Ns_1,
"feature_natural_electron_configuration_0_2": Ns_2,
"feature_natural_electron_configuration_1_1": Np_1,
"feature_natural_electron_configuration_1_2": Np_2,
"feature_natural_electron_configuration_2_1": Nd_1,
"feature_natural_electron_configuration_2_2": Nd_2,
"feature_n_lone_pairs_1": Nlp_1,
"feature_n_lone_pairs_2": Nlp_2
}}
newedge_attribute = ["feature_natural_atomic_charge_1",
"feature_natural_atomic_charge_2",
"feature_natural_electron_configuration_0_1",
"feature_natural_electron_configuration_0_2",
"feature_natural_electron_configuration_1_1",
"feature_natural_electron_configuration_1_2",
"feature_natural_electron_configuration_2_1",
"feature_natural_electron_configuration_2_2",
"feature_n_lone_pairs_1",
"feature_n_lone_pairs_2",
"feature_wiberg_bond_order",
"feature_n_bn",
"feature_bond_max_energy",
"feature_antibond_min_energy",
"feature_bond_max_0",
"feature_bond_max_1",
"feature_bond_max_2",
"feature_identity"]
if model_number == 2:
new_attributes = {(node1, node2, 0): {"feature_natural_electron_population_valence_1": Vnat_1,
"feature_natural_electron_population_valence_2": Vnat_2,
"feature_natural_electron_configuration_0_1": Ns_1,
"feature_natural_electron_configuration_0_2": Ns_2,
"feature_natural_electron_configuration_1_1": Np_1,
"feature_natural_electron_configuration_1_2": Np_2,
"feature_natural_electron_configuration_2_1": Nd_1,
"feature_natural_electron_configuration_2_2": Nd_2,
"feature_n_lone_pairs_1": Nlp_1,
"feature_n_lone_pairs_2": Nlp_2
}}
newedge_attribute = ["feature_natural_electron_population_valence_1",
"feature_natural_electron_population_valence_2",
"feature_natural_electron_configuration_0_1",
"feature_natural_electron_configuration_0_2",
"feature_natural_electron_configuration_1_1",
"feature_natural_electron_configuration_1_2",
"feature_natural_electron_configuration_2_1",
"feature_natural_electron_configuration_2_2",
"feature_n_lone_pairs_1",
"feature_n_lone_pairs_2",
"feature_wiberg_bond_order",
"feature_n_bn",
"feature_bond_max_energy",
"feature_antibond_min_energy",
"feature_bond_max_0",
"feature_bond_max_1",
"feature_bond_max_2",
"feature_identity"]
if model_number == 4:
new_attributes = {(node1, node2, 0): {"feature_natural_atomic_charge_1": qnat_1,
"feature_natural_atomic_charge_2": qnat_2,
"feature_natural_electron_population_valence_1": Vnat_1,
"feature_natural_electron_population_valence_2": Vnat_2,
"feature_natural_electron_configuration_0_1": Ns_1,
"feature_natural_electron_configuration_0_2": Ns_2,
"feature_natural_electron_configuration_1_1": Np_1,
"feature_natural_electron_configuration_1_2": Np_2,
"feature_natural_electron_configuration_2_1": Nd_1,
"feature_natural_electron_configuration_2_2": Nd_2,
"feature_n_lone_pairs_1": Nlp_1,
"feature_n_lone_pairs_2": Nlp_2,
"feature_n_lone_vacancies_1": Nlv_1,
"feature_n_lone_vacancies_2": Nlv_2
}}
newedge_attribute = ["feature_natural_atomic_charge_1",
"feature_natural_atomic_charge_2",
"feature_natural_electron_population_valence_1",
"feature_natural_electron_population_valence_2",
"feature_natural_electron_configuration_0_1",
"feature_natural_electron_configuration_0_2",
"feature_natural_electron_configuration_1_1",
"feature_natural_electron_configuration_1_2",
"feature_natural_electron_configuration_2_1",
"feature_natural_electron_configuration_2_2",
"feature_n_lone_pairs_1",
"feature_n_lone_pairs_2",
"feature_n_lone_vacancies_1",
"feature_n_lone_vacancies_2",
"feature_bond_distance",
"feature_wiberg_bond_order",
"feature_n_bn",
"feature_bond_max_0",
"feature_bond_max_1",
"feature_bond_max_2",
"feature_n_nbn",
"feature_antibond_min_0",
"feature_antibond_min_1",
"feature_antibond_min_2",
"feature_identity"]
if model_number == 5:
new_attributes = {(node1, node2, 0): {"feature_natural_atomic_charge_1": qnat_1,
"feature_natural_atomic_charge_2": qnat_2,
"feature_natural_electron_population_valence_1": Vnat_1,
"feature_natural_electron_population_valence_2": Vnat_2,
"feature_n_lone_pairs_1": Nlp_1,
"feature_n_lone_pairs_2": Nlp_2,
"feature_lone_pair_max_energy_1": LPe_1,
"feature_lone_pair_max_energy_2": LPe_2,
"feature_lone_pair_energy_min_max_difference_1": LPde_1,
"feature_lone_pair_energy_min_max_difference_2": LPde_2,
"feature_n_lone_vacancies_1": Nlv_1,
"feature_n_lone_vacancies_2": Nlv_2,
"feature_lone_vacancy_min_energy_1": LVe_1,
"feature_lone_vacancy_min_energy_2": LVe_2,
"feature_lone_vacancy_energy_min_max_difference_1": LVde_1,
"feature_lone_vacancy_energy_min_max_difference_2": LVde_2,
}}
newedge_attribute = ["feature_natural_atomic_charge_1",
"feature_natural_atomic_charge_2",
"feature_natural_electron_population_valence_1",
"feature_natural_electron_population_valence_2",
"feature_n_lone_pairs_1",
"feature_n_lone_pairs_2",
"feature_lone_pair_max_energy_1",
"feature_lone_pair_max_energy_2",
"feature_lone_pair_energy_min_max_difference_1",
"feature_lone_pair_energy_min_max_difference_2",
"feature_n_lone_vacancies_1",
"feature_n_lone_vacancies_2",
"feature_lone_vacancy_min_energy_1",
"feature_lone_vacancy_min_energy_2",
"feature_lone_vacancy_energy_min_max_difference_1",
"feature_lone_vacancy_energy_min_max_difference_2",
"feature_bond_distance",
"feature_wiberg_bond_order",
"feature_n_bn",
"feature_bond_max_energy",
"feature_bond_energy_min_max_difference",
"feature_n_nbn",
"feature_antibond_min_energy",
"feature_antibond_energy_min_max_difference",
"feature_identity"]
# add new edge attributes
nx.set_edge_attributes(G, new_attributes)
return newedge_attribute
def vector_feature_PT(depth_max, ac_operator, model_number, walk):
"""Generate a set of labels for the PT features at different depths
Args:
depth_max (int): Maximum distance to read the graph
ac_operator (str): Arithmetic operator applied to the properties
model_number (int): Type of new edge attribute
walk (str): Type of autocorrelation to be performed
Returns:
list: Labels to define the AC vector with PT components
"""
# set of attributes for nodes and edges
feature_node = ['feature_atomic_number',
'feature_identity',
'feature_node_degree',
'feature_covalent_radius',
'feature_electronegativity']
feature_edge = ['feature_wiberg_bond_order_int',
'feature_bond_distance',
'feature_identity']
feature_node_depth, feature_edge_depth = [], []
# feature heading for node and edges with PT properties
Z = [f'Z-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
I = [f'I-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
ND = [f'T-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
CR = [f'S-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
X = [f'chi-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
BO = [f'BO-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
d = [f'd-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
Zi = [f'Zi-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
Zj = [f'Zj-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
Ti = [f'Ti-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
Tj = [f'Tj-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
Xi = [f'chi_i-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
Xj = [f'chi_j-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
Xij = [f'chi_ij-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
Si = [f'Si-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
Sj = [f'Sj-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
BO_ = [f'BO-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
d_ = [f'd-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
I_ = [f'I-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
feature_node_depth = Z + I + ND + CR + X
feature_node_depth.insert(0, 'id')
feature_edge_depth = BO + d + I
feature_edge_depth.insert(0, 'id')
feature_new1_edge_depth = Zi + Zj + Ti + Tj + Xi + Xj + d_ + BO_ + I_
feature_new1_edge_depth.insert(0, 'id')
feature_new2_edge_depth = Zi + Zj + Ti + Tj + Xij + d_ + BO_ + I_
feature_new2_edge_depth.insert(0, 'id')
feature_new3_edge_depth = Zi + Zj + Ti + Tj + Xij + Si + Sj + BO_ + I_
feature_new3_edge_depth.insert(0, 'id')
feature_set = [feature_node,
feature_edge,
feature_node_depth,
feature_edge_depth,
feature_new1_edge_depth,
feature_new2_edge_depth,
feature_new3_edge_depth]
return feature_set
def vector_feature_NBO(depth_max, ac_operator, model_number, walk):
"""Generate a set of labels for the NBO features at different depths
Args:
depth_max (int): Maximum distance to read the graph
ac_operator (str): Arithmetic operator applied to the properties
model_number (int): Model number
walk (str): Type of autocorrelation to be performed
Returns:
list: Labels to define the AC vector with NBO components
"""
# set of attributes for nodes and edges
feature_node_uNat = ['feature_atomic_number',
'feature_natural_atomic_charge',
'feature_natural_electron_population_valence',
'feature_natural_electron_configuration_0',
'feature_natural_electron_configuration_1',
'feature_natural_electron_configuration_2',
'feature_n_lone_pairs',
'feature_lone_pair_energy_min_max_difference',
'feature_lone_pair_max_energy',
'feature_lone_pair_max_occupation',
'feature_lone_pair_max_0',
'feature_lone_pair_max_1',
'feature_lone_pair_max_2',
'feature_n_lone_vacancies',
'feature_lone_vacancy_energy_min_max_difference',
'feature_lone_vacancy_min_energy',
'feature_lone_vacancy_min_occupation',
'feature_lone_vacancy_min_0',
'feature_lone_vacancy_min_1',
'feature_lone_vacancy_min_2',
'feature_identity'
]
feature_edge_uNat = ['feature_wiberg_bond_order',
'feature_bond_distance',
'feature_n_bn',
'feature_n_nbn',
'feature_bond_energy_min_max_difference',
'feature_bond_max_energy',
'feature_bond_max_occupation',
'feature_bond_max_0',
'feature_bond_max_1',
'feature_bond_max_2',
'feature_antibond_energy_min_max_difference',
'feature_antibond_min_energy',
'feature_antibond_min_occupation',
'feature_antibond_min_0',
'feature_antibond_min_1',
'feature_antibond_min_2',
'feature_identity']
feature_edge_dNat = ['feature_wiberg_bond_order',
'feature_bond_distance',
'feature_stabilisation_energy_max',
'feature_stabilisation_energy_average',
'feature_donor_nbo_energy',
'feature_donor_nbo_min_max_energy_gap',
'feature_donor_nbo_occupation',
'feature_donor_nbo_0',
'feature_donor_nbo_1',
'feature_donor_nbo_2',
'feature_acceptor_nbo_energy',
'feature_acceptor_nbo_min_max_energy_gap',
'feature_acceptor_nbo_occupation',
'feature_acceptor_nbo_0',
'feature_acceptor_nbo_1',
'feature_acceptor_nbo_2',
'feature_identity']
feature_node_uNat_depth, feature_edge_uNat_depth = [], []
feature_node_dNat_depth, feature_edge_dNat_depth = [], []
feature_new1_edge_uNat_depth, feature_new2_edge_uNat_depth = [], []
feature_new4_edge_uNat_depth, feature_new5_edge_uNat_depth = [], []
# feature heading for node and edges with NBO properties
Z = [f'Z-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
qnat = [f'qnat-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
Vnat = [f'Vnat-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
Ns = [f'Ns-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
Np = [f'Np-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
Nd = [f'Nd-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
Nlp = [f'Nlp-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
LPe = [f'LPe-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
LPocc = [f'LPocc-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
LPs = [f'LPs-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
LPp = [f'LPp-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
LPd = [f'LPd-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
LPde = [f'LPde-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
Nlv = [f'Nlv-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
LVe = [f'LVe-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
LVocc = [f'LVocc-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
LVs = [f'LVs-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
LVp = [f'LVp-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
LVd = [f'LVd-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
LVde = [f'LVde-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
BO = [f'BO-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
d = [f'd-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
Nbn = [f'Nbn-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
BNe = [f'BNe-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
BNocc = [f'BNocc-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
BNs = [f'BNs-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
BNp = [f'BNp-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
BNd = [f'BNd-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
BNde = [f'BNde-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
Nbn_ = [f'Nbn_-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
BNe_ = [f'BNe_-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
BNocc_ = [f'BNocc_-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
BNs_ = [f'BNs_-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
BNp_ = [f'BNp_-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
BNd_ = [f'BNd_-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
BNde_ = [f'BNde_-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
E2max = [f'E2max-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
E2avg = [f'E2avg-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
Dtype = [f'Dtype-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
De = [f'De-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
Docc = [f'Docc-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
Ds = [f'Ds-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
Dp = [f'Dp-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
Dd= [f'Dd-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
Dde = [f'Dde-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
Ae = [f'Ae-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
Aocc = [f'Aocc-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
As = [f'As-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
Ap = [f'Ap-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
Ad = [f'Ad-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
Ade = [f'Ade-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
qnat_i = [f'qnat_i-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)] # qnat_i = [f'qnat_i-{i}_{ac_operator}_BB_{model_number}' for i in range(depth_max + 1)]
Vnat_i = [f'Vnat_i-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
Ns_i = [f'Ns_i-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
Np_i = [f'Np_i-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
Nd_i = [f'Nd_i-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
qnat_j = [f'qnat_j-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
Vnat_j = [f'Vnat_j-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
Ns_j = [f'Ns_j-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
Np_j = [f'Np_j-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
Nd_j = [f'Nd_j-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
Nlp_i = [f'Nlp_i-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
Nlp_j = [f'Nlp_j-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
LPe_i = [f'LPe_i-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
LPe_j = [f'LPe_j-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
LPde_i = [f'LPde_i-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
LPde_j = [f'LPde_j-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
Nlv_i = [f'Nlv_i-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
Nlv_j = [f'Nlv_j-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
LVe_i = [f'LVe_i-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
LVe_j = [f'LVe_j-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
LVde_i = [f'LVde_i-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
LVde_j = [f'LVde_j-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
I = [f'I-{i}_{ac_operator}_{walk}' for i in range(depth_max + 1)]
feature_node_uNat_depth = Z + qnat + Vnat + Ns + Np + Nd + Nlp + \
LPde + LPe + LPocc + LPs + LPp + LPd + Nlv + LVde + LVe + LVocc + \
LVs + LVp + LVd + I
feature_node_uNat_depth.insert(0, 'id')
feature_node_dNat_depth = Z + qnat + Vnat + Ns + Np + Nd + Nlp + \
LPde + LPe + LPocc + LPs + LPp + LPd + Nlv + LVde + LVe + LVocc + \
LVs + LVp + LVd + I
feature_node_dNat_depth.insert(0, 'id')
feature_edge_uNat_depth = BO + d + Nbn + Nbn_ + BNde + BNe + BNocc + BNs + BNp + \
BNd + BNde_ + BNe_ + BNocc_ + BNs_ + BNp_ + BNd_ + I
feature_edge_uNat_depth.insert(0, 'id')
feature_edge_dNat_depth = BO + d + E2max + E2avg + De + Dde + Docc + \
Ds + Dp + Dd + Ae + Ade + Aocc + As + Ap + Ad + I
feature_edge_dNat_depth.insert(0, 'id')
feature_new1_edge_uNat_depth = qnat_i + qnat_j + Ns_i + Ns_j + \
Np_i + Np_j + Nd_i + Nd_j + Nlp_i + Nlp_j + BO + Nbn + BNe + BNe_ + BNs + \
BNp + BNd + I
feature_new1_edge_uNat_depth.insert(0, 'id')
feature_new2_edge_uNat_depth = Vnat_i + Vnat_j + Ns_i + Ns_j + \
Np_i + Np_j + Nd_i + Nd_j + Nlp_i + Nlp_j + BO + Nbn + BNe + BNe_ + BNs + \
BNp + BNd + I
feature_new2_edge_uNat_depth.insert(0, 'id')
feature_new4_edge_uNat_depth = qnat_i + qnat_j + Vnat_i + Vnat_j + \
Ns_i + Ns_j + Np_i + Np_j + Nd_i + Nd_j + Nlp_i + Nlp_j + Nlv_i + Nlv_j + \
d + BO + Nbn + BNs + BNp + BNd + Nbn_ + BNs_ + BNp_ + BNd_ + I
feature_new4_edge_uNat_depth.insert(0, 'id')
feature_new5_edge_uNat_depth = qnat_i + qnat_j + Vnat_i + Vnat_j + \
Nlp_i + Nlp_j + LPe_i + LPe_j + LPde_i + LPde_j + Nlv_i + Nlv_j + \
LVe_i + LVe_j + LVde_i + LVde_j + d + BO + Nbn + BNe + BNde + Nbn_ + \
BNe_ + BNde_ + I
feature_new5_edge_uNat_depth.insert(0, 'id')
feature_set = [feature_node_uNat,
feature_edge_uNat,
feature_edge_dNat,
feature_node_uNat_depth,
feature_edge_uNat_depth,
feature_node_dNat_depth,
feature_edge_dNat_depth,
feature_new1_edge_uNat_depth,
feature_new2_edge_uNat_depth,
feature_new4_edge_uNat_depth,
feature_new5_edge_uNat_depth
]
return feature_set