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 +
")");
268 long startTime = System.nanoTime();
271 }
catch (Exception e) {
272 logger.log(Level.SEVERE,
"Error optimizing ring closing conformation: " + e.getMessage());
273 throw new DENOPTIMException(
"Error optimizing ring closing conformation: " + e.getMessage(), e);
275 long endTime = System.nanoTime();
276 long time = (endTime - startTime);
277 logger.log(Level.FINE,
"TIME (RC conf. search): "+time/1000000+
" ms"
278 +
" #frags: " + chemObj.getGraph().getVertexList().size()
279 +
" #atoms: " + chemObj.getIAtomContainer().getAtomCount()
280 +
" #rotBnds: " + chemObj.getRotatableBonds().size());
282 logger.log(Level.INFO,
"Ring-closing conformational optimization done. "
283 +
"Now, post-processing.");
289 chemObj.purgeListRotatableBonds();
321 IAtomContainer fmol = chemObj.getIAtomContainer();
323 String molName = chemObj.getName();
328 logger.log(Level.INFO,
"Attempting Ring Closure via conformational"
329 +
" adaptation for " + molName
330 +
" (PSSROT - Iteration: " +
itn +
")");
332 List<String> molSpecificKeyFileLines =
new ArrayList<String>();
336 int iZMatRcaA = chemObj.getZMatIdxOfRCA(
338 int iZMatRcaB = chemObj.getZMatIdxOfRCA(
340 molSpecificKeyFileLines.add(
"RC-PAIR " + iZMatRcaA +
" "
345 molSpecificKeyFileLines.add(
"RC11BNDTERM");
346 molSpecificKeyFileLines.add(
"RC12BNDTERM NONE");
351 int s0t = fmol.indexOf(rca0.
getSrcAtom()) + 1;
352 int s1t = fmol.indexOf(rca1.
getSrcAtom()) + 1;
353 int i0t = chemObj.getZMatIdxOfRCA(rca0);
354 int i1t = chemObj.getZMatIdxOfRCA(rca1);
361 molSpecificKeyFileLines.add(
"RC-11-PAIRS " + i0t +
" " +s1t +
" "
362 + parA +
" " + parB);
363 molSpecificKeyFileLines.add(
"RC-11-PAIRS " + s0t +
" " + i1t +
" "
364 + parA +
" " + parB);
367 long startTime = System.nanoTime();
372 molSpecificKeyFileLines,
379 long endTime = System.nanoTime();
380 long time = (endTime - startTime);
381 logger.log(Level.FINE,
"TIME (RC conf. search): "+time/1000000+
" ms"
382 +
" #frags: " + chemObj.getGraph().getVertexList().size()
383 +
" #atoms: " + chemObj.getIAtomContainer().getAtomCount()
384 +
" #rotBnds: " + chemObj.getRotatableBonds().size());
386 logger.log(Level.INFO,
"RC-PSSROT done. Now, post-processing.");
392 chemObj.purgeListRotatableBonds();
426 List<RingClosure> candidatesClosures =
new ArrayList<RingClosure>();
429 logger.log(Level.FINEST,
"closeRings: evaluating closure of " + op);
432 Point3d srcA = rcaA.
getSrcAtom().getPoint3d();
433 Point3d atmA = rcaA.
getIAtom().getPoint3d();
434 Point3d srcB = rcaB.
getSrcAtom().getPoint3d();
435 Point3d atmB = rcaB.
getIAtom().getPoint3d();
437 candidatesClosures.add(rc);
440 double lenH = srcA.distance(atmA);
441 double lenT = srcB.distance(atmB);
442 double distTolerance = (lenH + lenT) / 2.0;
444 double minDistH1T2 = -1.0;
445 double minDistH2T1 = -1.0;
446 double minDistH2T2 = -1.0;
447 double maxDistH1T2 = 0.0;
448 double maxDistH2T1 = 0.0;
449 double maxDistH2T2 = 0.0;
452 maxDistH1T2 = distTolerance;
453 maxDistH2T1 = distTolerance;
454 maxDistH2T2 = lenH + lenT;
456 boolean closeThisBnd = rc.
isClosable(minDistH1T2, maxDistH1T2,
457 minDistH2T1, maxDistH2T1,
458 minDistH2T2, maxDistH2T2,
469 logger.log(Level.WARNING,
"WARNING! "
470 +
"Attempt to add ring closing bond "
471 +
"did not add any actual chemical bond because the "
472 +
"bond type of the chord is '" + bndTyp +
"'.");
499 IAtomContainer fmol = mol.getIAtomContainer();
500 ZMatrix zmat = mol.getZMatrix();
507 IAtom fatm = rca.getIAtom();
511 IAtom newAtm =
new PseudoAtom(duSymbol,
new Point3d(fatm.getPoint3d()));
512 newAtm.setProperties(fatm.getProperties());
513 AtomContainerManipulator.replaceAtomByAtom(
514 mol.getIAtomContainer(),fatm,newAtm);
515 rca.setIAtom(newAtm);
534 IAtom fatm = rca.getIAtom();
544 IAtom newAtm =
new PseudoAtom(
"H",
new Point3d(fatm.getPoint3d()));
545 newAtm.setProperties(fatm.getProperties());
546 AtomContainerManipulator.replaceAtomByAtom(
547 mol.getIAtomContainer(),fatm,newAtm);
548 rca.setIAtom(newAtm);
553 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 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).
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.