Skip to content

Commit 5ec078b

Browse files
committed
feat: expose search_amber_rad
1 parent 463feb9 commit 5ec078b

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

src/kimmdy/tools.py

+24-9
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ def modify_top(
9292
gro: Optional[str] = None,
9393
residuetypes: Optional[str] = None,
9494
radicals: Optional[list[int]] = None,
95+
search_amber_rad: bool = True,
9596
):
9697
"""Modify topology in various ways.
9798
@@ -115,7 +116,11 @@ def modify_top(
115116
non-amber atom types.
116117
radicals
117118
Radicals in the system PRIOR to removing hydrogens with the removeH
118-
option. One based.
119+
option. One based. Can be detected automatically in amber topologies.
120+
search_amber_rad
121+
Automatic radical search only implemented for amber. If you do use
122+
another ff, set this to false, and provide a list of radicals
123+
manually, if necessary.
119124
"""
120125

121126
top_path = Path(topology).with_suffix(".top").resolve()
@@ -154,7 +159,7 @@ def modify_top(
154159
print("Reading topology..", end="")
155160
top = Topology(
156161
read_top(top_path),
157-
radicals=" ".join(radicals),
162+
radicals=" ".join(radicals) if search_amber_rad else None,
158163
residuetypes_path=residuetypes_path,
159164
)
160165
print("Done")
@@ -264,6 +269,15 @@ def get_modify_top_cmdline_args() -> argparse.Namespace:
264269
"compatible gro/top file pair. Output analog to top.",
265270
type=str,
266271
)
272+
parser.add_argument(
273+
"-a",
274+
"--search_amber_rad",
275+
action="store_true",
276+
help="Automatic radical search only implemented for amber. If you do"
277+
"use another ff, set this to false, and provide a list of radicals"
278+
"manually, if necessary.",
279+
default=True,
280+
)
267281
parser.add_argument(
268282
"-t",
269283
"--residuetypes",
@@ -285,13 +299,14 @@ def entry_point_modify_top():
285299
args = get_modify_top_cmdline_args()
286300

287301
modify_top(
288-
args.top,
289-
args.out,
290-
args.parameterize,
291-
args.removeH,
292-
args.gro,
293-
args.residuetypes,
294-
args.radicals,
302+
topology=args.top,
303+
out=args.out,
304+
parameterize=args.parameterize,
305+
removeH=args.removeH,
306+
gro=args.gro,
307+
residuetypes=args.residuetypes,
308+
radicals=args.radicals,
309+
search_amber_rad=args.search_amber_rad,
295310
)
296311

297312

0 commit comments

Comments
 (0)