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 (rcaComb.isEmpty())
155 logger.log(Level.WARNING,
"Attempt to close rings with "
156 +
"no compatible RCA combination. "
157 +
"This is most likely a mistake. Please, "
158 +
"make sure that ring-closing vertexes are"
159 +
"properly detected.");
161 if (
logger.isLoggable(Level.FINE))
166 s = s + p.getFirst() +
":" + p.getSecond() +
" ";
168 logger.log(Level.FINE,
"Attempting Ring Closure with RCA "
169 +
"Combination (" + i +
"): " + s);
179 if (newRingClosed < rcaComb.size())
181 String err =
"#RingClosureTool: uncomplete closure (closed "
182 + newRingClosed +
"/" + rcaComb.size() +
")";
220 else if (nRcA > nRcB)
228 double dist = scoreA - scoreB;
229 double trsh = Math.min(scoreA,scoreB) * 0.05;
230 if (dist > 0.0 && dist > trsh)
234 if (dist < 0.0 && Math.abs(dist) > trsh)
242 if (proxScoreA < proxScoreB)
246 else if (proxScoreA > proxScoreB)
279 IAtomContainer fmol = chemObj.getIAtomContainer();
281 String molName = chemObj.getName();
286 logger.log(Level.INFO,
"Attempting Ring Closure via conformational"
287 +
" adaptation for " + molName
288 +
" (PSSROT - Iteration: " +
itn +
")");
290 List<String> molSpecificKeyFileLines =
new ArrayList<String>();
294 int iTnkAtmRcaA = chemObj.getTnkAtmIdOfRCA(
296 int iTnkAtmRcaB = chemObj.getTnkAtmIdOfRCA(
298 molSpecificKeyFileLines.add(
"RC-PAIR " + iTnkAtmRcaA +
" "
303 molSpecificKeyFileLines.add(
"RC11BNDTERM");
304 molSpecificKeyFileLines.add(
"RC12BNDTERM NONE");
309 int s0t = fmol.indexOf(rca0.
getSrcAtom()) + 1;
310 int s1t = fmol.indexOf(rca1.
getSrcAtom()) + 1;
311 int i0t = chemObj.getTnkAtmIdOfRCA(rca0);
312 int i1t = chemObj.getTnkAtmIdOfRCA(rca1);
319 molSpecificKeyFileLines.add(
"RC-11-PAIRS " + i0t +
" " +s1t +
" "
320 + parA +
" " + parB);
321 molSpecificKeyFileLines.add(
"RC-11-PAIRS " + s0t +
" " + i1t +
" "
322 + parA +
" " + parB);
325 long startTime = System.nanoTime();
328 molSpecificKeyFileLines,
335 long endTime = System.nanoTime();
336 long time = (endTime - startTime);
337 logger.log(Level.FINE,
"TIME (RC conf. search): "+time/1000000+
" ms"
338 +
" #frags: " + chemObj.getGraph().getVertexList().size()
339 +
" #atoms: " + chemObj.getIAtomContainer().getAtomCount()
340 +
" #rotBnds: " + chemObj.getRotatableBonds().size());
342 logger.log(Level.INFO,
"RC-PSSROT done. Now, post-processing.");
348 chemObj.purgeListRotatableBonds();
382 List<RingClosure> candidatesClosures =
new ArrayList<RingClosure>();
385 logger.log(Level.FINEST,
"closeRings: evaluating closure of " + op);
388 Point3d srcA = rcaA.
getSrcAtom().getPoint3d();
389 Point3d atmA = rcaA.
getIAtom().getPoint3d();
390 Point3d srcB = rcaB.
getSrcAtom().getPoint3d();
391 Point3d atmB = rcaB.
getIAtom().getPoint3d();
393 candidatesClosures.add(rc);
396 double lenH = srcA.distance(atmA);
397 double lenT = srcB.distance(atmB);
398 double distTolerance = (lenH + lenT) / 2.0;
400 double minDistH1T2 = -1.0;
401 double minDistH2T1 = -1.0;
402 double minDistH2T2 = -1.0;
403 double maxDistH1T2 = 0.0;
404 double maxDistH2T1 = 0.0;
405 double maxDistH2T2 = 0.0;
408 maxDistH1T2 = distTolerance;
409 maxDistH2T1 = distTolerance;
410 maxDistH2T2 = lenH + lenT;
412 boolean closeThisBnd = rc.
isClosable(minDistH1T2, maxDistH1T2,
413 minDistH2T1, maxDistH2T1,
414 minDistH2T2, maxDistH2T2,
425 logger.log(Level.WARNING,
"WARNING! "
426 +
"Attempt to add ring closing bond "
427 +
"did not add any actual chemical bond because the "
428 +
"bond type of the chord is '" + bndTyp +
"'.");
455 IAtomContainer fmol = mol.getIAtomContainer();
463 IAtom fatm = rca.getIAtom();
467 IAtom newAtm =
new PseudoAtom(duSymbol,
new Point3d(fatm.getPoint3d()));
468 newAtm.setProperties(fatm.getProperties());
469 AtomContainerManipulator.replaceAtomByAtom(
470 mol.getIAtomContainer(),fatm,newAtm);
471 rca.setIAtom(newAtm);
490 IAtom fatm = rca.getIAtom();
503 IAtom newAtm =
new PseudoAtom(
"H",
new Point3d(fatm.getPoint3d()));
504 newAtm.setProperties(fatm.getProperties());
505 AtomContainerManipulator.replaceAtomByAtom(
506 mol.getIAtomContainer(),fatm,newAtm);
507 rca.setIAtom(newAtm);
512 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.