Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions AutoREACTER/detectors/detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@
the simulation.
"""

import warnings

warnings.warn(
"""This script is deprecated and will be modified in future versions. Within v0.2, the whole package will primaraliy
support on jupyter notebook and the CLI is removed. Please use the notebook version for now and refer to the README for how to use the package.""",
DeprecationWarning,
stacklevel=2
)

import json

# Attempt to import detector modules. Handles different import paths depending on
Expand Down
315 changes: 315 additions & 0 deletions AutoREACTER/detectors/non_monomer_detector.py

Large diffs are not rendered by default.

382 changes: 211 additions & 171 deletions AutoREACTER/detectors/reaction_detector.py

Large diffs are not rendered by default.

519 changes: 354 additions & 165 deletions AutoREACTER/input_parser.py

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -16,40 +16,6 @@
- Implement duplicate reaction detection and handling.
"""


"""TODO (Reaction Template Pipeline):
from dataclasses import dataclass
from typing import Literal

@dataclass(slots=True, frozen=True)
class MonomerRole:
spec: MoleculeSpec
functionality_type: str
fg_name: str
fg_smarts_1: str
fg_count_1: int
fg_smarts_2: str | None = None
fg_count_2: int | None = None

@dataclass(slots=True, frozen=True)
class ReactionDefinition:
reaction_name: str
reaction_smarts: str
same_reactants: bool
delete_atom: bool
references: dict
monomer_1: MonomerRole
monomer_2: MonomerRole | None = None
"""


"""
def withdraw(balance, amount):
if amount > balance:
raise InsufficientFundsError(amount - balance, f"Cannot withdraw {amount}, only {balance} available.")
return balance - amount
"""

"""
TODO: Preserve stable reaction_id for each reaction (never renumber).
Maintain a seq_id mapping for the current filtered set (continuous 1..N) for UI/export.
Expand Down
36 changes: 29 additions & 7 deletions examples/example_1.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"from AutoREACTER.cache import GetCacheDir, RunDirectoryManager, RetentionCleanup\n",
"from AutoREACTER.detectors.functional_groups_detector import FunctionalGroupsDetector\n",
"from AutoREACTER.detectors.reaction_detector import ReactionDetector\n",
"from AutoREACTER.detectors.non_monomer_detector import NonReactantsDetector\n",
"from AutoREACTER.reaction_template_builder.run_reaction_template_pipeline import ReactionTemplatePipeline\n",
"from rdkit import Chem\n",
"from rdkit.Chem import Draw\n",
Expand All @@ -31,9 +32,10 @@
"Initialization()\n",
"input_parser = InputParser()\n",
"\n",
"input_parser = InputParser()\n",
"cache_dir = GetCacheDir().staging_dir\n",
"dated_cache_dir = RunDirectoryManager.make_dated_run_dir(cache_dir, chdir_to=\"none\")\n",
"# future use\n",
"# #future use\n",
"# RunDirectoryManager.copy_into_run(cache_dir, dated_cache_dir)\n",
"\n",
"\n"
Expand Down Expand Up @@ -105,15 +107,12 @@
"metadata": {},
"outputs": [],
"source": [
"# Detector must be called after the inputs are validated, because it operates on validated MonomerEntry objects (validated_inputs.monomers)\n",
"# Run the detector only after the inputs have been validated, as it consumes validated_inputs.monomers to execute the detection workflow.\n",
"functional_groups_detector = FunctionalGroupsDetector()\n",
"functional_groups, functional_groups_imgs = \n",
"functional_groups, functional_groups_imgs = \\\n",
" functional_groups_detector.functional_groups_detector(\n",
" validated_inputs.monomers\n",
" )\n",
"\n",
"for fg_img in functional_groups_imgs:\n",
" print(fg_img.indexes_to_highlight)"
" )"
]
},
{
Expand All @@ -135,6 +134,7 @@
"outputs": [],
"source": [
"reaction_detector = ReactionDetector()\n",
"non_monomer_detector = NonReactantsDetector()\n",
"reaction_instances = reaction_detector.reaction_detector(functional_groups)\n",
"img = reaction_detector.create_reaction_image_grid(reaction_instances)\n",
"img"
Expand All @@ -150,6 +150,28 @@
"selected_reactions = reaction_detector.reaction_selection(reaction_instances)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c811c031",
"metadata": {},
"outputs": [],
"source": [
"non_reactants_list = non_monomer_detector.non_monomer_detector(validated_inputs, selected_reactions)\n",
"img_non_reactants = non_monomer_detector.non_reactants_to_visualization(non_reactants_list)\n",
"img_non_reactants"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "00d75b1a",
"metadata": {},
"outputs": [],
"source": [
"updated_inputs = non_monomer_detector.non_reactant_selection(validated_inputs, non_reactants_list)"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down
15 changes: 0 additions & 15 deletions examples/example_1_inputs.json

This file was deleted.

86 changes: 50 additions & 36 deletions examples/example_1_inputs_count_mode.json
Original file line number Diff line number Diff line change
@@ -1,39 +1,53 @@
{
"simulation_name": "Example_Count_Mode",
"temperature": [300, 400, 500],
"density": 0.8,

"composition": {
"method": "counts",
"targets": [
{"tag": "10k"},
{"tag": "100k"}
]
},

"monomers": [
{
"name": "tmc",
"smiles": "ClC(=O)c1cc(cc(c1)C(Cl)=O)C(Cl)=O",
"count": {
"10k": 220,
"100k": 2200
}
},
{
"name": "mpd",
"smiles": "C1=CC(=CC(=C1)N)N",
"count": {
"10k": 220,
"100k": 2200
}

"simulation_name": "Example_Count_Mode",

"replicas": {
"temperatures": [300, 400, 500],
"density": [0.8],
"method": "counts",

"systems": [

{
"tag": "10k",

"monomer_counts": {
"tmc": 220,
"mpd": 220,
"ethanol": 110
}
},

{
"tag": "100k",

"monomer_counts": {
"tmc": 2200,
"mpd": 2200,
"ethanol": 1100
}
}

]
},
{
"smiles": "CCO",
"count": {
"10k": 110,
"100k": 1100
}
}
]

"monomers": [

{
"name": "tmc",
"smiles": "ClC(=O)c1cc(cc(c1)C(Cl)=O)C(Cl)=O"
},

{
"name": "mpd",
"smiles": "C1=CC(=CC(=C1)N)N"
},

{
"name": "ethanol",
"smiles": "CCO"
}

]
}
55 changes: 30 additions & 25 deletions examples/example_1_inputs_count_mode_FF.json
Original file line number Diff line number Diff line change
@@ -1,39 +1,44 @@
{
"simulation_name": "Example_Count_Mode",
"temperature": [300, 400, 500],
"density": 0.8,
"force_field": "PCFF",
"composition": {

"replicas": {
"temperatures": [300, 400, 500],
"density": [0.8],
"method": "counts",
"targets": [
{"tag": "10k"},
{"tag": "100k"}

"systems": [
{
"tag": "10k",
"monomer_counts": {
"tmc": 220,
"mpd": 220,
"data_3": 110
}
},
{
"tag": "100k",
"monomer_counts": {
"tmc": 2200,
"mpd": 2200,
"data_3": 1100
}
}
]
},

"monomers": [

"force_field": "PCFF",

"monomers": [
{
"name": "tmc",
"smiles": "ClC(=O)c1cc(cc(c1)C(Cl)=O)C(Cl)=O",
"count": {
"10k": 220,
"100k": 2200
}
"smiles": "ClC(=O)c1cc(cc(c1)C(Cl)=O)C(Cl)=O"
},
{
"name": "mpd",
"smiles": "C1=CC(=CC(=C1)N)N",
"count": {
"10k": 220,
"100k": 2200
}
"smiles": "C1=CC(=CC(=C1)N)N"
},
{
"smiles": "CCO",
"count": {
"10k": 110,
"100k": 1100
}
"smiles": "CCO"
}
]
}
}
46 changes: 46 additions & 0 deletions examples/example_1_inputs_count_mode_with_non_monomers.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{

"simulation_name": "Example_Count_Mode",

"replicas": {
"temperatures": [300, 400, 500],
"density": [0.8],
"method": "counts",

"systems": [

{
"tag": "10k",

"monomer_counts": {
"tmc": 220,
"mpd": 220
}
},

{
"tag": "100k",

"monomer_counts": {
"tmc": 2200,
"mpd": 2200
}
}

]
},

"monomers": [

{
"name": "tmc",
"smiles": "ClC(=O)c1cc(cc(c1)C(Cl)=O)C(Cl)=O"
},

{
"name": "mpd",
"smiles": "C1=CC(=CC(=C1)N)N"
}

]
}
Loading