19package denoptim.graph.rings;
21import java.util.ArrayList;
22import java.util.Arrays;
23import java.util.Collections;
24import java.util.HashMap;
25import java.util.Iterator;
29import java.util.logging.Level;
30import java.util.logging.Logger;
32import javax.vecmath.Point3d;
34import org.openscience.cdk.Bond;
35import org.openscience.cdk.graph.ShortestPaths;
36import org.openscience.cdk.graph.matrix.TopologicalMatrix;
37import org.openscience.cdk.interfaces.IAtom;
38import org.openscience.cdk.interfaces.IAtomContainer;
39import org.openscience.cdk.interfaces.IBond;
40import org.openscience.cdk.interfaces.IChemObjectBuilder;
41import org.openscience.cdk.silent.SilentChemObjectBuilder;
43import denoptim.constants.DENOPTIMConstants;
44import denoptim.exception.DENOPTIMException;
45import denoptim.fragspace.FragmentSpace;
46import denoptim.graph.APClass;
47import denoptim.graph.AttachmentPoint;
48import denoptim.graph.DGraph;
49import denoptim.graph.Edge;
50import denoptim.graph.Edge.BondType;
51import denoptim.graph.EmptyVertex;
52import denoptim.graph.Fragment;
53import denoptim.graph.Ring;
54import denoptim.graph.Vertex;
55import denoptim.graph.Vertex.BBType;
56import denoptim.utils.ManySMARTSQuery;
57import denoptim.utils.MoleculeUtils;
58import denoptim.utils.ObjectPair;
59import denoptim.utils.RingClosingUtils;
89 boolean closable =
false;
108 String s =
"Unrecognized closability evaluation mode";
109 throw new IllegalArgumentException(s);
132 settings.
getLogger().log(Level.FINE,
"Evaluating constitutional "
136 IChemObjectBuilder builder = SilentChemObjectBuilder.getInstance();
137 IAtomContainer mol = builder.newAtomContainer();
142 catch (CloneNotSupportedException e)
144 throw new IllegalArgumentException(e);
150 Map<Vertex,ArrayList<Integer>> vIdToAtmId =
154 List<Integer> atmIdsInVrtxPath =
new ArrayList<Integer>();
157 atmIdsInVrtxPath.addAll(vIdToAtmId.get(v));
162 ArrayList<IAtom> toRemove =
new ArrayList<IAtom>();
163 for (
int i=0; i<mol.getAtomCount(); i++)
165 if (!atmIdsInVrtxPath.contains(i))
167 IAtom candAtm = mol.getAtom(i);
168 boolean isNeighbour =
false;
169 List<IAtom> nbrs = mol.getConnectedAtomsList(candAtm);
170 for (IAtom nbrAtm : nbrs)
172 if (atmIdsInVrtxPath.contains(mol.indexOf(nbrAtm)))
180 toRemove.add(candAtm);
185 IAtom atmH = mol.getAtom(vIdToAtmId.get(subGraph.
getHeadVertex()).get(0));
186 IAtom atmT = mol.getAtom(vIdToAtmId.get(subGraph.
getTailVertex()).get(0));
187 IAtom srcH = mol.getConnectedAtomsList(atmH).get(0);
188 IAtom srcT = mol.getConnectedAtomsList(atmT).get(0);
189 int iSrcH = mol.indexOf(srcH);
190 int iSrcT = mol.indexOf(srcT);
200 "WARNING! Attempt to add ring closing bond "
201 +
"did not add any actual chemical bond because the "
202 +
"bond type of the chord is '" + bndTyp +
"'.");
206 for (IAtom a : toRemove)
211 StringBuilder sb =
new StringBuilder();
212 sb.append(
"Molecular representation of path includes:");
213 for (IAtom a : mol.atoms())
215 sb.append(
" " + a.getSymbol() + mol.indexOf(a) +
" "
216 + a.getProperties());
218 settings.
getLogger().log(Level.FINEST, sb.toString());
220 boolean closable =
false;
223 boolean spanRequiredEls =
false;
225 if (reqRingEl.size() != 0)
228 List<IAtom> atomsPath =
new ArrayList<IAtom>();
229 ShortestPaths sp =
new ShortestPaths(mol, srcH);
230 atomsPath =
new ArrayList<IAtom>(Arrays.asList(sp.atomsTo(srcT)));
233 for (String el : reqRingEl)
235 for (IAtom a : atomsPath)
239 spanRequiredEls =
true;
248 if (!spanRequiredEls)
251 "Candidate ring doesn't involve any among the required "
260 if (smarts.size() != 0)
266 String msg =
"Attempt to match SMARTS for "
267 +
"constitution-based ring-closability conditions "
268 +
"returned an error! Ignoring " + msq.
getMessage();
269 settings.
getLogger().log(Level.WARNING,msg);
271 for (String name : smarts.keySet())
276 "Candidate closable path matches constitutional "
277 +
"closability criterion: " + smarts.get(name));
285 "Contitutional closability: " + closable);
311 "Evaluating 3D closability of path: "
317 boolean closable =
false;
334 settings.
getLogger().warning(
"Could not create 3D model "
335 +
"for potentially closeable path that will be "
336 +
"considered not ring-closable.");
350 settings.
getLogger().warning(
"Could not create 3D model "
351 +
"for potentially closeable path that will be "
352 +
"considered not ring-closable.");
360 ArrayList<Boolean> rotatability =
new ArrayList<Boolean>();
361 for (
int i=0; i < bondsPath.size(); i++)
363 IBond bnd = bondsPath.get(i);
364 Object rotFlag = bnd.getProperty(
366 if (rotFlag ==
null || !Boolean.valueOf(rotFlag.toString()))
368 rotatability.add(
false);
372 rotatability.add(
true);
375 settings.
getLogger().log(Level.FINE,
"Rotatability: "+rotatability);
382 ArrayList<ArrayList<Point3d>> dihRefs =
384 if (dihRefs.size() != rotatability.size()-2)
386 throw new IllegalStateException(
"Number of bonds and number of "
387 +
"dihidrals angles are inconsistent in PathSubGraph."
388 +
" Contact the author.");
392 ArrayList<ArrayList<Double>> closableConfs =
393 new ArrayList<ArrayList<Double>>();
408 settings.
getLogger().log(Level.FINE,
"Path closablility: "+closable);
General set of constants used in DENOPTIM.
static final String BONDPROPROTATABLE
String tag of Bond's property used to store the property of being rotatable.
A vertex is a data structure that has an identity and holds a list of AttachmentPoints.
This object represents a path in a DGraph.
List< IBond > getBondPath()
Returns the list of bonds in the path between the head and the tail.
void makeMolecularRepresentation(IAtomContainer mol, boolean make3D, Logger logger, Randomizer randomizer)
Creates the molecular representation, list of atoms and bonds involved in the path between the head a...
List< Vertex > getVertecesPath()
Returns the list of verteces involved.
String getChainID()
Returns the string representation of the path.
List< IAtom > getAtomPath()
Returns the list of atoms in the path between the head and the tail.
Vertex getHeadVertex()
Returns the vertex representing the head of the chain.
ArrayList< ArrayList< Point3d > > getDihedralRefPoints()
Returns the list of point to be used to define the torsion of a bond uniquely (independently on the s...
Vertex getTailVertex()
Returns the vertex representing the tail of the chain.
List< Edge > getEdgesPath()
Returns the list of edges involved.
void setRCC(RingClosingConformations rcc)
Set the ring closing conformations to this object.
Tool to explore the conformational space of chains of atoms and identify ring closing conformations.
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...
Parameters and setting related to handling ring closures.
boolean doExhaustiveConfSrch()
boolean checkInterdependentChains()
Set< String > getRequiredRingElements()
RingClosuresArchive getRingClosuresArchive()
int getClosabilityEvalMode()
Map< String, String > getConstitutionalClosabilityConds()
Data structure to store and handle information about sub-structures (i.e., chains of fragments) and r...
RingClosingConformations getRCCsOfChain(String chainId)
void storeEntry(String chainId, boolean closable, RingClosingConformations rcc)
Append a new closable chain entry to the archive.
boolean getClosabilityOfChain(String chainId)
String containsChain(PathSubGraph chain)
Logger getLogger()
Get the name of the program specific logger.
Randomizer getRandomizer()
Returns the current program-specific randomizer.
Container of lists of atoms matching a list of SMARTS.
int getNumMatchesOfQuery(String query)
Utilities for molecule conversion.
static void removeRCA(IAtomContainer mol)
Replace any PseudoAtoms representing ring closing attractors with H.
static String getSymbolOrLabel(IAtom atm)
Gets either the elemental symbol (for standard atoms) of the label (for pseudo-atoms).
static Map< Vertex, ArrayList< Integer > > getVertexToAtomIdMap(ArrayList< Vertex > vertLst, IAtomContainer mol)
Method to generate the map making in relation DENOPTIMVertex ID and atom index in the IAtomContainer ...
Possible chemical bond types an edge can represent.
boolean hasCDKAnalogue()
Checks if it is possible to convert this edge type into a CDK bond.