19package denoptim.graph.rings;
21import java.util.ArrayList;
23import java.util.logging.Level;
24import java.util.logging.Logger;
26import javax.vecmath.AxisAngle4d;
27import javax.vecmath.Matrix3d;
28import javax.vecmath.Point3d;
29import javax.vecmath.Vector3d;
31import org.openscience.cdk.Atom;
32import org.openscience.cdk.interfaces.IAtom;
33import org.openscience.cdk.interfaces.IAtomContainer;
34import org.openscience.cdk.interfaces.IBond;
35import org.openscience.cdk.interfaces.IChemObjectBuilder;
36import org.openscience.cdk.silent.SilentChemObjectBuilder;
38import denoptim.constants.DENOPTIMConstants;
39import denoptim.io.DenoptimIO;
40import denoptim.utils.MathUtils;
66 ArrayList<Boolean> rotatability,
67 ArrayList<ArrayList<Point3d>> dihRefs,
68 ArrayList<ArrayList<Double>> closableConfs,
75 if (rotatability.size() != sz-1)
77 throw new Error(
"ERROR! Cannot evaluate closability of path: "
78 +
"path and list of bonds are not compatible!"
79 +
"(" + sz +
", " + rotatability.size() +
")"
80 +
" Please, Report this bug to the author.");
85 settings.
getLogger().log(Level.WARNING,
"Too many rotatable bonds "
86 +
"for systematic search. We assume the path is closable.");
91 List<Point3d> ptsChain =
new ArrayList<Point3d>();
92 for (
int i=0; i<path.size(); i++)
94 ptsChain.add(
new Point3d(path.get(i).getPoint3d()));
106 path.get(h2).getPoint3d(),
107 path.get(t1).getPoint3d(),
108 path.get(t2).getPoint3d());
111 settings.
getLogger().log(Level.FINE,
"RingClosability conditions "
112 +
"vector:" + clsablConds);
116 ArrayList<Double> dihedrals =
new ArrayList<Double>();
117 ArrayList<Double> dihIncement =
new ArrayList<Double>();
119 for (
int i=2; i<ptsChain.size(); i++)
126 settings.
getLogger().log(Level.FINE,
"Skipping linearity in "
128 rotatability.set(i-1,
false);
138 dihIncement.add(0.0);
142 ArrayList<Point3d> refPoints = dihRefs.get(i-3);
148 dihIncement.add(0.0);
153 dihIncement.add(0.0);
155 settings.
getLogger().log(Level.FINE,
"Exploring torsional space... (dim:"
158 long startTime = System.nanoTime();
172 long endTime = System.nanoTime();
173 long time = (endTime - startTime) / (
long) 1000.0;
175 settings.
getLogger().log(Level.FINE,
"TIME (microsec) for exploration "
176 +
"of torsional space: "+ time);
178 if (closableConfs.size() > 0)
205 ArrayList<Boolean> rotatability,
206 ArrayList<Double> dihedrals,
207 ArrayList<Double> dihIncement,
210 int h1,
int h2,
int t1,
int t2,
211 ArrayList<Double> clsablConds,
212 ArrayList<ArrayList<Double>> closableConfs,
213 boolean doExhaustiveSearch,
214 boolean writeAllConfs,
220 logger.log(Level.FINEST,
"-Rec: "+activeRot);
221 int totStp = (int) (360.0 / step);
222 if (!rotatability.get(activeRot))
224 logger.log(Level.FINEST, rec+
"-Rec: not active");
227 for (
int i=0; i<totStp; i++)
229 logger.log(Level.FINEST,rec+
"-RecLop: "+activeRot+
" I:"+i);
232 dihIncement.set(activeRot,dihIncement.get(activeRot) + step);
235 Point3d srcRotBnd = chain.get(activeRot);
236 Point3d endRotBnd = chain.get(activeRot+1);
237 Vector3d rotAxis =
new Vector3d(endRotBnd.x - srcRotBnd.x,
238 endRotBnd.y - srcRotBnd.y,
239 endRotBnd.z - srcRotBnd.z);
241 Matrix3d rotMat =
new Matrix3d();
243 rotMat.set(
new AxisAngle4d(rotAxis,Math.toRadians(step)));
245 logger.log(Level.FINEST,
" srcRotBnd: " + srcRotBnd+
NL
246 +
" endRotBnd: " + endRotBnd+
NL
247 +
" rotAxis: " + rotAxis+
NL
248 +
" rotMat: " + rotMat);
250 for (
int ip = activeRot+2; ip<chain.size(); ip++)
252 Point3d pt = chain.get(ip);
254 Vector3d newVec =
new Vector3d(pt.x - srcRotBnd.x,
258 rotMat.transform(newVec);
261 pt.x = newVec.x + srcRotBnd.x;
262 pt.y = newVec.y + srcRotBnd.y;
263 pt.z = newVec.z + srcRotBnd.z;
267 if (activeRot+1 < dihedrals.size())
271 int nextRot = activeRot+1;
290 Point3d pH1 = chain.get(h1);
291 Point3d pH2 = chain.get(h2);
292 Point3d pT1 = chain.get(t1);
293 Point3d pT2 = chain.get(t2);
299 ArrayList<Double> conf =
new ArrayList<Double>();
300 for (
int ib=0; ib<dihedrals.size(); ib++)
302 double tot = dihedrals.get(ib) + dihIncement.get(ib);
309 closableConfs.add(conf);
311 StringBuilder sb =
new StringBuilder();
312 sb.append(
"Found closable path conformation!");
316 sb.append(
" Dihedrals: " + dihedrals+
NL);
317 sb.append(
" Increments: " + dihIncement+
NL);
318 sb.append(
" Conf.: " + conf+
NL);
319 sb.append(
" See 'closable.sdf'"+
NL);
321 logger.log(Level.FINE, sb.toString());
327 StringBuilder sb =
new StringBuilder();
329 sb.append(
"Conformation of path is NOT "
330 +
"closable! See 'not_closable.sdf'");
331 sb.append(
" Dihedrals: " + dihedrals+
NL);
332 sb.append(
" Increments: " + dihIncement+
NL);
333 sb.append(
" Chain:"+
NL);
334 for (
int ii=0; ii<chain.size(); ii++)
335 sb.append(
" " + chain.get(ii)+
NL);
336 logger.log(Level.FINE, sb.toString());
340 if (!doExhaustiveSearch)
344 logger.log(Level.FINE,
"Stop recursive conf. search."
345 +
" (rec.: " + rec +
")");
352 if (rotatability.get(activeRot))
354 dihIncement.set(activeRot,dihIncement.get(activeRot)-step*(totStp-1));
357 Point3d srcRotBnd = chain.get(activeRot);
358 Point3d endRotBnd = chain.get(activeRot+1);
359 Vector3d rotAxis =
new Vector3d(endRotBnd.x - srcRotBnd.x,
360 endRotBnd.y - srcRotBnd.y,
361 endRotBnd.z - srcRotBnd.z);
363 Matrix3d rotMat =
new Matrix3d();
364 rotMat.set(
new AxisAngle4d(rotAxis,
365 Math.toRadians(-step * (totStp - 1))));
367 for (
int ip = activeRot+2; ip<chain.size(); ip++)
369 Point3d pt = chain.get(ip);
371 Vector3d newVec =
new Vector3d(pt.x - srcRotBnd.x,
375 rotMat.transform(newVec);
378 pt.x = newVec.x + srcRotBnd.x;
379 pt.y = newVec.y + srcRotBnd.y;
380 pt.z = newVec.z + srcRotBnd.z;
394 IChemObjectBuilder builder = SilentChemObjectBuilder.getInstance();
395 IAtomContainer mol = builder.newAtomContainer();
396 for (
int ia=0 ; ia<chain.size(); ia++)
398 Atom atm =
new Atom(
"He",chain.get(ia));
401 mol.addBond(ia-1,ia,IBond.Order.valueOf(
"SINGLE"));
406 }
catch (Throwable thr)
408 System.out.println(
"Unable to write SDF: "+thr);
General set of constants used in DENOPTIM.
static final String EOL
new line character
Tool to explore the conformational space of chains of atoms and identify ring closing conformations.
static void reportForDebug(String filename, List< Point3d > chain)
Method for reporting a path of atoms (list of points) as SDF file.
static boolean evaluateClosability(List< IAtom > path, ArrayList< Boolean > rotatability, ArrayList< ArrayList< Point3d > > dihRefs, ArrayList< ArrayList< Double > > closableConfs, RingClosureParameters settings)
Giving a list of points in 3D space (the path) this method evaluates whether it exists at least one c...
static boolean hasClosableRotamer(List< Point3d > chain, ArrayList< Boolean > rotatability, ArrayList< Double > dihedrals, ArrayList< Double > dihIncement, int activeRot, double step, int h1, int h2, int t1, int t2, ArrayList< Double > clsablConds, ArrayList< ArrayList< Double > > closableConfs, boolean doExhaustiveSearch, boolean writeAllConfs, Logger logger, int rec)
Scan rotatable space looking for conformations that satisfy closability condition.
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.
ArrayList< Double > getClosabilityConditions(double etrxTol)
Returns the list of min/max values defining the closability conditions.
Parameters and setting related to handling ring closures.
boolean doExhaustiveConfSrch()
double getConfPathExtraTolerance()
int getMaxNumberRotatableBonds()
double getLinearityLimit()
double getPathConfSearchStep()
Utility methods for input/output.
static void writeSDFFile(String fileName, IAtomContainer mol)
Writes IAtomContainer to SDF file.
Logger getLogger()
Get the name of the program specific logger.
Some useful math operations.
static double angle(Point3d a, Point3d b, Point3d c)
Calculate the angle between the 3 points.
static double computeDihedralAngle(Point3d p0, Point3d p1, Point3d p2, Point3d p3)
Compute the dihedral angle.