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;
122 String s =
"Unrecognized closability evaluation mode";
123 throw new IllegalArgumentException(s);
146 settings.
getLogger().log(Level.FINE,
"Evaluating constitutional "
150 IChemObjectBuilder builder = SilentChemObjectBuilder.getInstance();
151 IAtomContainer mol = builder.newAtomContainer();
156 catch (CloneNotSupportedException e)
158 throw new IllegalArgumentException(e);
164 Map<Vertex,ArrayList<Integer>> vIdToAtmId =
168 List<Integer> atmIdsInVrtxPath =
new ArrayList<Integer>();
171 atmIdsInVrtxPath.addAll(vIdToAtmId.get(v));
176 ArrayList<IAtom> toRemove =
new ArrayList<IAtom>();
177 for (
int i=0; i<mol.getAtomCount(); i++)
179 if (!atmIdsInVrtxPath.contains(i))
181 IAtom candAtm = mol.getAtom(i);
182 boolean isNeighbour =
false;
183 List<IAtom> nbrs = mol.getConnectedAtomsList(candAtm);
184 for (IAtom nbrAtm : nbrs)
186 if (atmIdsInVrtxPath.contains(mol.indexOf(nbrAtm)))
194 toRemove.add(candAtm);
199 IAtom atmH = mol.getAtom(vIdToAtmId.get(subGraph.
getHeadVertex()).get(0));
200 IAtom atmT = mol.getAtom(vIdToAtmId.get(subGraph.
getTailVertex()).get(0));
201 IAtom srcH = mol.getConnectedAtomsList(atmH).get(0);
202 IAtom srcT = mol.getConnectedAtomsList(atmT).get(0);
203 int iSrcH = mol.indexOf(srcH);
204 int iSrcT = mol.indexOf(srcT);
214 "WARNING! Attempt to add ring closing bond "
215 +
"did not add any actual chemical bond because the "
216 +
"bond type of the chord is '" + bndTyp +
"'.");
220 for (IAtom a : toRemove)
225 StringBuilder sb =
new StringBuilder();
226 sb.append(
"Molecular representation of path includes:");
227 for (IAtom a : mol.atoms())
229 sb.append(
" " + a.getSymbol() + mol.indexOf(a) +
" "
230 + a.getProperties());
232 settings.
getLogger().log(Level.FINEST, sb.toString());
234 boolean closable =
false;
237 boolean spanRequiredEls =
false;
239 if (reqRingEl.size() != 0)
242 List<IAtom> atomsPath =
new ArrayList<IAtom>();
243 ShortestPaths sp =
new ShortestPaths(mol, srcH);
244 atomsPath =
new ArrayList<IAtom>(Arrays.asList(sp.atomsTo(srcT)));
247 for (String el : reqRingEl)
249 for (IAtom a : atomsPath)
253 spanRequiredEls =
true;
262 if (!spanRequiredEls)
265 "Candidate ring doesn't involve any among the required "
274 if (smarts.size() != 0)
280 String msg =
"Attempt to match SMARTS for "
281 +
"constitution-based ring-closability conditions "
282 +
"returned an error! Ignoring " + msq.
getMessage();
283 settings.
getLogger().log(Level.WARNING,msg);
285 for (String name : smarts.keySet())
290 "Candidate closable path matches constitutional "
291 +
"closability criterion: " + smarts.get(name));
299 "Contitutional closability: " + closable);
325 "Evaluating 3D closability of path: "
331 boolean closable =
false;
348 settings.
getLogger().warning(
"Could not create 3D model "
349 +
"for potentially closeable path that will be "
350 +
"considered not ring-closable.");
364 settings.
getLogger().warning(
"Could not create 3D model "
365 +
"for potentially closeable path that will be "
366 +
"considered not ring-closable.");
374 ArrayList<Boolean> rotatability =
new ArrayList<Boolean>();
375 for (
int i=0; i < bondsPath.size(); i++)
377 IBond bnd = bondsPath.get(i);
378 Object rotFlag = bnd.getProperty(
380 if (rotFlag ==
null || !Boolean.valueOf(rotFlag.toString()))
382 rotatability.add(
false);
386 rotatability.add(
true);
389 settings.
getLogger().log(Level.FINE,
"Rotatability: "+rotatability);
396 ArrayList<ArrayList<Point3d>> dihRefs =
398 if (dihRefs.size() != rotatability.size()-2)
400 throw new IllegalStateException(
"Number of bonds and number of "
401 +
"dihidrals angles are inconsistent in PathSubGraph."
402 +
" Contact the author.");
406 ArrayList<ArrayList<Double>> closableConfs =
407 new ArrayList<ArrayList<Double>>();
422 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.