torch-molecule 0.1.0.dev2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- torch_molecule/__init__.py +70 -0
- torch_molecule/base/__init__.py +8 -0
- torch_molecule/base/base.py +396 -0
- torch_molecule/base/encoder.py +44 -0
- torch_molecule/base/generator.py +24 -0
- torch_molecule/base/old_encoder.py +322 -0
- torch_molecule/base/old_predictor.py +904 -0
- torch_molecule/base/old_predictor2.py +436 -0
- torch_molecule/base/predictor.py +112 -0
- torch_molecule/encoder/attrmask/__init__.py +3 -0
- torch_molecule/encoder/attrmask/model.py +113 -0
- torch_molecule/encoder/attrmask/modeling_attrmask.py +304 -0
- torch_molecule/encoder/constant.py +13 -0
- torch_molecule/encoder/contextpred/__init__.py +3 -0
- torch_molecule/encoder/contextpred/model.py +207 -0
- torch_molecule/encoder/contextpred/modeling_contextpred.py +299 -0
- torch_molecule/encoder/contextpred/utils.py +206 -0
- torch_molecule/encoder/edgepred/__init__.py +3 -0
- torch_molecule/encoder/edgepred/model.py +104 -0
- torch_molecule/encoder/edgepred/modeling_edgepred.py +285 -0
- torch_molecule/encoder/graphmae/__init__.py +3 -0
- torch_molecule/encoder/graphmae/dataloader.py +206 -0
- torch_molecule/encoder/graphmae/model.py +137 -0
- torch_molecule/encoder/graphmae/modeling_graphmae.py +323 -0
- torch_molecule/encoder/infograph/__init__.py +3 -0
- torch_molecule/encoder/infograph/loss_function.py +128 -0
- torch_molecule/encoder/infograph/model.py +92 -0
- torch_molecule/encoder/infograph/modeling_infograph.py +301 -0
- torch_molecule/encoder/infograph/module.py +31 -0
- torch_molecule/encoder/moama/__init__.py +3 -0
- torch_molecule/encoder/moama/model.py +131 -0
- torch_molecule/encoder/moama/modeling_moama.py +307 -0
- torch_molecule/encoder/moama/utils.py +143 -0
- torch_molecule/encoder/pretrained/__init__.py +3 -0
- torch_molecule/encoder/pretrained/modeling_pretrained.py +274 -0
- torch_molecule/encoder/supervised/__init__.py +3 -0
- torch_molecule/encoder/supervised/model.py +97 -0
- torch_molecule/encoder/supervised/modeling_supervised.py +354 -0
- torch_molecule/generator/digress/__init__.py +3 -0
- torch_molecule/generator/digress/diffusion.py +194 -0
- torch_molecule/generator/digress/modeling_digress.py +503 -0
- torch_molecule/generator/digress/transformer.py +360 -0
- torch_molecule/generator/digress/utils.py +196 -0
- torch_molecule/generator/gdss/__init__.py +3 -0
- torch_molecule/generator/gdss/layers.py +257 -0
- torch_molecule/generator/gdss/model.py +204 -0
- torch_molecule/generator/gdss/modeling_gdss.py +474 -0
- torch_molecule/generator/gdss/sde.py +334 -0
- torch_molecule/generator/gdss/solver.py +227 -0
- torch_molecule/generator/gdss/toremove/ScoreNetworkA.py +167 -0
- torch_molecule/generator/gdss/toremove/ScoreNetworkX.py +85 -0
- torch_molecule/generator/gdss/utils.py +240 -0
- torch_molecule/generator/graph_dit/__init__.py +3 -0
- torch_molecule/generator/graph_dit/diffusion.py +188 -0
- torch_molecule/generator/graph_dit/modeling_graph_dit.py +581 -0
- torch_molecule/generator/graph_dit/transformer.py +207 -0
- torch_molecule/generator/graph_dit/utils.py +220 -0
- torch_molecule/generator/graph_ga/__init__.py +3 -0
- torch_molecule/generator/graph_ga/crossover.py +182 -0
- torch_molecule/generator/graph_ga/modeling_graph_ga.py +310 -0
- torch_molecule/generator/graph_ga/mutate.py +136 -0
- torch_molecule/generator/graph_ga/oracle.py +95 -0
- torch_molecule/generator/jtvae/__init__.py +3 -0
- torch_molecule/generator/jtvae/jtnn/chemutils.py +450 -0
- torch_molecule/generator/jtvae/jtnn/datautils.py +127 -0
- torch_molecule/generator/jtvae/jtnn/jtmpn.py +140 -0
- torch_molecule/generator/jtvae/jtnn/jtnn_dec.py +350 -0
- torch_molecule/generator/jtvae/jtnn/jtnn_enc.py +131 -0
- torch_molecule/generator/jtvae/jtnn/mol_tree.py +111 -0
- torch_molecule/generator/jtvae/jtnn/mpn.py +129 -0
- torch_molecule/generator/jtvae/jtnn/nnutils.py +66 -0
- torch_molecule/generator/jtvae/jtnn/vocab.py +31 -0
- torch_molecule/generator/jtvae/jtnn_vae.py +246 -0
- torch_molecule/generator/jtvae/modeling_jtvae.py +247 -0
- torch_molecule/generator/lstm/__init__.py +3 -0
- torch_molecule/generator/lstm/action_sampler.py +91 -0
- torch_molecule/generator/lstm/lstm.py +59 -0
- torch_molecule/generator/lstm/modeling_lstm.py +263 -0
- torch_molecule/generator/lstm/smiles_char_dict.py +123 -0
- torch_molecule/generator/lstm/utils.py +62 -0
- torch_molecule/generator/molgpt/__init__.py +3 -0
- torch_molecule/generator/molgpt/dataset.py +87 -0
- torch_molecule/generator/molgpt/gpt.py +251 -0
- torch_molecule/generator/molgpt/modeling_molgpt.py +427 -0
- torch_molecule/generator/pretrained/modeling_pretrained.py +1 -0
- torch_molecule/nn/__init__.py +16 -0
- torch_molecule/nn/attention.py +63 -0
- torch_molecule/nn/embedder.py +183 -0
- torch_molecule/nn/gnn.py +631 -0
- torch_molecule/nn/mlp.py +34 -0
- torch_molecule/predictor/bfgnn/__init__.py +3 -0
- torch_molecule/predictor/bfgnn/model.py +116 -0
- torch_molecule/predictor/bfgnn/modeling_bfgnn.py +81 -0
- torch_molecule/predictor/dir/__init__.py +3 -0
- torch_molecule/predictor/dir/model.py +235 -0
- torch_molecule/predictor/dir/modeling_dir.py +161 -0
- torch_molecule/predictor/dir/utils.py +40 -0
- torch_molecule/predictor/gnn/__init__.py +3 -0
- torch_molecule/predictor/gnn/model.py +114 -0
- torch_molecule/predictor/gnn/modeling_gnn.py +706 -0
- torch_molecule/predictor/gnn/old_modeling_gnn.py +707 -0
- torch_molecule/predictor/grea/__init__.py +3 -0
- torch_molecule/predictor/grea/model.py +190 -0
- torch_molecule/predictor/grea/modeling_grea.py +107 -0
- torch_molecule/predictor/grea/old1_features.py +229 -0
- torch_molecule/predictor/grea/old1_modeling_grea.py +493 -0
- torch_molecule/predictor/grea/utils.py +97 -0
- torch_molecule/predictor/grin/__init__.py +3 -0
- torch_molecule/predictor/grin/model.py +116 -0
- torch_molecule/predictor/grin/modeling_grin.py +91 -0
- torch_molecule/predictor/irm/__init__.py +3 -0
- torch_molecule/predictor/irm/model.py +127 -0
- torch_molecule/predictor/irm/modeling_irm.py +179 -0
- torch_molecule/predictor/lstm/__init__.py +3 -0
- torch_molecule/predictor/lstm/model.py +145 -0
- torch_molecule/predictor/lstm/modeling_lstm.py +627 -0
- torch_molecule/predictor/lstm/token_from_smiles.py +85 -0
- torch_molecule/predictor/old_modeling_graph.py +650 -0
- torch_molecule/predictor/rpgnn/__init__.py +3 -0
- torch_molecule/predictor/rpgnn/model.py +185 -0
- torch_molecule/predictor/rpgnn/modeling_rpgnn.py +76 -0
- torch_molecule/predictor/sgir/__init__.py +3 -0
- torch_molecule/predictor/sgir/modeling_sgir.py +260 -0
- torch_molecule/predictor/sgir/strategy.py +266 -0
- torch_molecule/predictor/smiles_transformer/__init__.py +3 -0
- torch_molecule/predictor/smiles_transformer/model.py +424 -0
- torch_molecule/predictor/smiles_transformer/modeling_transformer.py +252 -0
- torch_molecule/predictor/ssr/__init__.py +3 -0
- torch_molecule/predictor/ssr/model.py +283 -0
- torch_molecule/predictor/ssr/modeling_ssr.py +267 -0
- torch_molecule/predictor/ssr/utils.py +185 -0
- torch_molecule/utils/__init__.py +31 -0
- torch_molecule/utils/checker.py +158 -0
- torch_molecule/utils/checkpoint.py +294 -0
- torch_molecule/utils/format.py +140 -0
- torch_molecule/utils/generic/metrics.py +530 -0
- torch_molecule/utils/generic/pseudo_tasks.py +11 -0
- torch_molecule/utils/generic/weights.py +30 -0
- torch_molecule/utils/graph/features.py +178 -0
- torch_molecule/utils/graph/graph_from_smiles.py +134 -0
- torch_molecule/utils/graph/graph_to_smiles.py +312 -0
- torch_molecule/utils/hf.py +232 -0
- torch_molecule/utils/search.py +64 -0
- torch_molecule-0.1.0.dev2.dist-info/METADATA +243 -0
- torch_molecule-0.1.0.dev2.dist-info/RECORD +148 -0
- torch_molecule-0.1.0.dev2.dist-info/WHEEL +5 -0
- torch_molecule-0.1.0.dev2.dist-info/licenses/LICENSE +21 -0
- torch_molecule-0.1.0.dev2.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
#Dictionary mapping each character to a corresponding token (integer).
|
|
2
|
+
char_dic = {
|
|
3
|
+
'<pad>':0,
|
|
4
|
+
'#': 1, # Triple bond
|
|
5
|
+
'%': 2, # Two-digit ring closure (e.g., "%10")
|
|
6
|
+
'(': 3, # Branch opening
|
|
7
|
+
')': 4, # Branch closing
|
|
8
|
+
'*': 5, # Wildcard atom (used in BigSMILES for polymer repeating units)
|
|
9
|
+
'+': 6, # Positive charge
|
|
10
|
+
'-': 7, # Negative charge
|
|
11
|
+
'0': 8, # Ring closure digit
|
|
12
|
+
'1': 9,
|
|
13
|
+
'2': 10,
|
|
14
|
+
'3': 11,
|
|
15
|
+
'4': 12,
|
|
16
|
+
'5': 13,
|
|
17
|
+
'6': 14,
|
|
18
|
+
'7': 15,
|
|
19
|
+
'8': 16,
|
|
20
|
+
'9': 17,
|
|
21
|
+
'=': 18, # Double bond
|
|
22
|
+
'B': 19, # Boron
|
|
23
|
+
'C': 20, # Carbon
|
|
24
|
+
'F': 21, # Fluorine
|
|
25
|
+
'G': 22,
|
|
26
|
+
'H': 23, # Hydrogen
|
|
27
|
+
'I': 24, # Iodine
|
|
28
|
+
'K': 25,
|
|
29
|
+
'L': 26,
|
|
30
|
+
'N': 27, # Nitrogen
|
|
31
|
+
'O': 28, # Oxygen
|
|
32
|
+
'P': 29, # Phosphorus
|
|
33
|
+
'S': 30, # Sulfur
|
|
34
|
+
'T': 31,
|
|
35
|
+
'Z': 32,
|
|
36
|
+
'[': 33, # Open bracket for isotopes, charges, or explicit atoms
|
|
37
|
+
']': 34, # Close bracket
|
|
38
|
+
'a': 35, # Aromatic atoms
|
|
39
|
+
'b': 36,
|
|
40
|
+
'c': 37, # Aromatic carbon
|
|
41
|
+
'd': 38,
|
|
42
|
+
'e': 39,
|
|
43
|
+
'i': 40,
|
|
44
|
+
'l': 41,
|
|
45
|
+
'n': 42, # Aromatic nitrogen
|
|
46
|
+
'o': 43, # Aromatic oxygen
|
|
47
|
+
'r': 44,
|
|
48
|
+
's': 45, # Aromatic sulfur
|
|
49
|
+
'/': 46, # Cis/trans stereochemistry
|
|
50
|
+
'\\': 47, # Cis/trans stereochemistry
|
|
51
|
+
'@': 48, # Chirality
|
|
52
|
+
'.': 49, # Disconnected structures
|
|
53
|
+
'{': 50, # BigSMILES / CurlySMILES polymer notation
|
|
54
|
+
'}': 51, # BigSMILES / CurlySMILES polymer notation
|
|
55
|
+
'<': 52, # CurlySMILES syntax for polymer representations
|
|
56
|
+
'>': 53 # CurlySMILES syntax for polymer representations
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
def create_tensor_dataset(string_list, input_len, pad_token=0):
|
|
60
|
+
"""
|
|
61
|
+
Converts a list of strings into tokenized sequences, pads each sequence to input_len,
|
|
62
|
+
and wraps them in a TensorDataset.
|
|
63
|
+
|
|
64
|
+
Args:
|
|
65
|
+
string_list (list of str): List of input strings.
|
|
66
|
+
input_len (int): The fixed length to pad/truncate each token sequence.
|
|
67
|
+
pad_token (int, optional): The token used for padding. Defaults to 0.
|
|
68
|
+
|
|
69
|
+
Returns:
|
|
70
|
+
List of tokens.
|
|
71
|
+
"""
|
|
72
|
+
tokenized_list = []
|
|
73
|
+
|
|
74
|
+
for s in string_list:
|
|
75
|
+
# Convert each character in the string to a token
|
|
76
|
+
tokens = [char_dic[char] for char in s]
|
|
77
|
+
# Pad the token sequence if it's shorter than input_len; otherwise, truncate it
|
|
78
|
+
if len(tokens) < input_len:
|
|
79
|
+
tokens = tokens + [pad_token] * (input_len - len(tokens))
|
|
80
|
+
else:
|
|
81
|
+
tokens = tokens[:input_len]
|
|
82
|
+
|
|
83
|
+
tokenized_list.append(tokens)
|
|
84
|
+
|
|
85
|
+
return tokenized_list
|