19package denoptim.graph.rings;
21import static org.junit.jupiter.api.Assertions.assertEquals;
22import static org.junit.jupiter.api.Assertions.assertFalse;
23import static org.junit.jupiter.api.Assertions.assertNotEquals;
24import static org.junit.jupiter.api.Assertions.assertTrue;
26import java.util.ArrayList;
27import java.util.HashMap;
28import java.util.HashSet;
32import java.util.logging.Logger;
34import javax.vecmath.Point3d;
36import org.junit.jupiter.api.Test;
37import org.openscience.cdk.Atom;
38import org.openscience.cdk.PseudoAtom;
39import org.openscience.cdk.interfaces.IAtom;
40import org.openscience.cdk.interfaces.IAtomContainer;
41import org.openscience.cdk.interfaces.IChemObjectBuilder;
42import org.openscience.cdk.silent.SilentChemObjectBuilder;
44import denoptim.exception.DENOPTIMException;
45import denoptim.fragspace.FragmentSpace;
46import denoptim.fragspace.FragmentSpaceParameters;
47import denoptim.graph.APClass;
48import denoptim.graph.DGraph;
49import denoptim.graph.Fragment;
50import denoptim.graph.Vertex;
51import denoptim.graph.Vertex.BBType;
52import denoptim.molecularmodeling.ThreeDimTreeBuilder;
53import denoptim.utils.Randomizer;
81 IChemObjectBuilder builder = SilentChemObjectBuilder.getInstance();
83 IAtomContainer iacO = builder.newAtomContainer();
84 IAtom aO =
new Atom(
"O",
new Point3d(0,0,0));
87 vO.
addAP(0,
new Point3d(0,-1,0), apc);
88 vO.
addAP(0,
new Point3d(2,0,0), apc);
89 vO.
addAP(0,
new Point3d(0,1,0), apc);
91 IAtomContainer iacC = builder.newAtomContainer();
92 IAtom aC =
new Atom(
"C",
new Point3d(0,0,0));
95 vC.
addAP(0,
new Point3d(0,-1,0), apc);
96 vC.
addAP(0,
new Point3d(2,0,0), apc);
97 vC.
addAP(0,
new Point3d(0,1,0), apc);
99 IAtomContainer iacCd = builder.newAtomContainer();
100 IAtom aCd =
new Atom(
"C",
new Point3d(0,0,0));
103 vC2.
addAP(0,
new Point3d(0,-1,0), apc);
104 vC2.
addAP(0,
new Point3d(0,1,0), apc);
115 IAtomContainer iacN = builder.newAtomContainer();
116 IAtom aN =
new Atom(
"N",
new Point3d(0,0,0));
119 vN.
addAP(0,
new Point3d(0,-1,0), apc);
120 vN.
addAP(0,
new Point3d(2,0,0), apc);
121 vN.
addAP(0,
new Point3d(0,1,0), apc);
125 IAtomContainer iacD = builder.newAtomContainer();
127 new Point3d(0,0,0)));
129 rcvM.
addAP(0,
new Point3d(-1,0,0), atMinus);
140 IAtomContainer iacE = builder.newAtomContainer();
142 new Point3d(0,0,0)));
144 rcvP.
addAP(0,
new Point3d(-1,0,0), atPlus);
170 Logger logger = Logger.getLogger(
"DummyLogger");
191 int numCompatibilities = 0;
192 for (
int i=0; i<rcvs.size(); i++)
195 for (
int j=i+1; j<rcvs.size(); j++)
201 numCompatibilities++;
207 assertEquals(15, numCompatibilities);
214 rcParams.rceMode = 0;
215 for (
int i=0; i<rcvs.size(); i++)
218 for (
int j=i+1; j<rcvs.size(); j++)
231 Map<String,String> allowedConstitutions =
new HashMap<String,String>();
232 allowedConstitutions.put(
"case-1",
"[#6]1[#6][#8][#6][#6][#6]1");
233 allowedConstitutions.put(
"case-2",
"[#6]1[#6][#7][#6][#6][#6]1");
236 Map<Vertex,Set<Vertex>> expectedRCCompatibilities =
237 new HashMap<Vertex,Set<Vertex>>();
238 expectedRCCompatibilities.put(rcvM,
new HashSet<Vertex>());
239 expectedRCCompatibilities.get(rcvM).add(rcvP3);
240 expectedRCCompatibilities.put(rcvP2,
new HashSet<Vertex>());
241 expectedRCCompatibilities.get(rcvP2).add(rcvM2);
242 expectedRCCompatibilities.get(rcvP2).add(rcvM3);
247 expectedRCCompatibilities.put(rcvP,
new HashSet<Vertex>());
248 expectedRCCompatibilities.get(rcvP).add(rcvP3);
250 numCompatibilities = 0;
251 for (
int i=0; i<rcvs.size(); i++)
254 for (
int j=i+1; j<rcvs.size(); j++)
260 numCompatibilities++;
261 assertTrue(expectedRCCompatibilities.containsKey(vI));
262 assertTrue(expectedRCCompatibilities.get(vI).contains(vJ));
266 assertEquals(4, numCompatibilities);
274 rcParams.rceMode = 0;
275 Set<String> elementsRequired =
new HashSet<String>();
276 elementsRequired.add(
"N");
277 elementsRequired.add(
"Ru");
278 rcParams.reqElInRings = elementsRequired;
280 expectedRCCompatibilities =
new HashMap<Vertex,Set<Vertex>>();
281 expectedRCCompatibilities.put(rcvP,
new HashSet<Vertex>());
282 expectedRCCompatibilities.get(rcvP).add(rcvM2);
283 expectedRCCompatibilities.get(rcvP).add(rcvM3);
284 expectedRCCompatibilities.put(rcvP2,
new HashSet<Vertex>());
285 expectedRCCompatibilities.get(rcvP2).add(rcvM2);
286 expectedRCCompatibilities.get(rcvP2).add(rcvM3);
291 expectedRCCompatibilities.put(rcvM,
new HashSet<Vertex>());
292 expectedRCCompatibilities.get(rcvM).add(rcvM2);
293 expectedRCCompatibilities.get(rcvM).add(rcvM3);
294 expectedRCCompatibilities.put(rcvP3,
new HashSet<Vertex>());
295 expectedRCCompatibilities.get(rcvP3).add(rcvM2);
296 expectedRCCompatibilities.get(rcvP3).add(rcvM3);
297 expectedRCCompatibilities.put(rcvM2,
new HashSet<Vertex>());
298 expectedRCCompatibilities.get(rcvM2).add(rcvM3);
300 numCompatibilities = 0;
301 for (
int i=0; i<rcvs.size(); i++)
304 for (
int j=i+1; j<rcvs.size(); j++)
310 numCompatibilities++;
311 assertTrue(expectedRCCompatibilities.containsKey(vI));
312 assertTrue(expectedRCCompatibilities.get(vI).contains(vJ));
316 assertEquals(9, numCompatibilities);
static final APClass RCACLASSPLUS
Conventional class of attachment points on ring-closing vertexes.
static final APClass RCACLASSMINUS
Conventional class of attachment points on ring-closing vertexes.
static APClass make(String ruleAndSubclass)
Creates an APClass if it does not exist already, or returns the reference to the existing instance.
Container for the list of vertices and the edges that connect them.
void addVertex(Vertex vertex)
Appends a vertex to this graph without creating any edge.
ArrayList< Vertex > getRCVertices()
Search for ring closing vertices: vertices that contain only a RingClosingAttractor
void appendVertexOnAP(AttachmentPoint srcAP, AttachmentPoint trgAP)
Append a vertex to this graph: adds the new vertex to the list of vertices belonging to the graph,...
Class representing a continuously connected portion of chemical object holding attachment points.
void addAP(int atomPositionNumber)
Adds an attachment point with a dummy APClass.
Fragment clone()
Returns a deep copy of this fragments.
A vertex is a data structure that has an identity and holds a list of AttachmentPoints.
void setVertexId(long vertexId2)
void setAsRCV(boolean isRCV)
AttachmentPoint getAP(int i)
Get attachment point i on this vertex.
This object represents a path in a DGraph.
The RingClosingAttractor represent the available valence/connection that allows to close a ring.
static final HashMap< APClass, String > RCALABELPERAPCLASS
Conventional labels for attractor pseudoatom.
Parameters and setting related to handling ring closures.
void setConstitutionalClosabilityConds(Map< String, String > ringClosabCondAsSMARTS)
Sets the list of constitutions that can be formed by ring closure.
Tool to build build three-dimensional (3D) tree-like molecular structures from DGraph.
void setAlignBBsIn3D(boolean align)
Sets the flag that controls whether building blocks have to be aligned according to the AP vectors or...
IAtomContainer convertGraphTo3DAtomContainer(DGraph graph)
Created a three-dimensional molecular representation from a given DGraph.
Tool to generate random numbers and random decisions.
The type of building block.