19package denoptim.graph.rings;
21import java.util.ArrayList;
22import java.util.Arrays;
26import java.util.logging.Level;
28import javax.vecmath.Point3d;
30import org.openscience.cdk.graph.ShortestPaths;
31import org.openscience.cdk.interfaces.IAtom;
32import org.openscience.cdk.interfaces.IAtomContainer;
33import org.openscience.cdk.interfaces.IBond;
34import org.openscience.cdk.interfaces.IChemObjectBuilder;
35import org.openscience.cdk.silent.SilentChemObjectBuilder;
37import denoptim.constants.DENOPTIMConstants;
38import denoptim.exception.DENOPTIMException;
39import denoptim.graph.Edge.BondType;
40import denoptim.graph.Vertex;
41import denoptim.utils.ManySMARTSQuery;
42import denoptim.utils.MoleculeUtils;
72 boolean closable =
false;
105 String s =
"Unrecognized closability evaluation mode";
106 throw new IllegalArgumentException(s);
129 settings.
getLogger().log(Level.FINE,
"Evaluating constitutional "
133 IChemObjectBuilder builder = SilentChemObjectBuilder.getInstance();
134 IAtomContainer mol = builder.newAtomContainer();
139 catch (CloneNotSupportedException e)
141 throw new IllegalArgumentException(e);
147 Map<Vertex,ArrayList<Integer>> vIdToAtmId =
151 List<Integer> atmIdsInVrtxPath =
new ArrayList<Integer>();
154 atmIdsInVrtxPath.addAll(vIdToAtmId.get(v));
159 ArrayList<IAtom> toRemove =
new ArrayList<IAtom>();
160 for (
int i=0; i<mol.getAtomCount(); i++)
162 if (!atmIdsInVrtxPath.contains(i))
164 IAtom candAtm = mol.getAtom(i);
165 boolean isNeighbour =
false;
166 List<IAtom> nbrs = mol.getConnectedAtomsList(candAtm);
167 for (IAtom nbrAtm : nbrs)
169 if (atmIdsInVrtxPath.contains(mol.indexOf(nbrAtm)))
177 toRemove.add(candAtm);
182 IAtom atmH = mol.getAtom(vIdToAtmId.get(subGraph.
getHeadVertex()).get(0));
183 IAtom atmT = mol.getAtom(vIdToAtmId.get(subGraph.
getTailVertex()).get(0));
184 IAtom srcH = mol.getConnectedAtomsList(atmH).get(0);
185 IAtom srcT = mol.getConnectedAtomsList(atmT).get(0);
186 int iSrcH = mol.indexOf(srcH);
187 int iSrcT = mol.indexOf(srcT);
197 "WARNING! Attempt to add ring closing bond "
198 +
"did not add any actual chemical bond because the "
199 +
"bond type of the chord is '" + bndTyp +
"'.");
203 for (IAtom a : toRemove)
208 StringBuilder sb =
new StringBuilder();
209 sb.append(
"Molecular representation of path includes:");
210 for (IAtom a : mol.atoms())
212 sb.append(
" " + a.getSymbol() + mol.indexOf(a) +
" "
213 + a.getProperties());
215 settings.
getLogger().log(Level.FINEST, sb.toString());
217 boolean closable =
false;
220 boolean spanRequiredEls =
false;
222 if (reqRingEl.size() != 0)
225 List<IAtom> atomsPath =
new ArrayList<IAtom>();
226 ShortestPaths sp =
new ShortestPaths(mol, srcH);
227 atomsPath =
new ArrayList<IAtom>(Arrays.asList(sp.atomsTo(srcT)));
230 for (String el : reqRingEl)
232 for (IAtom a : atomsPath)
236 spanRequiredEls =
true;
245 if (!spanRequiredEls)
248 "Candidate ring doesn't involve any among the required "
257 if (smarts.size() != 0)
263 String msg =
"Attempt to match SMARTS for "
264 +
"constitution-based ring-closability conditions "
265 +
"returned an error! Ignoring " + msq.
getMessage();
266 settings.
getLogger().log(Level.WARNING,msg);
268 for (String name : smarts.keySet())
273 "Candidate closable path matches constitutional "
274 +
"closability criterion: " + smarts.get(name));
282 "Contitutional closability: " + closable);
308 "Evaluating 3D closability of path: "
314 boolean closable =
false;
331 settings.
getLogger().warning(
"Could not create 3D model "
332 +
"for potentially closeable path that will be "
333 +
"considered not ring-closable.");
347 settings.
getLogger().warning(
"Could not create 3D model "
348 +
"for potentially closeable path that will be "
349 +
"considered not ring-closable.");
357 ArrayList<Boolean> rotatability =
new ArrayList<Boolean>();
358 for (
int i=0; i < bondsPath.size(); i++)
360 IBond bnd = bondsPath.get(i);
361 Object rotFlag = bnd.getProperty(
363 if (rotFlag ==
null || !Boolean.valueOf(rotFlag.toString()))
365 rotatability.add(
false);
369 rotatability.add(
true);
372 settings.
getLogger().log(Level.FINE,
"Rotatability: "+rotatability);
379 ArrayList<ArrayList<Point3d>> dihRefs =
381 if (dihRefs.size() != rotatability.size()-2)
383 throw new IllegalStateException(
"Number of bonds and number of "
384 +
"dihidrals angles are inconsistent in PathSubGraph."
385 +
" Contact the author.");
389 ArrayList<ArrayList<Double>> closableConfs =
390 new ArrayList<ArrayList<Double>>();
405 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.