Skip to content

Commit

Permalink
Merge pull request #44 from Acellera/simplify_molscore_conf
Browse files Browse the repository at this point in the history
Simplify molscore conf
  • Loading branch information
albertbou92 authored Jul 24, 2024
2 parents db10246 + 6b5e823 commit e4f29d4
Show file tree
Hide file tree
Showing 29 changed files with 73 additions and 163 deletions.
8 changes: 1 addition & 7 deletions scripts/a2c/a2c.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#! /usr/bin/python3
import datetime
import json
import os
import random
import shutil
from pathlib import Path

import hydra
Expand Down Expand Up @@ -88,16 +86,12 @@ def main(cfg: "DictConfig"):
) from MOLSCORE_ERR

if cfg.molscore_mode == "single":
# Save molscore output. Also redirect output to save_dir
cfg.molscore_task = shutil.copy(cfg.molscore_task, save_dir)
data = json.load(open(cfg.molscore_task, "r"))
json.dump(data, open(cfg.molscore_task, "w"), indent=4)
task = MolScore(
model_name=cfg.agent_name,
task_config=cfg.molscore_task,
budget=cfg.total_smiles,
output_dir=os.path.abspath(save_dir),
add_run_dir=False,
add_run_dir=True,
**cfg.get("molscore_kwargs", {}),
)
run_a2c(cfg, task)
Expand Down
8 changes: 3 additions & 5 deletions scripts/a2c/config_denovo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ num_envs: 16 # Number of smiles to generate in parallel
total_smiles: 10_000 # Total number of smiles to generate

# Scoring function
molscore_mode: benchmark # single, benchmark, or curriculum
molscore_task: MolOpt # task configuration (JSON), benchmark (preset only), or curriculum task (preset only)
molscore_kwargs:
include: ["Albuterol_similarity"]
custom_task: null # Requires molscore to be set to null
molscore_mode: single # single, benchmark, or curriculum
molscore_task: MolOpt:Albuterol_similarity # task configuration (JSON), benchmark (preset only), or curriculum task (preset only)
custom_task: null # Requires custom_task mode to be set to null

# Promptsmiles configuration
prompt: null # e.g. c1ccccc # Fix the beginning of the generated molecules
Expand Down
8 changes: 3 additions & 5 deletions scripts/a2c/config_fragment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ num_envs: 16 # Number of smiles to generate in parallel
total_smiles: 10_000 # Total number of smiles to generate

# Scoring function
molscore_mode: benchmark # single, benchmark, or curriculum
molscore_task: MolOpt # task configuration (JSON), benchmark (preset only), or curriculum task (preset only)
molscore_kwargs:
include: ["Celecoxxib_rediscovery"]
custom_task: null # Requires molscore to be set to null
molscore_mode: single # single, benchmark, or curriculum
molscore_task: MolOpt:Celecoxxib_rediscovery # task configuration (JSON), benchmark (preset only), or curriculum task (preset only)
custom_task: null # Requires molscore_task to be set to null

# Promptsmiles configuration
promptsmiles: c1(C)ccc(*)cc1.NS(=O)(=O)(*)
Expand Down
8 changes: 3 additions & 5 deletions scripts/a2c/config_scaffold.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ num_envs: 16 # Number of smiles to generate in parallel
total_smiles: 10_000 # Total number of smiles to generate

# Scoring function
molscore_mode: benchmark # single, benchmark, or curriculum
molscore_task: LibINVENT_Exp1 # task configuration (JSON), benchmark (preset only), or curriculum task (preset only)
molscore_kwargs:
include: ["DRD2_SelRF_SubFilt_DF"]
custom_task: null # Requires molscore to be set to null
molscore_mode: single # single, benchmark, or curriculum
molscore_task: LibINVENT_Exp1:DRD2_SelRF_SubFilt_DF # task configuration (JSON), benchmark (preset only), or curriculum task (preset only)
custom_task: null # Requires molscore_task to be set to null

# Promptsmiles configuration
promptsmiles: N1(*)CCN(CC1)CCCCN(*)
Expand Down
8 changes: 1 addition & 7 deletions scripts/ahc/ahc.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#! /usr/bin/python3
import datetime
import json
import os
import random
import shutil
from copy import deepcopy
from pathlib import Path

Expand Down Expand Up @@ -90,16 +88,12 @@ def main(cfg: "DictConfig"):
) from MOLSCORE_ERR

if cfg.molscore_mode == "single":
# Save molscore output. Also redirect output to save_dir
cfg.molscore_task = shutil.copy(cfg.molscore_task, save_dir)
data = json.load(open(cfg.molscore_task, "r"))
json.dump(data, open(cfg.molscore_task, "w"), indent=4)
task = MolScore(
model_name=cfg.agent_name,
task_config=cfg.molscore_task,
budget=cfg.total_smiles,
output_dir=os.path.abspath(save_dir),
add_run_dir=False,
add_run_dir=True,
**cfg.get("molscore_kwargs", {}),
)
run_ahc(cfg, task)
Expand Down
8 changes: 3 additions & 5 deletions scripts/ahc/config_denovo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ num_envs: 128 # Number of smiles to generate in parallel
total_smiles: 10_000 # Total number of smiles to generate

# Scoring function
molscore_mode: benchmark # single, benchmark, or curriculum
molscore_task: MolOpt # task configuration (JSON), benchmark (preset only), or curriculum task (preset only)
molscore_kwargs:
include: ["Albuterol_similarity"]
custom_task: null # Requires molscore to be set to null
molscore_mode: single # single, benchmark, or curriculum
molscore_task: MolOpt:Albuterol_similarity # task configuration (JSON), benchmark (preset only), or curriculum task (preset only)
custom_task: null # Requires custom_task mode to be set to null

# Promptsmiles configuration
prompt: null # e.g. c1ccccc # Fix the beginning of the generated molecules
Expand Down
8 changes: 3 additions & 5 deletions scripts/ahc/config_fragment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ num_envs: 128 # Number of smiles to generate in parallel
total_smiles: 10_000 # Total number of smiles to generate

# Scoring function
molscore_mode: benchmark # single, benchmark, or curriculum
molscore_task: MolOpt # task configuration (JSON), benchmark (preset only), or curriculum task (preset only)
molscore_kwargs:
include: ["Celecoxxib_rediscovery"]
custom_task: null # Requires molscore to be set to null
molscore_mode: single # single, benchmark, or curriculum
molscore_task: MolOpt:Celecoxxib_rediscovery # task configuration (JSON), benchmark (preset only), or curriculum task (preset only)
custom_task: null # Requires molscore_task to be set to null

# Promptsmiles configuration
promptsmiles: c1(C)ccc(*)cc1.NS(=O)(=O)(*)
Expand Down
8 changes: 3 additions & 5 deletions scripts/ahc/config_scaffold.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ num_envs: 128 # Number of smiles to generate in parallel
total_smiles: 10_000 # Total number of smiles to generate

# Scoring function
molscore_mode: benchmark # single, benchmark, or curriculum
molscore_task: LibINVENT_Exp1 # task configuration (JSON), benchmark (preset only), or curriculum task (preset only)
molscore_kwargs:
include: ["DRD2_SelRF_SubFilt_DF"]
custom_task: null # Requires molscore to be set to null
molscore_mode: single # single, benchmark, or curriculum
molscore_task: LibINVENT_Exp1:DRD2_SelRF_SubFilt_DF # task configuration (JSON), benchmark (preset only), or curriculum task (preset only)
custom_task: null # Requires molscore_task to be set to null

# Promptsmiles configuration
promptsmiles: N1(*)CCN(CC1)CCCCN(*)
Expand Down
8 changes: 3 additions & 5 deletions scripts/dpo/config_denovo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ num_envs: 128 # Number of smiles to generate in parallel
total_smiles: 10_000 # Total number of smiles to generate

# Scoring function
molscore_mode: benchmark # single, benchmark, or curriculum
molscore_task: MolOpt # task configuration (JSON), benchmark (preset only), or curriculum task (preset only)
molscore_kwargs:
include: ["Albuterol_similarity"]
custom_task: null # Requires molscore to be set to null
molscore_mode: single # single, benchmark, or curriculum
molscore_task: MolOpt:Albuterol_similarity # task configuration (JSON), benchmark (preset only), or curriculum task (preset only)
custom_task: null # Requires custom_task mode to be set to null

# Promptsmiles configuration
prompt: null # e.g. c1ccccc # Fix the beginning of the generated molecules
Expand Down
8 changes: 3 additions & 5 deletions scripts/dpo/config_fragment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ num_envs: 128 # Number of smiles to generate in parallel
total_smiles: 10_000 # Total number of smiles to generate

# Scoring function
molscore_mode: benchmark # single, benchmark, or curriculum
molscore_task: MolOpt # task configuration (JSON), benchmark (preset only), or curriculum task (preset only)
molscore_kwargs:
include: ["Celecoxxib_rediscovery"]
custom_task: null # Requires molscore to be set to null
molscore_mode: single # single, benchmark, or curriculum
molscore_task: MolOpt:Celecoxxib_rediscovery # task configuration (JSON), benchmark (preset only), or curriculum task (preset only)
custom_task: null # Requires molscore_task to be set to null

# Promptsmiles configuration
promptsmiles: c1(C)ccc(*)cc1.NS(=O)(=O)(*)
Expand Down
8 changes: 3 additions & 5 deletions scripts/dpo/config_scaffold.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ num_envs: 128 # Number of smiles to generate in parallel
total_smiles: 10_000 # Total number of smiles to generate

# Scoring function
molscore_mode: benchmark # single, benchmark, or curriculum
molscore_task: LibINVENT_Exp1 # task configuration (JSON), benchmark (preset only), or curriculum task (preset only)
molscore_kwargs:
include: ["DRD2_SelRF_SubFilt_DF"]
custom_task: null # Requires molscore to be set to null
molscore_mode: single # single, benchmark, or curriculum
molscore_task: LibINVENT_Exp1:DRD2_SelRF_SubFilt_DF # task configuration (JSON), benchmark (preset only), or curriculum task (preset only)
custom_task: null # Requires molscore_task to be set to null

# Promptsmiles configuration
promptsmiles: N1(*)CCN(CC1)CCCCN(*)
Expand Down
8 changes: 1 addition & 7 deletions scripts/dpo/dpo.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#! /usr/bin/python3
import datetime
import json
import os
import random
import shutil
from copy import deepcopy
from pathlib import Path

Expand Down Expand Up @@ -83,16 +81,12 @@ def main(cfg: "DictConfig"):
) from MOLSCORE_ERR

if cfg.molscore_mode == "single":
# Save molscore output. Also redirect output to save_dir
cfg.molscore_task = shutil.copy(cfg.molscore_task, save_dir)
data = json.load(open(cfg.molscore_task, "r"))
json.dump(data, open(cfg.molscore_task, "w"), indent=4)
task = MolScore(
model_name=cfg.agent_name,
task_config=cfg.molscore_task,
budget=cfg.total_smiles,
output_dir=os.path.abspath(save_dir),
add_run_dir=False,
add_run_dir=True,
**cfg.get("molscore_kwargs", {}),
)
run_dpo(cfg, task)
Expand Down
8 changes: 3 additions & 5 deletions scripts/hill_climb/config_denovo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ num_envs: 1024 # Number of smiles to generate in parallel
total_smiles: 10_000 # Total number of smiles to generate

# Scoring function
molscore_mode: benchmark # single, benchmark, or curriculum
molscore_task: MolOpt # task configuration (JSON), benchmark (preset only), or curriculum task (preset only)
molscore_kwargs:
include: ["Albuterol_similarity"]
custom_task: null # Requires molscore to be set to null
molscore_mode: single # single, benchmark, or curriculum
molscore_task: MolOpt:Albuterol_similarity # task configuration (JSON), benchmark (preset only), or curriculum task (preset only)
custom_task: null # Requires custom_task mode to be set to null

# Promptsmiles configuration
prompt: null # e.g. c1ccccc # Fix the beginning of the generated molecules
Expand Down
8 changes: 3 additions & 5 deletions scripts/hill_climb/config_fragment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ num_envs: 128 # Number of smiles to generate in parallel
total_smiles: 10_000 # Total number of smiles to generate

# Scoring function
molscore_mode: benchmark # single, benchmark, or curriculum
molscore_task: MolOpt # task configuration (JSON), benchmark (preset only), or curriculum task (preset only)
molscore_kwargs:
include: ["Celecoxxib_rediscovery"]
custom_task: null # Requires molscore to be set to null
molscore_mode: single # single, benchmark, or curriculum
molscore_task: MolOpt:Celecoxxib_rediscovery # task configuration (JSON), benchmark (preset only), or curriculum task (preset only)
custom_task: null # Requires molscore_task to be set to null

# Promptsmiles configuration
promptsmiles: c1(C)ccc(*)cc1.NS(=O)(=O)(*)
Expand Down
8 changes: 3 additions & 5 deletions scripts/hill_climb/config_scaffold.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ num_envs: 128 # Number of smiles to generate in parallel
total_smiles: 10_000 # Total number of smiles to generate

# Scoring function
molscore_mode: benchmark # single, benchmark, or curriculum
molscore_task: LibINVENT_Exp1 # task configuration (JSON), benchmark (preset only), or curriculum task (preset only)
molscore_kwargs:
include: ["DRD2_SelRF_SubFilt_DF"]
custom_task: null # Requires molscore to be set to null
molscore_mode: single # single, benchmark, or curriculum
molscore_task: LibINVENT_Exp1:DRD2_SelRF_SubFilt_DF # task configuration (JSON), benchmark (preset only), or curriculum task (preset only)
custom_task: null # Requires molscore_task to be set to null

# Promptsmiles configuration
promptsmiles: N1(*)CCN(CC1)CCCCN(*)
Expand Down
8 changes: 1 addition & 7 deletions scripts/hill_climb/hill_climb.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#! /usr/bin/python3
import datetime
import json
import os
import random
import shutil
from copy import deepcopy
from pathlib import Path

Expand Down Expand Up @@ -91,16 +89,12 @@ def main(cfg: "DictConfig"):
) from MOLSCORE_ERR

if cfg.molscore_mode == "single":
# Save molscore output. Also redirect output to save_dir
cfg.molscore_task = shutil.copy(cfg.molscore_task, save_dir)
data = json.load(open(cfg.molscore_task, "r"))
json.dump(data, open(cfg.molscore_task, "w"), indent=4)
task = MolScore(
model_name=cfg.agent_name,
task_config=cfg.molscore_task,
budget=cfg.total_smiles,
output_dir=os.path.abspath(save_dir),
add_run_dir=False,
add_run_dir=True,
**cfg.get("molscore_kwargs", {}),
)
run_hill_climb(cfg, task)
Expand Down
8 changes: 3 additions & 5 deletions scripts/ppo/config_denovo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ num_envs: 64 # Number of smiles to generate in parallel
total_smiles: 10_000 # Total number of smiles to generate

# Scoring function
molscore_mode: benchmark # single, benchmark, or curriculum
molscore_task: MolOpt # task configuration (JSON), benchmark (preset only), or curriculum task (preset only)
molscore_kwargs:
include: ["Albuterol_similarity"]
custom_task: null # Requires molscore to be set to null
molscore_mode: single # single, benchmark, or curriculum
molscore_task: MolOpt:Albuterol_similarity # task configuration (JSON), benchmark (preset only), or curriculum task (preset only)
custom_task: null # Requires custom_task mode to be set to null

# Promptsmiles configuration
prompt: null # e.g. c1ccccc # Fix the beginning of the generated molecules
Expand Down
8 changes: 3 additions & 5 deletions scripts/ppo/config_fragment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ num_envs: 64 # Number of smiles to generate in parallel
total_smiles: 10_000 # Total number of smiles to generate

# Scoring function
molscore_mode: benchmark # single, benchmark, or curriculum
molscore_task: MolOpt # task configuration (JSON), benchmark (preset only), or curriculum task (preset only)
molscore_kwargs:
include: ["Celecoxxib_rediscovery"]
custom_task: null # Requires molscore to be set to null
molscore_mode: single # single, benchmark, or curriculum
molscore_task: MolOpt:Celecoxxib_rediscovery # task configuration (JSON), benchmark (preset only), or curriculum task (preset only)
custom_task: null # Requires molscore_task to be set to null

# Promptsmiles configuration
promptsmiles: c1(C)ccc(*)cc1.NS(=O)(=O)(*)
Expand Down
8 changes: 3 additions & 5 deletions scripts/ppo/config_scaffold.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ num_envs: 64 # Number of smiles to generate in parallel
total_smiles: 10_000 # Total number of smiles to generate

# Scoring function
molscore_mode: benchmark # single, benchmark, or curriculum
molscore_task: LibINVENT_Exp1 # task configuration (JSON), benchmark (preset only), or curriculum task (preset only)
molscore_kwargs:
include: ["DRD2_SelRF_SubFilt_DF"]
custom_task: null # Requires molscore to be set to null
molscore_mode: single # single, benchmark, or curriculum
molscore_task: LibINVENT_Exp1:DRD2_SelRF_SubFilt_DF # task configuration (JSON), benchmark (preset only), or curriculum task (preset only)
custom_task: null # Requires molscore_task to be set to null

# Promptsmiles configuration
promptsmiles: N1(*)CCN(CC1)CCCCN(*)
Expand Down
8 changes: 1 addition & 7 deletions scripts/ppo/ppo.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#! /usr/bin/python3
import datetime
import json
import os
import random
import shutil
from pathlib import Path

import hydra
Expand Down Expand Up @@ -93,16 +91,12 @@ def main(cfg: "DictConfig"):
) from MOLSCORE_ERR

if cfg.molscore_mode == "single":
# Save molscore output. Also redirect output to save_dir
cfg.molscore_task = shutil.copy(cfg.molscore_task, save_dir)
data = json.load(open(cfg.molscore_task, "r"))
json.dump(data, open(cfg.molscore_task, "w"), indent=4)
task = MolScore(
model_name=cfg.agent_name,
task_config=cfg.molscore_task,
budget=cfg.total_smiles,
output_dir=os.path.abspath(save_dir),
add_run_dir=False,
add_run_dir=True,
**cfg.get("molscore_kwargs", {}),
)
run_ppo(cfg, task)
Expand Down
8 changes: 3 additions & 5 deletions scripts/reinforce/config_denovo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ num_envs: 128 # Number of smiles to generate in parallel
total_smiles: 10_000 # Total number of smiles to generate

# Scoring function
molscore_mode: benchmark # single, benchmark, or curriculum
molscore_task: MolOpt # task configuration (JSON), benchmark (preset only), or curriculum task (preset only)
molscore_kwargs:
include: ["Albuterol_similarity"]
custom_task: null # Requires molscore to be set to null
molscore_mode: single # single, benchmark, or curriculum
molscore_task: MolOpt:Albuterol_similarity # task configuration (JSON), benchmark (preset only), or curriculum task (preset only)
custom_task: null # Requires custom_task mode to be set to null

# Promptsmiles configuration
prompt: null # e.g. c1ccccc # Fix the beginning of the generated molecules
Expand Down
8 changes: 3 additions & 5 deletions scripts/reinforce/config_fragment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ num_envs: 128 # Number of smiles to generate in parallel
total_smiles: 10_000 # Total number of smiles to generate

# Scoring function
molscore_mode: benchmark # single, benchmark, or curriculum
molscore_task: MolOpt # task configuration (JSON), benchmark (preset only), or curriculum task (preset only)
molscore_kwargs:
include: ["Celecoxxib_rediscovery"]
custom_task: null # Requires molscore to be set to null
molscore_mode: single # single, benchmark, or curriculum
molscore_task: MolOpt:Celecoxxib_rediscovery # task configuration (JSON), benchmark (preset only), or curriculum task (preset only)
custom_task: null # Requires molscore_task to be set to null

# Promptsmiles configuration
promptsmiles: c1(C)ccc(*)cc1.NS(=O)(=O)(*)
Expand Down
Loading

0 comments on commit e4f29d4

Please sign in to comment.