wengong-jin / icml18-jtnn

Junction Tree Variational Autoencoder for Molecular Graph Generation (ICML 2018)
MIT License
509 stars 190 forks source link

gen_latent.py: smile code not found #57

Open chaitanyadwivedii opened 4 years ago

chaitanyadwivedii commented 4 years ago

While generating latent representations for BO, there are a few molecules that are perhaps not in the vocabulary, I get the following error: File "gen_latent.py", line 84, in <module> mol_vec = model.encode_latent_mean(batch) File "JT-VAE/icml18-jtnn/jtnn/jtnn_vae.py", line 61, in encode_latent_mean _, tree_vec, mol_vec = self.encode(mol_batch) File "JT-VAE/icml18-jtnn/jtnn/jtnn_vae.py", line 48, in encode set_batch_nodeID(mol_batch, self.vocab) File "JT-VAE/icml18-jtnn/jtnn/jtnn_vae.py", line 22, in set_batch_nodeID node.wid = vocab.get_index(node.smiles) File "JT-VAE/icml18-jtnn/jtnn/mol_tree.py", line 18, in get_index return self.vmap[smiles] KeyError: 'C1=CN=NC=C1'

jenna1701 commented 4 years ago

I fixed this by adding the missing key to the vocab whenever this error comes up.