19package denoptim.molecularmodeling;
21import java.util.ArrayList;
22import java.util.Collections;
23import java.util.Comparator;
26import java.util.logging.Level;
27import java.util.logging.Logger;
29import javax.vecmath.Point3d;
31import org.openscience.cdk.PseudoAtom;
32import org.openscience.cdk.interfaces.IAtom;
33import org.openscience.cdk.interfaces.IAtomContainer;
34import org.openscience.cdk.tools.manipulator.AtomContainerManipulator;
36import denoptim.constants.DENOPTIMConstants;
37import denoptim.exception.DENOPTIMException;
38import denoptim.files.FileUtils;
39import denoptim.graph.Edge.BondType;
40import denoptim.graph.rings.RingClosingAttractor;
41import denoptim.graph.rings.RingClosure;
42import denoptim.graph.rings.RingClosureParameters;
43import denoptim.integration.rcoserver.RCOSocketServerClient;
44import denoptim.integration.tinker.ConformationalSearchPSSROT;
45import denoptim.integration.tinker.TinkerException;
46import denoptim.molecularmodeling.zmatrix.ZMatrix;
47import denoptim.molecularmodeling.zmatrix.ZMatrixAtom;
48import denoptim.programs.RunTimeParameters.ParametersType;
49import denoptim.programs.moldecularmodelbuilder.MMBuilderParameters;
50import denoptim.utils.ObjectPair;
72 final String
fsep = System.getProperty(
"file.separator");
111 ArrayList<ChemicalObjectModel> rcMols =
new ArrayList<ChemicalObjectModel>();
112 for (
int i=0; i<mol.getRCACombinations().size(); i++)
114 Set<ObjectPair> rcaComb = mol.getRCACombinations().get(i);
115 if (rcaComb.isEmpty())
117 logger.log(Level.WARNING,
"Attempt to close rings with "
118 +
"no compatible RCA combination. "
119 +
"This is most likely a mistake. Please, "
120 +
"make sure that ring-closing vertexes are"
121 +
"properly detected.");
123 if (
logger.isLoggable(Level.FINE))
128 s = s + p.getFirst() +
":" + p.getSecond() +
" ";
130 logger.log(Level.FINE,
"Attempting Ring Closure with RCA "
131 +
"Combination (" + i +
"): " + s);
144 String msg =
"ERROR! Tinker failed on task '"
145 + te.taskName +
"'!";
148 msg = msg + settings.NL + te.
solution;
150 logger.log(Level.SEVERE, msg);
160 if (newRingClosed < rcaComb.size())
162 String err =
"#RingClosureTool: uncomplete closure (closed "
163 + newRingClosed +
"/" + rcaComb.size() +
")";
201 else if (nRcA > nRcB)
209 double dist = scoreA - scoreB;
210 double trsh = Math.min(scoreA,scoreB) * 0.05;
211 if (dist > 0.0 && dist > trsh)
215 if (dist < 0.0 && Math.abs(dist) > trsh)
223 if (proxScoreA < proxScoreB)
227 else if (proxScoreA > proxScoreB)
257 String molName = chemObj.getName();
262 logger.log(Level.INFO,
"Attempting Ring Closure via conformational"
263 +
" adaptation for " + molName
264 +
" (Iteration: " +
itn +
")");
270 long startTime = System.nanoTime();
273 }
catch (Exception e) {
274 logger.log(Level.SEVERE,
"Error optimizing ring closing conformation: " + e.getMessage());
275 throw new DENOPTIMException(
"Error optimizing ring closing conformation: " + e.getMessage(), e);
277 long endTime = System.nanoTime();
278 long time = (endTime - startTime);
279 logger.log(Level.FINE,
"TIME (RC conf. search): "+time/1000000+
" ms"
280 +
" #frags: " + chemObj.getGraph().getVertexList().size()
281 +
" #atoms: " + chemObj.getIAtomContainer().getAtomCount()
282 +
" #rotBnds: " + chemObj.getRotatableBonds().size());
284 logger.log(Level.INFO,
"Ring-closing conformational optimization done. "
285 +
"Now, post-processing.");
291 chemObj.purgeListRotatableBonds();
323 IAtomContainer fmol = chemObj.getIAtomContainer();
325 String molName = chemObj.getName();
330 logger.log(Level.INFO,
"Attempting Ring Closure via conformational"
331 +
" adaptation for " + molName
332 +
" (PSSROT - Iteration: " +
itn +
")");
334 List<String> molSpecificKeyFileLines =
new ArrayList<String>();
338 int iZMatRcaA = chemObj.getZMatIdxOfRCA(
340 int iZMatRcaB = chemObj.getZMatIdxOfRCA(
342 molSpecificKeyFileLines.add(
"RC-PAIR " + iZMatRcaA +
" "
347 molSpecificKeyFileLines.add(
"RC11BNDTERM");
348 molSpecificKeyFileLines.add(
"RC12BNDTERM NONE");
353 int s0t = fmol.indexOf(rca0.
getSrcAtom()) + 1;
354 int s1t = fmol.indexOf(rca1.
getSrcAtom()) + 1;
355 int i0t = chemObj.getZMatIdxOfRCA(rca0);
356 int i1t = chemObj.getZMatIdxOfRCA(rca1);
363 molSpecificKeyFileLines.add(
"RC-11-PAIRS " + i0t +
" " +s1t +
" "
364 + parA +
" " + parB);
365 molSpecificKeyFileLines.add(
"RC-11-PAIRS " + s0t +
" " + i1t +
" "
366 + parA +
" " + parB);
369 long startTime = System.nanoTime();
374 molSpecificKeyFileLines,
381 long endTime = System.nanoTime();
382 long time = (endTime - startTime);
383 logger.log(Level.FINE,
"TIME (RC conf. search): "+time/1000000+
" ms"
384 +
" #frags: " + chemObj.getGraph().getVertexList().size()
385 +
" #atoms: " + chemObj.getIAtomContainer().getAtomCount()
386 +
" #rotBnds: " + chemObj.getRotatableBonds().size());
388 logger.log(Level.INFO,
"RC-PSSROT done. Now, post-processing.");
394 chemObj.purgeListRotatableBonds();
428 List<RingClosure> candidatesClosures =
new ArrayList<RingClosure>();
431 logger.log(Level.FINEST,
"closeRings: evaluating closure of " + op);
434 Point3d srcA = rcaA.
getSrcAtom().getPoint3d();
435 Point3d atmA = rcaA.
getIAtom().getPoint3d();
436 Point3d srcB = rcaB.
getSrcAtom().getPoint3d();
437 Point3d atmB = rcaB.
getIAtom().getPoint3d();
439 candidatesClosures.add(rc);
442 double lenH = srcA.distance(atmA);
443 double lenT = srcB.distance(atmB);
444 double distTolerance = (lenH + lenT) / 2.0;
446 double minDistH1T2 = -1.0;
447 double minDistH2T1 = -1.0;
448 double minDistH2T2 = -1.0;
449 double maxDistH1T2 = 0.0;
450 double maxDistH2T1 = 0.0;
451 double maxDistH2T2 = 0.0;
454 maxDistH1T2 = distTolerance;
455 maxDistH2T1 = distTolerance;
456 maxDistH2T2 = lenH + lenT;
458 boolean closeThisBnd = rc.
isClosable(minDistH1T2, maxDistH1T2,
459 minDistH2T1, maxDistH2T1,
460 minDistH2T2, maxDistH2T2,
471 logger.log(Level.WARNING,
"WARNING! "
472 +
"Attempt to add ring closing bond "
473 +
"did not add any actual chemical bond because the "
474 +
"bond type of the chord is '" + bndTyp +
"'.");
501 IAtomContainer fmol = mol.getIAtomContainer();
502 ZMatrix zmat = mol.getZMatrix();
509 IAtom fatm = rca.getIAtom();
513 IAtom newAtm =
new PseudoAtom(duSymbol,
new Point3d(fatm.getPoint3d()));
514 newAtm.setProperties(fatm.getProperties());
515 AtomContainerManipulator.replaceAtomByAtom(
516 mol.getIAtomContainer(),fatm,newAtm);
517 rca.setIAtom(newAtm);
536 IAtom fatm = rca.getIAtom();
546 IAtom newAtm =
new PseudoAtom(
"H",
new Point3d(fatm.getPoint3d()));
547 newAtm.setProperties(fatm.getProperties());
548 AtomContainerManipulator.replaceAtomByAtom(
549 mol.getIAtomContainer(),fatm,newAtm);
550 rca.setIAtom(newAtm);
555 mol.updateXYZFromINT();
General set of constants used in DENOPTIM.
static final String MOLERRORTAG
SDF tag containing errors during execution of molecule specific tasks.
static final String DUMMYATMSYMBOL
Symbol of dummy atom.
static void deleteFilesContaining(String path, String pattern)
Delete all files with pathname containing a given string.
The RingClosingAttractor represent the available valence/connection that allows to close a ring.
IAtom getSrcAtom()
Get the atom in the parent fragment that holds the attachment point occupied by this RingClosingAttra...
void setUsed()
Set this RingClosingAttractor to 'used'.
IAtom getIAtom()
Get the atom corresponding to this RingClosingAttractor in the molecular representation.
BondType getRCBondType()
Get the type of bond this attractor is meant to close.
RingClosure represents the arrangement of atoms and PseudoAtoms identifying the head and tail of a ch...
boolean isClosable(ArrayList< Double > clsablConds, Logger logger)
Evaluate closability by comparing the distances and the dot product with the given critera.
Parameters and setting related to handling ring closures.
double getRCDistTolerance()
double getRCDotPrTolerance()
Sends the request to produce a socket server running the RingClosingMM service.
static synchronized RCOSocketServerClient getInstance(String hostname, Integer port)
Gets the singleton instance of RCOSocketServerClient.
void setRecordRequestsFileName(String requestFileName)
Sets the pathname to file where to record requests sent to the server.
void runConformationalOptimization(ChemicalObjectModel chemObj, Logger logger)
Runs a conformational optimization using the services provided by the socket server configured for th...
Exceptions resulting from a failure of Tinker.
String solution
Proposed solution to the failure, or empty string.
Collector of molecular information, related to a single chemical object, that is deployed within the ...
double getAtomOverlapScore()
Return the atoms overlap score which is calculated for all atoms pairs not in 1-4 or lower relationsh...
double getNewRingClosuresQuality()
Return the overal evaluation of the whole list of RingClosures.
ChemicalObjectModel deepcopy()
Return a new Molecule3DBuilder having exactly the same features of this Molecule3DBuilder.
List< Set< ObjectPair > > getRCACombinations()
Returns the list of combinations of RingClosingAttractor.
IAtomContainer getIAtomContainer()
Returns the CDK representation of the molecular system.
void addBond(IAtom atmA, IAtom atmB, RingClosure nRc, BondType bndTyp)
Modify the molecule adding a cyclic bond between two atoms.
List< RingClosure > getNewRingClosures()
Return the list of RingClosures that have been identified as closable head/tail of atom chains during...
Representation of an atom in the ZMatrix.
void setBondLength(Double bondLength)
Set the bond length.
void setSymbol(String symbol)
Set the symbol of the atom.
Representation of an atom container's geometry with internal coordinates.
ZMatrixAtom getAtom(int index)
Get the atom at the given index.
boolean containsParameters(ParametersType type)
RunTimeParameters getParameters(ParametersType type)
Logger getLogger()
Get the name of the program specific logger.
Parameters for the conformer generator (3D builder).
String getPathnameForRecordingRCOServerRequests()
ArrayList< String > getInitPSSROTParams()
Integer getRCOServerPort()
String getWorkingDirectory()
ArrayList< String > getRestPSSROTParams()
HashMap< String, Integer > getTinkerMap()
String getRCOServerHostname()
ArrayList< String > getRSKeyFileParams()
This class is the equivalent of the Pair data structure used in C++ Although AbstractMap....
Possible chemical bond types an edge can represent.
boolean hasCDKAnalogue()
Checks if it is possible to convert this edge type into a CDK bond.
Identifier of the type of parameters.
RC_PARAMS
Parameters pertaining to ring closures in graphs.