19package denoptim.graph.rings;
21import static org.junit.jupiter.api.Assertions.assertEquals;
22import static org.junit.jupiter.api.Assertions.assertNotNull;
23import static org.junit.jupiter.api.Assertions.assertNull;
24import static org.junit.jupiter.api.Assertions.assertThrows;
26import java.util.ArrayList;
27import java.util.Arrays;
28import java.util.HashMap;
31import java.util.logging.Logger;
33import javax.vecmath.Point3d;
35import org.junit.jupiter.api.Test;
36import org.openscience.cdk.Atom;
37import org.openscience.cdk.Bond;
38import org.openscience.cdk.PseudoAtom;
39import org.openscience.cdk.interfaces.IAtom;
40import org.openscience.cdk.interfaces.IAtomContainer;
41import org.openscience.cdk.interfaces.IBond;
42import org.openscience.cdk.interfaces.IChemObjectBuilder;
43import org.openscience.cdk.silent.SilentChemObjectBuilder;
45import denoptim.exception.DENOPTIMException;
46import denoptim.fragspace.FragmentSpace;
47import denoptim.graph.APClass;
48import denoptim.graph.DGraph;
49import denoptim.graph.DGraphTest;
50import denoptim.graph.Edge;
51import denoptim.graph.Edge.BondType;
52import denoptim.graph.EmptyVertex;
53import denoptim.graph.Fragment;
54import denoptim.graph.Vertex;
55import denoptim.graph.Vertex.BBType;
56import denoptim.molecularmodeling.ThreeDimTreeBuilder;
57import denoptim.utils.Randomizer;
87 IChemObjectBuilder builder = SilentChemObjectBuilder.getInstance();
89 IAtomContainer iacA = builder.newAtomContainer();
90 IAtom iaA1 =
new Atom(
"O",
new Point3d(0,0,0));
91 IAtom iaA2 =
new Atom(
"O",
new Point3d(1,0,0));
94 iacA.addBond(
new Bond(iaA1, iaA2, IBond.Order.SINGLE));
96 vA.
addAP(0,
new Point3d(0,-1,0),apc);
97 vA.
addAP(1,
new Point3d(2,0,0),apc);
99 IAtomContainer iacB = builder.newAtomContainer();
100 IAtom iaB1 =
new Atom(
"C",
new Point3d(0,0,0));
101 IAtom iaB2 =
new Atom(
"C",
new Point3d(1,0,0));
102 IAtom iaB3 =
new Atom(
"C",
new Point3d(1,-0.33,0));
103 IAtom iaB4 =
new Atom(
"C",
new Point3d(1,-0.66,0));
104 IAtom iaB5 =
new Atom(
"C",
new Point3d(1,-1,0));
105 IAtom iaB6 =
new Atom(
"C",
new Point3d(0,-1,0));
106 IAtom iaB7 =
new Atom(
"C",
new Point3d(0,-0.5,0));
114 iacB.addBond(
new Bond(iaB1, iaB2, IBond.Order.SINGLE));
115 iacB.addBond(
new Bond(iaB2, iaB3, IBond.Order.SINGLE));
116 iacB.addBond(
new Bond(iaB3, iaB4, IBond.Order.SINGLE));
117 iacB.addBond(
new Bond(iaB4, iaB5, IBond.Order.SINGLE));
118 iacB.addBond(
new Bond(iaB5, iaB6, IBond.Order.SINGLE));
119 iacB.addBond(
new Bond(iaB6, iaB7, IBond.Order.SINGLE));
120 iacB.addBond(
new Bond(iaB1, iaB7, IBond.Order.SINGLE));
122 vB.
addAP(0,
new Point3d(-1,0,0),apc);
123 vB.
addAP(5,
new Point3d(-1,-1,0),apc);
124 vB.
addAP(6,
new Point3d(1,1,0),apc);
126 IAtomContainer iacC = builder.newAtomContainer();
127 IAtom iaC1 =
new Atom(
"N",
new Point3d(0,0,0));
128 IAtom iaC2 =
new Atom(
"N",
new Point3d(-1,0,0));
129 IAtom iaC3 =
new Atom(
"N",
new Point3d(0,-1,0));
133 iacC.addBond(
new Bond(iaC1, iaC2, IBond.Order.SINGLE));
134 iacC.addBond(
new Bond(iaC2, iaC3, IBond.Order.SINGLE));
135 iacC.addBond(
new Bond(iaC1, iaC3, IBond.Order.SINGLE));
137 vC.
addAP(0,
new Point3d(1,0,0),apc);
138 vC.
addAP(1,
new Point3d(-1,1,0),apc);
139 vC.
addAP(2,
new Point3d(-1,-1,0),apc);
141 IAtomContainer iacG = builder.newAtomContainer();
142 IAtom iaG1 =
new Atom(
"P",
new Point3d(0,0,0));
143 IAtom iaG2 =
new Atom(
"P",
new Point3d(0,0,1));
144 IAtom iaG3 =
new Atom(
"P",
new Point3d(0,0,2));
148 iacG.addBond(
new Bond(iaG1, iaG2, IBond.Order.SINGLE));
149 iacG.addBond(
new Bond(iaG2, iaG3, IBond.Order.SINGLE));
151 vG.
addAP(0,
new Point3d(1,0,0),apc);
153 IAtomContainer iacD = builder.newAtomContainer();
154 iacD.addAtom(
new PseudoAtom(
"ATN",
new Point3d(0,0,0)));
159 IAtomContainer iacE = builder.newAtomContainer();
160 iacE.addAtom(
new PseudoAtom(
"ATN",
new Point3d(0,0,0)));
199 IChemObjectBuilder builder = SilentChemObjectBuilder.getInstance();
201 IAtomContainer iacA = builder.newAtomContainer();
202 IAtom iaA1 =
new Atom(
"O",
new Point3d(0,0,0));
205 vA.
addAP(0,
new Point3d(0,-1,0),apc);
206 vA.
addAP(0,
new Point3d(1,-1,0),apc);
208 IAtomContainer iacB = builder.newAtomContainer();
209 IAtom iaB1 =
new Atom(
"C",
new Point3d(0,0,0));
212 vB.
addAP(0,
new Point3d(-1,0,0),apc);
213 vB.
addAP(0,
new Point3d(-1,-1,0),apc);
215 IAtomContainer iacC = builder.newAtomContainer();
216 IAtom iaC1 =
new Atom(
"N",
new Point3d(0,0,0));
219 vC.
addAP(0,
new Point3d(1,0,0),apc);
220 vC.
addAP(0,
new Point3d(1,1,0),apc);
222 IAtomContainer iacG = builder.newAtomContainer();
223 IAtom iaG1 =
new Atom(
"P",
new Point3d(0,0,0));
226 vG.
addAP(0,
new Point3d(1,0,0),apc);
227 vG.
addAP(0,
new Point3d(-1,1,0),apc);
229 IAtomContainer iacD = builder.newAtomContainer();
230 iacD.addAtom(
new PseudoAtom(
"ATN",
new Point3d(0,0,0)));
235 IAtomContainer iacE = builder.newAtomContainer();
236 iacE.addAtom(
new PseudoAtom(
"ATN",
new Point3d(0,0,0)));
267 "Number of vertices in the path");
269 "First vertex in the path is the fifth vertex in the graph.");
283 "Number of vertices in the path");
285 "Number of edges in the path");
287 "First vertex in the path");
289 "Second vertex in the path");
295 "Number of vertices in the path");
297 "Number of edges in the path");
299 "First vertex in the path");
301 "Second vertex in the path");
303 "Third vertex in the path");
319 "Number of vertices in the path");
353 "Number of vertices in the path");
355 "Number of edges in the path");
366 Map<Vertex, List<Vertex>> adjacency =
new HashMap<>();
376 Map<Vertex, List<Vertex>> adjacency2 =
new HashMap<>();
390 "Number of vertices in the path");
392 "Number of edges in the path");
394 assertNull(e,
"Edge is supposed to be null in path driven only by adjacency rule");
410 "Number of vertices in the path");
412 "Number of edges in the path");
414 assertNull(edges.get(0),
"Edge is supposed to be null in path driven only by adjacency rule");
415 assertNotNull(edges.get(1),
"Edge is supposed to be not null in path driven by adjacency and actual edges");
416 assertNotNull(edges.get(2),
"Edge is supposed to be not null in path driven by adjacency and actual edges");
417 assertEquals(
BondType.
SINGLE, edges.get(1).getBondType(),
"Bond type in the path");
418 assertEquals(
BondType.
TRIPLE, edges.get(2).getBondType(),
"Bond type in the path");
429 Logger logger = Logger.getLogger(
"DummyLogger");
445 assertEquals(14,iacA.getAtomCount(),
"Atom count in the path");
448 assertEquals(6,iacB.getAtomCount(),
"Atom count in the path");
Class defining a space of building blocks.
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.
Vertex getVertexAtPosition(int pos)
Returns the vertex that is in the given position of the list of vertices belonging to this graph.
void addEdge(Edge edge)
Adds the edge to the list of edges belonging to this graph.
Unit test for DENOPTIMGraph.
static FragmentSpace prepare()
static DGraph makeTestGraphO_B(FragmentSpace fs)
Creates a test graph that intentionally violates APClass compatibility and looks like this:
This class represents the edge between two vertices.
An empty vertex has the behaviors of a vertex, but has no molecular structure.
void addAP()
Adds an attachment point with no APClass or other attribute.
Class representing a continuously connected portion of chemical object holding attachment points.
void addAP(int atomPositionNumber)
Adds an attachment point with a dummy APClass.
void setAsRCV(boolean isRCV)
AttachmentPoint getAP(int i)
Get attachment point i on this vertex.
This object represents a path in a DGraph.
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.
IAtomContainer getMolecularRepresentation()
Returns the molecular representation.
List< Edge > getEdgesPath()
Returns the list of edges involved, if any.
Unit test for PathSubGraph.
void testMakePathSubGraph_givenAdjacency()
void testMakePathSubGraph_sameVrtx()
static DGraph makeTestGraphB()
Build a graph meant to be used in unit tests.
void testMakePathSubGraph_sameBranch()
void testMakePathSubGraph_differentBranch()
static DGraph makeTestGraphA()
Build a graph meant to be used in unit tests.
void testMakePathSubGraph_withIAC()
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.
Possible chemical bond types an edge can represent.
The type of building block.