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;
83 IChemObjectBuilder builder = SilentChemObjectBuilder.getInstance();
85 IAtomContainer iacO = builder.newAtomContainer();
86 IAtom aO =
new Atom(
"O",
new Point3d(0,0,0));
89 vO.
addAP(0,
new Point3d(0,-1,0), apc);
90 vO.
addAP(0,
new Point3d(2,0,0), apc);
91 vO.
addAP(0,
new Point3d(0,1,0), apc);
93 IAtomContainer iacC = builder.newAtomContainer();
94 IAtom aC =
new Atom(
"C",
new Point3d(0,0,0));
97 vC.
addAP(0,
new Point3d(0,-1,0), apc);
98 vC.
addAP(0,
new Point3d(2,0,0), apc);
99 vC.
addAP(0,
new Point3d(0,1,0), apc);
101 IAtomContainer iacCd = builder.newAtomContainer();
102 IAtom aCd =
new Atom(
"C",
new Point3d(0,0,0));
105 vC2.
addAP(0,
new Point3d(0,-1,0), apc);
106 vC2.
addAP(0,
new Point3d(0,1,0), apc);
117 IAtomContainer iacN = builder.newAtomContainer();
118 IAtom aN =
new Atom(
"N",
new Point3d(0,0,0));
121 vN.
addAP(0,
new Point3d(0,-1,0), apc);
122 vN.
addAP(0,
new Point3d(2,0,0), apc);
123 vN.
addAP(0,
new Point3d(0,1,0), apc);
127 IAtomContainer iacD = builder.newAtomContainer();
129 new Point3d(0,0,0)));
131 rcvM.
addAP(0,
new Point3d(-1,0,0), atMinus);
142 IAtomContainer iacE = builder.newAtomContainer();
144 new Point3d(0,0,0)));
146 rcvP.
addAP(0,
new Point3d(-1,0,0), atPlus);
181 IChemObjectBuilder builder = SilentChemObjectBuilder.getInstance();
183 IAtomContainer iacO = builder.newAtomContainer();
184 IAtom aO =
new Atom(
"O",
new Point3d(0,0,0));
187 vO.
addAP(0,
new Point3d(0,-1,0), apc);
188 vO.
addAP(0,
new Point3d(2,0,0), apc);
189 vO.
addAP(0,
new Point3d(0,1,0), apc);
191 IAtomContainer iacC = builder.newAtomContainer();
192 IAtom aC =
new Atom(
"C",
new Point3d(0,0,0));
195 vC.
addAP(0,
new Point3d(0,-1,0), apc);
196 vC.
addAP(0,
new Point3d(2,0,0), apc);
197 vC.
addAP(0,
new Point3d(0,1,0), apc);
199 IAtomContainer iacCd = builder.newAtomContainer();
200 IAtom aCd =
new Atom(
"C",
new Point3d(0,0,0));
203 vC2.
addAP(0,
new Point3d(0,-1,0), apc);
204 vC2.
addAP(0,
new Point3d(0,1,0), apc);
215 IAtomContainer iacN = builder.newAtomContainer();
216 IAtom aN =
new Atom(
"N",
new Point3d(0,0,0));
219 vN.
addAP(0,
new Point3d(0,-1,0), apc);
220 vN.
addAP(0,
new Point3d(2,0,0), apc);
221 vN.
addAP(0,
new Point3d(0,1,0), apc);
225 IAtomContainer iacD = builder.newAtomContainer();
227 new Point3d(0,0,0)));
229 rcvM.
addAP(0,
new Point3d(-1,0,0), atMinus);
240 IAtomContainer iacE = builder.newAtomContainer();
242 new Point3d(0,0,0)));
244 rcvP.
addAP(0,
new Point3d(-1,0,0), atPlus);
270 Logger logger = Logger.getLogger(
"DummyLogger");
284 new ArrayList<Vertex>(),
285 new ArrayList<Vertex>(),
286 new ArrayList<Vertex>(),
287 new HashMap<
APClass,ArrayList<APClass>>(),
288 new HashMap<APClass,APClass>(),
289 new HashSet<APClass>(),
290 new HashMap<
APClass,ArrayList<APClass>>());
303 assertEquals(0, wLst.size());
305 for (
int i=0; i<rcvs.size(); i++)
308 for (
int j=i; j<rcvs.size(); j++)
319 HashMap<APClass,ArrayList<APClass>> cpMap =
320 new HashMap<APClass,ArrayList<APClass>>();
321 ArrayList<APClass> lstA =
new ArrayList<APClass>();
323 cpMap.put(apcA, lstA);
325 new ArrayList<Vertex>(),
326 new ArrayList<Vertex>(),
327 new ArrayList<Vertex>(),
329 new HashMap<APClass,APClass>(),
330 new HashSet<APClass>(),
338 assertNotEquals(0, wLst.size());
339 Map<Vertex,Set<Vertex>> expectedRCCompatibilities =
340 new HashMap<Vertex,Set<Vertex>>();
341 expectedRCCompatibilities.put(rcvM,
new HashSet<Vertex>());
342 expectedRCCompatibilities.get(rcvM).add(rcvP3);
343 expectedRCCompatibilities.put(rcvP,
new HashSet<Vertex>());
344 expectedRCCompatibilities.get(rcvP).add(rcvM2);
345 expectedRCCompatibilities.get(rcvP).add(rcvM3);
346 expectedRCCompatibilities.put(rcvP2,
new HashSet<Vertex>());
347 expectedRCCompatibilities.get(rcvP2).add(rcvM2);
348 expectedRCCompatibilities.get(rcvP2).add(rcvM3);
349 int numCompatibilities = 0;
350 for (
int i=0; i<rcvs.size(); i++)
354 for (
int j=i; j<rcvs.size(); j++)
359 numCompatibilities++;
360 assertTrue(expectedRCCompatibilities.containsKey(vI));
361 assertTrue(expectedRCCompatibilities.get(vI).contains(vJ));
365 assertEquals(5,numCompatibilities);
370 List<Integer> biases =
new ArrayList<Integer>();
371 for (
int i=0; i<8; i++)
382 assertNotEquals(0, wLst.size());
383 expectedRCCompatibilities =
new HashMap<Vertex,Set<Vertex>>();
384 expectedRCCompatibilities.put(rcvM,
new HashSet<Vertex>());
385 expectedRCCompatibilities.get(rcvM).add(rcvP3);
386 expectedRCCompatibilities.put(rcvP2,
new HashSet<Vertex>());
387 expectedRCCompatibilities.get(rcvP2).add(rcvM2);
388 expectedRCCompatibilities.get(rcvP2).add(rcvM3);
389 numCompatibilities = 0;
390 for (
int i=0; i<rcvs.size(); i++)
394 for (
int j=i; j<rcvs.size(); j++)
399 numCompatibilities++;
400 assertTrue(expectedRCCompatibilities.containsKey(vI));
401 assertTrue(expectedRCCompatibilities.get(vI).contains(vJ));
405 assertEquals(3, numCompatibilities);
410 biases =
new ArrayList<Integer>();
411 for (
int i=0; i<8; i++)
422 assertNotEquals(0, wLst.size());
423 expectedRCCompatibilities =
new HashMap<Vertex,Set<Vertex>>();
424 expectedRCCompatibilities.put(rcvP,
new HashSet<Vertex>());
425 expectedRCCompatibilities.get(rcvP).add(rcvM2);
426 expectedRCCompatibilities.get(rcvP).add(rcvM3);
427 numCompatibilities = 0;
428 for (
int i=0; i<rcvs.size(); i++)
432 for (
int j=i; j<rcvs.size(); j++)
437 numCompatibilities++;
438 assertTrue(expectedRCCompatibilities.containsKey(vI));
439 assertTrue(expectedRCCompatibilities.get(vI).contains(vJ));
443 assertEquals(2, numCompatibilities);
448 biases =
new ArrayList<Integer>();
449 for (
int i=0; i<8; i++)
460 assertEquals(0, wLst.size());
461 numCompatibilities = 0;
462 for (
int i=0; i<rcvs.size(); i++)
466 for (
int j=i; j<rcvs.size(); j++)
471 numCompatibilities++;
475 assertEquals(0, numCompatibilities);
Class defining a space of building blocks.
void setAPclassBasedApproach(boolean useAPC)
Set the fragment space to behave according to APClass-based approach.
Parameters defining the fragment space.
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.
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 setRingSizeBias(List< Integer > biases)
Sets the preference for certain ring sizes or the prohibition to generate certain rings (i....
Utility class to calculate and manage the alternative ring sizes achievable by formation of Rings.
List< Vertex > getRSBiasedListOfCandidates()
boolean getCompatibilityOfPair(Vertex vI, Vertex vJ)
void initialize(IAtomContainer origMol, DGraph graph)
Makes this ring size manager work on a specific system that has a molecular representation and a DENO...
Unit test for ring size manager.
void testEvaluateRCVPair()
static DGraph makeTestGraphA()
Build a graph meant to be used in unit tests.
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.