Coverage for biobb_amber/sander/sander_mdrun.py: 50%
211 statements
« prev ^ index » next coverage.py v7.6.10, created at 2025-01-28 08:28 +0000
« prev ^ index » next coverage.py v7.6.10, created at 2025-01-28 08:28 +0000
1#!/usr/bin/env python3
3"""Module containing the SanderMDRun class and the command line interface."""
4import argparse
5from typing import Optional
6import shutil
7import re
8from pathlib import Path, PurePath
9from biobb_common.generic.biobb_object import BiobbObject
10from biobb_common.configuration import settings
11from biobb_common.tools import file_utils as fu
12from biobb_common.tools.file_utils import launchlogger
13from biobb_amber.sander.common import check_input_path, check_output_path
16class SanderMDRun(BiobbObject):
17 """
18 | biobb_amber SanderMDRun
19 | Wrapper of the `AmberTools (AMBER MD Package) sander tool <https://ambermd.org/AmberTools.php>`_ module.
20 | Runs energy minimization, molecular dynamics, and NMR refinements using sander tool from the AmberTools MD package.
22 Args:
23 input_top_path (str): Input topology file (AMBER ParmTop). File type: input. `Sample file <https://github.com/bioexcel/biobb_amber/raw/master/biobb_amber/test/data/sander/cln025.prmtop>`_. Accepted formats: top (edam:format_3881), parmtop (edam:format_3881), prmtop (edam:format_3881).
24 input_crd_path (str): Input coordinates file (AMBER crd). File type: input. `Sample file <https://github.com/bioexcel/biobb_amber/raw/master/biobb_amber/test/data/sander/cln025.inpcrd>`_. Accepted formats: crd (edam:format_3878), mdcrd (edam:format_3878), inpcrd (edam:format_3878), netcdf (edam:format_3650), nc (edam:format_3650), ncrst (edam:format_3886), rst (edam:format_3886).
25 input_mdin_path (str) (Optional): Input configuration file (MD run options) (AMBER mdin). File type: input. `Sample file <https://github.com/bioexcel/biobb_amber/raw/master/biobb_amber/test/data/sander/npt.mdin>`_. Accepted formats: mdin (edam:format_2330), in (edam:format_2330), txt (edam:format_2330).
26 input_cpin_path (str) (Optional): Input constant pH file (AMBER cpin). File type: input. `Sample file <https://github.com/bioexcel/biobb_amber/raw/master/biobb_amber/test/data/sander/cln025.cpin>`_. Accepted formats: cpin (edam:format_2330).
27 input_ref_path (str) (Optional): Input reference coordinates for position restraints. File type: input. `Sample file <https://github.com/bioexcel/biobb_amber/raw/master/biobb_amber/test/data/sander/sander.rst>`_. Accepted formats: rst (edam:format_3886), rst7 (edam:format_3886), netcdf (edam:format_3650), nc (edam:format_3650), ncrst (edam:format_3886), crd (edam:format_3878).
28 output_log_path (str): Output log file. File type: output. `Sample file <https://github.com/bioexcel/biobb_amber/raw/master/biobb_amber/test/reference/sander/sander.log>`_. Accepted formats: log (edam:format_2330), out (edam:format_2330), txt (edam:format_2330), o (edam:format_2330).
29 output_traj_path (str): Output trajectory file. File type: output. `Sample file <https://github.com/bioexcel/biobb_amber/raw/master/biobb_amber/test/reference/sander/sander.x>`_. Accepted formats: trj (edam:format_3878), crd (edam:format_3878), mdcrd (edam:format_3878), x (edam:format_3878), netcdf (edam:format_3650), nc (edam:format_3650).
30 output_rst_path (str): Output restart file. File type: output. `Sample file <https://github.com/bioexcel/biobb_amber/raw/master/biobb_amber/test/reference/sander/sander.rst>`_. Accepted formats: rst (edam:format_3886), rst7 (edam:format_3886), netcdf (edam:format_3650), nc (edam:format_3650), ncrst (edam:format_3886).
31 output_cpout_path (str) (Optional): Output constant pH file (AMBER cpout). File type: output. `Sample file <https://github.com/bioexcel/biobb_amber/raw/master/biobb_amber/test/reference/sander/sander.cpout>`_. Accepted formats: cpout (edam:format_2330).
32 output_cprst_path (str) (Optional): Output constant pH restart file (AMBER rstout). File type: output. `Sample file <https://github.com/bioexcel/biobb_amber/raw/master/biobb_amber/test/reference/sander/sander.cprst>`_. Accepted formats: cprst (edam:format_3886), rst (edam:format_3886), rst7 (edam:format_3886).
33 output_mdinfo_path (str) (Optional): Output MD info. File type: output. `Sample file <https://github.com/bioexcel/biobb_amber/raw/master/biobb_amber/test/reference/sander/sander.mdinfo>`_. Accepted formats: mdinfo (edam:format_2330).
34 properties (dict - Python dictionary object containing the tool parameters, not input/output files):
35 * **mdin** (*dict*) - ({}) Sander MD run options specification. (Used if *input_mdin_path* is None)
36 * **simulation_type** (*str*) - ("minimization") Default options for the mdin file. Each creates a different mdin file. Values: `minimization <https://biobb-amber.readthedocs.io/en/latest/_static/mdins/min.mdin>`_ (Runs an energy minimization), `min_vacuo <https://biobb-amber.readthedocs.io/en/latest/_static/mdins/min_vacuo.mdin>`_ (Runs an energy minimization in vacuo), `NVT <https://biobb-amber.readthedocs.io/en/latest/_static/mdins/nvt.mdin>`_ (Runs an NVT equilibration), `npt <https://biobb-amber.readthedocs.io/en/latest/_static/mdins/npt.mdin>`_ (Runs an NPT equilibration), `free <https://biobb-amber.readthedocs.io/en/latest/_static/mdins/free.mdin>`_ (Runs a MD simulation), `heat <https://biobb-amber.readthedocs.io/en/latest/_static/mdins/heat.mdin>`_ (Heats the MD system).
37 * **binary_path** (*str*) - ("sander") sander binary path to be used.
38 * **direct_mdin** (*bool*) - (False) Use input_mdin_path as it is, skip file parsing.
39 * **mpi_bin** (*str*) - (None) Path to the MPI runner. Usually "mpirun" or "srun".
40 * **mpi_np** (*int*) - (0) [0~1000|1] Number of MPI processes. Usually an integer bigger than 1.
41 * **mpi_flags** (*str*) - (None) Path to the MPI hostlist file.
42 * **remove_tmp** (*bool*) - (True) [WF property] Remove temporal files.
43 * **restart** (*bool*) - (False) [WF property] Do not execute if output files exist.
44 * **sandbox_path** (*str*) - ("./") [WF property] Parent path to the sandbox directory.
45 * **container_path** (*str*) - (None) Container path definition.
46 * **container_image** (*str*) - ('afandiadib/ambertools:serial') Container image definition.
47 * **container_volume_path** (*str*) - ('/tmp') Container volume path definition.
48 * **container_working_dir** (*str*) - (None) Container working directory definition.
49 * **container_user_id** (*str*) - (None) Container user_id definition.
50 * **container_shell_path** (*str*) - ('/bin/bash') Path to default shell inside the container.
52 Examples:
53 This is a use example of how to use the building block from Python::
55 from biobb_amber.sander.sander_mdrun import sander_mdrun
56 prop = {
57 'simulation_type' : 'minimization',
58 'mdin' : {
59 'dt' : 0.002
60 }
61 }
62 sander_mdrun(input_top_path='/path/to/topology.top',
63 input_crd_path='/path/to/coordinates.crd',
64 output_traj_path='/path/to/newTrajectory.crd',
65 output_rst_path='/path/to/newRestart.rst',
66 output_log_path='/path/to/newAmberlog.log',
67 properties=prop)
69 Info:
70 * wrapped_software:
71 * name: AmberTools Sander
72 * version: >20.9
73 * license: LGPL 2.1
74 * multinode: mpi
75 * ontology:
76 * name: EDAM
77 * schema: http://edamontology.org/EDAM.owl
79 """
81 def __init__(self, input_top_path: str, input_crd_path: str, output_log_path: str, output_traj_path: str, output_rst_path: str,
82 input_ref_path: Optional[str] = None, input_mdin_path: Optional[str] = None, input_cpin_path: Optional[str] = None, output_cpout_path: Optional[str] = None, output_cprst_path: Optional[str] = None, output_mdinfo_path: Optional[str] = None,
83 properties: Optional[dict] = None, **kwargs) -> None:
85 properties = properties or {}
87 # Call parent class constructor
88 super().__init__(properties)
89 self.locals_var_dict = locals().copy()
91 # Input/Output files
92 self.io_dict = {
93 'in': {'input_top_path': input_top_path,
94 'input_crd_path': input_crd_path,
95 'input_mdin_path': input_mdin_path,
96 'input_ref_path': input_ref_path,
97 'input_cpin_path': input_cpin_path},
98 'out': {'output_log_path': output_log_path,
99 'output_traj_path': output_traj_path,
100 'output_rst_path': output_rst_path,
101 'output_cpout_path': output_cpout_path,
102 'output_cprst_path': output_cprst_path,
103 'output_mdinfo_path': output_mdinfo_path}
104 }
106 # Properties specific for BB
107 self.properties = properties
108 self.simulation_type = properties.get('simulation_type', "minimization")
109 self.binary_path = properties.get('binary_path', "sander")
111 self.direct_mdin = properties.get('direct_mdin', False)
112 self.mdin = {k: str(v) for k, v in properties.get('mdin', dict()).items()}
114 if 'restraintmask' in self.mdin and self.mdin['restraintmask'][0] != '"' and self.mdin['restraintmask'][-1] != '"':
115 self.mdin['restraintmask'] = "\"" + self.mdin['restraintmask'] + "\""
117 # Properties for MPI
118 self.mpi_bin = properties.get('mpi_bin')
119 self.mpi_np = properties.get('mpi_np')
120 self.mpi_flags = properties.get('mpi_flags')
122 # Check the properties
123 self.check_properties(properties)
124 self.check_arguments()
126 def check_data_params(self, out_log, out_err):
127 """ Checks input/output paths correctness """
129 # Check input(s)
130 self.io_dict["in"]["input_top_path"] = check_input_path(self.io_dict["in"]["input_top_path"], "input_top_path", False, out_log, self.__class__.__name__)
131 self.io_dict["in"]["input_crd_path"] = check_input_path(self.io_dict["in"]["input_crd_path"], "input_crd_path", False, out_log, self.__class__.__name__)
132 self.io_dict["in"]["input_mdin_path"] = check_input_path(self.io_dict["in"]["input_mdin_path"], "input_mdin_path", True, out_log, self.__class__.__name__)
133 self.io_dict["in"]["input_cpin_path"] = check_input_path(self.io_dict["in"]["input_cpin_path"], "input_cpin_path", True, out_log, self.__class__.__name__)
134 self.io_dict["in"]["input_ref_path"] = check_input_path(self.io_dict["in"]["input_ref_path"], "input_ref_path", True, out_log, self.__class__.__name__)
136 # Check output(s)
137 self.io_dict["out"]["output_log_path"] = check_output_path(self.io_dict["out"]["output_log_path"], "output_log_path", False, out_log, self.__class__.__name__)
138 self.io_dict["out"]["output_traj_path"] = check_output_path(self.io_dict["out"]["output_traj_path"], "output_traj_path", False, out_log, self.__class__.__name__)
139 self.io_dict["out"]["output_rst_path"] = check_output_path(self.io_dict["out"]["output_rst_path"], "output_rst_path", False, out_log, self.__class__.__name__)
140 self.io_dict["out"]["output_cpout_path"] = check_output_path(self.io_dict["out"]["output_cpout_path"], "output_cpout_path", True, out_log, self.__class__.__name__)
141 self.io_dict["out"]["output_cprst_path"] = check_output_path(self.io_dict["out"]["output_cprst_path"], "output_cprst_path", True, out_log, self.__class__.__name__)
142 self.io_dict["out"]["output_mdinfo_path"] = check_output_path(self.io_dict["out"]["output_mdinfo_path"], "output_mdinfo_path", True, out_log, self.__class__.__name__)
144 def create_mdin(self, path: Optional[str] = None) -> str:
145 """Creates an AMBER MD configuration file (mdin) using the properties file settings"""
146 mdin_list = []
147 mdin_firstPart = []
148 mdin_middlePart = []
149 mdin_lastPart = []
151 self.output_mdin_path = path
153 if self.io_dict['in']['input_mdin_path']:
154 # MDIN parameters read from an input mdin file
155 if (not self.direct_mdin):
156 mdin_firstPart.append("Mdin read from input file: " + self.stage_io_dict['in']['input_mdin_path'])
157 mdin_firstPart.append("and modified by the biobb_amber module from the BioBB library ")
158 with open(self.stage_io_dict['in']['input_mdin_path']) as input_params:
159 firstPart = True
160 secondPart = False
161 for line in input_params:
162 if '=' in line and not secondPart:
163 firstPart = False
164 mdin_middlePart.append(line.rstrip())
165 else:
166 if (firstPart):
167 mdin_firstPart.append(line.rstrip())
168 elif (secondPart):
169 mdin_lastPart.append(line.rstrip())
170 else:
171 secondPart = True
172 mdin_lastPart.append(line.rstrip())
174 for line in mdin_middlePart:
175 if ('!' in line or '#' in line) and not ('!@' in line or '!:' in line):
176 # Parsing lines with comments (#,!), e.g. :
177 # ntc=2, ntf=2, ! SHAKE, constrain lenghts of the bonds having H
178 params = re.split('!|#', line)
179 for param in params[0].split(','):
180 if param.strip():
181 mdin_list.append(" " + param.strip() + " ! " + params[1])
182 elif ('@' in line or ':' in line):
183 # Parsing masks, e.g. :
184 # restraintmask = ":1-40@P,O5',C5',C4',C3',O3'", restraint_wt = 0.5
185 mylist = re.findall(r'(?:[^,"]|"(?:\\.|[^"])*")+', line)
186 [mdin_list.append(" " + i.lstrip()) for i in mylist] # type: ignore
187 else:
188 for param in line.split(','):
189 if param.strip():
190 if not param.strip().startswith('!'):
191 mdin_list.append(" " + param.strip())
193 else:
194 # MDIN parameters added by the biobb_amber module
195 mdin_list.append("This mdin file has been created by the biobb_amber module from the BioBB library ")
197 sim_type = self.properties.get('simulation_type', 'minimization')
198 # sim_type = self.mdin.get('simulation_type', 'minimization')
199 minimization = (sim_type == 'minimization')
200 min_vacuo = (sim_type == 'min_vacuo')
201 heat = (sim_type == 'heat')
202 nvt = (sim_type == 'nvt')
203 npt = (sim_type == 'npt')
204 free = (sim_type == 'free')
205 md = (nvt or npt or free or heat)
207 mdin_list.append("Type of mdin: " + sim_type)
208 mdin_list.append("&cntrl")
210 # Pre-configured simulation type parameters
211 if minimization:
212 mdin_list.append(" imin = 1 ! BioBB simulation_type minimization")
213 if min_vacuo:
214 mdin_list.append(" imin = 1 ! BioBB simulation_type min_vacuo")
215 mdin_list.append(" ncyc = 250 ! BioBB simulation_type min_vacuo")
216 mdin_list.append(" ntb = 0 ! BioBB simulation_type min_vacuo")
217 mdin_list.append(" igb = 0 ! BioBB simulation_type min_vacuo")
218 mdin_list.append(" cut = 12 ! BioBB simulation_type min_vacuo")
219 if md:
220 mdin_list.append(" imin = 0 ! BioBB simulation_type nvt|npt|free|heat")
221 mdin_list.append(" cut = 10.0 ! BioBB simulation_type nvt|npt|free|heat")
222 mdin_list.append(" ntr = 0 ! BioBB simulation_type nvt|npt|free|heat")
223 mdin_list.append(" ntc = 2 ! BioBB simulation_type nvt|npt|free|heat")
224 mdin_list.append(" ntf = 2 ! BioBB simulation_type nvt|npt|free|heat")
225 mdin_list.append(" ntt = 3 ! BioBB simulation_type nvt|npt|free|heat")
226 mdin_list.append(" ig = -1 ! BioBB simulation_type nvt|npt|free|heat")
227 mdin_list.append(" ioutfm = 1 ! BioBB simulation_type nvt|npt|free|heat")
228 mdin_list.append(" iwrap = 1 ! BioBB simulation_type nvt|npt|free|heat")
229 mdin_list.append(" nstlim = 5000 ! BioBB simulation_type nvt|npt|free|heat")
230 mdin_list.append(" dt = 0.002 ! BioBB simulation_type nvt|npt|free|heat")
231 if npt:
232 mdin_list.append(" irest = 1 ! BioBB simulation_type npt")
233 mdin_list.append(" gamma_ln = 5.0 ! BioBB simulation_type npt")
234 mdin_list.append(" pres0 = 1.0 ! BioBB simulation_type npt")
235 mdin_list.append(" ntp = 1 ! BioBB simulation_type npt")
236 mdin_list.append(" taup = 2.0 ! BioBB simulation_type npt")
237 mdin_list.append(" ntx = 5 ! BioBB simulation_type npt")
238 if nvt:
239 mdin_list.append(" irest = 1 ! BioBB simulation_type nvt")
240 mdin_list.append(" gamma_ln = 5.0 ! BioBB simulation_type nvt")
241 mdin_list.append(" ntb = 1 ! BioBB simulation_type nvt")
242 mdin_list.append(" ntx = 5 ! BioBB simulation_type nvt")
243 if heat:
244 mdin_list.append(" tempi = 0.0 ! BioBB simulation_type heat")
245 mdin_list.append(" temp0 = 300.0 ! BioBB simulation_type heat")
246 mdin_list.append(" irest = 0 ! BioBB simulation_type heat")
247 mdin_list.append(" ntb = 1 ! BioBB simulation_type heat") # periodic boundaries
248 mdin_list.append(" gamma_ln = 1.0 ! BioBB simulation_type heat")
249 # mdin_list.append(" nmropt = 1 ! BioBB simulation_type heat")
251 # mdin_lastPart.append("/")
252 # mdin_lastPart.append("&wt")
253 # mdin_lastPart.append(" TYPE = 'TEMP0' ! BioBB simulation_type heat")
254 # mdin_lastPart.append(" ISTEP1 = 1 ! BioBB simulation_type heat")
255 # mdin_lastPart.append(" ISTEP2 = 4000 ! BioBB simulation_type heat")
256 # mdin_lastPart.append(" VALUE1 = 10.0 ! BioBB simulation_type heat")
257 # mdin_lastPart.append(" VALUE2 = 300.0 ! BioBB simulation_type heat")
258 # mdin_lastPart.append("/")
259 # mdin_lastPart.append("&wt")
260 # mdin_lastPart.append(" TYPE = 'END' ! BioBB simulation_type heat")
261 # mdin_lastPart.append("/")
263 if (not self.direct_mdin):
265 # Adding the rest of parameters in the config file to the mdin file
266 # if the parameter has already been added replace the value
267 parameter_keys = [parameter.split('=')[0].strip() for parameter in mdin_list]
268 for k, v in self.mdin.items():
269 config_parameter_key = str(k).strip()
270 if config_parameter_key in parameter_keys:
271 mdin_list[parameter_keys.index(config_parameter_key)] = ' ' + config_parameter_key + ' = ' + str(v) + ' ! BioBB property'
272 else:
273 mdin_list.append(' ' + config_parameter_key + ' = '+str(v) + ' ! BioBB property')
275 # Writing MD configuration file (mdin)
276 with open(str(self.output_mdin_path), 'w') as mdin:
277 # Start of file keyword(s)
278 if mdin_firstPart:
279 for line in mdin_firstPart:
280 mdin.write(line + '\n')
282 # MD config parameters
283 for line in mdin_list:
284 mdin.write(line + '\n')
286 # End of file keyword(s)
287 if mdin_lastPart:
288 for line in mdin_lastPart:
289 mdin.write(line + '\n')
290 else:
291 mdin.write("&end\n")
292 else:
293 # Copying generated output file to the final (user-given) file name
294 shutil.copy2(self.io_dict['in']['input_mdin_path'], str(self.output_mdin_path))
296 return str(self.output_mdin_path)
298 @launchlogger
299 def launch(self):
300 """Launches the execution of the BuildLinearStructure module."""
302 # check input/output paths and parameters
303 self.check_data_params(self.out_log, self.err_log)
305 # Setup Biobb
306 if self.check_restart():
307 return 0
308 self.stage_files()
310 # Creating temporary folder
311 # self.tmp_folder = fu.create_unique_dir()
312 # fu.log('Creating %s temporary folder' % self.tmp_folder, self.out_log)
314 # if self.io_dict['in']['input_mdin_path']:
315 # self.output_mdin_path = self.io_dict['in']['input_mdin_path']
316 # else:
317 # self.output_mdin_path = self.create_mdin(path=str(Path(self.tmp_folder).joinpath("sander.mdin")))
318 # self.output_mdin_path = self.create_mdin(path=str(Path(self.tmp_folder).joinpath("sander.mdin")))
320 # Creating temporary folder & Sander configuration (instructions) file
321 if self.container_path:
322 # instructions_file = str(PurePath(self.stage_io_dict['unique_dir']).joinpath("leap.in"))
323 # instructions_file_path = str(PurePath(self.container_volume_path).joinpath("leap.in"))
324 instructions_file = self.create_mdin(path=str(Path(self.stage_io_dict['unique_dir']).joinpath("sander.mdin")))
325 self.output_mdin_path = str(PurePath(self.container_volume_path).joinpath(PurePath(instructions_file).name))
326 self.tmp_folder = None
327 else:
328 self.tmp_folder = fu.create_unique_dir()
329 fu.log('Creating %s temporary folder' % self.tmp_folder, self.out_log)
330 self.output_mdin_path = self.create_mdin(path=str(Path(self.tmp_folder).joinpath("sander.mdin")))
332 # Command line
333 # sander -O -i mdin/min.mdin -p $1.cpH.prmtop -c ph$i/$1.inpcrd -r ph$i/$1.min.rst7 -o ph$i/$1.min.o
334 self.cmd = [self.binary_path,
335 '-O',
336 '-i', self.output_mdin_path,
337 '-p', self.stage_io_dict['in']['input_top_path'],
338 '-c', self.stage_io_dict['in']['input_crd_path'],
339 '-r', self.stage_io_dict['out']['output_rst_path'],
340 '-o', self.stage_io_dict['out']['output_log_path'],
341 '-x', self.stage_io_dict['out']['output_traj_path']
342 ]
344 if self.io_dict['in']['input_ref_path']:
345 self.cmd.append('-ref')
346 self.cmd.append(self.stage_io_dict['in']['input_ref_path'])
348 if self.io_dict['in']['input_cpin_path']:
349 self.cmd.append('-cpin')
350 self.cmd.append(self.stage_io_dict['in']['input_cpin_path'])
352 if self.io_dict['out']['output_mdinfo_path']:
353 self.cmd.append('-inf')
354 self.cmd.append(self.stage_io_dict['out']['output_mdinfo_path'])
356 if self.io_dict['out']['output_cpout_path']:
357 self.cmd.append('-cpout')
358 self.cmd.append(self.stage_io_dict['out']['output_cpout_path'])
360 if self.io_dict['out']['output_cprst_path']:
361 self.cmd.append('-cprestrt')
362 self.cmd.append(self.stage_io_dict['out']['output_cprst_path'])
364 # general mpi properties
365 if self.mpi_bin:
366 mpi_cmd = [self.mpi_bin]
367 if self.mpi_np:
368 mpi_cmd.append('-n')
369 mpi_cmd.append(str(self.mpi_np))
370 if self.mpi_flags:
371 mpi_cmd.extend(self.mpi_flags)
372 self.cmd = mpi_cmd + self.cmd
374 # Run Biobb block
375 self.run_biobb()
377 # Copy files to host
378 self.copy_to_host()
380 # remove temporary folder(s)
381 '''if self.remove_tmp:
382 if self.container_path: self.tmp_files.append(self.stage_io_dict['unique_dir'])
383 else:
384 self.tmp_files.append(self.tmp_folder)
385 self.tmp_files.append("mdinfo")
386 self.remove_tmp_files()'''
388 self.tmp_files.extend([
389 # self.stage_io_dict.get("unique_dir", ""),
390 "mdinfo",
391 str(self.tmp_folder)
392 ])
393 self.remove_tmp_files()
395 self.check_arguments(output_files_created=True, raise_exception=False)
397 return self.return_code
400def sander_mdrun(input_top_path: str, input_crd_path: str,
401 output_log_path: str, output_traj_path: str, output_rst_path: str,
402 input_mdin_path: Optional[str] = None, input_cpin_path: Optional[str] = None,
403 output_cpout_path: Optional[str] = None, output_cprst_path: Optional[str] = None,
404 output_mdinfo_path: Optional[str] = None, input_ref_path: Optional[str] = None,
405 properties: Optional[dict] = None, **kwargs) -> int:
406 """Create :class:`SanderMDRun <sander.sander_mdrun.SanderMDRun>`sander.sander_mdrun.SanderMDRun class and
407 execute :meth:`launch() <sander.sander_mdrun.SanderMDRun.launch>` method"""
409 return SanderMDRun(input_top_path=input_top_path,
410 input_crd_path=input_crd_path,
411 input_mdin_path=input_mdin_path,
412 input_cpin_path=input_cpin_path,
413 input_ref_path=input_ref_path,
414 output_log_path=output_log_path,
415 output_traj_path=output_traj_path,
416 output_rst_path=output_rst_path,
417 output_cpout_path=output_cpout_path,
418 output_cprst_path=output_cprst_path,
419 output_mdinfo_path=output_mdinfo_path,
420 properties=properties).launch()
422 sander_mdrun.__doc__ = SanderMDRun.__doc__
425def main():
426 parser = argparse.ArgumentParser(description='Running energy minimization, molecular dynamics, and NMR refinements using sander tool from the AmberTools MD package.', formatter_class=lambda prog: argparse.RawTextHelpFormatter(prog, width=99999))
427 parser.add_argument('--config', required=False, help='Configuration file')
429 # Specific args
430 required_args = parser.add_argument_group('required arguments')
431 required_args.add_argument('--input_top_path', required=True, help='Input topology file (AMBER ParmTop). Accepted formats: top, prmtop, parmtop.')
432 required_args.add_argument('--input_crd_path', required=True, help='Input coordinates file (AMBER crd). Accepted formats: crd, mdcrd.')
433 # required_args.add_argument('--input_mdin_path', required=False, help='Input configuration file (MD run options) (AMBER mdin). Accepted formats: mdin, in, txt.')
434 parser.add_argument('--input_mdin_path', required=False, help='Input configuration file (MD run options) (AMBER mdin). Accepted formats: mdin, in, txt.')
435 # required_args.add_argument('--input_cpin_path', required=False, help='Input constant pH file (AMBER cpin). Accepted formats: cpin.')
436 parser.add_argument('--input_cpin_path', required=False, help='Input constant pH file (AMBER cpin). Accepted formats: cpin.')
437 # required_args.add_argument('--input_ref_path', required=False, help='Input reference coordinates for position restraints. Accepted formats: rst, rst7.')
438 parser.add_argument('--input_ref_path', required=False, help='Input reference coordinates for position restraints. Accepted formats: rst, rst7.')
439 required_args.add_argument('--output_log_path', required=True, help='Output log file. Accepted formats: log, out, txt.')
440 required_args.add_argument('--output_traj_path', required=True, help='Output trajectory file. Accepted formats: trj, crd, mdcrd, x.')
441 required_args.add_argument('--output_rst_path', required=True, help='Output restart file. Accepted formats: rst, rst7.')
442 # required_args.add_argument('--output_cpout_path', required=False, help='Output constant pH file (AMBER cpout). Accepted formats: cpout.')
443 parser.add_argument('--output_cpout_path', required=False, help='Output constant pH file (AMBER cpout). Accepted formats: cpout.')
444 # required_args.add_argument('--output_cprst_path', required=False, help='Output constant pH restart file (AMBER rstout). Accepted formats: cprst.')
445 parser.add_argument('--output_cprst_path', required=False, help='Output constant pH restart file (AMBER rstout). Accepted formats: cprst.')
446 # required_args.add_argument('--output_mdinfo_path', required=False, help='Output MD info. Accepted formats: mdinfo.')
447 parser.add_argument('--output_mdinfo_path', required=False, help='Output MD info. Accepted formats: mdinfo.')
449 args = parser.parse_args()
450 # config = args.config if args.config else None
451 args.config = args.config or "{}"
452 # properties = settings.ConfReader(config=config).get_prop_dic()
453 properties = settings.ConfReader(config=args.config).get_prop_dic()
455 # Specific call
456 sander_mdrun(input_top_path=args.input_top_path,
457 input_crd_path=args.input_crd_path,
458 input_mdin_path=args.input_mdin_path,
459 input_cpin_path=args.input_cpin_path,
460 input_ref_path=args.input_ref_path,
461 output_log_path=args.output_log_path,
462 output_traj_path=args.output_traj_path,
463 output_rst_path=args.output_rst_path,
464 output_cpout_path=args.output_cpout_path,
465 output_cprst_path=args.output_cprst_path,
466 output_mdinfo_path=args.output_mdinfo_path,
467 properties=properties)
470if __name__ == '__main__':
471 main()