19package denoptim.graph.rings;
21import static org.junit.jupiter.api.Assertions.assertTrue;
24import java.util.ArrayList;
25import java.util.HashMap;
26import java.util.HashSet;
28import java.util.logging.Logger;
30import javax.vecmath.Point3d;
32import org.junit.jupiter.api.Test;
33import org.openscience.cdk.Atom;
34import org.openscience.cdk.PseudoAtom;
35import org.openscience.cdk.interfaces.IAtom;
36import org.openscience.cdk.interfaces.IAtomContainer;
37import org.openscience.cdk.interfaces.IChemObjectBuilder;
38import org.openscience.cdk.silent.SilentChemObjectBuilder;
40import denoptim.fragspace.FragmentSpace;
41import denoptim.fragspace.FragmentSpaceParameters;
42import denoptim.graph.APClass;
43import denoptim.graph.DGraph;
44import denoptim.graph.Fragment;
45import denoptim.graph.Ring;
46import denoptim.graph.Vertex;
47import denoptim.graph.Vertex.BBType;
48import denoptim.io.DenoptimIO;
49import denoptim.molecularmodeling.ThreeDimTreeBuilder;
50import denoptim.utils.Randomizer;
79 IChemObjectBuilder builder = SilentChemObjectBuilder.getInstance();
81 IAtomContainer iacO = builder.newAtomContainer();
82 IAtom aO =
new Atom(
"O",
new Point3d(0,0,0));
85 vO.
addAP(0,
new Point3d(0,-1,0), apc);
86 vO.
addAP(0,
new Point3d(2,0,0), apc);
87 vO.
addAP(0,
new Point3d(0,1,0), apc);
89 IAtomContainer iacC = builder.newAtomContainer();
90 IAtom aC =
new Atom(
"C",
new Point3d(0,0,0));
93 vC.
addAP(0,
new Point3d(0,-1,0), apc);
94 vC.
addAP(0,
new Point3d(2,0,0), apc);
95 vC.
addAP(0,
new Point3d(0,1,0), apc);
97 IAtomContainer iacCd = builder.newAtomContainer();
98 IAtom aCd =
new Atom(
"C",
new Point3d(0,0,0));
101 vC2.
addAP(0,
new Point3d(0,-1,0), apc);
102 vC2.
addAP(0,
new Point3d(0,1,0), apc);
122 IAtomContainer iacN = builder.newAtomContainer();
123 IAtom aN =
new Atom(
"N",
new Point3d(0,0,0));
126 vN.
addAP(0,
new Point3d(0,-1,0), apc);
127 vN.
addAP(0,
new Point3d(2,0,0), apc);
128 vN.
addAP(0,
new Point3d(0,1,0), apc);
132 IAtomContainer iacD = builder.newAtomContainer();
134 new Point3d(0,0,0)));
136 rcvM.
addAP(0,
new Point3d(-1,0,0), atMinus);
150 IAtomContainer iacE = builder.newAtomContainer();
152 new Point3d(0,0,0)));
154 rcvP.
addAP(0,
new Point3d(-1,0,0), atPlus);
188 Logger logger = Logger.getLogger(
"DummyLogger");
198 HashMap<APClass,ArrayList<APClass>> cpMap =
199 new HashMap<APClass,ArrayList<APClass>>();
200 ArrayList<APClass> lstA =
new ArrayList<APClass>();
202 cpMap.put(apc, lstA);
205 new ArrayList<Vertex>(),
206 new ArrayList<Vertex>(),
207 new ArrayList<Vertex>(),
209 new HashMap<APClass,APClass>(),
210 new HashSet<APClass>(),
216 List<Integer> biases =
new ArrayList<Integer>();
217 for (
int i=0; i<4; i++)
221 for (
int i=4; i<8; i++)
225 for (
int i=8; i<10; i++)
240 List<Integer> foundRingSizes =
new ArrayList<Integer>();
241 int maxCheckedSize = 15;
242 for (
int i=0; i<maxCheckedSize; i++)
244 foundRingSizes.add(0);
247 for (
int i=0; i<50; i++)
249 List<Ring> rings = iter.
next();
250 assertTrue(rings.size()>1);
251 for (
Ring ring : rings)
253 foundRingSizes.set(ring.getSize(), foundRingSizes.get(ring.getSize())+1);
258 System.out.println(
"Combination "+i);
259 for (
Ring ring : rings)
261 System.out.println(
" -> " + ring.getHeadVertex().getVertexId()
262 +
"---" + ring.getTailVertex().getVertexId()
263 +
" (" + ring.getSize() +
")");
265 System.out.println(
" ");
271 System.out.println(
"RingSizes");
272 for (
int i=0; i<maxCheckedSize; i++)
273 System.out.println(
" "+i+
" = "+foundRingSizes.get(i));
277 for (
int i=0; i<6; i++)
279 assertTrue(foundRingSizes.get(i) == 0);
281 assertTrue(foundRingSizes.get(6) > 0);
282 assertTrue(foundRingSizes.get(7) > 0);
283 assertTrue(foundRingSizes.get(8) > 0);
284 assertTrue(foundRingSizes.get(9) == 0);
285 assertTrue(foundRingSizes.get(10) == 0);
286 assertTrue(foundRingSizes.get(11) > 0);
287 assertTrue(foundRingSizes.get(12) > 0);
288 assertTrue(foundRingSizes.get(13) == 0);
289 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.