1package denoptim.molecularmodeling;
22import static org.junit.jupiter.api.Assertions.assertEquals;
25import java.util.ArrayList;
26import java.util.Arrays;
27import java.util.HashMap;
28import java.util.HashSet;
29import java.util.logging.Logger;
31import javax.vecmath.Point3d;
33import org.junit.jupiter.api.Test;
34import org.openscience.cdk.Atom;
35import org.openscience.cdk.PseudoAtom;
36import org.openscience.cdk.interfaces.IAtom;
37import org.openscience.cdk.interfaces.IAtomContainer;
38import org.openscience.cdk.silent.Bond;
40import denoptim.fragspace.FragmentSpace;
41import denoptim.fragspace.FragmentSpaceParameters;
42import denoptim.graph.APClass;
43import denoptim.graph.DGraph;
44import denoptim.graph.Edge;
45import denoptim.graph.Edge.BondType;
46import denoptim.graph.EmptyVertex;
47import denoptim.graph.Fragment;
48import denoptim.graph.Vertex;
49import denoptim.graph.Vertex.BBType;
50import denoptim.io.DenoptimIO;
51import denoptim.utils.MoleculeUtils;
52import denoptim.utils.Randomizer;
74 HashMap<APClass,ArrayList<APClass>> cpMap =
75 new HashMap<APClass,ArrayList<APClass>>();
76 cpMap.put(a0,
new ArrayList<APClass>(Arrays.asList(a0, b0)));
77 HashMap<APClass,APClass> capMap =
new HashMap<APClass,APClass>();
79 HashSet<APClass> forbEnds =
new HashSet<APClass>();
84 IAtom a1 =
new Atom(
"C",
new Point3d(
new double[]{0.0, 0.0, 0.0}));
85 IAtom a2 =
new Atom(
"C",
new Point3d(
new double[]{1.0, 0.0, 0.0}));
89 frg1.
addAP(0, a0,
new Point3d(
new double[]{0.0, 0.0, 1.0}));
90 frg1.
addAP(1, a0,
new Point3d(
new double[]{1.0, 1.0, 1.0}));
94 IAtom a3 =
new Atom(
"C",
new Point3d(
new double[]{0.0, 0.0, 0.0}));
96 frg2.
addAP(0, a0,
new Point3d(
new double[]{0.0, 1.0, 1.0}));
97 frg2.
addAP(0, b0,
new Point3d(
new double[]{0.0, 1.0, -1.0}));
101 IAtom a7 =
new Atom(
"C",
new Point3d(
new double[]{2.0, 0.0, 0.0}));
102 IAtom a8 =
new Atom(
"O",
new Point3d(
new double[]{3.0, 0.0, 0.0}));
105 frg3.
addBond(
new Bond(a7, a8));
106 frg3.
addAP(0, a0,
new Point3d(
new double[]{2.0, 1.0, 1.0}));
107 frg3.
addAP(0, a0,
new Point3d(
new double[]{2.0, 1.0, -1.0}));
108 frg3.
addAP(0, b0,
new Point3d(
new double[]{3.0, 1.0, -1.0}));
112 IAtom a4 =
new PseudoAtom(
"ATP",
new Point3d(
113 new double[]{0.0, 0.0, 0.0}));
115 rca1.
addAP(0, ap0,
new Point3d(
new double[]{0.0, 1.0, 1.0}));
119 IAtom a5 =
new PseudoAtom(
"ATM",
new Point3d(
120 new double[]{1.0, 0.0, 0.0}));
122 rca2.
addAP(0, am0,
new Point3d(
new double[]{0.0, 1.0, 1.0}));
126 IAtom a6 =
new Atom(
"H",
new Point3d(
new double[]{0.0, 0.0, 0.0}));
128 cap.
addAP(0, h0,
new Point3d(
new double[]{0.0, 1.0, 1.0}));
131 ArrayList<Vertex> scaff =
new ArrayList<Vertex>();
133 ArrayList<Vertex> frags =
new ArrayList<Vertex>();
138 ArrayList<Vertex> caps =
new ArrayList<Vertex>();
143 cpMap, capMap, forbEnds, cpMap);
172 Logger logger = Logger.getLogger(
"DummyLogger");
177 assertEquals(4, mol.getBondCount(),
"Number of bonds without the "
179 assertEquals(5, mol.getAtomCount(),
"Number of atoms in cyclic molecule"
180 +
" before forming ring");
187 assertEquals(3, mol.getBondCount(),
"Number of bonds, including the "
189 assertEquals(3, mol.getAtomCount(),
"Number of atoms in cyclic "
190 +
"molecule after removal of RCAs");
219 assertEquals(4, acyclicMol.getBondCount(),
"Number of bonds in acyclic "
220 +
"graph with RCAs");
221 assertEquals(5, acyclicMol.getAtomCount(),
"Number of atoms in acyclic "
222 +
"molecule before forming ring");
252 assertEquals(1, molFromEmptyScaff.getBondCount(),
"Number of bonds in "
253 +
"mol with empty scaffold");
254 assertEquals(3, molFromEmptyScaff.getAtomCount(),
"Number of atoms in "
255 +
"mol with empty scaffold");
305 assertEquals(2, molWithEmptyNodes.getBondCount(),
"Number of bonds in "
306 +
"mol with empty scaffold and other nodes");
307 assertEquals(5, molWithEmptyNodes.getAtomCount(),
"Number of atoms in "
308 +
"mol with empty scaffold and other nodes");
321 IAtom a1 =
new Atom(
"C",
new Point3d(
new double[]{0.0, 0.0, 0.0}));
322 IAtom a2 =
new Atom(
"C",
new Point3d(
new double[]{1.0, 0.0, 0.0}));
325 frg1.
addBond(
new Bond(a1, a2));
326 frg1.
addAP(0, a0,
new Point3d(
new double[]{0.0, 0.0, 1.0}));
327 frg1.
addAP(1, a0,
new Point3d(
new double[]{1.0, 1.0, 1.0}));
331 IAtom a7 =
new Atom(
"C",
new Point3d(
new double[]{2.0, 0.0, 0.0}));
332 IAtom a8 =
new Atom(
"O",
new Point3d(
new double[]{3.0, 0.0, 0.0}));
335 frg3.
addBond(
new Bond(a7, a8));
336 frg3.
addAP(0, a0,
new Point3d(
new double[]{2.0, 1.0, 1.0}));
337 frg3.
addAP(0, a0,
new Point3d(
new double[]{2.0, 1.0, -1.0}));
338 frg3.
addAP(0, b0,
new Point3d(
new double[]{3.0, 1.0, -1.0}));
342 IAtom a41 =
new Atom(
"Si",
new Point3d(
new double[]{0.0, 5.0, 5.0}));
343 IAtom a42 =
new Atom(
"P",
new Point3d(
new double[]{1.0, 5.0, 5.0}));
346 frg4.
addBond(
new Bond(a41, a42));
347 frg4.
addAP(0, a0,
new Point3d(
new double[]{0.0, 5.0, 6.0}));
348 frg4.
addAP(1, a0,
new Point3d(
new double[]{1.0, 6.0, 6.0}));
352 IAtom a53 =
new Atom(
"N",
new Point3d(
new double[]{0.0, 5.0, 5.0}));
354 frg5.
addAP(0, a0,
new Point3d(
new double[]{0.0, 6.0, 6.0}));
355 frg5.
addAP(0, b0,
new Point3d(
new double[]{0.0, 6.0, 4.0}));
359 IAtom a6 =
new Atom(
"H",
new Point3d(
new double[]{0.0, 0.0, 0.0}));
361 cap.
addAP(0, h0,
new Point3d(
new double[]{0.0, 1.0, 1.0}));
416 Logger logger = Logger.getLogger(
"DummyLogger");
423 assertEquals(9, mol.getBondCount());
424 assertEquals(11, mol.getAtomCount());
427 for (IAtom atom : mol.atoms())
429 if (atom.getSymbol().equals(
"N"))
431 assertEquals(1, mol.getConnectedAtomsList(atom).size());
432 assertEquals(
"Si", mol.getConnectedAtomsList(atom).get(0).getSymbol());
434 if (atom.getSymbol().equals(
"P"))
436 assertEquals(1, mol.getConnectedAtomsList(atom).size());
437 assertEquals(
"Si", mol.getConnectedAtomsList(atom).get(0).getSymbol());
439 if (atom.getSymbol().equals(
"Si"))
441 assertEquals(2, mol.getConnectedAtomsList(atom).size());
442 assertEquals(
"P", mol.getConnectedAtomsList(atom).get(0).getSymbol());
443 assertEquals(
"N", mol.getConnectedAtomsList(atom).get(1).getSymbol());
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 addEdge(Edge edge)
Adds the edge to the list of edges belonging to this graph.
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.
Fragment clone()
Returns a deep copy of this fragments.
void projectAPsToProperties()
Finds the DENOPTIMAttachmentPoint objects defined as properties of the atoms in this container,...
A vertex is a data structure that has an identity and holds a list of AttachmentPoints.
void setVertexId(long vertexId2)
void setBuildingBlockType(Vertex.BBType buildingBlockType)
AttachmentPoint getAP(int i)
Get attachment point i on this vertex.
static Vertex newVertexFromLibrary(int bbId, Vertex.BBType bbt, FragmentSpace fragSpace)
Builds a new molecular fragment kind of vertex.
Tool to build build three-dimensional (3D) tree-like molecular structures from DGraph.
IAtomContainer convertGraphTo3DAtomContainer(DGraph graph)
Created a three-dimensional molecular representation from a given DGraph.
Unit test for TreeBuilder3D.
void testConversionTo3dTreeWithDisconnectedGraphs()
void testConversionTo3dTree()
Utilities for molecule conversion.
static int getDimensions(IAtomContainer mol)
Determines the dimensionality of the given chemical object.
Tool to generate random numbers and random decisions.
Possible chemical bond types an edge can represent.
The type of building block.