19package denoptim.graph.rings;
21import static org.junit.jupiter.api.Assertions.assertTrue;
23import java.util.ArrayList;
24import java.util.HashMap;
25import java.util.HashSet;
27import java.util.logging.Logger;
29import javax.vecmath.Point3d;
31import org.junit.jupiter.api.Test;
32import org.openscience.cdk.Atom;
33import org.openscience.cdk.PseudoAtom;
34import org.openscience.cdk.interfaces.IAtom;
35import org.openscience.cdk.interfaces.IAtomContainer;
36import org.openscience.cdk.interfaces.IChemObjectBuilder;
37import org.openscience.cdk.silent.SilentChemObjectBuilder;
39import denoptim.fragspace.FragmentSpace;
40import denoptim.fragspace.FragmentSpaceParameters;
41import denoptim.graph.APClass;
42import denoptim.graph.DGraph;
43import denoptim.graph.Fragment;
44import denoptim.graph.Ring;
45import denoptim.graph.Vertex;
46import denoptim.graph.Vertex.BBType;
47import denoptim.molecularmodeling.ThreeDimTreeBuilder;
48import denoptim.utils.Randomizer;
77 IChemObjectBuilder builder = SilentChemObjectBuilder.getInstance();
79 IAtomContainer iacO = builder.newAtomContainer();
80 IAtom aO =
new Atom(
"O",
new Point3d(0,0,0));
83 vO.
addAP(0,
new Point3d(0,-1,0), apc);
84 vO.
addAP(0,
new Point3d(2,0,0), apc);
85 vO.
addAP(0,
new Point3d(0,1,0), apc);
87 IAtomContainer iacC = builder.newAtomContainer();
88 IAtom aC =
new Atom(
"C",
new Point3d(0,0,0));
91 vC.
addAP(0,
new Point3d(0,-1,0), apc);
92 vC.
addAP(0,
new Point3d(2,0,0), apc);
93 vC.
addAP(0,
new Point3d(0,1,0), apc);
95 IAtomContainer iacCd = builder.newAtomContainer();
96 IAtom aCd =
new Atom(
"C",
new Point3d(0,0,0));
99 vC2.
addAP(0,
new Point3d(0,-1,0), apc);
100 vC2.
addAP(0,
new Point3d(0,1,0), apc);
120 IAtomContainer iacN = builder.newAtomContainer();
121 IAtom aN =
new Atom(
"N",
new Point3d(0,0,0));
124 vN.
addAP(0,
new Point3d(0,-1,0), apc);
125 vN.
addAP(0,
new Point3d(2,0,0), apc);
126 vN.
addAP(0,
new Point3d(0,1,0), apc);
130 IAtomContainer iacD = builder.newAtomContainer();
132 new Point3d(0,0,0)));
134 rcvM.
addAP(0,
new Point3d(-1,0,0), atMinus);
148 IAtomContainer iacE = builder.newAtomContainer();
150 new Point3d(0,0,0)));
152 rcvP.
addAP(0,
new Point3d(-1,0,0), atPlus);
186 Logger logger = Logger.getLogger(
"DummyLogger");
196 HashMap<APClass,ArrayList<APClass>> cpMap =
197 new HashMap<APClass,ArrayList<APClass>>();
198 ArrayList<APClass> lstA =
new ArrayList<APClass>();
200 cpMap.put(apc, lstA);
203 new ArrayList<Vertex>(),
204 new ArrayList<Vertex>(),
205 new ArrayList<Vertex>(),
207 new HashMap<APClass,APClass>(),
208 new HashSet<APClass>(),
214 List<Integer> biases =
new ArrayList<Integer>();
215 for (
int i=0; i<4; i++)
219 for (
int i=4; i<8; i++)
223 for (
int i=8; i<10; i++)
238 List<Integer> foundRingSizes =
new ArrayList<Integer>();
239 int maxCheckedSize = 15;
240 for (
int i=0; i<maxCheckedSize; i++)
242 foundRingSizes.add(0);
245 for (
int i=0; i<50; i++)
247 List<Ring> rings = iter.
next();
248 assertTrue(rings.size()>1);
249 for (
Ring ring : rings)
251 foundRingSizes.set(ring.getSize(), foundRingSizes.get(ring.getSize())+1);
256 System.out.println(
"Combination "+i);
257 for (
Ring ring : rings)
259 System.out.println(
" -> " + ring.getHeadVertex().getVertexId()
260 +
"---" + ring.getTailVertex().getVertexId()
261 +
" (" + ring.getSize() +
")");
263 System.out.println(
" ");
269 System.out.println(
"RingSizes");
270 for (
int i=0; i<maxCheckedSize; i++)
271 System.out.println(
" "+i+
" = "+foundRingSizes.get(i));
275 for (
int i=0; i<6; i++)
277 assertTrue(foundRingSizes.get(i) == 0);
279 assertTrue(foundRingSizes.get(6) > 0);
280 assertTrue(foundRingSizes.get(7) > 0);
281 assertTrue(foundRingSizes.get(8) > 0);
282 assertTrue(foundRingSizes.get(9) == 0);
283 assertTrue(foundRingSizes.get(10) == 0);
284 assertTrue(foundRingSizes.get(11) > 0);
285 assertTrue(foundRingSizes.get(12) > 0);
286 assertTrue(foundRingSizes.get(13) == 0);
287 assertTrue(foundRingSizes.get(14) == 0);
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.
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.
This class represents the closure of a ring in a spanning tree.
void setVertexId(long vertexId2)
void setAsRCV(boolean isRCV)
AttachmentPoint getAP(int i)
Get attachment point i on this vertex.
Unit test for the iterator over random combination of rings.
void testEvaluateConstitutionalClosability()
A class for iterating over sets of ring combinations generated by considering any constrain and setti...
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....
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.