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.tinker.ConformationalSearchPSSROT;
44import denoptim.integration.tinker.TinkerAtom;
45import denoptim.integration.tinker.TinkerException;
46import denoptim.integration.tinker.TinkerMolecule;
47import denoptim.programs.RunTimeParameters.ParametersType;
48import denoptim.programs.moldecularmodelbuilder.MMBuilderParameters;
49import denoptim.utils.ObjectPair;
68 final String
fsep = System.getProperty(
"file.separator");
107 ArrayList<TinkerAtom> lstAtoms = tmol.getAtoms();
108 int numberOfAtoms = lstAtoms.size();
109 for (
int i = 0; i < numberOfAtoms; i++)
116 String msg =
"Unable to assign atom type to atom '" + st +
"'.";
123 logger.log(Level.FINEST,
"Set parameter for " + st);
127 String msg =
"No valid Tinker atom type for atom " + st;
149 ArrayList<ChemicalObjectModel> rcMols =
new ArrayList<ChemicalObjectModel>();
150 for (
int i=0; i<mol.getRCACombinations().size(); i++)
152 Set<ObjectPair> rcaComb = mol.getRCACombinations().get(i);
153 if (
logger.isLoggable(Level.FINE))
158 s = s + p.getFirst() +
":" + p.getSecond() +
" ";
160 logger.log(Level.FINE,
"Attempting Ring Closure with RCA "
161 +
"Combination (" + i +
"): " + s);
171 if (newRingClosed < rcaComb.size())
173 String err =
"#RingClosureTool: uncomplete closure (closed "
174 + newRingClosed +
"/" + rcaComb.size() +
")";
212 else if (nRcA > nRcB)
220 double dist = scoreA - scoreB;
221 double trsh = Math.min(scoreA,scoreB) * 0.05;
222 if (dist > 0.0 && dist > trsh)
226 if (dist < 0.0 && Math.abs(dist) > trsh)
234 if (proxScoreA < proxScoreB)
238 else if (proxScoreA > proxScoreB)
271 IAtomContainer fmol = chemObj.getIAtomContainer();
273 String molName = chemObj.getName();
278 logger.log(Level.INFO,
"Attempting Ring Closure via conformational"
279 +
" adaptation for " + molName
280 +
" (PSSROT - Iteration: " +
itn +
")");
282 List<String> molSpecificKeyFileLines =
new ArrayList<String>();
286 int iTnkAtmRcaA = chemObj.getTnkAtmIdOfRCA(
288 int iTnkAtmRcaB = chemObj.getTnkAtmIdOfRCA(
290 molSpecificKeyFileLines.add(
"RC-PAIR " + iTnkAtmRcaA +
" "
295 molSpecificKeyFileLines.add(
"RC11BNDTERM");
296 molSpecificKeyFileLines.add(
"RC12BNDTERM NONE");
301 int s0t = fmol.indexOf(rca0.
getSrcAtom()) + 1;
302 int s1t = fmol.indexOf(rca1.
getSrcAtom()) + 1;
303 int i0t = chemObj.getTnkAtmIdOfRCA(rca0);
304 int i1t = chemObj.getTnkAtmIdOfRCA(rca1);
311 molSpecificKeyFileLines.add(
"RC-11-PAIRS " + i0t +
" " +s1t +
" "
312 + parA +
" " + parB);
313 molSpecificKeyFileLines.add(
"RC-11-PAIRS " + s0t +
" " + i1t +
" "
314 + parA +
" " + parB);
317 long startTime = System.nanoTime();
320 molSpecificKeyFileLines,
327 long endTime = System.nanoTime();
328 long time = (endTime - startTime);
329 logger.log(Level.FINE,
"TIME (RC conf. search): "+time/1000000+
" ms"
330 +
" #frags: " + chemObj.getGraph().getVertexList().size()
331 +
" #atoms: " + chemObj.getIAtomContainer().getAtomCount()
332 +
" #rotBnds: " + chemObj.getRotatableBonds().size());
334 logger.log(Level.INFO,
"RC-PSSROT done. Now, post-processing.");
340 chemObj.purgeListRotatableBonds();
374 List<RingClosure> candidatesClosures =
new ArrayList<RingClosure>();
377 logger.log(Level.FINEST,
"closeRings: evaluating closure of " + op);
380 Point3d srcA = rcaA.
getSrcAtom().getPoint3d();
381 Point3d atmA = rcaA.
getIAtom().getPoint3d();
382 Point3d srcB = rcaB.
getSrcAtom().getPoint3d();
383 Point3d atmB = rcaB.
getIAtom().getPoint3d();
385 candidatesClosures.add(rc);
388 double lenH = srcA.distance(atmA);
389 double lenT = srcB.distance(atmB);
390 double distTolerance = (lenH + lenT) / 2.0;
392 double minDistH1T2 = -1.0;
393 double minDistH2T1 = -1.0;
394 double minDistH2T2 = -1.0;
395 double maxDistH1T2 = 0.0;
396 double maxDistH2T1 = 0.0;
397 double maxDistH2T2 = 0.0;
400 maxDistH1T2 = distTolerance;
401 maxDistH2T1 = distTolerance;
402 maxDistH2T2 = lenH + lenT;
404 boolean closeThisBnd = rc.
isClosable(minDistH1T2, maxDistH1T2,
405 minDistH2T1, maxDistH2T1,
406 minDistH2T2, maxDistH2T2,
417 logger.log(Level.WARNING,
"WARNING! "
418 +
"Attempt to add ring closing bond "
419 +
"did not add any actual chemical bond because the "
420 +
"bond type of the chord is '" + bndTyp +
"'.");
447 IAtomContainer fmol = mol.getIAtomContainer();
455 IAtom fatm = rca.getIAtom();
459 IAtom newAtm =
new PseudoAtom(duSymbol,
new Point3d(fatm.getPoint3d()));
460 newAtm.setProperties(fatm.getProperties());
461 AtomContainerManipulator.replaceAtomByAtom(
462 mol.getIAtomContainer(),fatm,newAtm);
463 rca.setIAtom(newAtm);
482 IAtom fatm = rca.getIAtom();
495 IAtom newAtm =
new PseudoAtom(
"H",
new Point3d(fatm.getPoint3d()));
496 newAtm.setProperties(fatm.getProperties());
497 AtomContainerManipulator.replaceAtomByAtom(
498 mol.getIAtomContainer(),fatm,newAtm);
499 rca.setIAtom(newAtm);
504 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()
Based on the code from ffx.kenai.com Michael J.
void setDistAngle(double[] distAngles)
void setAtomString(String atomStr)
void setAtomType(int ffAtomType)
Exceptions resulting from a failure of Tinker.
TinkerAtom getAtom(int pos)
Returns the atom which has the XYZ index set to pos.
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.
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.
ArrayList< Set< ObjectPair > > getRCACombinations()
Returns the list of combinations of RingClosingAttractor.
ArrayList< RingClosure > getNewRingClosures()
Return the list of RingClosures that have been identified as closable head/tail of atom chains during...
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()
String getWorkingDirectory()
ArrayList< String > getRestPSSROTParams()
HashMap< String, Integer > getTinkerMap()
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.