14 void buildIndex(char* readF, int gap, bool hasQ) {
20 char buf[sizeof(nReads) + sizeof(gap) + sizeof(nPos)];
23 sprintf(idxF, "%s.ridx", readF);
26 if (!fin.is_open()) { fprintf(stderr, "Cannot open %s! It may not exist.\n", readF); exit(-1); }
27 ofstream fout(idxF, ios::binary);
29 startPos = fout.tellp();
30 memset(buf, 0, sizeof(buf));
31 fout.write((char*)buf, sizeof(buf));
35 streampos pos = fin.tellg();
38 success = (getline(fin, line));
39 if (!success) continue;
40 success = (getline(fin, line));
41 if (!success) continue;
44 success = (getline(fin, line));
45 if (!success) continue;
46 success = (getline(fin, line));
47 if (!success) continue;
50 if (nReads % gap == 0) {
52 fout.write((char*)&pos, sizeof(pos));
56 if (verbose && nReads % 1000000 == 0) { printf("FIN %lld\n", (long long)nReads); }
60 fout.write((char*)&nReads, sizeof(nReads));
61 fout.write((char*)&gap, sizeof(gap));
62 fout.write((char*)&nPos, sizeof(nPos));
67 if (verbose) { printf("Build Index %s is Done!\n", readF); }
70 int main(int argc, char* argv[]) {
72 printf("Usage : rsem-build-read-index gap hasQ quiet readFile1, readFile2, ...\n");
78 verbose = !atoi(argv[3]);
79 for (int i = 4; i < argc; i++) {
80 buildIndex(argv[i], gap, hasQ);