Commit 3631e208 authored by Jacob Durrant's avatar Jacob Durrant
Browse files

Update javascript grid code.

parent 1d695d4d
......@@ -10,3 +10,4 @@ pretrained/**
!pretrained/README.md
.DS_Store
grid_0.right_answer.json
*****
OpenBabel09102001113D
66 66 0 0 1 0 0 0 0 0999 V2000
14.6200 9.9440 24.4710 C 0 0 0 0 0 0 0 0 0 0 0 0
15.7480 8.9120 24.4560 C 0 0 0 0 0 0 0 0 0 0 0 0
16.0850 8.4010 25.5410 O 0 0 0 0 0 0 0 0 0 0 0 0
16.3130 8.6420 23.3670 O 0 0 0 0 0 0 0 0 0 0 0 0
13.2690 9.2400 24.5300 C 0 0 0 0 0 0 0 0 0 0 0 0
12.9530 8.6610 25.9060 C 0 0 0 0 0 0 0 0 0 0 0 0
11.5780 8.0220 25.9870 C 0 0 0 0 0 0 0 0 0 0 0 0
10.7970 8.0380 25.0250 O 0 0 0 0 0 0 0 0 0 0 0 0
11.2470 7.5340 27.1750 N 0 0 0 0 0 0 0 0 0 0 0 0
9.9720 6.8700 27.4160 C 0 0 2 0 0 0 0 0 0 0 0 0
9.3670 7.3930 28.7190 C 0 0 0 0 0 0 0 0 0 0 0 0
10.0850 7.8880 29.5910 O 0 0 0 0 0 0 0 0 0 0 0 0
10.2030 5.3550 27.5530 C 0 0 0 0 0 0 0 0 0 0 0 0
11.4450 4.7020 26.3760 S 0 0 0 0 0 0 0 0 0 0 0 0
8.0510 7.2770 28.8380 N 0 0 0 0 0 0 0 0 0 0 0 0
7.3820 7.6900 30.0580 C 0 0 0 0 0 0 0 0 0 0 0 0
6.9000 9.1180 30.0690 C 0 0 0 0 0 0 0 0 0 0 0 0
6.0060 9.4220 30.8870 O 0 0 0 0 0 0 0 0 0 0 0 0
7.3950 9.9270 29.2540 O 0 0 0 0 0 0 0 0 0 0 0 0
5.7920 2.7370 28.0810 C 0 0 0 0 0 0 0 0 0 0 0 0
5.1050 2.1790 29.1650 O 0 0 0 0 0 0 0 0 0 0 0 0
7.1260 2.3100 27.8760 C 0 0 0 0 0 0 0 0 0 0 0 0
7.8880 2.8040 26.8050 C 0 0 0 0 0 0 0 0 0 0 0 0
7.3230 3.7760 25.8990 C 0 0 0 0 0 0 0 0 0 0 0 0
5.9880 4.1980 26.1300 C 0 0 0 0 0 0 0 0 0 0 0 0
5.2430 3.6890 27.1990 C 0 0 0 0 0 0 0 0 0 0 0 0
8.0950 4.3720 24.7030 C 0 0 0 0 0 0 0 0 0 0 0 0
7.5850 5.1970 23.9310 O 0 0 0 0 0 0 0 0 0 0 0 0
9.6100 3.9850 24.4110 C 0 0 1 0 0 0 0 0 0 0 0 0
9.8770 3.3130 23.0520 C 0 0 0 0 0 0 0 0 0 0 0 0
11.1860 2.5160 22.9220 C 0 0 0 0 0 0 0 0 0 0 0 0
10.6730 5.0250 24.7730 C 0 0 0 0 0 0 0 0 0 0 0 0
4.0210 1.1970 29.0350 C 0 0 0 0 0 0 0 0 0 0 0 0
3.8530 0.2730 30.2430 C 0 0 0 0 0 0 0 0 0 0 0 0
4.7490 -0.5720 30.4860 O 0 0 0 0 0 0 0 0 0 0 0 0
2.8040 0.3540 30.9250 O 0 0 0 0 0 0 0 0 0 0 0 0
7.8760 1.1450 28.9840 Cl 0 0 0 0 0 0 0 0 0 0 0 0
9.5230 2.1350 26.6450 Cl 0 0 0 0 0 0 0 0 0 0 0 0
14.7284 10.5851 25.3582 H 0 0 0 0 0 0 0 0 0 0 0 0
13.2699 8.4196 23.7972 H 0 0 0 0 0 0 0 0 0 0 0 0
12.4849 9.9654 24.2674 H 0 0 0 0 0 0 0 0 0 0 0 0
13.0051 9.4725 26.6467 H 0 0 0 0 0 0 0 0 0 0 0 0
13.7076 7.8972 26.1452 H 0 0 0 0 0 0 0 0 0 0 0 0
11.8946 7.6247 27.9316 H 0 0 0 0 0 0 0 0 0 0 0 0
9.2861 7.0690 26.5794 H 0 0 0 0 0 0 0 0 0 0 0 0
9.2481 4.8387 27.3750 H 0 0 0 0 0 0 0 0 0 0 0 0
10.5479 5.1456 28.5763 H 0 0 0 0 0 0 0 0 0 0 0 0
7.5156 6.9020 28.0812 H 0 0 0 0 0 0 0 0 0 0 0 0
8.0859 7.5612 30.8934 H 0 0 0 0 0 0 0 0 0 0 0 0
6.5111 7.0350 30.2080 H 0 0 0 0 0 0 0 0 0 0 0 0
5.5377 4.9275 25.4666 H 0 0 0 0 0 0 0 0 0 0 0 0
4.2263 4.0327 27.3514 H 0 0 0 0 0 0 0 0 0 0 0 0
9.7941 3.1773 25.1346 H 0 0 0 0 0 0 0 0 0 0 0 0
9.8899 4.1026 22.2863 H 0 0 0 0 0 0 0 0 0 0 0 0
9.0447 2.6221 22.8523 H 0 0 0 0 0 0 0 0 0 0 0 0
11.2564 2.0891 21.9107 H 0 0 0 0 0 0 0 0 0 0 0 0
11.1963 1.7042 23.6641 H 0 0 0 0 0 0 0 0 0 0 0 0
12.0415 3.1847 23.0981 H 0 0 0 0 0 0 0 0 0 0 0 0
10.1990 6.0171 24.8039 H 0 0 0 0 0 0 0 0 0 0 0 0
11.4535 5.0155 23.9979 H 0 0 0 0 0 0 0 0 0 0 0 0
4.2260 0.5740 28.1519 H 0 0 0 0 0 0 0 0 0 0 0 0
3.0781 1.7438 28.8871 H 0 0 0 0 0 0 0 0 0 0 0 0
14.6731 10.5345 23.5803 H 0 0 0 0 0 0 0 0 0 0 0 0
5.6703 8.7752 31.4760 H 0 0 0 0 0 0 0 0 0 0 0 0
2.1566 0.9977 30.7141 H 0 0 0 0 0 0 0 0 0 0 0 0
16.0245 9.0518 22.5753 H 0 0 0 0 0 0 0 0 0 0 0 0
1 2 1 0 0 0 0
1 39 1 0 0 0 0
1 63 1 0 0 0 0
2 4 1 0 0 0 0
2 3 2 0 0 0 0
4 66 1 0 0 0 0
5 1 1 0 0 0 0
5 40 1 0 0 0 0
5 41 1 0 0 0 0
6 5 1 0 0 0 0
6 42 1 0 0 0 0
6 43 1 0 0 0 0
7 6 1 0 0 0 0
7 8 2 0 0 0 0
9 7 1 0 0 0 0
9 44 1 0 0 0 0
10 9 1 0 0 0 0
10 11 1 0 0 0 0
10 45 1 6 0 0 0
11 15 1 0 0 0 0
11 12 2 0 0 0 0
13 10 1 0 0 0 0
13 46 1 0 0 0 0
13 47 1 0 0 0 0
14 13 1 0 0 0 0
15 16 1 0 0 0 0
15 48 1 0 0 0 0
16 17 1 0 0 0 0
16 49 1 0 0 0 0
16 50 1 0 0 0 0
17 19 2 0 0 0 0
17 18 1 0 0 0 0
18 64 1 0 0 0 0
20 21 1 0 0 0 0
21 33 1 0 0 0 0
22 20 2 0 0 0 0
22 37 1 0 0 0 0
23 22 1 0 0 0 0
23 38 1 0 0 0 0
24 23 2 0 0 0 0
24 25 1 0 0 0 0
25 26 2 0 0 0 0
25 51 1 0 0 0 0
26 20 1 0 0 0 0
26 52 1 0 0 0 0
27 24 1 0 0 0 0
27 28 2 0 0 0 0
29 27 1 0 0 0 0
29 30 1 0 0 0 0
29 53 1 1 0 0 0
30 31 1 0 0 0 0
30 54 1 0 0 0 0
30 55 1 0 0 0 0
31 56 1 0 0 0 0
31 57 1 0 0 0 0
31 58 1 0 0 0 0
32 29 1 0 0 0 0
32 14 1 0 0 0 0
32 59 1 0 0 0 0
32 60 1 0 0 0 0
33 34 1 0 0 0 0
33 61 1 0 0 0 0
33 62 1 0 0 0 0
34 36 1 0 0 0 0
34 35 2 0 0 0 0
36 65 1 0 0 0 0
M END
$$$$
@<TRIPOS>MOLECULE
*****
66 66 0 0 0
SMALL
GASTEIGER
@<TRIPOS>ATOM
1 C 14.6200 9.9440 24.4710 C.3 0 UNK0 0.0452
2 C 15.7480 8.9120 24.4560 C.2 0 UNK0 0.3047
3 O 16.0850 8.4010 25.5410 O.2 0 UNK0 -0.2510
4 O 16.3130 8.6420 23.3670 O.3 0 UNK0 -0.4806
5 C 13.2690 9.2400 24.5300 C.3 0 UNK0 -0.0347
6 C 12.9530 8.6610 25.9060 C.3 0 UNK0 0.0245
7 C 11.5780 8.0220 25.9870 C.2 0 UNK0 0.2136
8 O 10.7970 8.0380 25.0250 O.2 0 UNK0 -0.2758
9 N 11.2470 7.5340 27.1750 N.am 1 UNK1 -0.3033
10 C 9.9720 6.8700 27.4160 C.3 1 UNK1 0.1083
11 C 9.3670 7.3930 28.7190 C.2 1 UNK1 0.2346
12 O 10.0850 7.8880 29.5910 O.2 1 UNK1 -0.2737
13 C 10.2030 5.3550 27.5530 C.3 1 UNK1 0.0207
14 S 11.4450 4.7020 26.3760 S.3 1 UNK1 -0.1577
15 N 8.0510 7.2770 28.8380 N.am 2 GLY2 -0.3033
16 CA 7.3820 7.6900 30.0580 C.3 2 GLY2 0.1089
17 C 6.9000 9.1180 30.0690 C.2 2 GLY2 0.3221
18 OXT 6.0060 9.4220 30.8870 O.3 2 GLY2 -0.4795
19 O 7.3950 9.9270 29.2540 O.2 2 GLY2 -0.2492
20 C 5.7920 2.7370 28.0810 C.ar 1 UNK1 0.1410
21 O 5.1050 2.1790 29.1650 O.3 1 UNK1 -0.4793
22 C 7.1260 2.3100 27.8760 C.ar 1 UNK1 0.1014
23 C 7.8880 2.8040 26.8050 C.ar 1 UNK1 0.0733
24 C 7.3230 3.7760 25.8990 C.ar 1 UNK1 0.0376
25 C 5.9880 4.1980 26.1300 C.ar 1 UNK1 -0.0463
26 C 5.2430 3.6890 27.1990 C.ar 1 UNK1 -0.0177
27 C 8.0950 4.3720 24.7030 C.2 1 UNK1 0.1684
28 O 7.5850 5.1970 23.9310 O.2 1 UNK1 -0.2917
29 C 9.6100 3.9850 24.4110 C.3 1 UNK1 0.0309
30 C 9.8770 3.3130 23.0520 C.3 1 UNK1 -0.0453
31 C 11.1860 2.5160 22.9220 C.3 1 UNK1 -0.0646
32 C 10.6730 5.0250 24.7730 C.3 1 UNK1 0.0036
33 C 4.0210 1.1970 29.0350 C.3 1 UNK1 0.1858
34 C 3.8530 0.2730 30.2430 C.2 1 UNK1 0.3427
35 O 4.7490 -0.5720 30.4860 O.2 1 UNK1 -0.2472
36 O 2.8040 0.3540 30.9250 O.3 1 UNK1 -0.4783
37 CL 7.8760 1.1450 28.9840 Cl 1 UNK1 -0.0782
38 CL 9.5230 2.1350 26.6450 Cl 1 UNK1 -0.0812
39 H 14.7284 10.5851 25.3582 H 0 UNK0 0.0378
40 H 13.2699 8.4196 23.7972 H 0 UNK0 0.0275
41 H 12.4849 9.9654 24.2674 H 0 UNK0 0.0275
42 H 13.0051 9.4725 26.6467 H 0 UNK0 0.0358
43 H 13.7076 7.8972 26.1452 H 0 UNK0 0.0358
44 H 11.8946 7.6247 27.9316 H 1 UNK1 0.1495
45 H 9.2861 7.0690 26.5794 H 1 UNK1 0.0603
46 H 9.2481 4.8387 27.3750 H 1 UNK1 0.0399
47 H 10.5479 5.1456 28.5763 H 1 UNK1 0.0399
48 H 7.5156 6.9020 28.0812 H 2 GLY2 0.1493
49 HA1 8.0859 7.5612 30.8934 H 2 GLY2 0.0577
50 HA2 6.5111 7.0350 30.2080 H 2 GLY2 0.0577
51 H 5.5377 4.9275 25.4666 H 1 UNK1 0.0626
52 H 4.2263 4.0327 27.3514 H 1 UNK1 0.0655
53 H 9.7941 3.1773 25.1346 H 1 UNK1 0.0389
54 H 9.8899 4.1026 22.2863 H 1 UNK1 0.0270
55 H 9.0447 2.6221 22.8523 H 1 UNK1 0.0270
56 H 11.2564 2.0891 21.9107 H 1 UNK1 0.0230
57 H 11.1963 1.7042 23.6641 H 1 UNK1 0.0230
58 H 12.0415 3.1847 23.0981 H 1 UNK1 0.0230
59 H 10.1990 6.0171 24.8039 H 1 UNK1 0.0383
60 H 11.4535 5.0155 23.9979 H 1 UNK1 0.0383
61 H 4.2260 0.5740 28.1519 H 1 UNK1 0.0815
62 H 3.0781 1.7438 28.8871 H 1 UNK1 0.0815
63 H 14.6731 10.5345 23.5803 H 0 UNK0 0.0378
64 HXT 5.6703 8.7752 31.4760 H 2 GLY2 0.2951
65 H 2.1566 0.9977 30.7141 H 1 UNK1 0.2952
66 H 16.0245 9.0518 22.5753 H 0 UNK0 0.2951
@<TRIPOS>BOND
1 1 2 1
2 1 39 1
3 2 4 1
4 2 3 2
5 5 1 1
6 5 40 1
7 5 41 1
8 6 5 1
9 6 42 1
10 6 43 1
11 7 6 1
12 7 8 2
13 9 7 am
14 9 44 1
15 10 9 1
16 10 11 1
17 10 45 1
18 11 15 am
19 11 12 2
20 13 10 1
21 13 46 1
22 13 47 1
23 14 13 1
24 15 16 1
25 15 48 1
26 16 17 1
27 16 49 1
28 16 50 1
29 17 19 2
30 17 18 1
31 20 21 1
32 21 33 1
33 22 20 ar
34 22 37 1
35 23 22 ar
36 23 38 1
37 24 23 ar
38 24 25 ar
39 25 26 ar
40 25 51 1
41 26 20 ar
42 26 52 1
43 27 24 1
44 27 28 2
45 29 27 1
46 29 30 1
47 29 53 1
48 30 31 1
49 30 54 1
50 30 55 1
51 31 56 1
52 31 57 1
53 31 58 1
54 32 29 1
55 32 14 1
56 32 59 1
57 32 60 1
58 33 34 1
59 33 61 1
60 33 62 1
61 34 36 1
62 34 35 2
63 1 63 1
64 18 64 1
65 36 65 1
66 4 66 1
11gs_ligand
Created by X-TOOL on Fri Nov 18 12:30:35 2016
66 66 0 0 0 0 0 0 0 0999 V2000
14.7090 10.7820 23.2520 N 0 3 0 4 0 4
14.6200 9.9440 24.4710 C 0 0 0 2 0 4
15.7480 8.9120 24.4560 C 0 5 0 1 0 3
16.0850 8.4010 25.5410 O 0 0 0 1 0 1
16.3130 8.6420 23.3670 O 0 0 0 1 0 1
13.2690 9.2400 24.5300 C 0 0 0 3 0 4
12.9530 8.6610 25.9060 C 0 0 0 3 0 4
11.5780 8.0220 25.9870 C 0 0 0 1 0 3
10.7970 8.0380 25.0250 O 0 0 0 1 0 1
11.2470 7.5340 27.1750 N 0 0 0 2 0 3
9.9720 6.8700 27.4160 C 0 0 0 2 0 4
9.3670 7.3930 28.7190 C 0 0 0 1 0 3
10.0850 7.8880 29.5910 O 0 0 0 1 0 1
10.2030 5.3550 27.5530 C 0 0 0 3 0 4
11.4450 4.7020 26.3760 S 0 0 0 1 0 2
8.0510 7.2770 28.8380 N 0 0 0 2 0 3
7.3820 7.6900 30.0580 C 0 0 0 3 0 4
6.9000 9.1180 30.0690 C 0 5 0 1 0 3
6.0060 9.4220 30.8870 O 0 0 0 1 0 1
7.3950 9.9270 29.2540 O 0 0 0 1 0 1
5.7920 2.7370 28.0810 C 0 0 0 1 0 3
5.1050 2.1790 29.1650 O 0 0 0 1 0 2
7.1260 2.3100 27.8760 C 0 0 0 1 0 3
7.8880 2.8040 26.8050 C 0 0 0 1 0 3
7.3230 3.7760 25.8990 C 0 0 0 1 0 3
5.9880 4.1980 26.1300 C 0 0 0 2 0 3
5.2430 3.6890 27.1990 C 0 0 0 2 0 3
8.0950 4.3720 24.7030 C 0 0 0 1 0 3
7.5850 5.1970 23.9310 O 0 0 0 1 0 1
9.6100 3.9850 24.4110 C 0 0 0 2 0 4
9.8770 3.3130 23.0520 C 0 0 0 3 0 4
11.1860 2.5160 22.9220 C 0 0 0 4 0 4
10.6730 5.0250 24.7730 C 0 0 0 3 0 4
4.0210 1.1970 29.0350 C 0 0 0 3 0 4
3.8530 0.2730 30.2430 C 0 5 0 1 0 3
4.7490 -0.5720 30.4860 O 0 0 0 1 0 1
2.8040 0.3540 30.9250 O 0 0 0 1 0 1
7.8760 1.1450 28.9840 Cl 0 0 0 1 0 1
9.5230 2.1350 26.6450 Cl 0 0 0 1 0 1
13.9667 11.4639 23.2582 H 0 0 0 1 0 1
14.6216 10.1976 22.4354 H 0 0 0 1 0 1
15.5992 11.2545 23.2333 H 0 0 0 1 0 1
14.7284 10.5851 25.3582 H 0 0 0 1 0 1
13.2699 8.4196 23.7972 H 0 0 0 1 0 1
12.4849 9.9654 24.2674 H 0 0 0 1 0 1
13.0051 9.4725 26.6467 H 0 0 0 1 0 1
13.7076 7.8972 26.1452 H 0 0 0 1 0 1
11.8946 7.6247 27.9316 H 0 0 0 1 0 1
9.2861 7.0690 26.5794 H 0 0 0 1 0 1
9.2481 4.8387 27.3750 H 0 0 0 1 0 1
10.5479 5.1456 28.5763 H 0 0 0 1 0 1
7.5156 6.9020 28.0812 H 0 0 0 1 0 1
8.0859 7.5612 30.8934 H 0 0 0 1 0 1
6.5111 7.0350 30.2080 H 0 0 0 1 0 1
5.5377 4.9275 25.4666 H 0 0 0 1 0 1
4.2263 4.0327 27.3514 H 0 0 0 1 0 1
9.7941 3.1773 25.1346 H 0 0 0 1 0 1
9.8899 4.1026 22.2863 H 0 0 0 1 0 1
9.0447 2.6221 22.8523 H 0 0 0 1 0 1
11.2564 2.0891 21.9107 H 0 0 0 1 0 1
11.1963 1.7042 23.6641 H 0 0 0 1 0 1
12.0415 3.1847 23.0981 H 0 0 0 1 0 1
10.1990 6.0171 24.8039 H 0 0 0 1 0 1
11.4535 5.0155 23.9979 H 0 0 0 1 0 1
4.2260 0.5740 28.1519 H 0 0 0 1 0 1
3.0781 1.7438 28.8871 H 0 0 0 1 0 1
2 1 1 0 0 2
6 2 1 0 0 2
2 3 1 0 0 2
3 5 2 0 0 2
3 4 2 0 0 2
7 6 1 0 0 2
8 7 1 0 0 2
10 8 1 0 0 2
8 9 2 0 0 2
11 10 1 0 0 2
14 11 1 0 0 2
11 12 1 0 0 2
12 16 1 0 0 2
12 13 2 0 0 2
16 17 1 0 0 2
17 18 1 0 0 2
18 20 2 0 0 2
18 19 2 0 0 2
15 14 1 0 0 2
27 21 4 0 0 1
23 21 4 0 0 1
21 22 1 0 0 2
22 34 1 0 0 2
34 35 1 0 0 2
35 37 2 0 0 2
35 36 2 0 0 2
24 23 4 0 0 1
25 24 4 0 0 1
28 25 1 0 0 2
25 26 4 0 0 1
26 27 4 0 0 1
30 28 1 0 0 2
28 29 2 0 0 2
33 30 1 0 0 2
30 31 1 0 0 2
31 32 1 0 0 2
23 38 1 0 0 2
24 39 1 0 0 2
33 15 1 0 0 2
1 40 1 0 0 2
1 41 1 0 0 2
1 42 1 0 0 2
2 43 1 0 0 2
6 44 1 0 0 2
6 45 1 0 0 2
7 46 1 0 0 2
7 47 1 0 0 2
10 48 1 0 0 2
11 49 1 0 0 2
14 50 1 0 0 2
14 51 1 0 0 2
16 52 1 0 0 2
17 53 1 0 0 2
17 54 1 0 0 2
26 55 1 0 0 2
27 56 1 0 0 2
30 57 1 0 0 2
31 58 1 0 0 2
31 59 1 0 0 2
32 60 1 0 0 2
32 61 1 0 0 2
32 62 1 0 0 2
33 63 1 0 0 2
33 64 1 0 0 2
34 65 1 0 0 2
34 66 1 0 0 2
M END
> <MOLECULAR_FORMULA>
C23H27N3O10SCl2
> <MOLECULAR_WEIGHT>
608.2
> <NUM_HB_ATOMS>
14
> <NUM_ROTOR>
14
> <XLOGP2>
-0.56
$$$$
This diff is collapsed.
......@@ -99,7 +99,13 @@ class Atom:
:rtype: int
"""
return element_to_atomic_num[self.element]
elem = (
element_to_atomic_num[self.element]
if self.element in element_to_atomic_num
else 100
)
return elem
class Mol:
......
......@@ -68,7 +68,8 @@ def mol_gridify(
rot: (x,y,z,y) rotation quaternion
"""
r2 = 4 # fixed radius (^2)
# r2 = 4 # fixed radius (^2)
r2 = 3.0625 # TODO: Or is it 1.75 ^ 2 = 3.0625
half_width = width / 2
# TODO: Remove cruft below. Leaving here for now in case you need it.
......@@ -108,13 +109,14 @@ def mol_gridify(
for rotation_idx in range(len(grid)): # Rotation
for layer_idx in range(len(grid[rotation_idx])):
if layer_idx <= layer_offset:
if layer_idx < layer_offset:
continue
if layer_idx > layer_offset + num_layers_to_consider:
if layer_idx >= layer_offset + num_layers_to_consider:
continue
print(rotation_idx, layer_idx) # To indicate progress.
for x in range(len(grid[rotation_idx][layer_idx])):
for y in range(len(grid[rotation_idx][layer_idx][x])):
for z in range(len(grid[rotation_idx][layer_idx][y])):
......@@ -199,12 +201,26 @@ def mol_gridify(
d2 = atom_inf[1]
# compute effect
# Point type: 0 (effect(d,r) = exp((-2 * d^2) / r^2))
v = math.exp((-2 * d2) / r2)
# add effect
grid[rotation_idx][layer_offset + ft][x][y][z] += v
try:
# Acc type: 0 (sum overlapping points)
grid[rotation_idx][layer_offset + ft][x][y][z] += v
except:
import pdb; pdb.set_trace()
return grid
def flatten_tensor(grid, shape):
flat = []
for i1 in range(shape[0]):
for i2 in range(shape[1]):
for i3 in range(shape[2]):
for i4 in range(shape[3]):
for i5 in range(shape[4]):
flat.append(grid[i1][i2][i3][i4][i5])
return flat
def make_tensor(shape):
"""Creates a tensor to store the grid data in.
......@@ -237,12 +253,13 @@ def make_tensor(shape):
def rand_rot():
"""Returns a random uniform quaternion rotation."""
# q = np.random.normal(size=4) # sample quaternion from normal distribution
# q = q / np.sqrt(np.sum(q**2)) # normalize
# Below if random.
# q = [random.random() for i in range(4)]
# l = math.sqrt(sum([v ** 2 for v in q]))
# q = [v / l for v in q]
q = [random.random() for i in range(4)]
l = math.sqrt(sum([v ** 2 for v in q]))
q = [v / l for v in q]
# Below if not random
q = [1, 0, 0, 0]
return q
......@@ -270,22 +287,33 @@ def get_raw_batch(
res: grid resolution
"""
num_samples = 3 if num_samples is None else num_samples
num_samples = 1 if num_samples is None else num_samples # default was 3
width = 24 if width is None else width
res = 0.5 if res is None else res
# TODO: Harrison to check...
parent_channels = len(set(p_types))
rec_channels = len(set(r_types))
# Channels (index -> what is in the channel):
# 0: parent carbon
# 1: parent nitrogen
# 2: parent oxygen
# 3: parent other (not including hydrogen)
# 4: receptor carbon
# 5: receptor nitrogen
# 6: receptor oxygen
# 7: receptor sulfur
# 8: receptor other (not including hydrogen)
parent_channels = 4 # len(set(p_types))
rec_channels = 5 # len(set(r_types))
# TODO: For debugging
num_samples = 1
# num_samples = 1
B = num_samples
T = rec_channels + parent_channels
N = width
grid = make_tensor((B, T, N, N, N))
shape = (B, T, N, N, N)
grid = make_tensor(shape)
# for i in range(num_samples):
rot = rand_rot()
......@@ -299,4 +327,4 @@ def get_raw_batch(
grid, r_coords, r_types, parent_channels, rec_channels, width, res, conn, rot,
)
return grid
return flatten_tensor(grid, shape)
......@@ -3,6 +3,7 @@ rdkit/openbabel utility scripts
"""
# __pragma__ ('skip')
from rdkit import Chem
# __pragma__ ('noskip')
"""?
......@@ -19,7 +20,7 @@ def get_coords(mol):
return coords
def get_types(mol):
def get_atomic_nums(mol):
"""Returns an array of atomic numbers from an rdkit mol."""
return [mol.GetAtomWithIdx(i).GetAtomicNum() for i in range(mol.GetNumAtoms())]
......@@ -125,12 +126,15 @@ def load_receptor(rec_path):
def remove_hydrogens(m):
try:
for atom in m.GetAtoms():
atom.SetFormalCharge(0)
m = Chem.RemoveHs(m)
except:
m.atoms = [a for a in m.atoms if a.element != "H"]
# __pragma__ ('skip')
for atom in m.GetAtoms():
atom.SetFormalCharge(0)
m = Chem.RemoveHs(m)
# __pragma__ ('noskip')
"""?
m.atoms = [a for a in m.atoms if a.element != "H"]
?"""
return m
......@@ -193,15 +197,43 @@ def load_ligand(sdf):
return lig, frags
def mol_to_points(mol, atom_types):
def mol_to_points(mol, atom_types, note_sulfur=True):
"""convert an rdkit mol to an array of coordinates and layers"""
atom_types = [6, 7, 8, 9, 15, 16, 17, 35, 53] if atom_types is None else atom_types
atom_types = (
[6, 7, 8, 16,] # carbon # nitrogen # oxygen # sulfur
if atom_types is None