19package denoptim.integration.tinker;
21import java.util.ArrayList;
24import java.util.logging.Level;
25import java.util.logging.Logger;
27import org.openscience.cdk.interfaces.IAtomContainer;
29import denoptim.constants.DENOPTIMConstants;
30import denoptim.exception.DENOPTIMException;
31import denoptim.files.FileUtils;
32import denoptim.io.DenoptimIO;
33import denoptim.molecularmodeling.ChemicalObjectModel;
34import denoptim.molecularmodeling.zmatrix.ZMatrix;
35import denoptim.molecularmodeling.zmatrix.ZMatrixAtom;
36import denoptim.task.ProcessHandler;
37import denoptim.utils.ObjectPair;
50 private final static String
FSEP = System.getProperty(
"file.separator");
87 Map<String, Integer> atmTypeMap,
88 String runLabel, String ffFilePathName, List<String> keyFileLines,
89 List<String> subParamsInit, List<String> subParamsRest,
90 String pssExePathName, String xyzintPathName, String workDir,
93 for (
int i=0; i<mols.size(); i++)
95 Object molErroProp = mols.get(i).getIAtomContainer().getProperty(
97 if (molErroProp ==
null)
99 logger.log(Level.INFO,
"Field MOL_ERROR is null: proceeding "
100 +
"with conformational search.");
102 runLabel, ffFilePathName, keyFileLines,
103 subParamsInit, subParamsRest,
104 pssExePathName, xyzintPathName,
105 workDir, taskId, logger);
107 logger.log(Level.INFO,
"Field MOL_ERROR is NOT null: skiping "
108 +
"conformational search. Reason: " + molErroProp);
146 Map<String, Integer> atmTypeMap,
147 int idm, String runLabel,
148 String ffFilePathName, List<String> keyFileLines,
149 List<String> subParamsInit, List<String> subParamsRest,
150 String pssrotPathName, String xyzintPathName, String workDir,
151 int taskId, Logger logger)
154 logger.log(Level.INFO,
"Start conformational search on mol: " + idm);
157 int sz = chemObj.getNumberRotatableBonds();
160 logger.log(Level.FINE,
"No rotatable bond: skipping "
161 +
" PSSROT conformational search.");
167 ZMatrix zmat = chemObj.getZMatrix();
168 String molName = chemObj.getName();
171 String csIntFile = workDir +
FSEP + molName +
"_"+runLabel + idm
176 String csKeyFile = workDir +
FSEP + molName +
"_"+runLabel + idm
178 StringBuilder csSbKey =
new StringBuilder(512);
180 csSbKey.append(
"parameters ").append(ffFilePathName).append(
NL);
181 for (String line : keyFileLines)
183 if (line.toUpperCase().startsWith(
"PARAMETERS"))
185 csSbKey.append(line).append(
NL);
190 String csSubFile = workDir +
FSEP + molName +
"_"+runLabel + idm
192 StringBuilder csSbSub =
new StringBuilder(512);
193 csSbSub.append(csIntFile).append(
NL);
195 for (String line : subParamsInit)
197 csSbSub.append(line).append(
NL);
200 for (
ObjectPair rotBndOp : chemObj.getRotatableBonds())
202 int t1 = ((Integer)rotBndOp.getFirst()).intValue() + 1;
203 int t2 = ((Integer)rotBndOp.getSecond()).intValue() + 1;
204 csSbSub.append(t1).append(
" ").append(t2).append(
NL);
210 for (
int ir=0; ir<subParamsRest.size(); ir++)
215 int maxDirs = Integer.parseInt(subParamsRest.get(ir));
218 csSbSub.append(sz).append(
NL);
220 csSbSub.append(maxDirs).append(
NL);
223 String row = subParamsRest.get(ir);
224 csSbSub.append(row).append(
NL);
231 String firstLine = subParamsRest.get(0);
232 String lastLine = subParamsRest.get(subParamsRest.size()-1);
233 csSbSub.append(firstLine).append(
NL);
234 csSbSub.append(
"N").append(
NL);
235 csSbSub.append(lastLine).append(
NL);
240 logger.log(Level.INFO,
"Submitting PSSTOR Conformational Search");
243 String csLogFile = workDir +
FSEP + molName +
"_" + runLabel + idm
245 String csCmdStr = pssrotPathName +
" < " + csSubFile +
" > " +csLogFile;
246 String csID =
"" + taskId;
247 logger.log(Level.FINE,
"CMD: " + csCmdStr +
" TskID: " + csID);
254 String msg =
"PSSROT Conformational Search failed for ";
266 +
"_" + runLabel + idm +
".000", csLogFile,
267 runLabel +
"PSSROT job");
274 molName +
"_"+ runLabel + idm, csLogFile,
275 " Final Function Value and Deformation");
280 String newTnkICLog = workDir +
FSEP + molName +
"_"+runLabel + idm
282 String ocsID =
"" + taskId;
283 String ocsCmd = xyzintPathName +
" " + ocsIntfile +
" "
285 +
" > " + newTnkICLog;
286 logger.log(Level.INFO,
"CMD: " + ocsCmd+
" TskID: "+ocsID);
293 String msg =
"XYZINT (post conf.search) failed for " + molName;
305 String newTnkIC = workDir +
FSEP + molName +
"_" + runLabel + idm
308 "convert xyz to int for " + runLabel +
"job");
312 List<ZMatrixAtom> lstZAtoms = tmpZmat.
getAtoms();
313 for (
int i=0; i<lstZAtoms.size(); i++)
321 chemObj.updateXYZFromINT();
338 if (atmTypMap ==
null)
342 ZMatrix zmat = chemObj.getZMatrix();
343 IAtomContainer iac = chemObj.getIAtomContainer();
345 for (
int i = 0; i < iac.getAtomCount(); i++)
349 if (!atmTypMap.containsKey(st))
351 String msg =
"Unable to assign atom type to atom '" + st +
"'.";
354 Integer val = atmTypMap.get(st);
357 String msg =
"No valid Tinker atom type for atom " + st;
378 ArrayList<String> txtLines =
new ArrayList<String>();
388 String[] wFrstLine = txtLines.get(0).trim().split(
"\\s+");
389 int numAtms = Integer.parseInt(wFrstLine[0]);
392 if (numAtms+1 == txtLines.size())
397 StringBuilder sb =
new StringBuilder(512);
398 sb.append(txtLines.get(0));
400 for (
int i=1; i<txtLines.size(); i++)
402 String line = txtLines.get(i).trim();
404 if (line ==
"" || line ==
null)
407 String[] wLine = line.split(
"\\s+");
408 int atmNum = Integer.parseInt(wLine[0]);
411 sb.append(
NL).append(txtLines.get(i));
415 sb.append(
" ").append(txtLines.get(i));
General set of constants used in DENOPTIM.
static final String EOL
new line character
static final String MOLERRORTAG
SDF tag containing errors during execution of molecule specific tasks.
static void deleteFilesContaining(String path, String pattern)
Delete all files with pathname containing a given string.
Exceptions resulting from a failure of Tinker.
Toolbox of utilities for Tinker style molecular representation.
static ZMatrix readTinkerINT(String filename)
Reads a Tinker INT file.
static String getNameLastCycleFile(String workDir, String fname, String tinkerLog, String pattern)
Identifies how many iteration Tinker has done by looking into the log file, searching for a given pat...
static void writeTinkerINT(String filename, ZMatrix zmat)
Write Tinker INT file.
static void ensureOutputExistsOrRelayError(String outputPathName, String logPathName, String taskName)
Check for the existence of an output file for a Tinker job and, if the output file is not found,...
Utility methods for input/output.
static ArrayList< String > readList(String fileName)
Read list of data as text.
static void writeData(String fileName, String data, boolean append)
Write text-like data file.
Collector of molecular information, related to a single chemical object, that is deployed within the ...
Representation of an atom in the ZMatrix.
String getSymbol()
Get the symbol of the atom.
Double getAngle2Value()
Get the angle2 value.
void setBondLength(Double bondLength)
Set the bond length.
Integer getChiralFlag()
Get the chiral flag.
void setChiralFlag(Integer chiralFlag)
Set the chiral flag.
void setType(String type)
Set the type of the atom.
void setAngleValue(Double angleValue)
Set the angle value.
void setAngle2Value(Double angle2Value)
Set the angle2 value.
Double getBondLength()
Get the bond length.
Double getAngleValue()
Get the angle value.
Representation of an atom container's geometry with internal coordinates.
List< ZMatrixAtom > getAtoms()
Get the atoms in the ZMatrix.
ZMatrixAtom getAtom(int index)
Get the atom at the given index.
int getExitCode()
Get the exit code returned by the sub-process.
String getErrorOutput()
Get the content of the error output for the process.
void runProcessInBASH()
Run the process associated with the command from BASH http://www.javaworld.com/javaworld/jw-12-2000/j...
This class is the equivalent of the Pair data structure used in C++ Although AbstractMap....