$darkmode
DENOPTIM
MMBuilderParameters.java
Go to the documentation of this file.
1/*
2 * DENOPTIM
3 * Copyright (C) 2019 Vishwesh Venkatraman <vishwesh.venkatraman@ntnu.no> and
4 * Marco Foscato <marco.foscato@uib.no>
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as published
8 * by the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
15 *
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20package denoptim.programs.moldecularmodelbuilder;
21
22import java.lang.reflect.Field;
23import java.util.ArrayList;
24import java.util.HashMap;
25
26import denoptim.exception.DENOPTIMException;
27import denoptim.integration.tinker.TinkerUtils;
28import denoptim.molecularmodeling.MMBuilderUtils;
29import denoptim.programs.RunTimeParameters;
30
38{
42 protected boolean debug = false;
43
47 protected String toolPSSROT;
48
52 protected String toolXYZINT;
53
57 protected String toolINTXYZ;
58
62 protected boolean keepDummy = false;
63
67 protected String forceFieldFile;
68
72 protected String pssrotFile;
73
77 protected String rsPssrotFile;
78
82 protected String keyFile;
83
87 protected String rsKeyFile;
88
92 protected ArrayList<String> pssrotParams_Init;
93
97 protected ArrayList<String> pssrotParams_Rest;
98
102 protected ArrayList<String> keyFileParams;
103
107 protected ArrayList<String> rsPssrotParams_Init;
108
112 protected ArrayList<String> rsPssrotParams_Rest;
113
117 protected ArrayList<String> rsKeyFileParams;
118
124 protected int atomOrderingScheme = 1;
125
129 protected HashMap<String, Integer> TINKER_MAP;
130
134 protected int taskID;
135
139 protected String inpSDFFile;
140
144 protected String outSDFFile;
145
146
147//------------------------------------------------------------------------------
148
153 {
155 }
156
157//------------------------------------------------------------------------------
158
159 public int getTaskID()
160 {
161 return taskID;
162 }
163
164//------------------------------------------------------------------------------
165
166 public String getInputSDFFile()
167 {
168 return inpSDFFile;
169 }
170
171//------------------------------------------------------------------------------
172
173 public String getOutputSDFFile()
174 {
175 return outSDFFile;
176 }
177
178//------------------------------------------------------------------------------
179
180 public String getPSSROTTool()
181 {
182 return toolPSSROT;
183 }
184
185//------------------------------------------------------------------------------
186
187 public String getXYZINTTool()
188 {
189 return toolXYZINT;
190 }
191
192//------------------------------------------------------------------------------
193
194 public String getINTXYZTool()
195 {
196 return toolINTXYZ;
197 }
198
199//------------------------------------------------------------------------------
200
201 public String getParamFile()
202 {
203 return forceFieldFile;
204 }
205
206//------------------------------------------------------------------------------
207
208 public ArrayList<String> getInitPSSROTParams()
209 {
210 return pssrotParams_Init;
211 }
212
213//------------------------------------------------------------------------------
214
215 public ArrayList<String> getRSInitPSSROTParams()
216 {
217 return rsPssrotParams_Init;
218 }
219
220//------------------------------------------------------------------------------
221
222 public ArrayList<String> getRestPSSROTParams()
223 {
224 return pssrotParams_Rest;
225 }
226
227//------------------------------------------------------------------------------
228
229 public ArrayList<String> getRSRestPSSROTParams()
230 {
231 return rsPssrotParams_Rest;
232 }
233
234//------------------------------------------------------------------------------
235
236 public ArrayList<String> getKeyFileParams()
237 {
238 return keyFileParams;
239 }
240
241//------------------------------------------------------------------------------
242
243 public boolean getKeepDummyFlag()
244 {
245 return keepDummy;
246 }
247
248//------------------------------------------------------------------------------
249
250 public ArrayList<String> getRSKeyFileParams()
251 {
252 return rsKeyFileParams;
253 }
254
255//------------------------------------------------------------------------------
256
257 public boolean debug()
258 {
259 return debug;
260 }
261
262//------------------------------------------------------------------------------
263
265 {
266 return atomOrderingScheme;
267 }
268
269//------------------------------------------------------------------------------
270
271 public HashMap<String, Integer> getTinkerMap()
272 {
273 return TINKER_MAP;
274 }
275
276//------------------------------------------------------------------------------
277
278 public String getWorkingDirectory()
279 {
280 return workDir;
281 }
282
283//-----------------------------------------------------------------------------
284
292 public void interpretKeyword(String key, String value)
293 throws DENOPTIMException
294 {
295 String msg = "";
296 switch (key.toUpperCase())
297 {
298 case "TOOLPSSROT=":
299 toolPSSROT = value;
300 break;
301 case "TOOLXYZINT=":
302 toolXYZINT = value;
303 break;
304 case "TOOLINTXYZ=":
305 toolINTXYZ = value;
306 break;
307 case "FORCEFIELDFILE=":
308 forceFieldFile = value;
309 break;
310 case "KEYFILE=":
311 keyFile = value;
312 break;
313 case "RCKEYFILE=":
314 rsKeyFile = value;
315 break;
316 case "VERBOSITY=":
317 try
318 {
319 verbosity = Integer.parseInt(value);
320 }
321 catch (Throwable t)
322 {
323 msg = "Unable to understand value " + key + "'" + value + "'";
324 throw new DENOPTIMException(msg);
325 }
326 break;
327 case "DEBUG=":
328 debug = true;
329 break;
330 case "PSSROTPARAMS=":
331 pssrotFile = value;
332 break;
333 case "RCPSSROTPARAMS=":
334 rsPssrotFile = value;
335 break;
336 case "KEEPDUMMYATOMS":
337 keepDummy = true;
338 break;
339 case "ATOMORDERINGSCHEME=":
340 try
341 {
342 atomOrderingScheme = Integer.parseInt(value);
343 }
344 catch (Throwable t)
345 {
346 msg = "Unable to understand value " + key + "'" + value + "'";
347 throw new DENOPTIMException(msg);
348 }
349 break;
350 case "INPSDF=":
351 inpSDFFile = value;
352 break;
353 case "OUTSDF=":
354 outSDFFile = value;
355 break;
356 case "WORKDIR=":
357 workDir = value;
358 break;
359/*
360 case "=":
361 = value;
362 break;
363*/
364
365 default:
366 msg = "Keyword " + key + " is not a known keyword for the "
367 + "3d-molecular model builder. Check input files.";
368 throw new DENOPTIMException(msg);
369 }
370 }
371
372//------------------------------------------------------------------------------
373
379 {
380 ensureNotNull("wrkDir",workDir,"WORKDIR");
382
383 ensureNotNull("inpSDFFile",inpSDFFile,"INPSDF");
385
386 ensureNotNull("outSDFFile",outSDFFile,"OUTSDF");
387
388 ensureNotNull("toolPSSROT",toolPSSROT,"TOOLPSSROT");
390
391 ensureNotNull("toolXYZINT",toolXYZINT,"TOOLXYZINT");
393
394 ensureNotNull("toolINTXYZ",toolINTXYZ,"TOOLINTXYZ");
396
397 ensureNotNull("forceFieldFile",forceFieldFile,"FORCEFIELDFILE");
399
400 ensureNotNull("keyFile",keyFile,"KEYFILE");
402
403 ensureNotNull("pssrotFile",pssrotFile,"PSSROTPARAMS");
405
406
407 if (atomOrderingScheme < 1 || atomOrderingScheme > 2)
408 {
409 throw new Error("ERROR! Parameter 'atomOrderingScheme' can only "
410 + "be 1 or 2");
411 }
412
414 }
415
416//------------------------------------------------------------------------------
423 public String getPrintedList()
424 {
425 StringBuilder sb = new StringBuilder(1024);
426 sb.append(" " + paramTypeName() + " ").append(NL);
427 for (Field f : this.getClass().getDeclaredFields())
428 {
429 try
430 {
431 sb.append(f.getName()).append(" = ").append(
432 f.get(this)).append(NL);
433 }
434 catch (Throwable t)
435 {
436 sb.append("ERROR! Unable to print " + paramTypeName()
437 + " parameters. Cause: " + t);
438 break;
439 }
440 }
441 for (RunTimeParameters otherCollector : otherParameters.values())
442 {
443 sb.append(otherCollector.getPrintedList());
444 }
445 return sb.toString();
446 }
447
448//------------------------------------------------------------------------------
449
451 {
452 pssrotParams_Init = new ArrayList<>();
453 pssrotParams_Rest = new ArrayList<>();
454 keyFileParams = new ArrayList<>();
455 rsPssrotParams_Init = new ArrayList<>();
456 rsPssrotParams_Rest = new ArrayList<>();
457 rsKeyFileParams = new ArrayList<>();
458
463
465 {
466 if (rsPssrotFile==null)
467 throw new DENOPTIMException("Missing template for settings of "
468 + "ring-closing PSSROT jobs.");
471 if (rsKeyFile==null)
472 throw new DENOPTIMException("Missing template of "
473 + "ring-closing PSSROT key file.");
475 }
477 }
478
479//------------------------------------------------------------------------------
480}
Toolbox of utilities for Tinker style molecular representation.
static HashMap< String, Integer > readTinkerAtomTypes(String filename)
Read the Tinker atom mapping from Tinker Force Field.
static void readPSSROTParams(String filename, ArrayList< String > initPars, ArrayList< String > restPars)
Read the parameter settings to be used by PSSROT.
Utilities for molecular models builder.
static void readKeyFileParams(String filename, ArrayList< String > data)
Read the parameter settings to be used by PSSROT.
Collection of parameters controlling the behavior of the software.
Map< ParametersType, RunTimeParameters > otherParameters
Collection of other parameters by type.
void ensureFileExists(String pathname)
Ensures a pathname does lead to an existing file or triggers an error.
void ensureNotNull(String paramName, String param, String paramKey)
Ensures that a parameter is not null or triggers an error.
String paramTypeName()
Returns a string defining the type the parameters collected here.
void checkOtherParameters()
Checks any of the parameter collections contained in this instance.
final String NL
New line character.
void processOtherParameters()
Processes any of the parameter collections contained in this instance.
int verbosity
Verbosity level for logger.
Parameters for the conformer generator (3D builder).
String keyFile
Pathname to keywords file for Tinker's conformational search.
ArrayList< String > keyFileParams
Keywords for Tinker's conformational search.
String toolXYZINT
Pathname to Tinker's xyzint executable.
void processParameters()
Processes all parameters and initialize related objects.
ArrayList< String > rsKeyFileParams
Keywords for Tinker's ring-closing conformational search.
String getPrintedList()
Returns the list of parameters in a string with newline characters as delimiters.
ArrayList< String > pssrotParams_Init
Parameters for PSS part of Tinker's PSSROT step.
String pssrotFile
Pathname to parameters file for PSS part of Tinker's PSSROT.
String rsPssrotFile
Pathname to parameters file for PSS part of Tinker's ring-closing PSSROT.
String toolINTXYZ
Pathname to Tinker's intxyz executable.
String forceFieldFile
Pathname to force field parameters file for Tinker.
ArrayList< String > rsPssrotParams_Init
Parameters for PSS part of Tinker's ring-closing PSSROT step.
int atomOrderingScheme
Flag controlling the criterion used to reorder atom lists.
void interpretKeyword(String key, String value)
Processes a keyword/value pair and assign the related parameters.
ArrayList< String > pssrotParams_Rest
Parameters for linear search part of Tinker's PSSROT step.
boolean keepDummy
Flag controlling removal of dummy atoms from output geometry.
ArrayList< String > rsPssrotParams_Rest
Parameters for linear search part of Tinker's ring-closing PSSROT step.
String rsKeyFile
Pathname to keywords file for Tinker's ring-closing conformational search.
String toolPSSROT
Pathname to Tinker's pssrot executable.
MMB_PARAM
Parameters pertaining the construction of three-dimensional molecular models using the Tinker-based m...
RC_PARAMS
Parameters pertaining to ring closures in graphs.