38{
40
41 std::string testFile = "results/MyTestOut1.glf";
42
44
45
49
50
51 bool caughtException = false;
52 try
53 {
55 }
56 catch (std::exception& e)
57 {
58 caughtException = true;
59 }
60 assert(caughtException);
61
62
63 caughtException = false;
64 try
65 {
67 }
68 catch (std::exception& e)
69 {
70 caughtException = true;
71 }
72 assert(caughtException);
73
74
75 writeHeader(glfOut, 1);
76
77
78 caughtException = false;
79 try
80 {
82 }
83 catch (std::exception& e)
84 {
85 caughtException = true;
86 }
87 assert(caughtException);
88
89
90
91 writeRefSection1(glfOut);
92
93
94 caughtException = false;
95 try
96 {
98 }
99 catch (std::exception& e)
100 {
101 caughtException = true;
102 }
103 assert(caughtException);
104
105 writeSec1Record1(glfOut);
106
107 caughtException = false;
108 try
109 {
111 }
112 catch (std::exception& e)
113 {
114 caughtException = true;
115 }
116 assert(caughtException);
117
118 writeSec1Record2(glfOut);
119 writeEndMarker(glfOut);
120
121 writeRefSection2(glfOut);
122 writeSec2Record1(glfOut);
123 writeEndMarker(glfOut);
124
125
126
128
129
130
133
134 readHeader(glfIn, 1);
135 readRefSection1(glfIn);
136 readSec1Record1(glfIn);
137 readSec1Record2(glfIn);
138 readEndMarker(glfIn);
139 readRefSection2(glfIn);
140 readSec2Record1(glfIn);
141 readEndMarker(glfIn);
142 checkEOF(glfIn);
143
144
145
146 testFile = "results/MyTestOut2.glf";
148
149 writeHeader(glfOut, 2);
150 writeRefSection1(glfOut);
151 writeSec1Record1(glfOut);
152 writeSec1Record2(glfOut);
153
154 writeRefSection2(glfOut);
155 writeSec2Record1(glfOut);
156
158
159
160
162
163 readHeader(glfIn, 2);
164 readRefSection1(glfIn);
165 readSec1Record1(glfIn);
166 readSec1Record2(glfIn);
167 readEndMarker(glfIn);
168 readRefSection2(glfIn);
169 readSec2Record1(glfIn);
170 readEndMarker(glfIn);
171 checkEOF(glfIn);
172
173
174
175
176 testFile = "results/MyTestOut3.glf";
177 {
180
181 writeHeader(glfOutScoped, 3);
182 writeRefSection1(glfOutScoped);
183 writeSec1Record1(glfOutScoped);
184 writeSec1Record2(glfOutScoped);
185
186 writeRefSection2(glfOutScoped);
187 writeSec2Record1(glfOutScoped);
188
189
190 }
191
192
194
195
196 caughtException = false;
197 try
198 {
200 }
201 catch (std::exception& e)
202 {
203 caughtException = true;
204 }
205 assert(caughtException);
206
207
208 caughtException = false;
209 try
210 {
212 }
213 catch (std::exception& e)
214 {
215 caughtException = true;
216 }
217 assert(caughtException);
218
219 readHeader(glfIn, 3);
220
221
222 caughtException = false;
223 try
224 {
226 }
227 catch (std::exception& e)
228 {
229 caughtException = true;
230 }
231 assert(caughtException);
232
233
234 caughtException = false;
235 try
236 {
238 }
239 catch (std::exception& e)
240 {
241 caughtException = true;
242 }
243 assert(caughtException);
244
245 readRefSection1(glfIn);
246 readSec1Record1(glfIn);
247 readSec1Record2(glfIn);
248 readEndMarker(glfIn);
249 readRefSection2(glfIn);
250 readSec2Record1(glfIn);
251 readEndMarker(glfIn);
252 checkEOF(glfIn);
253
254
255
256
258
259 readHeader(glfIn, 3);
260 readRefSection1(glfIn);
261 readRefSection2(glfIn);
262 readSec2Record1(glfIn);
263 readEndMarker(glfIn);
264 checkEOF(glfIn);
265
266
267}
This class allows a user to easily read/write a GLF file.
bool getNextRefSection(GlfRefSection &refSection)
Gets the next reference section from the file & stores it in the passed in section,...
bool writeRefSection(const GlfRefSection &refSection)
Write the reference section to the file, adding an end marker record if there is a previous section a...
bool openForWrite(const char *filename, bool compressed=true)
Open a glf file for writing with the specified filename.
bool getNextRecord(GlfRecord &record)
Gets the nextrecord from the file & stores it in the passed in record.
bool openForRead(const char *filename)
Open a glf file for reading with the specified filename.
void close()
Close the file if there is one open, adding an end marker record if there is a previous section and o...
bool writeHeader(GlfHeader &header)
Writes the specified header into the file.
bool readHeader(GlfHeader &header)
Reads the header section from the file and stores it in the passed in header.
bool writeRecord(const GlfRecord &record)
Writes the specified record into the file.
This class allows a user to easily get/set the fields in a GLF record.
This class allows a user to easily get/set the fields in a GLF section/chromosome header.