File: PARSE_test.C

package info (click to toggle)
ball 1.5.0%2Bgit20180813.37fc53c-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 239,848 kB
  • sloc: cpp: 326,149; ansic: 4,208; python: 2,303; yacc: 1,778; lex: 1,099; xml: 958; sh: 322; makefile: 93
file content (177 lines) | stat: -rw-r--r-- 4,998 bytes parent folder | download | duplicates (8)
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
165
166
167
168
169
170
171
172
173
174
175
176
177
// -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//

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

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

// insert includes here
#include <BALL/SYSTEM/path.h>
#include <BALL/FORMAT/PDBFile.h>
#include <BALL/FORMAT/HINFile.h>
#include <BALL/FORMAT/INIFile.h>
#include <BALL/STRUCTURE/fragmentDB.h>
#include <BALL/MOLMEC/COMMON/radiusRuleProcessor.h>
#include <BALL/MOLMEC/COMMON/chargeRuleProcessor.h>
#include <BALL/STRUCTURE/defaultProcessors.h>

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

START_TEST(class_name)

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

using namespace BALL;

HINFile hinfile;
PDBFile pdbfile;
System system;
System ref_system;
FragmentDB db("");

Path path;
String tmp = path.find("solvation/PARSE.rul");
INIFile PARSE_rule_file(tmp);
PARSE_rule_file.read();
ChargeRuleProcessor charges(PARSE_rule_file);
RadiusRuleProcessor radii(PARSE_rule_file);
AtomConstIterator atom_it;
AtomConstIterator ref_atom_it;
float total_charge;
ClearChargeProcessor clear_charges;

CHECK("AlaGlySer: -CONH-, -OH, COO(-), NH3(+), aliphatic carbons with hydrogens")
	hinfile.open(BALL_TEST_DATA_PATH(AlaGlySer.hin));
	hinfile >> system;
	hinfile.close();
	system.apply(db.normalize_names);
	system.apply(clear_charges);
	system.apply(charges);
	system.apply(radii);
	for (atom_it = system.beginAtom(), total_charge = 0.0f; +atom_it; ++atom_it)
	{
		total_charge += atom_it->getCharge();
	}
	TEST_REAL_EQUAL(total_charge, 0.0)
	hinfile.open(BALL_TEST_DATA_PATH(AlaGlySer_PARSE_charges.hin));
	hinfile >> ref_system;
	hinfile.close();
	for (atom_it = system.beginAtom(), ref_atom_it = ref_system.beginAtom();
			+atom_it; ++atom_it, ++ref_atom_it)
	{
		TEST_REAL_EQUAL(atom_it->getCharge(), ref_atom_it->getCharge())
	}
RESULT

CHECK("AspGluAsnGlnArg: -COOH -CONH2 -CONH- -CNC-(NH2)2")
	system.clear();
	hinfile.open(BALL_TEST_DATA_PATH(AspGluAsnGlnArg.hin));
	hinfile >> system;
	hinfile.close();
	system.apply(db.normalize_names);
	system.apply(clear_charges);
	system.apply(charges);
	system.apply(radii);

	for (atom_it = system.beginAtom(), total_charge = 0.0f; +atom_it; ++atom_it)
	{
		total_charge += atom_it->getCharge();
	}
	TEST_REAL_EQUAL(total_charge, -0.0)
	ref_system.clear();
	hinfile.open(BALL_TEST_DATA_PATH(AspGluAsnGlnArg_PARSE_charges.hin));
	hinfile >> ref_system;
	hinfile.close();
	for (atom_it = system.beginAtom(), ref_atom_it = ref_system.beginAtom();
			+atom_it; ++atom_it, ++ref_atom_it)
	{
		TEST_REAL_EQUAL(atom_it->getCharge(), ref_atom_it->getCharge())
	}
RESULT

CHECK("PheTyrTrpHisLys+.hin")
	system.clear();
	hinfile.open(BALL_TEST_DATA_PATH(PheTyrTrpHisLys+.hin));
	hinfile >> system;
	hinfile.close();
	system.apply(db.normalize_names);
	system.apply(clear_charges);
	system.apply(charges);
	system.apply(radii);

	for (atom_it = system.beginAtom(), total_charge = 0.0f; +atom_it; ++atom_it)
	{
		total_charge += atom_it->getCharge();
	}
	TEST_REAL_EQUAL(total_charge, 1.0)
	ref_system.clear();
	hinfile.open(BALL_TEST_DATA_PATH(PheTyrTrpHisLys+_PARSE_charges.hin));
	hinfile >> ref_system;
	hinfile.close();
	for (atom_it = system.beginAtom(), ref_atom_it = ref_system.beginAtom();
			+atom_it; ++atom_it, ++ref_atom_it)
	{
		TEST_REAL_EQUAL(atom_it->getCharge(), ref_atom_it->getCharge())
	}
RESULT

CHECK("Cys-Asp-Glu-Tyr-His+Arg+.hin")
	system.clear();
	hinfile.open(BALL_TEST_DATA_PATH(Cys-Asp-Glu-Tyr-His+Arg+.hin));
	hinfile >> system;
	hinfile.close();
	system.apply(db.normalize_names);
	system.apply(clear_charges);
	system.apply(charges);
	system.apply(radii);

	for (atom_it = system.beginAtom(), total_charge = 0.0f; +atom_it; ++atom_it)
	{
		total_charge += atom_it->getCharge();
	}
	TEST_REAL_EQUAL(total_charge, -2.0)
	ref_system.clear();
	hinfile.open(BALL_TEST_DATA_PATH(Cys-Asp-Glu-Tyr-His+Arg+_PARSE_charges.hin));
	hinfile >> ref_system;
	hinfile.close();
	for (atom_it = system.beginAtom(), ref_atom_it = ref_system.beginAtom();
			+atom_it; ++atom_it, ++ref_atom_it)
	{
		TEST_REAL_EQUAL(atom_it->getCharge(), ref_atom_it->getCharge())
	}
RESULT


CHECK("SerThrLysCysMet.hin")
	system.clear();
	hinfile.open(BALL_TEST_DATA_PATH(SerThrLysCysMet.hin));
	hinfile >> system;
	hinfile.close();
	system.apply(db.normalize_names);
	system.apply(clear_charges);
	system.apply(charges);
	system.apply(radii);

	for (atom_it = system.beginAtom(), total_charge = 0.0f; +atom_it; ++atom_it)
	{
		total_charge += atom_it->getCharge();
	}
	TEST_REAL_EQUAL(total_charge, 0.0)
	ref_system.clear();
	hinfile.open(BALL_TEST_DATA_PATH(SerThrLysCysMet_PARSE_charges.hin));
	hinfile >> ref_system;
	hinfile.close();
	for (atom_it = system.beginAtom(), ref_atom_it = ref_system.beginAtom();
			+atom_it; ++atom_it, ++ref_atom_it)
	{
		TEST_REAL_EQUAL(atom_it->getCharge(), ref_atom_it->getCharge())
	}
RESULT


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