Debian Codegraph @

libkmer/positionDB-dump.C

raw
1 #include <stdio.h>
2 #include <stdlib.h>
3
4 #include "positionDB.H"
5 #include "bio++.H"
6
7
8 void
9 positionDB::dump(char *name) {
10 uint64 sizs[4] = {_chckWidth, _pptrWidth, 1, _sizeWidth};
11 uint64 vals[4] = {0, 0, 0, 0};
12 FILE *F = fopen(name, "w");
13
14 for (uint64 h=0; h<_tableSizeInEntries; h++) {
15 uint64 st, ed;
16
17 if (_hashTable_BP) {
18 st = getDecodedValue(_hashTable_BP, h * _hashWidth, _hashWidth);
19 ed = getDecodedValue(_hashTable_BP, h * _hashWidth + _hashWidth, _hashWidth);
20 } else {
21 st = _hashTable_FW[h];
22 ed = _hashTable_FW[h+1];
23 }
24
25 fprintf(F, "B "uint64FMT" "uint64FMT"-"uint64FMT"\n", h, st, ed);
26
27 while (st < ed) {
28 uint64 cb = st * _wFin;
29
30 getDecodedValues(_buckets, cb, (_sizeWidth == 0) ? 3 : 4, sizs, vals);
31
32 fprintf(F, "%c chk="uint64HEX" pos="uint64FMT" siz="uint64FMT,
33 (vals[2] == 0) ? 'D' : 'U', vals[0], vals[1], vals[3]);
34
35 if (vals[2] == 0) {
36 uint64 pos = vals[1] * _posnWidth;
37 uint64 len = getDecodedValue(_positions, pos, _posnWidth);
38
39 for (pos += _posnWidth; len > 0; pos += _posnWidth, len--)
40 fprintf(F, " "uint64FMT, getDecodedValue(_positions, pos, _posnWidth));
41 }
42
43 fprintf(F, "\n");
44
45 st++;
46 }
47 }
48
49 fclose(F);
50 }