Coverage for biobb_amber/leap/leap_solvate.py: 63%

182 statements  

« prev     ^ index     » next       coverage.py v7.6.10, created at 2025-01-28 08:28 +0000

1#!/usr/bin/env python3 

2 

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

4 

5import os 

6import argparse 

7import re 

8from pathlib import PurePath 

9from typing import List, Optional 

10 

11from biobb_common.configuration import settings 

12from biobb_common.generic.biobb_object import BiobbObject 

13from biobb_common.tools import file_utils as fu 

14from biobb_common.tools.file_utils import launchlogger 

15 

16from biobb_amber.leap.common import _from_string_to_list 

17 

18 

19class LeapSolvate(BiobbObject): 

20 """ 

21 | biobb_amber LeapSolvate 

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

23 | Creates and solvates a system box for an AMBER MD system using tLeap tool from the AmberTools MD package. 

24 

25 Args: 

26 input_pdb_path (str): Input 3D structure PDB file. File type: input. `Sample file <https://github.com/bioexcel/biobb_amber/raw/master/biobb_amber/test/data/leap/structure.leap.pdb>`_. Accepted formats: pdb (edam:format_1476). 

27 input_lib_path (str) (Optional): Input ligand library parameters file. File type: input. `Sample file <https://github.com/bioexcel/biobb_amber/raw/master/biobb_amber/test/data/leap/ligand.lib>`_. Accepted formats: lib (edam:format_3889), zip (edam:format_3987). 

28 input_frcmod_path (str) (Optional): Input ligand frcmod parameters file. File type: input. `Sample file <https://github.com/bioexcel/biobb_amber/raw/master/biobb_amber/test/data/leap/ligand.frcmod>`_. Accepted formats: frcmod (edam:format_3888), zip (edam:format_3987). 

29 input_params_path (str) (Optional): Additional leap parameter files to load with loadAmberParams Leap command. File type: input. `Sample file <https://github.com/bioexcel/biobb_amber/raw/master/biobb_amber/test/data/leap/frcmod.ionsdang_spce.txt>`_. Accepted formats: in (edam:format_2330), leapin (edam:format_2330), txt (edam:format_2330), zip (edam:format_3987). 

30 input_prep_path (str) (Optional): Additional leap parameter files to load with loadAmberPrep Leap command. File type: input. `Sample file <https://github.com/bioexcel/biobb_amber/raw/master/biobb_amber/test/data/leap/heme_all.in>`_. Accepted formats: in (edam:format_2330), leapin (edam:format_2330), txt (edam:format_2330), zip (edam:format_3987). 

31 input_source_path (str) (Optional): Additional leap command files to load with source Leap command. File type: input. `Sample file <https://github.com/bioexcel/biobb_amber/raw/master/biobb_amber/test/data/leap/leaprc.water.spce.txt>`_. Accepted formats: in (edam:format_2330), leapin (edam:format_2330), txt (edam:format_2330), zip (edam:format_3987). 

32 output_pdb_path (str): Output 3D structure PDB file matching the topology file. File type: output. `Sample file <https://github.com/bioexcel/biobb_amber/raw/master/biobb_amber/test/reference/leap/structure.solv.pdb>`_. Accepted formats: pdb (edam:format_1476). 

33 output_top_path (str): Output topology file (AMBER ParmTop). File type: output. `Sample file <https://github.com/bioexcel/biobb_amber/raw/master/biobb_amber/test/reference/leap/structure.solv.top>`_. Accepted formats: top (edam:format_3881), parmtop (edam:format_3881), prmtop (edam:format_3881). 

34 output_crd_path (str): Output coordinates file (AMBER crd). File type: output. `Sample file <https://github.com/bioexcel/biobb_amber/raw/master/biobb_amber/test/reference/leap/structure.solv.crd>`_. Accepted formats: crd (edam:format_3878), mdcrd (edam:format_3878), inpcrd (edam:format_3878). 

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

36 * **forcefield** (*list*) - (["protein.ff14SB","DNA.bsc1","gaff"]) Forcefields to be used for the structure generation. Each item should be either a path to a leaprc file or a string with the leaprc file name if the force field is included with Amber (e.g. "/path/to/leaprc.protein.ff14SB" or "protein.ff14SB"). Default values: ["protein.ff14SB","DNA.bsc1","gaff"]. 

37 * **water_type** (*str*) - ("TIP3PBOX") Water molecule parameters to be used for the topology. Values: POL3BOX, QSPCFWBOX, SPCBOX, SPCFWBOX, TIP3PBOX, TIP3PFBOX, TIP4PBOX, TIP4PEWBOX, OPCBOX, OPC3BOX, TIP5PBOX. 

38 * **box_type** (*str*) - ("truncated_octahedron") Type for the MD system box. Values: cubic, truncated_octahedron. 

39 * **ions_type** (*str*) - ("ionsjc_tip3p") Ions type. Values: ionsjc_tip3p, ionsjc_spce, ionsff99_tip3p, ions_charmm22, ionsjc_tip4pew, None. 

40 * **neutralise** (*bool*) - ("False") Energetically neutralise the system adding the necessary counterions. 

41 * **iso** (*bool*) - ("False") Make the box isometric. 

42 * **positive_ions_number** (*int*) - (0) Number of additional positive ions to include in the system box. 

43 * **negative_ions_number** (*int*) - (0) Number of additional negative ions to include in the system box. 

44 * **positive_ions_type** (*str*) - ("Na+") Type of additional positive ions to include in the system box. Values: Na+,K+. 

45 * **negative_ions_type** (*str*) - ("Cl-") Type of additional negative ions to include in the system box. Values: Cl-. 

46 * **distance_to_molecule** (*float*) - ("8.0") Size for the MD system box -in Angstroms-, defined such as the minimum distance between any atom originally present in solute and the edge of the periodic box is given by this distance parameter. 

47 * **closeness** (*float*) - ("1.0") How close, in Å, solvent ATOMs may come to solute ATOMs. 

48 * **binary_path** (*str*) - ("tleap") Path to the tleap executable binary. 

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

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

51 * **sandbox_path** (*str*) - ("./") [WF property] Parent path to the sandbox directory. 

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

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

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

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

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

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

58 

59 Examples: 

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

61 from biobb_amber.leap.leap_solvate import leap_solvate 

62 prop = { 

63 'forcefield': ['protein.ff14SB'], 

64 'water_type': 'TIP3PBOX', 

65 'box_type': 'truncated_octahedron', 

66 'neutralise' : True 

67 } 

68 leap_solvate(input_pdb_path='/path/to/structure.pdb', 

69 output_pdb_path='/path/to/newStructure.pdb', 

70 output_top_path='/path/to/newTopology.top', 

71 output_crd_path='/path/to/newCoordinates.crd', 

72 properties=prop) 

73 

74 Info: 

75 * wrapped_software: 

76 * name: AmberTools tLeap 

77 * version: >20.9 

78 * license: LGPL 2.1 

79 * ontology: 

80 * name: EDAM 

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

82 

83 """ 

84 

85 def __init__( 

86 self, 

87 input_pdb_path: str, 

88 output_pdb_path: str, 

89 output_top_path: str, 

90 output_crd_path: str, 

91 input_lib_path: Optional[str] = None, 

92 input_frcmod_path: Optional[str] = None, 

93 input_params_path: Optional[str] = None, 

94 input_prep_path: Optional[str] = None, 

95 input_source_path: Optional[str] = None, 

96 properties: Optional[dict] = None, 

97 **kwargs, 

98 ): 

99 properties = properties or {} 

100 

101 # Call parent class constructor 

102 super().__init__(properties) 

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

104 

105 # Input/Output files 

106 self.io_dict = { 

107 "in": { 

108 "input_pdb_path": input_pdb_path, 

109 "input_lib_path": input_lib_path, 

110 "input_frcmod_path": input_frcmod_path, 

111 "input_params_path": input_params_path, 

112 "input_prep_path": input_prep_path, 

113 "input_source_path": input_source_path, 

114 }, 

115 "out": { 

116 "output_pdb_path": output_pdb_path, 

117 "output_top_path": output_top_path, 

118 "output_crd_path": output_crd_path, 

119 }, 

120 } 

121 

122 # # Ligand Parameter lists 

123 # self.ligands_lib_list = [] 

124 # if input_lib_path: 

125 # self.ligands_lib_list.append(input_lib_path) 

126 # 

127 # self.ligands_frcmod_list = [] 

128 # if input_frcmod_path: 

129 # self.ligands_frcmod_list.append(input_frcmod_path) 

130 

131 # Set default forcefields 

132 amber_home_path = os.getenv("AMBERHOME") 

133 protein_ff14SB_path = os.path.join(amber_home_path, 'dat', 'leap', 'cmd', 'leaprc.protein.ff14SB') 

134 dna_bsc1_path = os.path.join(amber_home_path, 'dat', 'leap', 'cmd', 'leaprc.DNA.bsc1') 

135 gaff_path = os.path.join(amber_home_path, 'dat', 'leap', 'cmd', 'leaprc.gaff') 

136 

137 # Properties specific for BB 

138 self.properties = properties 

139 self.forcefield = _from_string_to_list( 

140 properties.get("forcefield", [protein_ff14SB_path, dna_bsc1_path, gaff_path]) 

141 ) 

142 # Find the paths of the leaprc files if only the force field names are provided 

143 self.forcefield = self.find_leaprc_paths(self.forcefield) 

144 self.water_type = properties.get("water_type", "TIP3PBOX") 

145 self.box_type = properties.get("box_type", "truncated_octahedron") 

146 self.ions_type = properties.get("ions_type", "ionsjc_tip3p") 

147 self.neutralise = properties.get("neutralise", False) 

148 self.iso = properties.get("iso", False) 

149 self.positive_ions_number = properties.get("positive_ions_number", 0) 

150 self.positive_ions_type = properties.get("positive_ions_type", "Na+") 

151 self.negative_ions_number = properties.get("negative_ions_number", 0) 

152 self.negative_ions_type = properties.get("negative_ions_type", "Cl-") 

153 self.distance_to_molecule = properties.get("distance_to_molecule", 8.0) 

154 self.closeness = properties.get("closeness", 1.0) 

155 self.binary_path = properties.get("binary_path", "tleap") 

156 

157 # Check the properties 

158 self.check_properties(properties) 

159 self.check_arguments() 

160 

161 def find_leaprc_paths(self, forcefields: List[str]) -> List[str]: 

162 """ 

163 Find the leaprc paths for the force fields provided. 

164 

165 For each item in the forcefields list, the function checks if the str is a path to an existing file. 

166 If not, it tries to find the file in the $AMBERHOME/dat/leap/cmd/ directory or the $AMBERHOME/dat/leap/cmd/oldff/ 

167 directory with and without the leaprc prefix. 

168 

169 Args: 

170 forcefields (List[str]): List of force fields to find the leaprc files for. 

171 

172 Returns: 

173 List[str]: List of leaprc file paths. 

174 """ 

175 

176 leaprc_paths = [] 

177 

178 for forcefield in forcefields: 

179 

180 num_paths = len(leaprc_paths) 

181 

182 # Check if the forcefield is a path to an existing file 

183 if os.path.exists(forcefield): 

184 leaprc_paths.append(forcefield) 

185 continue 

186 

187 # Check if the forcefield is in the leaprc directory 

188 leaprc_path = os.path.join(os.environ.get('AMBERHOME', ''), 'dat', 'leap', 'cmd', f"leaprc.{forcefield}") 

189 if os.path.exists(leaprc_path): 

190 leaprc_paths.append(leaprc_path) 

191 continue 

192 

193 # Check if the forcefield is in the oldff directory 

194 leaprc_path = os.path.join(os.environ.get('AMBERHOME', ''), 'dat', 'leap', 'cmd', 'oldff', f"leaprc.{forcefield}") 

195 if os.path.exists(leaprc_path): 

196 leaprc_paths.append(leaprc_path) 

197 continue 

198 

199 # Check if the forcefield is in the leaprc directory without the leaprc prefix 

200 leaprc_path = os.path.join(os.environ.get('AMBERHOME', ''), 'dat', 'leap', 'cmd', f"{forcefield}") 

201 if os.path.exists(leaprc_path): 

202 leaprc_paths.append(leaprc_path) 

203 continue 

204 

205 # Check if the forcefield is in the oldff directory without the leaprc prefix 

206 leaprc_path = os.path.join(os.environ.get('AMBERHOME', ''), 'dat', 'leap', 'cmd', 'oldff', f"{forcefield}") 

207 if os.path.exists(leaprc_path): 

208 leaprc_paths.append(leaprc_path) 

209 continue 

210 

211 new_num_paths = len(leaprc_paths) 

212 

213 if new_num_paths == num_paths: 

214 raise ValueError(f"Force field {forcefield} not found. Check the $AMBERHOME/dat/leap/cmd/ directory for available force fields or provide the path to an existing leaprc file.") 

215 

216 return leaprc_paths 

217 

218 # def check_data_params(self, out_log, err_log): 

219 # """ Checks input/output paths correctness """ 

220 

221 # # Check input(s) 

222 # self.io_dict["in"]["input_pdb_path"] = check_input_path(self.io_dict["in"]["input_pdb_path"], "input_pdb_path", False, out_log, self.__class__.__name__) 

223 # self.io_dict["in"]["input_lib_path"] = check_input_path(self.io_dict["in"]["input_lib_path"], "input_lib_path", True, out_log, self.__class__.__name__) 

224 # self.io_dict["in"]["input_frcmod_path"] = check_input_path(self.io_dict["in"]["input_frcmod_path"], "input_frcmod_path", True, out_log, self.__class__.__name__) 

225 # # self.io_dict["in"]["input_params_path"] = check_input_path(self.io_dict["in"]["input_params_path"], "input_params_path", True, out_log, self.__class__.__name__) 

226 # # self.io_dict["in"]["input_source_path"] = check_input_path(self.io_dict["in"]["input_source_path"], "input_source_path", True, out_log, self.__class__.__name__) 

227 

228 # # Check output(s) 

229 # self.io_dict["out"]["output_pdb_path"] = check_output_path(self.io_dict["out"]["output_pdb_path"], "output_pdb_path", False, out_log, self.__class__.__name__) 

230 # self.io_dict["out"]["output_top_path"] = check_output_path(self.io_dict["out"]["output_top_path"], "output_top_path", False, out_log, self.__class__.__name__) 

231 # self.io_dict["out"]["output_crd_path"] = check_output_path(self.io_dict["out"]["output_crd_path"], "output_crd_path", False, out_log, self.__class__.__name__) 

232 

233 @launchlogger 

234 def launch(self): 

235 """Launches the execution of the LeapSolvate module.""" 

236 

237 # check input/output paths and parameters 

238 # self.check_data_params(self.out_log, self.err_log) 

239 

240 # Setup Biobb 

241 if self.check_restart(): 

242 return 0 

243 self.stage_files() 

244 

245 box_command = "solvateOct" 

246 if self.box_type == "cubic": 

247 box_command = "solvateBox" 

248 

249 # Forcefield 

250 # source_ff_command = "source leaprc." + self.forcefield 

251 

252 # Water Type 

253 # leaprc.water.tip4pew, tip4pd, tip3p, spceb, spce, opc, fb4, fb3 

254 # Values: POL3BOX, QSPCFWBOX, SPCBOX, SPCFWBOX, TIP3PBOX, TIP3PFBOX, TIP4PBOX, TIP4PEWBOX, OPCBOX, OPC3BOX, TIP5PBOX. 

255 source_wat_command = "source leaprc.water.tip3p" 

256 if self.water_type == "TIP4PEWBOX": 

257 source_wat_command = "leaprc.water.tip4pew" 

258 if self.water_type == "TIP4PBOX": 

259 source_wat_command = "leaprc.water.tip4pd" 

260 if re.match(r"SPC", self.water_type): 

261 source_wat_command = "source leaprc.water.spce" 

262 if re.match(r"OPC", self.water_type): 

263 source_wat_command = "source leaprc.water.opc" 

264 

265 # Counterions 

266 ions_command = "" 

267 if self.neutralise: 

268 ions_command = ( 

269 ions_command + "addions mol " + self.negative_ions_type + " 0 \n" 

270 ) 

271 ions_command = ( 

272 ions_command + "addions mol " + self.positive_ions_type + " 0 \n" 

273 ) 

274 

275 if self.negative_ions_number != 0: 

276 ions_command = ( 

277 ions_command + "addions mol " + self.negative_ions_type + " " + str(self.negative_ions_number) + " \n" 

278 ) 

279 if self.positive_ions_number != 0: 

280 ions_command = ( 

281 ions_command + "addions mol " + self.positive_ions_type + " " + str(self.positive_ions_number) + " \n" 

282 ) 

283 

284 # Creating temporary folder & Leap configuration (instructions) file 

285 if self.container_path: 

286 instructions_file = str( 

287 PurePath(self.stage_io_dict["unique_dir"]).joinpath("leap.in") 

288 ) 

289 instructions_file_path = str( 

290 PurePath(self.container_volume_path).joinpath("leap.in") 

291 ) 

292 self.tmp_folder = None 

293 else: 

294 self.tmp_folder = fu.create_unique_dir() 

295 instructions_file = str(PurePath(self.tmp_folder).joinpath("leap.in")) 

296 fu.log("Creating %s temporary folder" % self.tmp_folder, self.out_log) 

297 instructions_file_path = instructions_file 

298 

299 ligands_lib_list = [] 

300 if self.io_dict["in"]["input_lib_path"] is not None: 

301 if self.io_dict["in"]["input_lib_path"].endswith(".zip"): 

302 ligands_lib_list = fu.unzip_list( 

303 self.stage_io_dict["in"]["input_lib_path"], 

304 dest_dir=self.tmp_folder, 

305 out_log=self.out_log, 

306 ) 

307 else: 

308 ligands_lib_list.append(self.stage_io_dict["in"]["input_lib_path"]) 

309 

310 ligands_frcmod_list = [] 

311 if self.io_dict["in"]["input_frcmod_path"] is not None: 

312 if self.io_dict["in"]["input_frcmod_path"].endswith(".zip"): 

313 ligands_frcmod_list = fu.unzip_list( 

314 self.stage_io_dict["in"]["input_frcmod_path"], 

315 dest_dir=self.tmp_folder, 

316 out_log=self.out_log, 

317 ) 

318 else: 

319 ligands_frcmod_list.append( 

320 self.stage_io_dict["in"]["input_frcmod_path"] 

321 ) 

322 

323 amber_params_list = [] 

324 if self.io_dict["in"]["input_params_path"] is not None: 

325 if self.io_dict["in"]["input_params_path"].endswith(".zip"): 

326 amber_params_list = fu.unzip_list( 

327 self.stage_io_dict["in"]["input_params_path"], 

328 dest_dir=self.tmp_folder, 

329 out_log=self.out_log, 

330 ) 

331 else: 

332 amber_params_list.append(self.stage_io_dict["in"]["input_params_path"]) 

333 

334 amber_prep_list = [] 

335 if self.io_dict["in"]["input_prep_path"] is not None: 

336 if self.io_dict["in"]["input_prep_path"].endswith(".zip"): 

337 amber_prep_list = fu.unzip_list( 

338 self.stage_io_dict["in"]["input_prep_path"], 

339 dest_dir=self.tmp_folder, 

340 out_log=self.out_log, 

341 ) 

342 else: 

343 amber_prep_list.append(self.stage_io_dict["in"]["input_prep_path"]) 

344 

345 leap_source_list = [] 

346 if self.io_dict["in"]["input_source_path"] is not None: 

347 if self.io_dict["in"]["input_source_path"].endswith(".zip"): 

348 leap_source_list = fu.unzip_list( 

349 self.stage_io_dict["in"]["input_source_path"], 

350 dest_dir=self.tmp_folder, 

351 out_log=self.out_log, 

352 ) 

353 else: 

354 leap_source_list.append(self.stage_io_dict["in"]["input_source_path"]) 

355 

356 with open(instructions_file, "w") as leapin: 

357 # Forcefields loaded by default: 

358 # Protein: ff14SB (PARM99 + frcmod.ff99SB + frcmod.parmbsc0 + OL3 for RNA) 

359 # leapin.write("source leaprc.protein.ff14SB \n") 

360 # DNA: parmBSC1 (ParmBSC1 (ff99 + bsc0 + bsc1) for DNA. Ivani et al. Nature Methods 13: 55, 2016) 

361 # leapin.write("source leaprc.DNA.bsc1 \n") 

362 # Ligands: GAFF (General Amber Force field, J. Comput. Chem. 2004 Jul 15;25(9):1157-74) 

363 # leapin.write("source leaprc.gaff \n") 

364 

365 # Forcefields loaded from input forcefield property 

366 for t in self.forcefield: 

367 leapin.write("source {}\n".format(t)) 

368 

369 # Additional Leap commands 

370 for leap_commands in leap_source_list: 

371 leapin.write("source " + leap_commands + "\n") 

372 

373 # Ions Type 

374 if self.ions_type != "None": 

375 leapin.write("loadamberparams frcmod." + self.ions_type + "\n") 

376 

377 # Additional Amber parameters 

378 for amber_params in amber_params_list: 

379 leapin.write("loadamberparams " + amber_params + "\n") 

380 

381 # Additional Amber prep files 

382 for amber_prep in amber_prep_list: 

383 leapin.write("loadamberprep " + amber_prep + "\n") 

384 

385 # Water Model loaded from input water_model property 

386 leapin.write(source_wat_command + " \n") 

387 

388 # Ligand(s) libraries (if any) 

389 for amber_lib in ligands_lib_list: 

390 leapin.write("loadOff " + amber_lib + "\n") 

391 for amber_frcmod in ligands_frcmod_list: 

392 leapin.write("loadamberparams " + amber_frcmod + "\n") 

393 

394 # Loading PDB file 

395 leapin.write( 

396 "mol = loadpdb " + self.stage_io_dict["in"]["input_pdb_path"] + " \n" 

397 ) 

398 

399 # Generating box + adding water molecules 

400 leapin.write( 

401 box_command + " mol " + self.water_type + " " + str(self.distance_to_molecule) 

402 ) 

403 leapin.write( 

404 " iso " + str(self.closeness) + "\n" 

405 ) if self.iso else leapin.write(" " + str(self.closeness) + "\n") 

406 

407 # Adding counterions 

408 leapin.write(ions_command) 

409 

410 # Saving output PDB file, coordinates and topology 

411 leapin.write( 

412 "savepdb mol " + self.stage_io_dict["out"]["output_pdb_path"] + " \n" 

413 ) 

414 leapin.write( 

415 "saveAmberParm mol " + self.stage_io_dict["out"]["output_top_path"] + " " + self.stage_io_dict["out"]["output_crd_path"] + "\n" 

416 ) 

417 leapin.write("quit \n") 

418 

419 # Command line 

420 self.cmd = [self.binary_path, "-f", instructions_file_path] 

421 

422 # Run Biobb block 

423 self.run_biobb() 

424 

425 # Copy files to host 

426 self.copy_to_host() 

427 

428 # Saving octahedron box with all decimals in PDB file. Needed for the add_ions BB. 

429 

430 # Getting octahedron box from generated crd file 

431 with open(self.io_dict["out"]["output_crd_path"], "r") as file: 

432 for line in file: 

433 pass 

434 

435 # Adding box as a first line in the generated pdb file with OCTBOX tag 

436 octbox = "OCTBOX " + line 

437 with open(self.io_dict["out"]["output_pdb_path"], "r+") as f: 

438 content = f.read() 

439 f.seek(0, 0) 

440 f.write(octbox + content) 

441 

442 # remove temporary folder(s) 

443 self.tmp_files.extend([ 

444 # self.stage_io_dict.get("unique_dir", ""), 

445 str(self.tmp_folder), "leap.log" 

446 ]) 

447 self.remove_tmp_files() 

448 

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

450 

451 return self.return_code 

452 

453 

454def leap_solvate( 

455 input_pdb_path: str, 

456 output_pdb_path: str, 

457 output_top_path: str, 

458 output_crd_path: str, 

459 input_lib_path: Optional[str] = None, 

460 input_frcmod_path: Optional[str] = None, 

461 input_params_path: Optional[str] = None, 

462 input_prep_path: Optional[str] = None, 

463 input_source_path: Optional[str] = None, 

464 properties: Optional[dict] = None, 

465 **kwargs, 

466) -> int: 

467 """Create :class:`LeapSolvate <leap.leap_solvate.LeapSolvate>`leap.leap_solvate.LeapSolvate class and 

468 execute :meth:`launch() <leap.leap_solvate.LeapSolvate.launch>` method""" 

469 

470 return LeapSolvate( 

471 input_pdb_path=input_pdb_path, 

472 input_lib_path=input_lib_path, 

473 input_frcmod_path=input_frcmod_path, 

474 input_params_path=input_params_path, 

475 input_prep_path=input_prep_path, 

476 input_source_path=input_source_path, 

477 output_pdb_path=output_pdb_path, 

478 output_top_path=output_top_path, 

479 output_crd_path=output_crd_path, 

480 properties=properties, 

481 ).launch() 

482 

483 leap_solvate.__doc__ = LeapSolvate.__doc__ 

484 

485 

486def main(): 

487 parser = argparse.ArgumentParser( 

488 description="Generating and solvating a system box for an AMBER MD system. using tLeap program from AmberTools MD package.", 

489 formatter_class=lambda prog: argparse.RawTextHelpFormatter(prog, width=99999), 

490 ) 

491 parser.add_argument("--config", required=False, help="Configuration file") 

492 

493 # Specific args 

494 required_args = parser.add_argument_group("required arguments") 

495 required_args.add_argument( 

496 "--input_pdb_path", 

497 required=True, 

498 help="Input 3D structure PDB file. Accepted formats: pdb.", 

499 ) 

500 required_args.add_argument( 

501 "--input_lib_path", 

502 required=False, 

503 help="Input ligand library parameters file. Accepted formats: lib, zip.", 

504 ) 

505 required_args.add_argument( 

506 "--input_frcmod_path", 

507 required=False, 

508 help="Input ligand frcmod parameters file. Accepted formats: frcmod, zip.", 

509 ) 

510 required_args.add_argument( 

511 "--input_params_path", 

512 required=False, 

513 help="Additional leap parameter files to load with loadAmberParams Leap command. Accepted formats: leapin, in, txt, zip.", 

514 ) 

515 required_args.add_argument( 

516 "--input_prep_path", 

517 required=False, 

518 help="Additional leap parameter files to load with loadAmberPrep Leap command. Accepted formats: leapin, in, txt, zip.", 

519 ) 

520 required_args.add_argument( 

521 "--input_source_path", 

522 required=False, 

523 help="Additional leap command files to load with source Leap command. Accepted formats: leapin, in, txt, zip.", 

524 ) 

525 required_args.add_argument( 

526 "--output_pdb_path", 

527 required=True, 

528 help="Output 3D structure PDB file matching the topology file. Accepted formats: pdb.", 

529 ) 

530 required_args.add_argument( 

531 "--output_top_path", 

532 required=True, 

533 help="Output topology file (AMBER ParmTop). Accepted formats: top.", 

534 ) 

535 required_args.add_argument( 

536 "--output_crd_path", 

537 required=True, 

538 help="Output coordinates file (AMBER crd). Accepted formats: crd.", 

539 ) 

540 

541 args = parser.parse_args() 

542 config = args.config if args.config else None 

543 properties = settings.ConfReader(config=config).get_prop_dic() 

544 

545 # Specific call 

546 leap_solvate( 

547 input_pdb_path=args.input_pdb_path, 

548 input_lib_path=args.input_lib_path, 

549 input_frcmod_path=args.input_frcmod_path, 

550 input_params_path=args.input_params_path, 

551 input_prep_path=args.input_prep_path, 

552 input_source_path=args.input_source_path, 

553 output_pdb_path=args.output_pdb_path, 

554 output_top_path=args.output_top_path, 

555 output_crd_path=args.output_crd_path, 

556 properties=properties, 

557 ) 

558 

559 

560if __name__ == "__main__": 

561 main()