$darkmode
DENOPTIM
FragmentAlignementTest.java
Go to the documentation of this file.
1package denoptim.fragmenter;
2
3import static org.junit.jupiter.api.Assertions.assertTrue;
4
5import javax.vecmath.Point3d;
6
7import org.junit.jupiter.api.Test;
8import org.openscience.cdk.Atom;
9import org.openscience.cdk.interfaces.IAtomContainer;
10import org.openscience.cdk.interfaces.IChemObjectBuilder;
11import org.openscience.cdk.silent.SilentChemObjectBuilder;
12
13import denoptim.graph.APClass;
14import denoptim.graph.Fragment;
15import denoptim.graph.Vertex.BBType;
16
21{
22
26 private IChemObjectBuilder builder = SilentChemObjectBuilder.getInstance();
27
28//-----------------------------------------------------------------------------
29
30 @Test
31 public void testGetMinimumRMSD() throws Exception
32 {
33 IAtomContainer mol1 = builder.newAtomContainer();
34 mol1.addAtom(new Atom("C", new Point3d(0,0,0)));
35 mol1.addAtom(new Atom("H", new Point3d(1,1,1)));
36 mol1.addAtom(new Atom("O", new Point3d(3,1,1)));
37 Fragment frag1 = new Fragment(mol1, BBType.UNDEFINED);
38 frag1.addAP(0, APClass.make("dummy:0"), new Point3d(3,0,0));
39 frag1.addAP(1, APClass.make("dummy:0"), new Point3d(3,2,0));
40
41 Fragment frag1clone = frag1.clone();
42
43 FragmentAlignement fa = new FragmentAlignement(frag1, frag1clone);
44 assertTrue(0.0001>fa.getMinimumRMSD());
45
46 IAtomContainer mol2 = builder.newAtomContainer();
47 mol2.addAtom(new Atom("O", new Point3d(3,1,1)));
48 mol2.addAtom(new Atom("H", new Point3d(1,1,1)));
49 mol2.addAtom(new Atom("C", new Point3d(0,0,0)));
50 Fragment frag2 = new Fragment(mol2, BBType.UNDEFINED);
51 frag2.addAP(1, APClass.make("dummy:0"), new Point3d(3,2,0));
52 frag2.addAP(2, APClass.make("dummy:0"), new Point3d(3,0,0));
53
54 fa = new FragmentAlignement(frag1, frag2);
55 assertTrue(0.0001>fa.getMinimumRMSD());
56
57 IAtomContainer mol3 = builder.newAtomContainer();
58 mol3.addAtom(new Atom("O", new Point3d(1,3,1)));
59 mol3.addAtom(new Atom("H", new Point3d(1,1,1)));
60 mol3.addAtom(new Atom("C", new Point3d(0,0,0)));
61 Fragment frag3 = new Fragment(mol3, BBType.UNDEFINED);
62 frag3.addAP(1, APClass.make("dummy:0"), new Point3d(0,3,2));
63 frag3.addAP(2, APClass.make("dummy:0"), new Point3d(0,3,0));
64
65 fa = new FragmentAlignement(frag1, frag3);
66 assertTrue(0.0001>fa.getMinimumRMSD());
67
68 IAtomContainer mol4 = builder.newAtomContainer();
69 mol4.addAtom(new Atom("O", new Point3d(3,1,1)));
70 mol4.addAtom(new Atom("H", new Point3d(1,1,1)));
71 mol4.addAtom(new Atom("C", new Point3d(1,0,0))); // difference here
72 Fragment frag4 = new Fragment(mol4, BBType.UNDEFINED);
73 frag4.addAP(1, APClass.make("dummy:0"), new Point3d(3,2,0));
74 frag4.addAP(2, APClass.make("dummy:0"), new Point3d(3,0,0));
75
76 fa = new FragmentAlignement(frag1, frag4);
77 assertTrue(0.1<fa.getMinimumRMSD());
78
79 IAtomContainer mol5 = builder.newAtomContainer();
80 mol5.addAtom(new Atom("O", new Point3d(3,1,1)));
81 mol5.addAtom(new Atom("H", new Point3d(1,1,1)));
82 mol5.addAtom(new Atom("C", new Point3d(0,0,0)));
83 Fragment frag5 = new Fragment(mol5, BBType.UNDEFINED);
84 frag5.addAP(1, APClass.make("dummy:0"), new Point3d(3,2,0));
85 frag5.addAP(2, APClass.make("dummy:0"), new Point3d(3,3,0)); // difference here
86
87 fa = new FragmentAlignement(frag1, frag5);
88 assertTrue(0.1<fa.getMinimumRMSD());
89 }
90
91//-----------------------------------------------------------------------------
92
93}
Class performing the alignment of Fragments.
double getMinimumRMSD()
Returns the lowest RMSD that could be found among all isomorphic mappings.
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
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
Fragment clone()
Returns a deep copy of this fragments.
Definition: Fragment.java:733
The type of building block.
Definition: Vertex.java:86