Skip to content

Commit

Permalink
fix #104 Add check for dot symbol and warn user
Browse files Browse the repository at this point in the history
  • Loading branch information
vandrw committed Nov 15, 2023
1 parent 120b776 commit 1e60b91
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion selfies/utils/encoding_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,16 @@ def selfies_to_encoding(
selfies += "[nop]" * (pad_to_len - len_selfies(selfies))

# integer encode
char_list = split_selfies(selfies)
char_list = list(split_selfies(selfies))

# Check if SELFIES string contains unconnected molecules
if "." in list(char_list) and not "." in vocab_stoi:
raise ValueError(
"The SELFIES string contains two unconnected molecules "
"(given by the '.' character), but vocab_stoi does not "
"contain the '.' key. Please add it or separate the molecules."
)

integer_encoded = [vocab_stoi[char] for char in char_list]

if enc_type == "label":
Expand Down

0 comments on commit 1e60b91

Please sign in to comment.