diff --git a/scripts/a2c/a2c.py b/scripts/a2c/a2c.py index ad3b21f..b247e41 100644 --- a/scripts/a2c/a2c.py +++ b/scripts/a2c/a2c.py @@ -1,9 +1,7 @@ #! /usr/bin/python3 import datetime -import json import os import random -import shutil from pathlib import Path import hydra @@ -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) diff --git a/scripts/a2c/config_denovo.yaml b/scripts/a2c/config_denovo.yaml index 316993e..186727b 100644 --- a/scripts/a2c/config_denovo.yaml +++ b/scripts/a2c/config_denovo.yaml @@ -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 diff --git a/scripts/a2c/config_fragment.yaml b/scripts/a2c/config_fragment.yaml index ca470e2..c410007 100644 --- a/scripts/a2c/config_fragment.yaml +++ b/scripts/a2c/config_fragment.yaml @@ -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)(*) diff --git a/scripts/a2c/config_scaffold.yaml b/scripts/a2c/config_scaffold.yaml index c482675..01cc2f9 100644 --- a/scripts/a2c/config_scaffold.yaml +++ b/scripts/a2c/config_scaffold.yaml @@ -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(*) diff --git a/scripts/ahc/ahc.py b/scripts/ahc/ahc.py index aeaedc2..d9a4c80 100644 --- a/scripts/ahc/ahc.py +++ b/scripts/ahc/ahc.py @@ -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 @@ -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) diff --git a/scripts/ahc/config_denovo.yaml b/scripts/ahc/config_denovo.yaml index 4d796d3..7c530a3 100644 --- a/scripts/ahc/config_denovo.yaml +++ b/scripts/ahc/config_denovo.yaml @@ -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 diff --git a/scripts/ahc/config_fragment.yaml b/scripts/ahc/config_fragment.yaml index 775651c..699468f 100644 --- a/scripts/ahc/config_fragment.yaml +++ b/scripts/ahc/config_fragment.yaml @@ -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)(*) diff --git a/scripts/ahc/config_scaffold.yaml b/scripts/ahc/config_scaffold.yaml index 5493e30..cbe5603 100644 --- a/scripts/ahc/config_scaffold.yaml +++ b/scripts/ahc/config_scaffold.yaml @@ -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(*) diff --git a/scripts/dpo/config_denovo.yaml b/scripts/dpo/config_denovo.yaml index 6790364..ea40bda 100644 --- a/scripts/dpo/config_denovo.yaml +++ b/scripts/dpo/config_denovo.yaml @@ -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 diff --git a/scripts/dpo/config_fragment.yaml b/scripts/dpo/config_fragment.yaml index 3b73a71..170482c 100644 --- a/scripts/dpo/config_fragment.yaml +++ b/scripts/dpo/config_fragment.yaml @@ -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)(*) diff --git a/scripts/dpo/config_scaffold.yaml b/scripts/dpo/config_scaffold.yaml index 989422d..b175001 100644 --- a/scripts/dpo/config_scaffold.yaml +++ b/scripts/dpo/config_scaffold.yaml @@ -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(*) diff --git a/scripts/dpo/dpo.py b/scripts/dpo/dpo.py index 8f15549..d86a2bd 100644 --- a/scripts/dpo/dpo.py +++ b/scripts/dpo/dpo.py @@ -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 @@ -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) diff --git a/scripts/hill_climb/config_denovo.yaml b/scripts/hill_climb/config_denovo.yaml index 67590e3..b930dee 100644 --- a/scripts/hill_climb/config_denovo.yaml +++ b/scripts/hill_climb/config_denovo.yaml @@ -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 diff --git a/scripts/hill_climb/config_fragment.yaml b/scripts/hill_climb/config_fragment.yaml index 76998a1..39ddff1 100644 --- a/scripts/hill_climb/config_fragment.yaml +++ b/scripts/hill_climb/config_fragment.yaml @@ -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)(*) diff --git a/scripts/hill_climb/config_scaffold.yaml b/scripts/hill_climb/config_scaffold.yaml index 05f48ad..2def918 100644 --- a/scripts/hill_climb/config_scaffold.yaml +++ b/scripts/hill_climb/config_scaffold.yaml @@ -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(*) diff --git a/scripts/hill_climb/hill_climb.py b/scripts/hill_climb/hill_climb.py index bd52904..bf6ca77 100644 --- a/scripts/hill_climb/hill_climb.py +++ b/scripts/hill_climb/hill_climb.py @@ -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 @@ -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) diff --git a/scripts/ppo/config_denovo.yaml b/scripts/ppo/config_denovo.yaml index d38b6a0..95f8699 100644 --- a/scripts/ppo/config_denovo.yaml +++ b/scripts/ppo/config_denovo.yaml @@ -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 diff --git a/scripts/ppo/config_fragment.yaml b/scripts/ppo/config_fragment.yaml index 0b69f21..1465b53 100644 --- a/scripts/ppo/config_fragment.yaml +++ b/scripts/ppo/config_fragment.yaml @@ -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)(*) diff --git a/scripts/ppo/config_scaffold.yaml b/scripts/ppo/config_scaffold.yaml index 2957069..527f7ed 100644 --- a/scripts/ppo/config_scaffold.yaml +++ b/scripts/ppo/config_scaffold.yaml @@ -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(*) diff --git a/scripts/ppo/ppo.py b/scripts/ppo/ppo.py index 31de2bf..abe6bbf 100644 --- a/scripts/ppo/ppo.py +++ b/scripts/ppo/ppo.py @@ -1,9 +1,7 @@ #! /usr/bin/python3 import datetime -import json import os import random -import shutil from pathlib import Path import hydra @@ -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) diff --git a/scripts/reinforce/config_denovo.yaml b/scripts/reinforce/config_denovo.yaml index 453afd2..dd336ae 100644 --- a/scripts/reinforce/config_denovo.yaml +++ b/scripts/reinforce/config_denovo.yaml @@ -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 diff --git a/scripts/reinforce/config_fragment.yaml b/scripts/reinforce/config_fragment.yaml index 43941a5..90b4ae4 100644 --- a/scripts/reinforce/config_fragment.yaml +++ b/scripts/reinforce/config_fragment.yaml @@ -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)(*) diff --git a/scripts/reinforce/config_scaffold.yaml b/scripts/reinforce/config_scaffold.yaml index 231cdb2..583f45b 100644 --- a/scripts/reinforce/config_scaffold.yaml +++ b/scripts/reinforce/config_scaffold.yaml @@ -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(*) diff --git a/scripts/reinforce/reinforce.py b/scripts/reinforce/reinforce.py index 4f1b23e..fa08624 100644 --- a/scripts/reinforce/reinforce.py +++ b/scripts/reinforce/reinforce.py @@ -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 @@ -91,15 +89,12 @@ def main(cfg: "DictConfig"): 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_reinforce(cfg, task) @@ -346,13 +341,11 @@ def get_log_prob(data, model): def compute_loss(data, model): - mask = data.get("mask").squeeze(-1) agent_log_prob = get_log_prob(data, model) agent_likelihood = (agent_log_prob * mask).sum(-1) reward = data.get(("next", "reward")).squeeze(-1).sum(-1) loss = -agent_likelihood * reward - return data, loss diff --git a/scripts/reinvent/config_denovo.yaml b/scripts/reinvent/config_denovo.yaml index 7fce6b6..579a306 100644 --- a/scripts/reinvent/config_denovo.yaml +++ b/scripts/reinvent/config_denovo.yaml @@ -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 diff --git a/scripts/reinvent/config_fragment.yaml b/scripts/reinvent/config_fragment.yaml index 67b4471..8ee0b9f 100644 --- a/scripts/reinvent/config_fragment.yaml +++ b/scripts/reinvent/config_fragment.yaml @@ -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)(*) diff --git a/scripts/reinvent/config_scaffold.yaml b/scripts/reinvent/config_scaffold.yaml index 99d0c99..7688c95 100644 --- a/scripts/reinvent/config_scaffold.yaml +++ b/scripts/reinvent/config_scaffold.yaml @@ -10,11 +10,10 @@ 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 +# Scoring function +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(*) diff --git a/scripts/reinvent/reinvent.py b/scripts/reinvent/reinvent.py index b83b884..1a848b1 100644 --- a/scripts/reinvent/reinvent.py +++ b/scripts/reinvent/reinvent.py @@ -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 @@ -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_reinvent(cfg, task) diff --git a/tutorials/breaking_down_configuration_files.md b/tutorials/breaking_down_configuration_files.md index 909449a..a71221c 100644 --- a/tutorials/breaking_down_configuration_files.md +++ b/tutorials/breaking_down_configuration_files.md @@ -67,14 +67,8 @@ This section is also common to all scripts. ACEGEN uses [molscore](https://githu ```yaml # Scoring function molscore_mode: single # single (run a single objective), benchmark (run multiple), or curriculum (run a sequence) -molscore_task: null # task configuration path (JSON), benchmark (preset only), or curriculum task (preset only) -molscore_kwargs: - include: [] # Allows to define only a subset of the benchmark scoring function (e.g. ["Albuterol_similarity"]) - # Other available kwargs - custom_benchmark: null # Path to a directory containing a list of benchmark configuration files or a sequence of objectives for curriculum learning - custom_tasks: [] # Individual configuration file paths (JSONs) to be added to the benchmark/curriculum - exclude: [] # Names of configuration files to exclude -custom_task: null # Requires molscore to be set to null. +molscore_task: MolOpt:Albuterol_similarity # accepts task configuration path (JSON), benchmark (preset only), or curriculum task (preset only). In this case it select a specific ibjective from the MolOpt benchmark +custom_task: null # Requires molscore to be set to null. Allows to select a custom scoting function. ``` ## Promptsmiles configuration