Coverage for biobb_amber/sander/sander_mdrun.py: 50%

210 statements  

« prev     ^ index     » next       coverage.py v7.5.1, created at 2024-05-07 08:11 +0000

1#!/usr/bin/env python3 

2 

3"""Module containing the SanderMDRun class and the command line interface.""" 

4import argparse 

5import shutil 

6import re 

7from pathlib import Path, PurePath 

8from biobb_common.generic.biobb_object import BiobbObject 

9from biobb_common.configuration import settings 

10from biobb_common.tools import file_utils as fu 

11from biobb_common.tools.file_utils import launchlogger 

12from biobb_amber.sander.common import check_input_path, check_output_path 

13 

14 

15class SanderMDRun(BiobbObject): 

16 """ 

17 | biobb_amber SanderMDRun 

18 | Wrapper of the `AmberTools (AMBER MD Package) sander tool <https://ambermd.org/AmberTools.php>`_ module. 

19 | Runs energy minimization, molecular dynamics, and NMR refinements using sander tool from the AmberTools MD package. 

20 

21 Args: 

22 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). 

23 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). 

24 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). 

25 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). 

26 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). 

27 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). 

28 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). 

29 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). 

30 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). 

31 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). 

32 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). 

33 properties (dict - Python dictionary object containing the tool parameters, not input/output files): 

34 * **mdin** (*dict*) - ({}) Sander MD run options specification. (Used if *input_mdin_path* is None) 

35 * **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). 

36 * **binary_path** (*str*) - ("sander") sander binary path to be used. 

37 * **direct_mdin** (*bool*) - (False) Use input_mdin_path as it is, skip file parsing. 

38 * **mpi_bin** (*str*) - (None) Path to the MPI runner. Usually "mpirun" or "srun". 

39 * **mpi_np** (*int*) - (0) [0~1000|1] Number of MPI processes. Usually an integer bigger than 1. 

40 * **mpi_flags** (*str*) - (None) Path to the MPI hostlist file. 

41 * **remove_tmp** (*bool*) - (True) [WF property] Remove temporal files. 

42 * **restart** (*bool*) - (False) [WF property] Do not execute if output files exist. 

43 * **container_path** (*str*) - (None) Container path definition. 

44 * **container_image** (*str*) - ('afandiadib/ambertools:serial') Container image definition. 

45 * **container_volume_path** (*str*) - ('/tmp') Container volume path definition. 

46 * **container_working_dir** (*str*) - (None) Container working directory definition. 

47 * **container_user_id** (*str*) - (None) Container user_id definition. 

48 * **container_shell_path** (*str*) - ('/bin/bash') Path to default shell inside the container. 

49 

50 Examples: 

51 This is a use example of how to use the building block from Python:: 

52 

53 from biobb_amber.sander.sander_mdrun import sander_mdrun 

54 prop = { 

55 'simulation_type' : 'minimization', 

56 'mdin' : { 

57 'dt' : 0.002 

58 } 

59 } 

60 sander_mdrun(input_top_path='/path/to/topology.top', 

61 input_crd_path='/path/to/coordinates.crd', 

62 output_traj_path='/path/to/newTrajectory.crd', 

63 output_rst_path='/path/to/newRestart.rst', 

64 output_log_path='/path/to/newAmberlog.log', 

65 properties=prop) 

66 

67 Info: 

68 * wrapped_software: 

69 * name: AmberTools Sander 

70 * version: >20.9 

71 * license: LGPL 2.1 

72 * multinode: mpi 

73 * ontology: 

74 * name: EDAM 

75 * schema: http://edamontology.org/EDAM.owl 

76 

77 """ 

78 def __init__(self, input_top_path: str, input_crd_path: str, output_log_path: str, output_traj_path: str, output_rst_path: str, 

79 input_ref_path: str = None, input_mdin_path: str = None, input_cpin_path: str = None, output_cpout_path: str = None, output_cprst_path: str = None, output_mdinfo_path: str = None, 

80 properties: dict = None, **kwargs) -> None: 

81 

82 properties = properties or {} 

83 

84 # Call parent class constructor 

85 super().__init__(properties) 

86 self.locals_var_dict = locals().copy() 

87 

88 # Input/Output files 

89 self.io_dict = { 

90 'in': {'input_top_path': input_top_path, 

91 'input_crd_path': input_crd_path, 

92 'input_mdin_path': input_mdin_path, 

93 'input_ref_path': input_ref_path, 

94 'input_cpin_path': input_cpin_path}, 

95 'out': {'output_log_path': output_log_path, 

96 'output_traj_path': output_traj_path, 

97 'output_rst_path': output_rst_path, 

98 'output_cpout_path': output_cpout_path, 

99 'output_cprst_path': output_cprst_path, 

100 'output_mdinfo_path': output_mdinfo_path} 

101 } 

102 

103 # Properties specific for BB 

104 self.properties = properties 

105 self.simulation_type = properties.get('simulation_type', "minimization") 

106 self.binary_path = properties.get('binary_path', "sander") 

107 

108 self.direct_mdin = properties.get('direct_mdin', False) 

109 self.mdin = {k: str(v) for k, v in properties.get('mdin', dict()).items()} 

110 

111 if 'restraintmask' in self.mdin and self.mdin['restraintmask'][0] != '"' and self.mdin['restraintmask'][-1] != '"': 

112 self.mdin['restraintmask'] = "\"" + self.mdin['restraintmask'] + "\"" 

113 

114 # Properties for MPI 

115 self.mpi_bin = properties.get('mpi_bin') 

116 self.mpi_np = properties.get('mpi_np') 

117 self.mpi_flags = properties.get('mpi_flags') 

118 

119 # Check the properties 

120 self.check_properties(properties) 

121 self.check_arguments() 

122 

123 def check_data_params(self, out_log, out_err): 

124 """ Checks input/output paths correctness """ 

125 

126 # Check input(s) 

127 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__) 

128 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__) 

129 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__) 

130 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__) 

131 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__) 

132 

133 # Check output(s) 

134 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__) 

135 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__) 

136 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__) 

137 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__) 

138 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__) 

139 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__) 

140 

141 def create_mdin(self, path: str = None) -> str: 

142 """Creates an AMBER MD configuration file (mdin) using the properties file settings""" 

143 mdin_list = [] 

144 mdin_firstPart = [] 

145 mdin_middlePart = [] 

146 mdin_lastPart = [] 

147 

148 self.output_mdin_path = path 

149 

150 if self.io_dict['in']['input_mdin_path']: 

151 # MDIN parameters read from an input mdin file 

152 if (not self.direct_mdin): 

153 mdin_firstPart.append("Mdin read from input file: " + self.stage_io_dict['in']['input_mdin_path']) 

154 mdin_firstPart.append("and modified by the biobb_amber module from the BioBB library ") 

155 with open(self.stage_io_dict['in']['input_mdin_path']) as input_params: 

156 firstPart = True 

157 secondPart = False 

158 for line in input_params: 

159 if '=' in line and not secondPart: 

160 firstPart = False 

161 mdin_middlePart.append(line.rstrip()) 

162 else: 

163 if (firstPart): 

164 mdin_firstPart.append(line.rstrip()) 

165 elif (secondPart): 

166 mdin_lastPart.append(line.rstrip()) 

167 else: 

168 secondPart = True 

169 mdin_lastPart.append(line.rstrip()) 

170 

171 for line in mdin_middlePart: 

172 if ('!' in line or '#' in line) and not ('!@' in line or '!:' in line): 

173 # Parsing lines with comments (#,!), e.g. : 

174 # ntc=2, ntf=2, ! SHAKE, constrain lenghts of the bonds having H 

175 params = re.split('!|#', line) 

176 for param in params[0].split(','): 

177 if param.strip(): 

178 mdin_list.append(" " + param.strip() + " ! " + params[1]) 

179 elif ('@' in line or ':' in line): 

180 # Parsing masks, e.g. : 

181 # restraintmask = ":1-40@P,O5',C5',C4',C3',O3'", restraint_wt = 0.5 

182 mylist = re.findall(r'(?:[^,"]|"(?:\\.|[^"])*")+', line) 

183 [mdin_list.append(" " + i.lstrip()) for i in mylist] 

184 else: 

185 for param in line.split(','): 

186 if param.strip(): 

187 if not param.strip().startswith('!'): 

188 mdin_list.append(" " + param.strip()) 

189 

190 else: 

191 # MDIN parameters added by the biobb_amber module 

192 mdin_list.append("This mdin file has been created by the biobb_amber module from the BioBB library ") 

193 

194 sim_type = self.properties.get('simulation_type', 'minimization') 

195 # sim_type = self.mdin.get('simulation_type', 'minimization') 

196 minimization = (sim_type == 'minimization') 

197 min_vacuo = (sim_type == 'min_vacuo') 

198 heat = (sim_type == 'heat') 

199 nvt = (sim_type == 'nvt') 

200 npt = (sim_type == 'npt') 

201 free = (sim_type == 'free') 

202 md = (nvt or npt or free or heat) 

203 

204 mdin_list.append("Type of mdin: " + sim_type) 

205 mdin_list.append("&cntrl") 

206 

207 # Pre-configured simulation type parameters 

208 if minimization: 

209 mdin_list.append(" imin = 1 ! BioBB simulation_type minimization") 

210 if min_vacuo: 

211 mdin_list.append(" imin = 1 ! BioBB simulation_type min_vacuo") 

212 mdin_list.append(" ncyc = 250 ! BioBB simulation_type min_vacuo") 

213 mdin_list.append(" ntb = 0 ! BioBB simulation_type min_vacuo") 

214 mdin_list.append(" igb = 0 ! BioBB simulation_type min_vacuo") 

215 mdin_list.append(" cut = 12 ! BioBB simulation_type min_vacuo") 

216 if md: 

217 mdin_list.append(" imin = 0 ! BioBB simulation_type nvt|npt|free|heat") 

218 mdin_list.append(" cut = 10.0 ! BioBB simulation_type nvt|npt|free|heat") 

219 mdin_list.append(" ntr = 0 ! BioBB simulation_type nvt|npt|free|heat") 

220 mdin_list.append(" ntc = 2 ! BioBB simulation_type nvt|npt|free|heat") 

221 mdin_list.append(" ntf = 2 ! BioBB simulation_type nvt|npt|free|heat") 

222 mdin_list.append(" ntt = 3 ! BioBB simulation_type nvt|npt|free|heat") 

223 mdin_list.append(" ig = -1 ! BioBB simulation_type nvt|npt|free|heat") 

224 mdin_list.append(" ioutfm = 1 ! BioBB simulation_type nvt|npt|free|heat") 

225 mdin_list.append(" iwrap = 1 ! BioBB simulation_type nvt|npt|free|heat") 

226 mdin_list.append(" nstlim = 5000 ! BioBB simulation_type nvt|npt|free|heat") 

227 mdin_list.append(" dt = 0.002 ! BioBB simulation_type nvt|npt|free|heat") 

228 if npt: 

229 mdin_list.append(" irest = 1 ! BioBB simulation_type npt") 

230 mdin_list.append(" gamma_ln = 5.0 ! BioBB simulation_type npt") 

231 mdin_list.append(" pres0 = 1.0 ! BioBB simulation_type npt") 

232 mdin_list.append(" ntp = 1 ! BioBB simulation_type npt") 

233 mdin_list.append(" taup = 2.0 ! BioBB simulation_type npt") 

234 mdin_list.append(" ntx = 5 ! BioBB simulation_type npt") 

235 if nvt: 

236 mdin_list.append(" irest = 1 ! BioBB simulation_type nvt") 

237 mdin_list.append(" gamma_ln = 5.0 ! BioBB simulation_type nvt") 

238 mdin_list.append(" ntb = 1 ! BioBB simulation_type nvt") 

239 mdin_list.append(" ntx = 5 ! BioBB simulation_type nvt") 

240 if heat: 

241 mdin_list.append(" tempi = 0.0 ! BioBB simulation_type heat") 

242 mdin_list.append(" temp0 = 300.0 ! BioBB simulation_type heat") 

243 mdin_list.append(" irest = 0 ! BioBB simulation_type heat") 

244 mdin_list.append(" ntb = 1 ! BioBB simulation_type heat") # periodic boundaries 

245 mdin_list.append(" gamma_ln = 1.0 ! BioBB simulation_type heat") 

246 # mdin_list.append(" nmropt = 1 ! BioBB simulation_type heat") 

247 

248 # mdin_lastPart.append("/") 

249 # mdin_lastPart.append("&wt") 

250 # mdin_lastPart.append(" TYPE = 'TEMP0' ! BioBB simulation_type heat") 

251 # mdin_lastPart.append(" ISTEP1 = 1 ! BioBB simulation_type heat") 

252 # mdin_lastPart.append(" ISTEP2 = 4000 ! BioBB simulation_type heat") 

253 # mdin_lastPart.append(" VALUE1 = 10.0 ! BioBB simulation_type heat") 

254 # mdin_lastPart.append(" VALUE2 = 300.0 ! BioBB simulation_type heat") 

255 # mdin_lastPart.append("/") 

256 # mdin_lastPart.append("&wt") 

257 # mdin_lastPart.append(" TYPE = 'END' ! BioBB simulation_type heat") 

258 # mdin_lastPart.append("/") 

259 

260 if (not self.direct_mdin): 

261 

262 # Adding the rest of parameters in the config file to the mdin file 

263 # if the parameter has already been added replace the value 

264 parameter_keys = [parameter.split('=')[0].strip() for parameter in mdin_list] 

265 for k, v in self.mdin.items(): 

266 config_parameter_key = str(k).strip() 

267 if config_parameter_key in parameter_keys: 

268 mdin_list[parameter_keys.index(config_parameter_key)] = ' ' + config_parameter_key + ' = ' + str(v) + ' ! BioBB property' 

269 else: 

270 mdin_list.append(' ' + config_parameter_key + ' = '+str(v) + ' ! BioBB property') 

271 

272 # Writing MD configuration file (mdin) 

273 with open(self.output_mdin_path, 'w') as mdin: 

274 # Start of file keyword(s) 

275 if mdin_firstPart: 

276 for line in mdin_firstPart: 

277 mdin.write(line + '\n') 

278 

279 # MD config parameters 

280 for line in mdin_list: 

281 mdin.write(line + '\n') 

282 

283 # End of file keyword(s) 

284 if mdin_lastPart: 

285 for line in mdin_lastPart: 

286 mdin.write(line + '\n') 

287 else: 

288 mdin.write("&end\n") 

289 else: 

290 # Copying generated output file to the final (user-given) file name 

291 shutil.copy2(self.io_dict['in']['input_mdin_path'], self.output_mdin_path) 

292 

293 return self.output_mdin_path 

294 

295 @launchlogger 

296 def launch(self): 

297 """Launches the execution of the BuildLinearStructure module.""" 

298 

299 # check input/output paths and parameters 

300 self.check_data_params(self.out_log, self.err_log) 

301 

302 # Setup Biobb 

303 if self.check_restart(): 

304 return 0 

305 self.stage_files() 

306 

307 # Creating temporary folder 

308 # self.tmp_folder = fu.create_unique_dir() 

309 # fu.log('Creating %s temporary folder' % self.tmp_folder, self.out_log) 

310 

311 # if self.io_dict['in']['input_mdin_path']: 

312 # self.output_mdin_path = self.io_dict['in']['input_mdin_path'] 

313 # else: 

314 # self.output_mdin_path = self.create_mdin(path=str(Path(self.tmp_folder).joinpath("sander.mdin"))) 

315 # self.output_mdin_path = self.create_mdin(path=str(Path(self.tmp_folder).joinpath("sander.mdin"))) 

316 

317 # Creating temporary folder & Sander configuration (instructions) file 

318 if self.container_path: 

319 # instructions_file = str(PurePath(self.stage_io_dict['unique_dir']).joinpath("leap.in")) 

320 # instructions_file_path = str(PurePath(self.container_volume_path).joinpath("leap.in")) 

321 instructions_file = self.create_mdin(path=str(Path(self.stage_io_dict['unique_dir']).joinpath("sander.mdin"))) 

322 self.output_mdin_path = str(PurePath(self.container_volume_path).joinpath(PurePath(instructions_file).name)) 

323 self.tmp_folder = None 

324 else: 

325 self.tmp_folder = fu.create_unique_dir() 

326 fu.log('Creating %s temporary folder' % self.tmp_folder, self.out_log) 

327 self.output_mdin_path = self.create_mdin(path=str(Path(self.tmp_folder).joinpath("sander.mdin"))) 

328 

329 # Command line 

330 # 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 

331 self.cmd = [self.binary_path, 

332 '-O', 

333 '-i', self.output_mdin_path, 

334 '-p', self.stage_io_dict['in']['input_top_path'], 

335 '-c', self.stage_io_dict['in']['input_crd_path'], 

336 '-r', self.stage_io_dict['out']['output_rst_path'], 

337 '-o', self.stage_io_dict['out']['output_log_path'], 

338 '-x', self.stage_io_dict['out']['output_traj_path'] 

339 ] 

340 

341 if self.io_dict['in']['input_ref_path']: 

342 self.cmd.append('-ref') 

343 self.cmd.append(self.stage_io_dict['in']['input_ref_path']) 

344 

345 if self.io_dict['in']['input_cpin_path']: 

346 self.cmd.append('-cpin') 

347 self.cmd.append(self.stage_io_dict['in']['input_cpin_path']) 

348 

349 if self.io_dict['out']['output_mdinfo_path']: 

350 self.cmd.append('-inf') 

351 self.cmd.append(self.stage_io_dict['out']['output_mdinfo_path']) 

352 

353 if self.io_dict['out']['output_cpout_path']: 

354 self.cmd.append('-cpout') 

355 self.cmd.append(self.stage_io_dict['out']['output_cpout_path']) 

356 

357 if self.io_dict['out']['output_cprst_path']: 

358 self.cmd.append('-cprestrt') 

359 self.cmd.append(self.stage_io_dict['out']['output_cprst_path']) 

360 

361 # general mpi properties 

362 if self.mpi_bin: 

363 mpi_cmd = [self.mpi_bin] 

364 if self.mpi_np: 

365 mpi_cmd.append('-n') 

366 mpi_cmd.append(str(self.mpi_np)) 

367 if self.mpi_flags: 

368 mpi_cmd.extend(self.mpi_flags) 

369 self.cmd = mpi_cmd + self.cmd 

370 

371 # Run Biobb block 

372 self.run_biobb() 

373 

374 # Copy files to host 

375 self.copy_to_host() 

376 

377 # remove temporary folder(s) 

378 '''if self.remove_tmp: 

379 if self.container_path: self.tmp_files.append(self.stage_io_dict['unique_dir']) 

380 else: 

381 self.tmp_files.append(self.tmp_folder) 

382 self.tmp_files.append("mdinfo") 

383 self.remove_tmp_files()''' 

384 

385 self.tmp_files.extend([ 

386 self.stage_io_dict.get("unique_dir"), 

387 "mdinfo", 

388 self.tmp_folder 

389 ]) 

390 self.remove_tmp_files() 

391 

392 self.check_arguments(output_files_created=True, raise_exception=False) 

393 

394 return self.return_code 

395 

396 

397def sander_mdrun(input_top_path: str, input_crd_path: str, 

398 output_log_path: str, output_traj_path: str, output_rst_path: str, 

399 input_mdin_path: str = None, input_cpin_path: str = None, 

400 output_cpout_path: str = None, output_cprst_path: str = None, 

401 output_mdinfo_path: str = None, input_ref_path: str = None, 

402 properties: dict = None, **kwargs) -> int: 

403 """Create :class:`SanderMDRun <sander.sander_mdrun.SanderMDRun>`sander.sander_mdrun.SanderMDRun class and 

404 execute :meth:`launch() <sander.sander_mdrun.SanderMDRun.launch>` method""" 

405 

406 return SanderMDRun(input_top_path=input_top_path, 

407 input_crd_path=input_crd_path, 

408 input_mdin_path=input_mdin_path, 

409 input_cpin_path=input_cpin_path, 

410 input_ref_path=input_ref_path, 

411 output_log_path=output_log_path, 

412 output_traj_path=output_traj_path, 

413 output_rst_path=output_rst_path, 

414 output_cpout_path=output_cpout_path, 

415 output_cprst_path=output_cprst_path, 

416 output_mdinfo_path=output_mdinfo_path, 

417 properties=properties).launch() 

418 

419 

420def main(): 

421 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)) 

422 parser.add_argument('--config', required=False, help='Configuration file') 

423 

424 # Specific args 

425 required_args = parser.add_argument_group('required arguments') 

426 required_args.add_argument('--input_top_path', required=True, help='Input topology file (AMBER ParmTop). Accepted formats: top, prmtop, parmtop.') 

427 required_args.add_argument('--input_crd_path', required=True, help='Input coordinates file (AMBER crd). Accepted formats: crd, mdcrd.') 

428 # required_args.add_argument('--input_mdin_path', required=False, help='Input configuration file (MD run options) (AMBER mdin). Accepted formats: mdin, in, txt.') 

429 parser.add_argument('--input_mdin_path', required=False, help='Input configuration file (MD run options) (AMBER mdin). Accepted formats: mdin, in, txt.') 

430 # required_args.add_argument('--input_cpin_path', required=False, help='Input constant pH file (AMBER cpin). Accepted formats: cpin.') 

431 parser.add_argument('--input_cpin_path', required=False, help='Input constant pH file (AMBER cpin). Accepted formats: cpin.') 

432 # required_args.add_argument('--input_ref_path', required=False, help='Input reference coordinates for position restraints. Accepted formats: rst, rst7.') 

433 parser.add_argument('--input_ref_path', required=False, help='Input reference coordinates for position restraints. Accepted formats: rst, rst7.') 

434 required_args.add_argument('--output_log_path', required=True, help='Output log file. Accepted formats: log, out, txt.') 

435 required_args.add_argument('--output_traj_path', required=True, help='Output trajectory file. Accepted formats: trj, crd, mdcrd, x.') 

436 required_args.add_argument('--output_rst_path', required=True, help='Output restart file. Accepted formats: rst, rst7.') 

437 # required_args.add_argument('--output_cpout_path', required=False, help='Output constant pH file (AMBER cpout). Accepted formats: cpout.') 

438 parser.add_argument('--output_cpout_path', required=False, help='Output constant pH file (AMBER cpout). Accepted formats: cpout.') 

439 # required_args.add_argument('--output_cprst_path', required=False, help='Output constant pH restart file (AMBER rstout). Accepted formats: cprst.') 

440 parser.add_argument('--output_cprst_path', required=False, help='Output constant pH restart file (AMBER rstout). Accepted formats: cprst.') 

441 # required_args.add_argument('--output_mdinfo_path', required=False, help='Output MD info. Accepted formats: mdinfo.') 

442 parser.add_argument('--output_mdinfo_path', required=False, help='Output MD info. Accepted formats: mdinfo.') 

443 

444 args = parser.parse_args() 

445 # config = args.config if args.config else None 

446 args.config = args.config or "{}" 

447 # properties = settings.ConfReader(config=config).get_prop_dic() 

448 properties = settings.ConfReader(config=args.config).get_prop_dic() 

449 

450 # Specific call 

451 sander_mdrun(input_top_path=args.input_top_path, 

452 input_crd_path=args.input_crd_path, 

453 input_mdin_path=args.input_mdin_path, 

454 input_cpin_path=args.input_cpin_path, 

455 input_ref_path=args.input_ref_path, 

456 output_log_path=args.output_log_path, 

457 output_traj_path=args.output_traj_path, 

458 output_rst_path=args.output_rst_path, 

459 output_cpout_path=args.output_cpout_path, 

460 output_cprst_path=args.output_cprst_path, 

461 output_mdinfo_path=args.output_mdinfo_path, 

462 properties=properties) 

463 

464 

465if __name__ == '__main__': 

466 main()