File: AtomBijection_test.C

package info (click to toggle)
ball 1.5.0%2Bgit20180813.37fc53c-11
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 239,924 kB
  • sloc: cpp: 326,149; ansic: 4,208; python: 2,303; yacc: 1,778; lex: 1,099; xml: 958; sh: 322; javascript: 164; makefile: 88
file content (164 lines) | stat: -rw-r--r-- 4,191 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
// -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//

#include <BALL/CONCEPT/classTest.h>
#include <BALLTestConfig.h>

///////////////////////////

#include <BALL/STRUCTURE/atomBijection.h>
#include <BALL/KERNEL/molecule.h>
#include <BALL/FORMAT/HINFile.h>


///////////////////////////


using namespace BALL;
String dumpBijection(AtomBijection& ab)
{
	String s;
	AtomBijection::iterator it(ab.begin());
	for (; it != ab.end(); ++it)
	{
		s += " - " + it->first->getFullName() + " - " + it->second->getFullName() + "\n";
	}
	return s;
}


START_TEST(AtomBijection)

/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////


PRECISION(0.001)
AtomBijection* ab_ptr = 0;
CHECK(AtomBijection())
	ab_ptr = new AtomBijection;
	TEST_NOT_EQUAL(ab_ptr, 0)
RESULT

CHECK(~AtomBijection())
	delete ab_ptr;
RESULT

CHECK(double calculateRMSD() const)
	Atom a1;
	Atom a2;
	a2.setPosition(Vector3(0.0, 0.0, 0.0));
	a1.setPosition(Vector3(1.0, 0.0, 0.0));
	AtomBijection ab;
	double rmsd = ab.calculateRMSD();
	TEST_EQUAL(ab.size(), 0)
	TEST_EQUAL(rmsd, 0.0)
	ab.push_back(AtomBijection::AtomPair(&a1, &a2));
	TEST_EQUAL(ab.size(), 1)
	rmsd = ab.calculateRMSD();
	TEST_EQUAL(rmsd, 1.0);
	a1.setPosition(Vector3(1.0, 0.0, 0.0));
	rmsd = ab.calculateRMSD();
	TEST_EQUAL(rmsd, 1.0);
	a1.setPosition(Vector3(0.0, 2.0, 0.0));
	rmsd = ab.calculateRMSD();
	TEST_EQUAL(rmsd, 2.0);
	a1.setPosition(Vector3(1.0, 1.0, 1.0));
	rmsd = ab.calculateRMSD();
	TEST_REAL_EQUAL(rmsd, sqrt((float)3.));
RESULT

Molecule benzene;
HINFile f(BALL_TEST_DATA_PATH(benzene.hin));
f >> benzene;
f.close();

Molecule pyrrole;
f.open(BALL_TEST_DATA_PATH(pyrrole.hin));
f >> pyrrole;
f.close();

Molecule indole;
f.open(BALL_TEST_DATA_PATH(indole.hin));
f >> indole;
f.close();

CHECK(AtomBijection(AtomContainer& A, AtomContainer& B))
	AtomBijection ab(indole, benzene);
	STATUS("Bijection: \n" << dumpBijection(ab))
	TEST_EQUAL(ab.size(), 12)
	double rmsd = ab.calculateRMSD();
	TEST_REAL_EQUAL(rmsd, 14.3947)
RESULT

CHECK(AtomBijection(AtomContainer& A, AtomContainer& B,  bool limit_to_selection))
	AtomIterator at = benzene.beginAtom();
	at->select();
	(++at)->select();
	(++at)->select();
	(++at)->select();
	//((benzene.beginAtom())++)->select();
	AtomBijection ab(indole, benzene, true);
	STATUS("Bijection: \n" << dumpBijection(ab))
	TEST_EQUAL(ab.size(), 4)
	double rmsd = ab.calculateRMSD();
	TEST_REAL_EQUAL(rmsd, 14.3404)
	(++at)->select();
	(++at)->select();
RESULT

CHECK(Size assignBackboneAtoms(AtomContainer& A, AtomContainer& B))
  // ???
RESULT

CHECK(Size assignByName(AtomContainer& A, AtomContainer& B))
	AtomBijection ab;
	ab.assignByName(indole, benzene);
	STATUS("Bijection: \n" << dumpBijection(ab))
	TEST_EQUAL(ab.size(), 12)
	double rmsd = ab.calculateRMSD();
	TEST_REAL_EQUAL(rmsd, 14.3947)
RESULT

CHECK(Size assignByName(AtomContainer& A, AtomContainer& B, bool limit_to_selection))
	AtomBijection ab;
	ab.assignByName(indole, benzene, true);
	STATUS("Bijection: \n" << dumpBijection(ab))
	TEST_EQUAL(ab.size(), 6)
	double rmsd = ab.calculateRMSD();
	TEST_REAL_EQUAL(rmsd, 14.3332)
RESULT


CHECK(Size assignCAlphaAtoms(AtomContainer& A, AtomContainer& B))
  // ???
RESULT

CHECK(Size assignTrivial(AtomContainer& A, AtomContainer& B))
	AtomBijection ab;
	ab.assignTrivial(indole, benzene);
	STATUS("Bijection: \n" << dumpBijection(ab))
	TEST_EQUAL(ab.size(), 12)
	double rmsd = ab.calculateRMSD();
	TEST_REAL_EQUAL(rmsd, 14.1103)
RESULT

CHECK (Size assignAtomsByProperty(AtomContainer& A, AtomContainer& B))
	AtomIterator at = benzene.beginAtom();
	at->setProperty("ATOMBIJECTION_RMSD_SELECTION", true);
	(++at)->setProperty("ATOMBIJECTION_RMSD_SELECTION", true);
	(++at)->setProperty("ATOMBIJECTION_RMSD_SELECTION", true);
	(++at)->setProperty("ATOMBIJECTION_RMSD_SELECTION", true);

	AtomBijection ab;
	ab.assignAtomsByProperty(indole, benzene);
	STATUS("Bijection: \n" << dumpBijection(ab))
	TEST_EQUAL(ab.size(), 4)
	double rmsd = ab.calculateRMSD();
	TEST_REAL_EQUAL(rmsd,  14.3404)
RESULT

/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////
END_TEST