ligandparam 0.3.2__tar.gz → 0.3.4__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 (76) hide show
  1. {ligandparam-0.3.2 → ligandparam-0.3.4}/PKG-INFO +14 -2
  2. {ligandparam-0.3.2 → ligandparam-0.3.4}/README.md +11 -0
  3. {ligandparam-0.3.2 → ligandparam-0.3.4}/pyproject.toml +5 -3
  4. ligandparam-0.3.4/src/ligandparam/cli/mol2_to_sage.py +20 -0
  5. {ligandparam-0.3.2 → ligandparam-0.3.4}/src/ligandparam/driver.py +60 -0
  6. {ligandparam-0.3.2 → ligandparam-0.3.4}/src/ligandparam/interfaces.py +92 -8
  7. {ligandparam-0.3.2 → ligandparam-0.3.4}/src/ligandparam/io/gaussianIO.py +4 -3
  8. ligandparam-0.3.4/src/ligandparam/log.py +91 -0
  9. ligandparam-0.3.4/src/ligandparam/parametrization.py +135 -0
  10. {ligandparam-0.3.2 → ligandparam-0.3.4}/src/ligandparam/recipes/freeligand.py +7 -7
  11. {ligandparam-0.3.2 → ligandparam-0.3.4}/src/ligandparam/recipes/lazyligand.py +10 -10
  12. {ligandparam-0.3.2 → ligandparam-0.3.4}/src/ligandparam/stages/__init__.py +2 -1
  13. {ligandparam-0.3.2 → ligandparam-0.3.4}/src/ligandparam/stages/abstractstage.py +141 -16
  14. {ligandparam-0.3.2 → ligandparam-0.3.4}/src/ligandparam/stages/build_system.py +116 -12
  15. {ligandparam-0.3.2 → ligandparam-0.3.4}/src/ligandparam/stages/charge.py +111 -21
  16. {ligandparam-0.3.2 → ligandparam-0.3.4}/src/ligandparam/stages/deepmd.py +84 -22
  17. {ligandparam-0.3.2 → ligandparam-0.3.4}/src/ligandparam/stages/displacemol.py +67 -14
  18. {ligandparam-0.3.2 → ligandparam-0.3.4}/src/ligandparam/stages/gaussian.py +285 -40
  19. ligandparam-0.3.4/src/ligandparam/stages/generate_sage_params.py +87 -0
  20. {ligandparam-0.3.2 → ligandparam-0.3.4}/src/ligandparam/stages/initialize.py +94 -5
  21. {ligandparam-0.3.2 → ligandparam-0.3.4}/src/ligandparam/stages/leap.py +90 -4
  22. {ligandparam-0.3.2 → ligandparam-0.3.4}/src/ligandparam/stages/lighfix.py +166 -28
  23. ligandparam-0.3.4/src/ligandparam/stages/parmchk.py +118 -0
  24. {ligandparam-0.3.2 → ligandparam-0.3.4}/src/ligandparam/stages/pdb_names.py +148 -2
  25. ligandparam-0.3.4/src/ligandparam/stages/resp.py +226 -0
  26. {ligandparam-0.3.2 → ligandparam-0.3.4}/src/ligandparam/stages/sdfconverters.py +162 -0
  27. {ligandparam-0.3.2 → ligandparam-0.3.4}/src/ligandparam/stages/smilestopdb.py +150 -1
  28. {ligandparam-0.3.2 → ligandparam-0.3.4}/src/ligandparam/stages/typematching.py +136 -5
  29. ligandparam-0.3.4/src/ligandparam/stages/utilsstages.py +29 -0
  30. {ligandparam-0.3.2 → ligandparam-0.3.4}/src/ligandparam/utils.py +42 -0
  31. {ligandparam-0.3.2 → ligandparam-0.3.4}/src/ligandparam.egg-info/PKG-INFO +14 -2
  32. {ligandparam-0.3.2 → ligandparam-0.3.4}/src/ligandparam.egg-info/SOURCES.txt +2 -0
  33. {ligandparam-0.3.2 → ligandparam-0.3.4}/src/ligandparam.egg-info/entry_points.txt +1 -0
  34. {ligandparam-0.3.2 → ligandparam-0.3.4}/src/ligandparam.egg-info/requires.txt +2 -1
  35. ligandparam-0.3.2/src/ligandparam/log.py +0 -39
  36. ligandparam-0.3.2/src/ligandparam/parametrization.py +0 -53
  37. ligandparam-0.3.2/src/ligandparam/stages/parmchk.py +0 -48
  38. ligandparam-0.3.2/src/ligandparam/stages/resp.py +0 -123
  39. ligandparam-0.3.2/src/ligandparam/stages/utilsstages.py +0 -13
  40. {ligandparam-0.3.2 → ligandparam-0.3.4}/setup.cfg +0 -0
  41. {ligandparam-0.3.2 → ligandparam-0.3.4}/src/ligandparam/__init__.py +0 -0
  42. {ligandparam-0.3.2 → ligandparam-0.3.4}/src/ligandparam/cli/__init__.py +0 -0
  43. {ligandparam-0.3.2 → ligandparam-0.3.4}/src/ligandparam/cli/cli_lighfix.py +0 -0
  44. {ligandparam-0.3.2 → ligandparam-0.3.4}/src/ligandparam/cli/ligandparam_getparam.py +0 -0
  45. {ligandparam-0.3.2 → ligandparam-0.3.4}/src/ligandparam/cli/smiles_to_pdb.py +0 -0
  46. {ligandparam-0.3.2 → ligandparam-0.3.4}/src/ligandparam/deprecated/stagegausrotation.py +0 -0
  47. {ligandparam-0.3.2 → ligandparam-0.3.4}/src/ligandparam/deprecated/stagegaussian.py +0 -0
  48. {ligandparam-0.3.2 → ligandparam-0.3.4}/src/ligandparam/deprecated/stagegaussiantomol2.py +0 -0
  49. {ligandparam-0.3.2 → ligandparam-0.3.4}/src/ligandparam/deprecated/stageinitialize.py +0 -0
  50. {ligandparam-0.3.2 → ligandparam-0.3.4}/src/ligandparam/deprecated/stagelazyresp.py +0 -0
  51. {ligandparam-0.3.2 → ligandparam-0.3.4}/src/ligandparam/deprecated/stageleap.py +0 -0
  52. {ligandparam-0.3.2 → ligandparam-0.3.4}/src/ligandparam/deprecated/stagenormalizecharges.py +0 -0
  53. {ligandparam-0.3.2 → ligandparam-0.3.4}/src/ligandparam/deprecated/stageparmchk.py +0 -0
  54. {ligandparam-0.3.2 → ligandparam-0.3.4}/src/ligandparam/io/__init__.py +0 -0
  55. {ligandparam-0.3.2 → ligandparam-0.3.4}/src/ligandparam/io/coordinates.py +0 -0
  56. {ligandparam-0.3.2 → ligandparam-0.3.4}/src/ligandparam/io/leapIO.py +0 -0
  57. {ligandparam-0.3.2 → ligandparam-0.3.4}/src/ligandparam/io/smiles.py +0 -0
  58. {ligandparam-0.3.2 → ligandparam-0.3.4}/src/ligandparam/multiresp/__init__.py +0 -0
  59. {ligandparam-0.3.2 → ligandparam-0.3.4}/src/ligandparam/multiresp/endstate.py +0 -0
  60. {ligandparam-0.3.2 → ligandparam-0.3.4}/src/ligandparam/multiresp/functions.py +0 -0
  61. {ligandparam-0.3.2 → ligandparam-0.3.4}/src/ligandparam/multiresp/intermolequiv.py +0 -0
  62. {ligandparam-0.3.2 → ligandparam-0.3.4}/src/ligandparam/multiresp/mdinutils.py +0 -0
  63. {ligandparam-0.3.2 → ligandparam-0.3.4}/src/ligandparam/multiresp/parmhelper.py +0 -0
  64. {ligandparam-0.3.2 → ligandparam-0.3.4}/src/ligandparam/multiresp/residueresp.py +0 -0
  65. {ligandparam-0.3.2 → ligandparam-0.3.4}/src/ligandparam/multiresp/respfunctions.py +0 -0
  66. {ligandparam-0.3.2 → ligandparam-0.3.4}/src/ligandparam/recipes/__init__.py +0 -0
  67. {ligandparam-0.3.2 → ligandparam-0.3.4}/src/ligandparam/recipes/buildligand.py +0 -0
  68. {ligandparam-0.3.2 → ligandparam-0.3.4}/src/ligandparam/recipes/dpfreeligand.py +0 -0
  69. {ligandparam-0.3.2 → ligandparam-0.3.4}/src/ligandparam/recipes/dplazyligand.py +0 -0
  70. {ligandparam-0.3.2 → ligandparam-0.3.4}/src/ligandparam/recipes/lazierligand.py +0 -0
  71. {ligandparam-0.3.2 → ligandparam-0.3.4}/src/ligandparam/recipes/optligand.py +0 -0
  72. {ligandparam-0.3.2 → ligandparam-0.3.4}/src/ligandparam/recipes/rnaligand.py +0 -0
  73. {ligandparam-0.3.2 → ligandparam-0.3.4}/src/ligandparam/stages/teststage.py +0 -0
  74. {ligandparam-0.3.2 → ligandparam-0.3.4}/src/ligandparam.egg-info/dependency_links.txt +0 -0
  75. {ligandparam-0.3.2 → ligandparam-0.3.4}/src/ligandparam.egg-info/top_level.txt +0 -0
  76. {ligandparam-0.3.2 → ligandparam-0.3.4}/tests/test_module.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ligandparam
3
- Version: 0.3.2
3
+ Version: 0.3.4
4
4
  Summary: A ligand parameterization package for Amber
5
5
  Author-email: Zeke Piskulich <piskulichz@gmail.com>
6
6
  License: MIT
@@ -16,8 +16,9 @@ Requires-Dist: requests
16
16
  Requires-Dist: MDAnalysis>2.7.0
17
17
  Requires-Dist: pathlib
18
18
  Requires-Dist: parmed
19
+ Requires-Dist: ase
20
+ Requires-Dist: openff-toolkit
19
21
  Provides-Extra: ml
20
- Requires-Dist: ase; extra == "ml"
21
22
  Requires-Dist: deepmd-kit; extra == "ml"
22
23
  Requires-Dist: tensorflow; extra == "ml"
23
24
  Requires-Dist: tblite; extra == "ml"
@@ -41,3 +42,14 @@ key features encountered by users, including...
41
42
 
42
43
  The online documentation is located here: https://ligandparam.readthedocs.io/en/latest/
43
44
 
45
+
46
+
47
+ ### Developing
48
+
49
+ #### Releasing a new version
50
+
51
+ 1. update `version` at `pyproject.toml`. Eg: `0.3.2`
52
+ 2. Add and commit the change. Then tag the commit: `git tag 0.3.2`
53
+ 3. `git push origin --tags`
54
+
55
+ gitlab's CI/CD will publish the new version automatically
@@ -8,3 +8,14 @@ key features encountered by users, including...
8
8
 
9
9
  The online documentation is located here: https://ligandparam.readthedocs.io/en/latest/
10
10
 
11
+
12
+
13
+ ### Developing
14
+
15
+ #### Releasing a new version
16
+
17
+ 1. update `version` at `pyproject.toml`. Eg: `0.3.2`
18
+ 2. Add and commit the change. Then tag the commit: `git tag 0.3.2`
19
+ 3. `git push origin --tags`
20
+
21
+ gitlab's CI/CD will publish the new version automatically
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "ligandparam"
7
- version = "0.3.2"
7
+ version = "0.3.4"
8
8
  description = "A ligand parameterization package for Amber"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.6"
@@ -23,7 +23,9 @@ dependencies = [
23
23
  "requests",
24
24
  "MDAnalysis>2.7.0",
25
25
  "pathlib",
26
- "parmed"
26
+ "parmed",
27
+ "ase",
28
+ "openff-toolkit"
27
29
  ]
28
30
 
29
31
  urls = { "Homepage" = "https://github.com/piskulichz/ligandparam" }
@@ -31,7 +33,6 @@ urls = { "Homepage" = "https://github.com/piskulichz/ligandparam" }
31
33
  [project.optional-dependencies]
32
34
 
33
35
  ml = [
34
- "ase",
35
36
  "deepmd-kit",
36
37
  "tensorflow",
37
38
  "tblite"
@@ -56,6 +57,7 @@ all = [
56
57
  lighfix = "ligandparam.cli.cli_lighfix:lighfix"
57
58
  lig-getparam = "ligandparam.cli.ligandparam_getparam:main"
58
59
  smiles-to-pdb = "ligandparam.cli.smiles_to_pdb:main"
60
+ lig-to-sage = "ligandparam.cli.mol2_to_sage:main"
59
61
 
60
62
 
61
63
  [tool.ruff]
@@ -0,0 +1,20 @@
1
+ from openff.toolkit import Molecule, ForceField, Topology, Quantity
2
+ from openff.interchange import Interchange
3
+ from openff.units import unit
4
+ from rdkit import Chem
5
+ from rdkit.Chem import AllChem
6
+ import os
7
+
8
+ from ligandparam.stages import StageSageCreate
9
+
10
+ def main():
11
+ import argparse
12
+ parser = argparse.ArgumentParser(description="Generate AMBER parameters from a mol2 file.")
13
+ parser.add_argument("input_mol2", type=str, help="Path to the input mol2 file.")
14
+ parser.add_argument("output_tag", type=str, help="Tag for the output files.")
15
+ args = parser.parse_args()
16
+ stage = StageSageCreate("sage_creation", args.input_mol2, os.getcwd(), out_parm=f"{args.output_tag}.parm7")
17
+ stage.execute()
18
+
19
+ if __name__ == "__main__":
20
+ main()
@@ -4,6 +4,33 @@ from pathlib import Path
4
4
 
5
5
 
6
6
  class Driver:
7
+ """ Base class for all parametrization drivers.
8
+
9
+ This class is the base class for all parametrizations. It is designed to be subclassed, and the subclass should
10
+ implement the stages that are needed to complete the parametrization.
11
+
12
+ Parameters
13
+ ----------
14
+ in_filename : str or Path
15
+ The input filename for the parametrization.
16
+ cwd : str or Path
17
+ The current working directory for the parametrization.
18
+ *args : list
19
+ Additional arguments to pass to the subclass.
20
+ **kwargs : dict
21
+ Additional keyword arguments to pass to the subclass.
22
+
23
+
24
+ Attributes
25
+ ----------
26
+ in_filename : str or Path
27
+ The input filename for the parametrization.
28
+ cwd : str or Path
29
+ The current working directory for the parametrization.
30
+ stages : list
31
+ The list of stages to run for the parametrization.
32
+
33
+ """
7
34
  @abstractmethod
8
35
  def __init__(self, in_filename: Union[Path, str], cwd: Union[Path, str], *args, **kwargs):
9
36
  """Initialize the Driver class object.
@@ -50,10 +77,21 @@ class Driver:
50
77
  ----------
51
78
  dry_run : bool, optional
52
79
  If True, the stages will not be executed, but the function will print the commands that would be executed.
80
+ nproc : int, optional
81
+ The number of processors to use for the stages that support parallel execution.
82
+ mem : int, optional
83
+ The amount of memory to use for the stages that support memory specification.
53
84
 
54
85
  Returns
55
86
  -------
56
87
  None
88
+
89
+ Raises
90
+ ------
91
+ RuntimeError
92
+ If a stage fails, a RuntimeError is raised with the error message from the stage.
93
+
94
+
57
95
  """
58
96
  for stage in self.stages:
59
97
  try:
@@ -72,6 +110,12 @@ class Driver:
72
110
  Returns
73
111
  -------
74
112
  None
113
+
114
+ Raises
115
+ ------
116
+ RuntimeError
117
+ If a stage fails, a RuntimeError is raised with the error message from the stage.
118
+
75
119
  """
76
120
 
77
121
  for stage in reversed(self.stages):
@@ -96,6 +140,7 @@ class Driver:
96
140
  Returns
97
141
  -------
98
142
  None
143
+
99
144
  """
100
145
  print("List of Stages to Run")
101
146
  for stage in self.stages:
@@ -116,6 +161,7 @@ class Driver:
116
161
  Returns
117
162
  -------
118
163
  None
164
+
119
165
  """
120
166
  for stage in self.stages:
121
167
  if stage.stage_name == stage_name:
@@ -136,6 +182,20 @@ class Driver:
136
182
  ----------
137
183
  stage_name : str
138
184
  The name of the stage to insert into the list of stages to run.
185
+ newstage : Stage
186
+ The stage object to insert into the list of stages to run.
187
+ print_info : bool, optional
188
+ If True, the function will print the list of stages after the new stage is inserted.
189
+
190
+ Returns
191
+ -------
192
+ None
193
+
194
+ Raises
195
+ ------
196
+ ValueError
197
+ If the specified stage is not in the list, a ValueError is raised.
198
+
139
199
  """
140
200
  idx = -1
141
201
  for stage in self.stages:
@@ -9,22 +9,68 @@ from ligandparam.log import get_logger
9
9
 
10
10
 
11
11
  class SimpleInterface:
12
+ """
13
+ A simple interface to call external programs.
14
+
15
+ This class is designed to be subclassed, with the `method` attribute set to the desired program. The `call` method will then execute the program with the specified arguments.
16
+
17
+ Parameters
18
+ ----------
19
+ *args : list
20
+ Additional arguments to pass to the subclass.
21
+ **kwargs : dict
22
+ Additional keyword arguments to pass to the subclass.
23
+
24
+ Attributes
25
+ ----------
26
+ method : str
27
+ The method to call the external program.
28
+ logger : logging.Logger
29
+ The logger to use for logging.
30
+ cwd : Path
31
+ The current working directory to run the program in.
32
+ nproc : int
33
+ The number of processors to use for the program.
34
+ """
35
+
12
36
  @abstractmethod
13
37
  def __init__(self, *args, **kwargs) -> None:
14
- """This class is a simple interface to call external programs.
15
-
16
- This class is a simple interface to call external programs. It is designed to be subclassed
17
- and the method attribute set to the desired program. The call method will then call the program
18
- with the specified arguments.
38
+ """
39
+ Initialize the SimpleInterface class.
19
40
 
41
+ This class is designed to be subclassed, with the `method` attribute set to the desired program. The `call` method will then execute the program with the specified arguments.
20
42
  """
21
43
  pass
22
44
 
23
45
  def set_method(self, method):
46
+ """
47
+ Set the method to call the external program.
48
+
49
+ Parameters
50
+ ----------
51
+ method : str
52
+ The name of the external program to call.
53
+ """
24
54
  self.method = method
25
55
  return
26
56
 
27
57
  def call(self, **kwargs):
58
+ """
59
+ Call the external program with the specified arguments.
60
+
61
+ Parameters
62
+ ----------
63
+ **kwargs : dict
64
+ Keyword arguments to pass to the external program. Special keys include:
65
+ - `dry_run` (bool): If True, log the command without executing it.
66
+ - `inp_pipe` (str): Input file to pipe into the program.
67
+ - `out_pipe` (str): Output file to pipe the program's output.
68
+
69
+ Raises
70
+ ------
71
+ RuntimeError
72
+ If the external program returns a non-zero exit code.
73
+ """
28
74
  dry_run = False
29
75
  if "dry_run" in kwargs:
30
76
  dry_run = kwargs["dry_run"]
@@ -34,10 +80,10 @@ class SimpleInterface:
34
80
  shell = False
35
81
  for key, value in kwargs.items():
36
82
  if key == "inp_pipe":
37
- command.extend([f"<", str(value)])
83
+ command.extend(["<", str(value)])
38
84
  shell = True
39
85
  elif key == "out_pipe":
40
- command.extend([f">", str(value)])
86
+ command.extend([">", str(value)])
41
87
  shell = True
42
88
  else:
43
89
  if value is not None:
@@ -70,9 +116,47 @@ class SimpleInterface:
70
116
 
71
117
 
72
118
  class Antechamber(SimpleInterface):
119
+ """
120
+ Interface to call the Antechamber program.
121
+
122
+ This class provides a simple interface to execute the Antechamber program.
123
+
124
+ Parameters
125
+ ----------
126
+ *args : list
127
+ Additional arguments to pass to the interface.
128
+ **kwargs : dict
129
+ Additional keyword arguments. Must include:
130
+ - `cwd` (str): Path to the working directory.
131
+
132
+ Attributes
133
+ ----------
134
+ cwd : Path
135
+ The current working directory to run the program in.
136
+ logger : logging.Logger
137
+ The logger to use for logging.
138
+ nproc : int
139
+ The number of processors to use for the program.
140
+ """
141
+
73
142
  @override
74
143
  def __init__(self, *args, **kwargs) -> None:
75
- """This class is a simple interface to call the Antechamber program."""
144
+ """
145
+ Initialize the Antechamber interface.
146
+
147
+ Parameters
148
+ ----------
149
+ *args : list
150
+ Additional arguments to pass to the interface.
151
+ **kwargs : dict
152
+ Additional keyword arguments. Must include:
153
+ - `cwd` (str): Path to the working directory.
154
+
155
+ Raises
156
+ ------
157
+ ValueError
158
+ If the `cwd` argument is missing.
159
+ """
76
160
  try:
77
161
  self.cwd = Path(kwargs["cwd"])
78
162
  except KeyError:
@@ -251,10 +251,11 @@ class GaussianReader:
251
251
  multiplicity : int
252
252
  The multiplicity of the molecule
253
253
 
254
- To Do
254
+ Notes
255
255
  -----
256
- - Add error handling for missing data
257
- - Check that this reads only the FINAL geometry
256
+ .. todo::
257
+ - Add error handling for missing data
258
+ - Check that this reads only the FINAL geometry
258
259
 
259
260
  """
260
261
  atn, coords = [], []
@@ -0,0 +1,91 @@
1
+ """
2
+ This module provides logging utilities for the ligandparam package.
3
+
4
+ Functions
5
+ ---------
6
+ get_logger() -> logging.Logger
7
+ Returns a logger with a null handler.
8
+
9
+ set_stream_logger(logging_level: int = logging.INFO) -> logging.Logger
10
+ Sets up a logger to output to the standard output stream.
11
+
12
+ set_file_logger(logfilename: Path, logname: str = None, filemode: str = 'a') -> logging.Logger
13
+ Sets up a logger to output to a file.
14
+ """
15
+
16
+ import sys
17
+ import logging
18
+ from pathlib import Path
19
+
20
+ from . import __logging_name__
21
+
22
+
23
+ def get_logger() -> logging.Logger:
24
+ """
25
+ Get a logger with a null handler.
26
+
27
+ Returns
28
+ -------
29
+ logging.Logger
30
+ A logger instance with a null handler.
31
+ """
32
+ logger = logging.getLogger(__logging_name__)
33
+ logger.setLevel(logging.INFO)
34
+ logger.addHandler(logging.NullHandler())
35
+ return logger
36
+
37
+ def set_stream_logger(logging_level: int = logging.INFO) -> logging.Logger:
38
+ """
39
+ Set up a logger to output to the standard output stream.
40
+
41
+ Parameters
42
+ ----------
43
+ logging_level : int, optional
44
+ The logging level to set for the logger, by default logging.INFO.
45
+
46
+ Returns
47
+ -------
48
+ logging.Logger
49
+ A logger instance configured to output to the standard output stream.
50
+ """
51
+ logger = logging.getLogger(__logging_name__)
52
+ logger.setLevel(logging_level)
53
+ stream_handler = logging.StreamHandler(sys.stdout)
54
+ stream_handler.setLevel(logging_level)
55
+ logger.addHandler(stream_handler)
56
+
57
+ return logger
58
+
59
+ def set_file_logger(logfilename: Path, logname: str = None, filemode: str = 'a') -> logging.Logger:
60
+ """
61
+ Set up a logger to output to a file.
62
+
63
+ Parameters
64
+ ----------
65
+ logfilename : Path
66
+ The path to the log file.
67
+ logname : str, optional
68
+ The name of the logger, by default None. If None, the module's logging name is used.
69
+ filemode : str, optional
70
+ The mode to open the log file, by default 'a'.
71
+
72
+ Returns
73
+ -------
74
+ logging.Logger
75
+ A logger instance configured to output to the specified file.
76
+ """
77
+ if logname is None:
78
+ logname = __logging_name__
79
+ logger = logging.getLogger(logname)
80
+ logger.setLevel(logging.INFO)
81
+ formatter = logging.Formatter(
82
+ "{asctime} - {levelname} - {message}",
83
+ style="{",
84
+ datefmt="%Y-%m-%d %H:%M:%S",
85
+ )
86
+ file_handler = logging.FileHandler(filename=logfilename, mode=filemode)
87
+ file_handler.setLevel(logging.INFO)
88
+ file_handler.setFormatter(formatter)
89
+ logger.addHandler(file_handler)
90
+
91
+ return logger
@@ -0,0 +1,135 @@
1
+ """
2
+ This module provides classes for parametrizing ligands and managing recipes.
3
+
4
+ Classes
5
+ -------
6
+ Parametrization
7
+ A class for parametrizing ligands using various stages.
8
+
9
+ Recipe
10
+ A subclass of Parametrization for managing ligand recipes.
11
+ """
12
+
13
+ import logging
14
+ from pathlib import Path
15
+ from typing import Optional, Union
16
+ from typing_extensions import override
17
+
18
+ from ligandparam.driver import Driver
19
+ from ligandparam.log import get_logger, set_stream_logger, set_file_logger
20
+
21
+
22
+ class Parametrization(Driver):
23
+ """
24
+ A class for parametrizing ligands using various stages.
25
+
26
+ Parameters
27
+ ----------
28
+ in_filename : Union[Path, str]
29
+ The input filename of the ligand.
30
+ cwd : Union[Path, str]
31
+ The current working directory.
32
+ *args : tuple
33
+ Additional positional arguments.
34
+ **kwargs : dict
35
+ Additional keyword arguments.
36
+
37
+ Keyword Args
38
+ ------------
39
+ label : str, optional
40
+ A label for the ligand, by default the stem of `in_filename`.
41
+ leaprc : list, optional
42
+ A list of leaprc files to use, by default ["leaprc.gaff2"].
43
+ logger : Union[str, logging.Logger], optional
44
+ The logger to use. Can be "file", "stream", or a logging.Logger instance.
45
+
46
+ Attributes
47
+ ----------
48
+ in_filename : Path
49
+ The resolved path to the input file.
50
+ label : str
51
+ The label for the ligand.
52
+ cwd : Path
53
+ The current working directory.
54
+ stages : list
55
+ A list of stages to run.
56
+ leaprc : list
57
+ A list of leaprc files to use.
58
+ logger : logging.Logger
59
+ The logger instance.
60
+
61
+ Raises
62
+ ------
63
+ ValueError
64
+ If an invalid logger type is provided.
65
+ """
66
+
67
+ @override
68
+ def __init__(self, in_filename: Union[Path, str], cwd: Union[Path, str], *args, **kwargs):
69
+ """
70
+ The rough approach to using this class is to generate a new Parametrization class, and then generate self.stages as a list
71
+ of stages that you want to run.
72
+
73
+ Parameters
74
+ ----------
75
+ in_filename : Union[Path, str]
76
+ The input filename of the ligand.
77
+ cwd : Union[Path, str]
78
+ The current working directory.
79
+ *args : tuple
80
+ Additional positional arguments.
81
+ **kwargs : dict
82
+ Additional keyword arguments.
83
+
84
+ Keyword Args
85
+ ------------
86
+ label : str, optional
87
+ A label for the ligand, by default the stem of `in_filename`.
88
+ leaprc : list, optional
89
+ A list of leaprc files to use, by default ["leaprc.gaff2"].
90
+ logger : Union[str, logging.Logger], optional
91
+ The logger to use. Can be "file", "stream", or a logging.Logger instance.
92
+
93
+ Raises
94
+ ------
95
+ ValueError
96
+ If an invalid logger type is provided.
97
+ """
98
+ self.in_filename = Path(in_filename).resolve()
99
+ self.label = kwargs.get("label", self.in_filename.stem)
100
+ self.cwd = Path(cwd)
101
+ self.stages = []
102
+ self.leaprc = kwargs.get("leaprc", ["leaprc.gaff2"])
103
+ try:
104
+ logger = kwargs.pop("logger")
105
+ if isinstance(logger, str):
106
+ if logger == "file":
107
+ self.logger = set_file_logger(self.cwd / f"{self.label}.log")
108
+ elif logger == "stream":
109
+ self.logger = set_stream_logger()
110
+ else:
111
+ raise ValueError("Invalid input string for logger. Must be either 'file' or 'stream'.")
112
+ elif isinstance(logger, logging.Logger):
113
+ self.logger = logger
114
+ else:
115
+ raise ValueError("logger must be a string or a logging.Logger instance.")
116
+ except KeyError:
117
+ self.logger = get_logger()
118
+
119
+ def add_leaprc(self, leaprc) -> None:
120
+ """
121
+ Add a leaprc file to the list of leaprc files.
122
+
123
+ Parameters
124
+ ----------
125
+ leaprc : str
126
+ The name of the leaprc file to add.
127
+ """
128
+ self.leaprc.append(leaprc)
129
+
130
+
131
+ class Recipe(Parametrization):
132
+ """
133
+ A subclass of Parametrization for managing ligand recipes.
134
+ """
135
+ pass
@@ -27,8 +27,8 @@ class FreeLigand(Recipe):
27
27
  Initializing from a pdb file, assigning atom types, running gaussian optimization, rotating and calculating grid effects on RESP charges, and then generating the final mol2/lib/frcmod files
28
28
  with RESP charges.
29
29
 
30
- Attributes:
31
- -----------
30
+ Attributes
31
+ ----------
32
32
  in_filename : Union[Path, str]
33
33
  The input file containing the ligand structure, typically in PDB format.
34
34
  cwd : Union[Path, str]
@@ -56,8 +56,8 @@ class FreeLigand(Recipe):
56
56
  kwargs : dict
57
57
  Additional keyword arguments that can be passed to the stages.
58
58
 
59
- Parameters:
60
- -----------
59
+ Parameters
60
+ ----------
61
61
  in_filename : Union[Path, str]
62
62
  The input file containing the ligand structure, typically in PDB format.
63
63
  cwd : Union[Path, str]
@@ -85,8 +85,8 @@ class FreeLigand(Recipe):
85
85
  kwargs : dict, optional
86
86
  Additional keyword arguments that can be passed to the stages.
87
87
 
88
- Raises:
89
- -------
88
+ Raises
89
+ ------
90
90
  KeyError
91
91
  If a required option is missing from the keyword arguments.
92
92
  ValueError
@@ -96,7 +96,7 @@ class FreeLigand(Recipe):
96
96
  AttributeError
97
97
  If a required attribute is not set during initialization.
98
98
 
99
- Example:
99
+ Examples
100
100
  --------
101
101
  >>> from ligandparam.recipes import FreeLigand
102
102
  >>> from pathlib import Path
@@ -23,8 +23,8 @@ class LazyLigand(Recipe):
23
23
  Initializing from a pdb file, assigning atom types, running gaussian optimization, and calculating RESP charges, and then generating the final mol2/lib/frcmod files
24
24
  with RESP charges.
25
25
 
26
- Attributes:
27
- -----------
26
+ Attributes
27
+ ----------
28
28
  in_filename : Union[Path, str]
29
29
  The input file containing the ligand structure, typically in PDB format.
30
30
  cwd : Union[Path, str]
@@ -51,9 +51,9 @@ class LazyLigand(Recipe):
51
51
  The directory for Gaussian scratch files, if not set, will use the environment variable.
52
52
  kwargs : dict
53
53
  Additional keyword arguments that can be passed to the stages.
54
-
55
- Parameters:
56
- -----------
54
+
55
+ Parameters
56
+ ----------
57
57
  in_filename : Union[Path, str]
58
58
  The input file containing the ligand structure, typically in PDB format.
59
59
  cwd : Union[Path, str]
@@ -81,8 +81,8 @@ class LazyLigand(Recipe):
81
81
  kwargs : dict, optional
82
82
  Additional keyword arguments that can be passed to the stages.
83
83
 
84
- Raises:
85
- -------
84
+ Raises
85
+ ------
86
86
  KeyError
87
87
  If a required option is missing from the keyword arguments.
88
88
  ValueError
@@ -92,7 +92,7 @@ class LazyLigand(Recipe):
92
92
  AttributeError
93
93
  If a required attribute is not set during initialization.
94
94
 
95
- Example:
95
+ Examples
96
96
  --------
97
97
  >>> from ligandparam.recipes import LazyLigand
98
98
  >>> from pathlib import Path
@@ -302,7 +302,7 @@ class LazyLigand(Recipe):
302
302
 
303
303
  This method executes the LazyLigand recipe, which includes running all the stages defined in the setup method.
304
304
 
305
- Parameters:
305
+ Parameters
306
306
  ----------
307
307
  dry_run : bool, optional
308
308
  If True, the stages will not be executed, but the commands that would be run will be printed.
@@ -311,7 +311,7 @@ class LazyLigand(Recipe):
311
311
  mem : Optional[int], optional
312
312
  The amount of memory (in GB) to allocate for the calculations. If None, will use the value set in the recipe.
313
313
 
314
- Returns:
314
+ Returns
315
315
  -------
316
316
  None
317
317
  """
@@ -12,4 +12,5 @@ from .smilestopdb import StageSmilesToPDB
12
12
  from .lighfix import LigHFix
13
13
  from .displacemol import StageDisplaceMol
14
14
  from .pdb_names import PDB_Name_Fixer
15
- from .deepmd import DPMinimize
15
+ from .deepmd import DPMinimize
16
+ from .generate_sage_params import StageSageCreate