graphchem.preprocessing.MoleculeEncoder
Bases: object
Source code in graphchem/preprocessing/features.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 |
|
vocab_sizes: Tuple[int]
property
total vocabulary/dictionary sizes for tokenizers, in form (atom vocab size, bond vocab size)
Returns:
Type | Description |
---|---|
Tuple[int]
|
Tuple[int]: (atom vocab size, bond vocab size) |
__init__(smiles)
MoleculeEncoder object: given a list of SMILES strings, construct/ train integer tokenizers to tokenize atom/bond features, parse molecule connectivity
Parameters:
Name | Type | Description | Default |
---|---|---|---|
smiles |
List[str]
|
SMILES strings to consider for encoder construction |
required |
Source code in graphchem/preprocessing/features.py
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
|
encode(smiles)
encode a molecule using its SMILES string
Parameters:
Name | Type | Description | Default |
---|---|---|---|
smiles |
str
|
molecule's SMILES string |
required |
Returns:
Type | Description |
---|---|
Tuple[torch.tensor]
|
Tuple['torch.tensor']: (encoded atom features, encoded bond features, molecule connectivity matrix) |
Source code in graphchem/preprocessing/features.py
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
|
encode_many(smiles)
batch encoding of SMILES strings
Parameters:
Name | Type | Description | Default |
---|---|---|---|
smiles |
List[str]
|
list of SMILES strings |
required |
Returns:
Type | Description |
---|---|
List[Tuple[torch.tensor]]
|
List[Tuple['torch.tensor']]: List of: (atom encoding, bond encoding, connectivity matrix) for each compound |
Source code in graphchem/preprocessing/features.py
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
|
load(filename)
load an encoder from file (current encoder attributes, including pre-trained tokenizers, are overwritten)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename |
str
|
filename/path of model |
required |
Returns:
Type | Description |
---|---|
None
|
None |
Source code in graphchem/preprocessing/features.py
241 242 243 244 245 246 247 248 249 250 251 252 253 |
|
save(filename)
save the encoder to a file
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename |
str
|
new filename/path for model |
required |
Returns:
Type | Description |
---|---|
None
|
None |
Source code in graphchem/preprocessing/features.py
228 229 230 231 232 233 234 235 236 237 238 239 |
|