$darkmode
DENOPTIM
ClusterableFragmentTest.java
Go to the documentation of this file.
1package denoptim.fragmenter;
2
3import static org.junit.jupiter.api.Assertions.assertFalse;
4import static org.junit.jupiter.api.Assertions.assertTrue;
5
6import javax.vecmath.Point3d;
7
8import org.junit.jupiter.api.Test;
9import org.openscience.cdk.Atom;
10import org.openscience.cdk.interfaces.IAtom;
11import org.openscience.cdk.interfaces.IAtomContainer;
12import org.openscience.cdk.interfaces.IBond;
13import org.openscience.cdk.interfaces.IChemObjectBuilder;
14import org.openscience.cdk.silent.SilentChemObjectBuilder;
15
16import denoptim.graph.APClass;
17import denoptim.graph.AttachmentPoint;
18import denoptim.graph.FragIsomorphNode;
19import denoptim.graph.Fragment;
20import denoptim.graph.Vertex.BBType;
21
26{
27
31 private IChemObjectBuilder builder = SilentChemObjectBuilder.getInstance();
32
33//------------------------------------------------------------------------------
34
35 @Test
36 public void testSetNaturalNodeOrder() throws Exception
37 {
38 IAtomContainer mol = builder.newAtomContainer();
39 mol.addAtom(new Atom("C", new Point3d(1,0,0)));
40 mol.addAtom(new Atom("H", new Point3d(2,0,0)));
41 mol.addAtom(new Atom("O", new Point3d(3,0,0)));
42 mol.addBond(0,1,IBond.Order.SINGLE);
43 mol.addBond(0,2,IBond.Order.SINGLE);
44 Fragment frag = new Fragment(mol, BBType.UNDEFINED);
45 frag.addAP(2, APClass.make("A:0"), new Point3d(4,0,0));
46 frag.addAP(1, APClass.make("B:0"), new Point3d(5,0,0));
47 frag.addAP(0, APClass.make("B:0"), new Point3d(6,0,0));
48 frag.addAP(2, APClass.make("B:0"), new Point3d(7,0,0));
51
52 double value = 0.0;
54 {
55 value += 1.0;
56 assertTrue(Math.abs(value-n.getPoint3d().x) < 0.0001);
57 }
58 }
59
60//------------------------------------------------------------------------------
61
62 @Test
63 public void testGetTransformedCopy() throws Exception
64 {
65 IAtomContainer mol = builder.newAtomContainer();
66 mol.addAtom(new Atom("C", new Point3d(1,0,0)));
67 mol.addAtom(new Atom("H", new Point3d(2,0,0)));
68 mol.addAtom(new Atom("O", new Point3d(3,0,0)));
69 mol.addBond(0,1,IBond.Order.SINGLE);
70 mol.addBond(0,2,IBond.Order.SINGLE);
71 Fragment frag = new Fragment(mol, BBType.UNDEFINED);
72 frag.addAP(2, APClass.make("A:0"), new Point3d(4,0,0));
73 frag.addAP(1, APClass.make("B:0"), new Point3d(5,0,0));
74 frag.addAP(0, APClass.make("B:0"), new Point3d(6,0,0));
75 frag.addAP(2, APClass.make("B:0"), new Point3d(7,0,0));
78
79 double[] newCoords = new double[] {-1,-1,-1, -2,-2,-2, -3,-3,-3,
80 -4,-4,-4, -5,-5,-5, -6,-6,-6, -7,-7,-7};
81 cf.setCoordsVector(newCoords);
82
83 Fragment fragCopy = cf.getTransformedCopy();
84
85 assertFalse(frag == fragCopy);
86 for (int i=0; i<fragCopy.getAtomCount(); i++)
87 {
88 IAtom atm = fragCopy.getAtom(i);
89 assertTrue(Math.abs(atm.getPoint3d().x - newCoords[i*3])<0.0001);
90 assertTrue(Math.abs(atm.getPoint3d().y - newCoords[1+i*3])<0.0001);
91 assertTrue(Math.abs(atm.getPoint3d().z - newCoords[2+i*3])<0.0001);
92 }
93 for (int i=0; i<fragCopy.getNumberOfAPs(); i++)
94 {
95 AttachmentPoint ap = fragCopy.getAP(i);
96 assertTrue(Math.abs(ap.getDirectionVector().x
97 - newCoords[fragCopy.getAtomCount()*3+i*3])<0.0001);
98 assertTrue(Math.abs(ap.getDirectionVector().y
99 - newCoords[fragCopy.getAtomCount()*3+1+i*3])<0.0001);
100 assertTrue(Math.abs(ap.getDirectionVector().z
101 - newCoords[fragCopy.getAtomCount()*3+2+i*3])<0.0001);
102 }
103 }
104
105//------------------------------------------------------------------------------
106
107}
Represents a fragment that can be clustered based on the 3*N coordinate of atoms and attachment point...
List< FragIsomorphNode > getOrderedNodes()
Get the ordered list of nodes representing each either an atom or an attachment point is the alignmen...
void setNaturalNodeOrder()
Define the node order from the list of atoms and attachment points.
void setCoordsVector(double[] coords)
Sets the coordinates of each atom and attachment point in this object.
IChemObjectBuilder builder
Private builder of atom containers.
static APClass make(String ruleAndSubclass)
Creates an APClass if it does not exist already, or returns the reference to the existing instance.
Definition: APClass.java:136
An attachment point (AP) is a possibility to attach a Vertex onto the vertex holding the AP (i....
Point3d getDirectionVector()
Returns the end of the direction vector.
Class representing a continuously connected portion of chemical object holding attachment points.
Definition: Fragment.java:61
void addAP(int atomPositionNumber)
Adds an attachment point with a dummy APClass.
Definition: Fragment.java:343
IAtom getAtom(int number)
Definition: Fragment.java:843
AttachmentPoint getAP(int i)
Get attachment point i on this vertex.
Definition: Vertex.java:920
The type of building block.
Definition: Vertex.java:86