AutoREACTER 0.2b1__tar.gz → 0.2.2__tar.gz

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.
Files changed (89) hide show
  1. {autoreacter-0.2b1 → autoreacter-0.2.2}/AutoREACTER/__init__.py +2 -2
  2. autoreacter-0.2.2/AutoREACTER/_compat.py +60 -0
  3. autoreacter-0.2.2/AutoREACTER/cache.py +155 -0
  4. {autoreacter-0.2b1 → autoreacter-0.2.2}/AutoREACTER/detectors/detector.py +259 -259
  5. {autoreacter-0.2b1 → autoreacter-0.2.2}/AutoREACTER/detectors/functional_groups_detector.py +497 -497
  6. {autoreacter-0.2b1 → autoreacter-0.2.2}/AutoREACTER/detectors/functional_groups_library.py +100 -17
  7. {autoreacter-0.2b1 → autoreacter-0.2.2}/AutoREACTER/detectors/non_monomer_detector.py +352 -352
  8. {autoreacter-0.2b1 → autoreacter-0.2.2}/AutoREACTER/detectors/reaction_detector.py +686 -686
  9. autoreacter-0.2.2/AutoREACTER/detectors/reactions_library.py +475 -0
  10. {autoreacter-0.2b1 → autoreacter-0.2.2}/AutoREACTER/initialization.py +1 -1
  11. {autoreacter-0.2b1 → autoreacter-0.2.2}/AutoREACTER/input_parser.py +98 -86
  12. autoreacter-0.2.2/AutoREACTER/reaction_preparation/ff_wrapper/FF_files/pcff.frc +5595 -0
  13. {autoreacter-0.2b1/AutoREACTER/reaction_preparation/lunar_client → autoreacter-0.2.2/AutoREACTER/reaction_preparation/ff_wrapper}/REACTER_files_builder.py +38 -18
  14. autoreacter-0.2.2/AutoREACTER/reaction_preparation/ff_wrapper/ff_locator.py +73 -0
  15. autoreacter-0.2.2/AutoREACTER/reaction_preparation/ff_wrapper/ff_wrapper.py +86 -0
  16. autoreacter-0.2.2/AutoREACTER/reaction_preparation/ff_wrapper/foyer_client/foyer_api_wrapper.py +336 -0
  17. autoreacter-0.2.2/AutoREACTER/reaction_preparation/ff_wrapper/foyer_client/foyer_lammps_support.py +192 -0
  18. autoreacter-0.2.2/AutoREACTER/reaction_preparation/ff_wrapper/lunar_client/config.py +1 -0
  19. {autoreacter-0.2b1/AutoREACTER/reaction_preparation → autoreacter-0.2.2/AutoREACTER/reaction_preparation/ff_wrapper}/lunar_client/locate_lunar.py +10 -4
  20. autoreacter-0.2.2/AutoREACTER/reaction_preparation/ff_wrapper/lunar_client/lunar_api_wrapper.py +92 -0
  21. autoreacter-0.2.2/AutoREACTER/reaction_preparation/ff_wrapper/lunar_client/lunar_executor.py +234 -0
  22. autoreacter-0.2.2/AutoREACTER/reaction_preparation/ff_wrapper/lunar_client/lunar_utils.py +113 -0
  23. autoreacter-0.2.2/AutoREACTER/reaction_preparation/ff_wrapper/lunar_client/merge_builder.py +107 -0
  24. {autoreacter-0.2b1/AutoREACTER/reaction_preparation/lunar_client → autoreacter-0.2.2/AutoREACTER/reaction_preparation/ff_wrapper}/molecule_3d_preparation.py +13 -7
  25. {autoreacter-0.2b1 → autoreacter-0.2.2}/AutoREACTER/reaction_preparation/reaction_processor/fragment_comparison.py +238 -238
  26. {autoreacter-0.2b1 → autoreacter-0.2.2}/AutoREACTER/reaction_preparation/reaction_processor/prepare_reactions.py +12 -3
  27. {autoreacter-0.2b1 → autoreacter-0.2.2}/AutoREACTER/reaction_preparation/reaction_processor/utils.py +161 -161
  28. {autoreacter-0.2b1 → autoreacter-0.2.2}/AutoREACTER/reaction_preparation/reaction_processor/walker.py +206 -206
  29. autoreacter-0.2.2/AutoREACTER/session.py +105 -0
  30. {autoreacter-0.2b1 → autoreacter-0.2.2}/AutoREACTER/sim_setup/simulation_setup.py +1 -1
  31. {autoreacter-0.2b1 → autoreacter-0.2.2}/AutoREACTER/sim_setup/system_property_calculations.py +25 -24
  32. {autoreacter-0.2b1 → autoreacter-0.2.2}/AutoREACTER/sim_setup/writers/densification_writer.py +15 -15
  33. {autoreacter-0.2b1 → autoreacter-0.2.2}/AutoREACTER/sim_setup/writers/lammps_settings.py +1 -1
  34. {autoreacter-0.2b1 → autoreacter-0.2.2}/AutoREACTER/sim_setup/writers/post_eq_writer.py +9 -9
  35. {autoreacter-0.2b1 → autoreacter-0.2.2}/AutoREACTER/sim_setup/writers/pre_eq_writer.py +156 -156
  36. {autoreacter-0.2b1 → autoreacter-0.2.2}/AutoREACTER/sim_setup/writers/rxn_first_stage_writer.py +221 -221
  37. {autoreacter-0.2b1 → autoreacter-0.2.2}/AutoREACTER/sim_setup/writers/rxn_second_stage_writer.py +219 -219
  38. {autoreacter-0.2b1 → autoreacter-0.2.2}/AutoREACTER/sim_setup/writers/writer.py +66 -66
  39. autoreacter-0.2.2/AutoREACTER.egg-info/SOURCES.txt +74 -0
  40. {autoreacter-0.2b1 → autoreacter-0.2.2}/LICENSE.md +20 -20
  41. autoreacter-0.2.2/MANIFEST.in +11 -0
  42. {autoreacter-0.2b1/AutoREACTER.egg-info → autoreacter-0.2.2}/PKG-INFO +27 -67
  43. autoreacter-0.2.2/README.md +76 -0
  44. autoreacter-0.2.2/docs/source/Draft.md +3 -0
  45. autoreacter-0.2.2/docs/source/_static/Overview.png +0 -0
  46. autoreacter-0.2.2/docs/source/_static/logo.png +0 -0
  47. autoreacter-0.2.2/docs/source/change_log.md +110 -0
  48. {autoreacter-0.2b1 → autoreacter-0.2.2}/docs/source/conf.py +45 -45
  49. autoreacter-0.2.2/docs/source/contact.md +9 -0
  50. autoreacter-0.2.2/docs/source/getting-started.md +11 -0
  51. autoreacter-0.2.2/docs/source/getting_started_pip_installation.md +64 -0
  52. autoreacter-0.2.2/docs/source/getting_started_source_installation.md +138 -0
  53. autoreacter-0.2.2/docs/source/index.rst +30 -0
  54. autoreacter-0.2.2/docs/source/input-configuration.md +170 -0
  55. autoreacter-0.2.2/docs/source/overview.md +53 -0
  56. autoreacter-0.2.2/docs/source/supported-force-fields.md +14 -0
  57. autoreacter-0.2.2/docs/source/supported-reactions.md +110 -0
  58. autoreacter-0.2.2/examples/example_1.ipynb +441 -0
  59. autoreacter-0.2.2/examples/example_1_inputs_count_mode.json +49 -0
  60. autoreacter-0.2.2/examples/example_1_inputs_count_mode_FF.json +40 -0
  61. autoreacter-0.2.2/examples/example_1_inputs_ratio_mode.json +41 -0
  62. autoreacter-0.2.2/examples/run_AutoREACTER.py +242 -0
  63. autoreacter-0.2.2/pyproject.toml +37 -0
  64. autoreacter-0.2.2/tests/test_lunar_api_wrapper.py +96 -0
  65. autoreacter-0.2b1/AutoREACTER/cache.py +0 -300
  66. autoreacter-0.2b1/AutoREACTER/detectors/reactions_library.py +0 -308
  67. autoreacter-0.2b1/AutoREACTER/reaction_preparation/lunar_client/config.py +0 -1
  68. autoreacter-0.2b1/AutoREACTER/reaction_preparation/lunar_client/lunar_api_wrapper.py +0 -694
  69. autoreacter-0.2b1/AutoREACTER/sim_setup/writers/__init__.py +0 -0
  70. autoreacter-0.2b1/AutoREACTER.egg-info/SOURCES.txt +0 -50
  71. autoreacter-0.2b1/AutoREACTER.egg-info/dependency_links.txt +0 -1
  72. autoreacter-0.2b1/AutoREACTER.egg-info/requires.txt +0 -6
  73. autoreacter-0.2b1/AutoREACTER.egg-info/top_level.txt +0 -6
  74. autoreacter-0.2b1/PKG-INFO +0 -139
  75. autoreacter-0.2b1/README.md +0 -122
  76. autoreacter-0.2b1/pyproject.toml +0 -25
  77. {autoreacter-0.2b1 → autoreacter-0.2.2}/AutoREACTER/detectors/__init__.py +0 -0
  78. {autoreacter-0.2b1 → autoreacter-0.2.2}/AutoREACTER/reaction_preparation/__init__.py +0 -0
  79. {autoreacter-0.2b1 → autoreacter-0.2.2}/AutoREACTER/reaction_preparation/build_reaction_system.py +0 -0
  80. {autoreacter-0.2b1/AutoREACTER/reaction_preparation/lunar_client → autoreacter-0.2.2/AutoREACTER/reaction_preparation/ff_wrapper}/__init__.py +0 -0
  81. {autoreacter-0.2b1/AutoREACTER/reaction_preparation/lunar_client → autoreacter-0.2.2/AutoREACTER/reaction_preparation/ff_wrapper}/ff_validator.py +0 -0
  82. {autoreacter-0.2b1/AutoREACTER/reaction_preparation/reaction_processor → autoreacter-0.2.2/AutoREACTER/reaction_preparation/ff_wrapper/foyer_client}/__init__.py +0 -0
  83. {autoreacter-0.2b1/AutoREACTER/reaction_template_builder → autoreacter-0.2.2/AutoREACTER/reaction_preparation/ff_wrapper/lunar_client}/__init__.py +0 -0
  84. {autoreacter-0.2b1/AutoREACTER/reaction_preparation/lunar_client → autoreacter-0.2.2/AutoREACTER/reaction_preparation/ff_wrapper}/modifiers_molecule_files.py +0 -0
  85. {autoreacter-0.2b1/AutoREACTER/reaction_preparation/lunar_client → autoreacter-0.2.2/AutoREACTER/reaction_preparation/ff_wrapper}/template_builder.py +0 -0
  86. {autoreacter-0.2b1/AutoREACTER/reaction_template_builder/lunar_client → autoreacter-0.2.2/AutoREACTER/reaction_preparation/reaction_processor}/__init__.py +0 -0
  87. {autoreacter-0.2b1/AutoREACTER/reaction_template_builder/reaction_template_pipeline → autoreacter-0.2.2/AutoREACTER/sim_setup}/__init__.py +0 -0
  88. {autoreacter-0.2b1/AutoREACTER/sim_setup → autoreacter-0.2.2/AutoREACTER/sim_setup/writers}/__init__.py +0 -0
  89. {autoreacter-0.2b1 → autoreacter-0.2.2}/setup.cfg +0 -0
@@ -5,13 +5,13 @@ Automated generation of LAMMPS/REACTER-ready reaction templates
5
5
  for polymerization workflows.
6
6
  """
7
7
 
8
- __version__ = "0.3.0b1"
8
+ __version__ = "0.2.2b1"
9
9
 
10
10
  from .input_parser import (
11
11
  InputParser,
12
12
  SimulationSetup,
13
13
  MonomerEntry,
14
- Replica,
14
+ Simulation,
15
15
  InputError,
16
16
  InputSchemaError,
17
17
  InputConflictError,
@@ -0,0 +1,60 @@
1
+ import sys
2
+ import collections
3
+ import collections.abc
4
+ import numpy as np
5
+
6
+ def apply_legacy_patches():
7
+ """
8
+ Injects removed aliases back into numpy and collections at runtime,
9
+ and bridges the OpenMM simtk namespace for older versions of Foyer/mBuild.
10
+ """
11
+ # 1. Restore removed Collections aliases
12
+ _missing_classes = [
13
+ "MutableSet", "MutableMapping", "Mapping", "MutableSequence",
14
+ "Sequence", "Set", "Iterable", "Iterator", "Callable",
15
+ "Container", "Hashable", "ItemsView", "KeysView", "ValuesView"
16
+ ]
17
+ for _name in _missing_classes:
18
+ if not hasattr(collections, _name) and hasattr(collections.abc, _name):
19
+ setattr(collections, _name, getattr(collections.abc, _name))
20
+
21
+ # 2. Restore removed NumPy aliases
22
+ if not hasattr(np, "float"): np.float = float
23
+ if not hasattr(np, "int"): np.int = int
24
+ if not hasattr(np, "complex"): np.complex = complex
25
+ if not hasattr(np, "bool"): np.bool = np.bool_
26
+ if not hasattr(np, "object"): np.object = np.object_
27
+ if not hasattr(np, "str"): np.str = np.str_
28
+
29
+ # 3. Robust OpenMM 'simtk' shim for Python 3.12+
30
+ try:
31
+ import sys
32
+ import types
33
+ import openmm
34
+ import openmm.app
35
+ import openmm.app.element
36
+ import openmm.unit
37
+
38
+ # Create pure, fake modules to bypass strict filesystem import checks
39
+ simtk = types.ModuleType("simtk")
40
+ simtk_openmm = types.ModuleType("simtk.openmm")
41
+ simtk_openmm_app = types.ModuleType("simtk.openmm.app")
42
+
43
+ # Copy the contents of the real modules into our fake ones
44
+ simtk_openmm.__dict__.update(openmm.__dict__)
45
+ simtk_openmm_app.__dict__.update(openmm.app.__dict__)
46
+
47
+ # Manually wire the internal tree together
48
+ simtk.openmm = simtk_openmm
49
+ simtk.unit = openmm.unit
50
+ simtk_openmm.app = simtk_openmm_app
51
+ simtk_openmm_app.element = openmm.app.element
52
+
53
+ # Register them in sys.modules so the 'import' statements find them instantly
54
+ sys.modules["simtk"] = simtk
55
+ sys.modules["simtk.openmm"] = simtk_openmm
56
+ sys.modules["simtk.openmm.app"] = simtk_openmm_app
57
+ sys.modules["simtk.openmm.app.element"] = openmm.app.element
58
+ sys.modules["simtk.unit"] = openmm.unit
59
+ except ImportError:
60
+ pass
@@ -0,0 +1,155 @@
1
+ from pathlib import Path
2
+ import shutil
3
+ import tempfile
4
+ import uuid
5
+ from AutoREACTER.reaction_preparation.ff_wrapper.REACTER_files_builder import REACTERFiles
6
+
7
+
8
+ class GetCacheDir:
9
+ def __init__(self, clear_staging: bool = True):
10
+ """
11
+ Initializes the cache manager.
12
+
13
+ Args:
14
+ clear_staging:
15
+ If True, clear all contents inside the staging directory.
16
+ The staging directory itself is preserved.
17
+ """
18
+ # Generate a unique staging directory for this run to prevent concurrent conflicts
19
+ run_id = uuid.uuid4().hex[:8]
20
+ # self.staging_dir = Path(tempfile.gettempdir()) / f"AutoREACTER_staging_{run_id}"
21
+ self.staging_dir = Path(tempfile.gettempdir()) / f"AutoREACTER_staging"
22
+ self.staging_dir.mkdir(parents=True, exist_ok=True)
23
+ self.clear_staging_dir()
24
+
25
+ def clear_staging_dir(self) -> None:
26
+ """
27
+ Clear all files and folders inside the staging cache directory.
28
+
29
+ This only clears the temporary staging directory contents.
30
+ It does not delete dated run folders.
31
+ """
32
+ self.staging_dir.mkdir(parents=True, exist_ok=True)
33
+
34
+ failed = []
35
+ for item in self.staging_dir.iterdir():
36
+ try:
37
+ if item.is_symlink() or item.is_file():
38
+ item.unlink()
39
+ elif item.is_dir():
40
+ shutil.rmtree(item)
41
+ except Exception as e:
42
+ print(f"[WARN] Failed to remove staging cache item {item}: {e}")
43
+ failed.append(item)
44
+
45
+ if failed:
46
+ print(f"[WARN] Staging cache partially cleared ({len(failed)} item(s) could not be removed): {self.staging_dir}")
47
+ else:
48
+ print(f"[OK] Cleared staging cache: {self.staging_dir}")
49
+
50
+
51
+ class RunDirectoryManager:
52
+ """
53
+ Handles creation and management of dated run directories for simulations.
54
+
55
+ Organizes output into a structure like: cache/YYYY-MM-DD/1/, cache/YYYY-MM-DD/2/, etc.
56
+ Provides utilities for moving files and updating REACTER file references.
57
+ """
58
+
59
+ def __init__(self, base_dir: Path):
60
+ """
61
+ Initialize with a base directory for storing run folders.
62
+
63
+ Args:
64
+ base_dir: Base path where dated run directories will be created
65
+ """
66
+ self.base_dir = Path(base_dir)
67
+ self.base_dir.mkdir(parents=True, exist_ok=True)
68
+
69
+ def remove_path(self, path: Path) -> None:
70
+ """
71
+ Remove a file, symlink, or directory recursively.
72
+ """
73
+ if path.is_symlink() or path.is_file():
74
+ path.unlink()
75
+ elif path.is_dir():
76
+ shutil.rmtree(path)
77
+
78
+ def move_into_run(self, source_dir: Path, dest_dir: Path) -> Path:
79
+ """
80
+ Move all contents from source_dir into dest_dir, overwriting if necessary.
81
+
82
+ Args:
83
+ source_dir: Directory containing files to move
84
+ dest_dir: Destination run directory
85
+
86
+ Returns:
87
+ Path: The destination directory
88
+ """
89
+ for item in source_dir.iterdir():
90
+ target = dest_dir / item.name
91
+
92
+ if target.exists():
93
+ self.remove_path(target)
94
+
95
+ shutil.move(str(item), str(target))
96
+
97
+ print(f"[OK] Moved files → {dest_dir}")
98
+ return dest_dir
99
+
100
+ def move_reacter_files(
101
+ self,
102
+ reacter_files: REACTERFiles,
103
+ staging_dir: Path,
104
+ final_dir: Path
105
+ ) -> REACTERFiles:
106
+ """
107
+ Move REACTER-related files from staging area into the final run directory
108
+ and update all internal Path references in the REACTERFiles object.
109
+
110
+ Args:
111
+ reacter_files: REACTERFiles object containing various file paths
112
+ staging_dir: Current staging directory (usually .../00_cache)
113
+ final_dir: Target run directory
114
+
115
+ Returns:
116
+ REACTERFiles: Updated object with remapped paths
117
+
118
+ Raises:
119
+ FileNotFoundError: If the expected REACTER files directory doesn't exist
120
+ """
121
+ old_base = staging_dir / "lunar" / "REACTER_files"
122
+
123
+ if not old_base.exists():
124
+ raise FileNotFoundError(f"REACTER files not found: {old_base}")
125
+
126
+ new_base = self.move_into_run(old_base, final_dir)
127
+
128
+ def remap(p: Path) -> Path:
129
+ """Remap a path from old_base to new_base while preserving relative structure."""
130
+ try:
131
+ return new_base / p.relative_to(old_base)
132
+ except ValueError:
133
+ return p
134
+
135
+ # Update all file references to point to the new location
136
+ reacter_files.force_field_data = remap(reacter_files.force_field_data)
137
+ reacter_files.in_file = remap(reacter_files.in_file)
138
+
139
+ for mol in reacter_files.molecule_files:
140
+ mol.molecule_files.lmp_molecule_file = remap(
141
+ mol.molecule_files.lmp_molecule_file
142
+ )
143
+
144
+ for tpl in reacter_files.template_files:
145
+ tpl.map_file = remap(tpl.map_file)
146
+ tpl.pre_reaction_file.lmp_molecule_file = remap(
147
+ tpl.pre_reaction_file.lmp_molecule_file
148
+ )
149
+ tpl.post_reaction_file.lmp_molecule_file = remap(
150
+ tpl.post_reaction_file.lmp_molecule_file
151
+ )
152
+
153
+ print(f"[OK] REACTER files moved → {new_base}")
154
+ return reacter_files
155
+