EricBoi commited on
Commit
b3226b4
·
1 Parent(s): b4d9ff9
Files changed (1) hide show
  1. app.py +55 -0
app.py CHANGED
@@ -14,6 +14,26 @@ import optax
14
 
15
  import pandas as pd
16
  from dcmnet.modules import MessagePassingModel
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
 
18
  from rdkit import Chem
19
  from rdkit.Chem import AllChem
@@ -65,6 +85,41 @@ smiles_image = Draw.MolToImage(smiles_mol)
65
  st.image(smiles_image)
66
 
67
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
  # Disable future warnings.
69
  import warnings
70
  warnings.simplefilter(action='ignore', category=FutureWarning)
 
14
 
15
  import pandas as pd
16
  from dcmnet.modules import MessagePassingModel
17
+ from dcmnet.utils import clip_colors, apply_model
18
+
19
+ # Model hyperparameters.
20
+ features = 16
21
+ max_degree = 2
22
+ num_iterations = 2
23
+ num_basis_functions = 8
24
+ cutoff = 4.0
25
+
26
+ # Create models
27
+ DCM1 = MessagePassingModel(
28
+ features=features,
29
+ max_degree=max_degree,
30
+ num_iterations=num_iterations,
31
+ num_basis_functions=num_basis_functions,
32
+ cutoff=cutoff,
33
+ n_dcm=1,
34
+ )
35
+
36
+
37
 
38
  from rdkit import Chem
39
  from rdkit.Chem import AllChem
 
85
  st.image(smiles_image)
86
 
87
 
88
+ vdw_surface = surface_points
89
+ max_N_atoms = 60
90
+ max_grid_points = 3143
91
+ max_grid_points - len(vdw_surface)
92
+ try:
93
+ Z = [np.array([int(_) for _ in elements])]
94
+ except:
95
+ Z = [np.array([ase.data.atomic_numbers[_.capitalize()] for _ in elements])]
96
+ pad_Z = np.array([np.pad(Z[0], ((0,max_N_atoms - len(Z[0]))))])
97
+ pad_coords = np.array([np.pad(coordinates, ((0, max_N_atoms - len(coordinates)), (0,0)))])
98
+
99
+ pad_vdw_surface = []
100
+ _ = np.pad(vdw_surface, ((0, max_grid_points - len(vdw_surface)), (0,0)), "constant", constant_values=(0, 10000))
101
+ pad_vdw_surface.append(_)
102
+ pad_vdw_surface = np.array(pad_vdw_surface)
103
+
104
+
105
+ data_batch = dict(
106
+ atomic_numbers=jnp.asarray(pad_Z),
107
+ positions=jnp.asarray(pad_coords),
108
+ mono=jnp.asarray(pad_Z),
109
+ ngrid=jnp.array([len(vdw_surface)]),
110
+ esp=jnp.asarray([np.zeros(max_grid_points)]),
111
+ vdw_surface=jnp.asarray(pad_vdw_surface),
112
+ )
113
+
114
+ psi4_test_batches = prepare_batches(data_key, data_batch, batch_size)
115
+
116
+ batchID = 0
117
+ errors_train = []
118
+ batch = psi4_test_batches[batchID]
119
+
120
+ mono, dipo = apply_model(DCM1, test_weights, batch, batch_size)
121
+
122
+
123
  # Disable future warnings.
124
  import warnings
125
  warnings.simplefilter(action='ignore', category=FutureWarning)