MCPcopy Create free account
hub / github.com/deweylab/RSEM / buildIndex

Function buildIndex

buildReadIndex.cpp:16–70  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14bool hasQ;
15
16void buildIndex(char* readF, int gap, bool hasQ) {
17 int nPos;
18 READ_INT_TYPE nReads;
19 bool success;
20 string line;
21 char idxF[STRLEN];
22 char buf[sizeof(nReads) + sizeof(gap) + sizeof(nPos)];
23 streampos startPos;
24
25 sprintf(idxF, "%s.ridx", readF);
26
27 ifstream fin(readF);
28 if (!fin.is_open()) { fprintf(stderr, "Cannot open %s! It may not exist.\n", readF); exit(-1); }
29 ofstream fout(idxF, ios::binary);
30
31 startPos = fout.tellp();
32 memset(buf, 0, sizeof(buf));
33 fout.write((char*)buf, sizeof(buf));
34
35 nReads = 0; nPos = 0;
36 do {
37 streampos pos = fin.tellg();
38 success = true;
39
40 success = (getline(fin, line));
41 if (!success) continue;
42 success = (getline(fin, line));
43 if (!success) continue;
44
45 if (hasQ) {
46 success = (getline(fin, line));
47 if (!success) continue;
48 success = (getline(fin, line));
49 if (!success) continue;
50 }
51
52 if (nReads % gap == 0) {
53 ++nPos;
54 fout.write((char*)&pos, sizeof(pos));
55 }
56 ++nReads;
57
58 if (verbose && nReads % 1000000 == 0) { cout<< "FIN "<< nReads<< endl; }
59 } while (success);
60
61 fout.seekp(startPos);
62 fout.write((char*)&nReads, sizeof(nReads));
63 fout.write((char*)&gap, sizeof(gap));
64 fout.write((char*)&nPos, sizeof(nPos));
65
66 fin.close();
67 fout.close();
68
69 if (verbose) { cout<< "Build Index "<< readF<< " is Done!"<< endl; }
70}
71
72int main(int argc, char* argv[]) {
73 if (argc < 5) {

Callers 1

mainFunction · 0.85

Calls 1

writeMethod · 0.45

Tested by

no test coverage detected