bayesianflow-for-chem 2.0.2__py3-none-any.whl → 2.0.3__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.

Potentially problematic release.


This version of bayesianflow-for-chem might be problematic. Click here for more details.

@@ -3,6 +3,7 @@
3
3
  """
4
4
  ChemBFN package.
5
5
  """
6
+ import colorama
6
7
  from . import data, tool, train, scorer, spectra
7
8
  from .model import ChemBFN, MLP, EnsembleChemBFN
8
9
  from .cli import main_script
@@ -17,7 +18,7 @@ __all__ = [
17
18
  "MLP",
18
19
  "EnsembleChemBFN",
19
20
  ]
20
- __version__ = "2.0.2"
21
+ __version__ = "2.0.3"
21
22
  __author__ = "Nianze A. Tao (Omozawa Sueno)"
22
23
 
23
24
 
@@ -28,4 +29,6 @@ def main() -> None:
28
29
  :return:
29
30
  :rtype: None
30
31
  """
32
+ colorama.just_fix_windows_console()
31
33
  main_script(__version__)
34
+ colorama.deinit()
@@ -180,14 +180,16 @@ def load_model_config(
180
180
  model_config = tomllib.load(f)
181
181
  if model_config["ChemBFN"]["num_vocab"] != "match vocabulary size":
182
182
  if not isinstance(model_config["ChemBFN"]["num_vocab"], int):
183
- print(f"Critical in {config_file}: You must specify num_vocab.")
183
+ print(
184
+ f"\033[0;31mCritical\033[0;0m in {config_file}: You must specify num_vocab."
185
+ )
184
186
  flag_critical += 1
185
187
  if model_config["ChemBFN"]["base_model"]:
186
188
  model_file = model_config["ChemBFN"]["base_model"]
187
189
  for fn in model_file:
188
190
  if not os.path.exists(fn):
189
191
  print(
190
- f"Critical in {config_file}: Base model file {fn} does not exist."
192
+ f"\033[0;31mCritical\033[0;0m in {config_file}: Base model file {fn} does not exist."
191
193
  )
192
194
  flag_critical += 1
193
195
  if "MLP" in model_config:
@@ -195,14 +197,14 @@ def load_model_config(
195
197
  b = model_config["MLP"]["size"][-1]
196
198
  if a != b:
197
199
  print(
198
- f"Critical in {config_file}: MLP hidden size {b} should match ChemBFN hidden size {a}."
200
+ f"\033[0;31mCritical\033[0;0m in {config_file}: MLP hidden size {b} should match ChemBFN hidden size {a}."
199
201
  )
200
202
  flag_critical += 1
201
203
  if model_config["MLP"]["base_model"]:
202
204
  model_file = model_config["MLP"]["base_model"]
203
205
  if not os.path.exists(model_file):
204
206
  print(
205
- f"Critical in {config_file}: Base model file {fn} does not exist."
207
+ f"\033[0;31mCritical\033[0;0m in {config_file}: Base model file {fn} does not exist."
206
208
  )
207
209
  flag_critical += 1
208
210
  return model_config, flag_critical, flag_warning
@@ -226,49 +228,61 @@ def load_runtime_config(
226
228
  config = tomllib.load(f)
227
229
  tokeniser_name = config["tokeniser"]["name"].lower()
228
230
  if not tokeniser_name in "smiles selfies safe fasta".split():
229
- print(f"Critical in {config_file}: Unknown tokensier name: {tokeniser_name}.")
231
+ print(
232
+ f"\033[0;31mCritical\033[0;0m in {config_file}: Unknown tokensier name: {tokeniser_name}."
233
+ )
230
234
  flag_critical += 1
231
235
  if tokeniser_name == "selfies":
232
236
  vocab = config["tokeniser"]["vocab"]
233
237
  if vocab.lower() == "default":
234
- print(f"Critical in {config_file}: You should specify a vocabulary file.")
238
+ print(
239
+ f"\033[0;31mCritical\033[0;0m in {config_file}: You should specify a vocabulary file."
240
+ )
235
241
  flag_critical += 1
236
242
  elif not os.path.exists(vocab):
237
- print(f"Critical in {config_file}: Vocabulary file {vocab} does not exist.")
243
+ print(
244
+ f"\033[0;31mCritical\033[0;0m in {config_file}: Vocabulary file {vocab} does not exist."
245
+ )
238
246
  flag_critical += 1
239
247
  if "train" in config:
240
248
  dataset_file = config["train"]["dataset"]
241
249
  if not os.path.exists(dataset_file):
242
250
  print(
243
- f"Critical in {config_file}: Dataset file {dataset_file} does not exist."
251
+ f"\033[0;31mCritical\033[0;0m in {config_file}: Dataset file {dataset_file} does not exist."
244
252
  )
245
253
  flag_critical += 1
246
254
  logger_name = config["train"]["logger_name"].lower()
247
255
  if not logger_name in "csv tensorboard wandb".split():
248
- print(f"Critical in {config_file}: Unknown logger: {logger_name}.")
256
+ print(
257
+ f"\033[0;31mCritical\033[0;0m in {config_file}: Unknown logger: {logger_name}."
258
+ )
249
259
  flag_critical += 1
250
260
  if config["train"]["restart"]:
251
261
  ckpt_file = config["train"]["restart"]
252
262
  if not os.path.exists(ckpt_file):
253
263
  print(
254
- f"Critical in {config_file}: Restart checkpoint file {ckpt_file} does not exist."
264
+ f"\033[0;31mCritical\033[0;0m in {config_file}: Restart checkpoint file {ckpt_file} does not exist."
255
265
  )
256
266
  flag_critical += 1
257
267
  if "inference" in config:
258
268
  if not "train" in config:
259
269
  if not isinstance(config["inference"]["sequence_length"], int):
260
270
  print(
261
- f"Critical in {config_file}: You must set an integer for sequence_length."
271
+ f"\033[0;31mCritical\033[0;0m in {config_file}: You must set an integer for sequence_length."
262
272
  )
263
273
  flag_critical += 1
264
274
  if config["inference"]["guidance_objective"]:
265
275
  if not "guidance_objective_strength" in config["inference"]:
266
276
  print(
267
- f"Critical in {config_file}: You need to add guidance_objective_strength."
277
+ f"\033[0;31mCritical\033[0;0m in {config_file}: You need to add guidance_objective_strength."
268
278
  )
269
279
  flag_critical += 1
270
280
  result_dir = Path(config["inference"]["result_file"]).parent
271
- assert os.path.exists(result_dir), f"directory {result_dir} does not exist."
281
+ if not os.path.exists(result_dir):
282
+ print(
283
+ f"\033[0;33mWarning\033[0;0m in {config_file}: Directory {result_dir} to save the result does not exist."
284
+ )
285
+ flag_warning += 1
272
286
  return config, flag_critical, flag_warning
273
287
 
274
288
 
@@ -306,7 +320,7 @@ def main_script(version: str) -> None:
306
320
  if runtime_config["train"]["enable_lora"]:
307
321
  if not model_config["ChemBFN"]["base_model"]:
308
322
  print(
309
- f"Warning in {parser.model_config}: You should load a pretrained model first."
323
+ f"\033[0;33mWarning\033[0;0m in {parser.model_config}: You should load a pretrained model first."
310
324
  )
311
325
  flag_warning += 1
312
326
  if not os.path.exists(runtime_config["train"]["checkpoint_save_path"]):
@@ -314,12 +328,12 @@ def main_script(version: str) -> None:
314
328
  else:
315
329
  if not model_config["ChemBFN"]["base_model"]:
316
330
  print(
317
- f"Warning in {parser.model_config}: You should load a pretrained ChemBFN model."
331
+ f"\033[0;33mWarning\033[0;0m in {parser.model_config}: You should load a pretrained ChemBFN model."
318
332
  )
319
333
  flag_warning += 1
320
334
  if not model_config["MLP"]["base_model"]:
321
335
  print(
322
- f"Warning in {parser.model_config}: You should load a pretrained MLP."
336
+ f"\033[0;33mWarning\033[0;0m in {parser.model_config}: You should load a pretrained MLP."
323
337
  )
324
338
  flag_warning += 1
325
339
  if "inference" in runtime_config:
@@ -9,6 +9,7 @@ import warnings
9
9
  from pathlib import Path
10
10
  from typing import List, Dict, Tuple, Union, Optional
11
11
  import torch
12
+ import colorama
12
13
  import numpy as np
13
14
  from torch import cuda, Tensor, softmax
14
15
  from torch.utils.data import DataLoader
@@ -141,6 +142,7 @@ def split_dataset(
141
142
  assert file.endswith(".csv")
142
143
  assert len(split_ratio) == 3
143
144
  assert method in ("random", "scaffold")
145
+ colorama.just_fix_windows_console()
144
146
  with open(file, "r") as f:
145
147
  data = list(csv.reader(f))
146
148
  header = data[0]
@@ -198,6 +200,7 @@ def split_dataset(
198
200
  with open(file.replace(".csv", "_val.csv"), "w", newline="") as fva:
199
201
  writer = csv.writer(fva)
200
202
  writer.writerows([header] + val_set)
203
+ colorama.deinit()
201
204
 
202
205
 
203
206
  @torch.no_grad()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bayesianflow_for_chem
3
- Version: 2.0.2
3
+ Version: 2.0.3
4
4
  Summary: Bayesian flow network framework for Chemistry
5
5
  Home-page: https://augus1999.github.io/bayesian-flow-network-for-chemistry/
6
6
  Author: Nianze A. Tao
@@ -23,6 +23,7 @@ License-File: LICENSE
23
23
  Requires-Dist: rdkit>=2025.3.5
24
24
  Requires-Dist: torch>=2.8.0
25
25
  Requires-Dist: torchao>=0.12
26
+ Requires-Dist: colorama>=0.4.6
26
27
  Requires-Dist: numpy>=2.3.2
27
28
  Requires-Dist: scipy>=1.16.1
28
29
  Requires-Dist: loralib>=0.1.2
@@ -49,6 +50,11 @@ Dynamic: summary
49
50
 
50
51
  This is the repository of the PyTorch implementation of ChemBFN model.
51
52
 
53
+ ## Build State
54
+
55
+ [![PyPI](https://img.shields.io/pypi/v/bayesianflow-for-chem?color=ff69b4)](https://pypi.org/project/bayesianflow-for-chem/)
56
+ ![pytest](https://github.com/Augus1999/bayesian-flow-network-for-chemistry/actions/workflows/pytest.yml/badge.svg)
57
+
52
58
  ## Features
53
59
 
54
60
  ChemBFN provides the state-of-the-art functionalities of
@@ -1,15 +1,15 @@
1
- bayesianflow_for_chem/__init__.py,sha256=ZFYmYKG9x1nn1ootKEjcAM1e5_8OYhmJ2iajT3Zq1rw,534
2
- bayesianflow_for_chem/cli.py,sha256=iies_Dr_rdwfXw5wcNmX2T36eo1UlvAtIkkZVYlKASQ,22125
1
+ bayesianflow_for_chem/__init__.py,sha256=D4bOlPLzpGhxTdr4Zb96Xtoc5y5BftiiuQT-SL86a7s,612
2
+ bayesianflow_for_chem/cli.py,sha256=decINvgtoDNUZy-wJvUE41ggUb-7RKZZh3Vbu0v_nSk,22695
3
3
  bayesianflow_for_chem/data.py,sha256=Pl0gGWHmMKTKHpsxznvLgYPCwwlLNL7nqH19Vipjkxs,6584
4
4
  bayesianflow_for_chem/model.py,sha256=bswVv3DiQTF3u37A80lrj_UPzklYtRH06woFfMXy84k,51643
5
5
  bayesianflow_for_chem/scorer.py,sha256=gQFUlkyxitch02ntqcRh1ZS8aondKLynW5U6NfTQTb4,4084
6
6
  bayesianflow_for_chem/spectra.py,sha256=Ba9ib1aDvTtDYbH3b4d-lIty3ZSQMu7jwehuV2KmhwA,1781
7
- bayesianflow_for_chem/tool.py,sha256=-ldRAvGLJndsgGY_anHMrIw19ePk2dVcx5qt2DGWI3s,21211
7
+ bayesianflow_for_chem/tool.py,sha256=8fNe8pL5veUHHnnqV02AQXDe76miKRrZzypjb9Nu_hA,21289
8
8
  bayesianflow_for_chem/train.py,sha256=hGKyhGhLch-exSYPZdLXrLn3gf39Q1VLSJs2qtuikQE,9709
9
9
  bayesianflow_for_chem/vocab.txt,sha256=HgtAZmpWYk4y8PqEVC4vqut1vE75DfRKE_10s2UW0rU,790
10
- bayesianflow_for_chem-2.0.2.dist-info/licenses/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
11
- bayesianflow_for_chem-2.0.2.dist-info/METADATA,sha256=2uEwTlHBiFBKxeS4QOBGTYw6VKgnpp-TZCuiQ88itq4,5762
12
- bayesianflow_for_chem-2.0.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
13
- bayesianflow_for_chem-2.0.2.dist-info/entry_points.txt,sha256=N63RMoJsr8rxuKxc7Fj802SL8J5AlpCoPkS8E3IFPLI,54
14
- bayesianflow_for_chem-2.0.2.dist-info/top_level.txt,sha256=KHsanI3BMCt8D9Qpze2ycrF6nMa3PyojgO6eS1c8kco,22
15
- bayesianflow_for_chem-2.0.2.dist-info/RECORD,,
10
+ bayesianflow_for_chem-2.0.3.dist-info/licenses/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
11
+ bayesianflow_for_chem-2.0.3.dist-info/METADATA,sha256=eR9Kn7lM9xsALxC5y2cThQQ5iiGX-atOl_sBaLdg_NM,6056
12
+ bayesianflow_for_chem-2.0.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
13
+ bayesianflow_for_chem-2.0.3.dist-info/entry_points.txt,sha256=N63RMoJsr8rxuKxc7Fj802SL8J5AlpCoPkS8E3IFPLI,54
14
+ bayesianflow_for_chem-2.0.3.dist-info/top_level.txt,sha256=KHsanI3BMCt8D9Qpze2ycrF6nMa3PyojgO6eS1c8kco,22
15
+ bayesianflow_for_chem-2.0.3.dist-info/RECORD,,