#include #include #include #include using namespace std; int main(void) { // read bim file from stdin; create exclude files + list of chr*chunk* int chr, bp; double genpos; string snpID, line; vector bps; while (cin >> chr >> snpID >> genpos >> bp) { bps.push_back(bp); getline(cin, line); // get rid of rest of line } int M = bps.size(); //cout << "chr" << chr << ": " << M << " variants in bim file" << endl; const int Mchunk = 50000, minOverlap = 5000; int chunks = 1, Mcovered = Mchunk; while (Mcovered < M) { chunks++; Mcovered += Mchunk-minOverlap; } vector chunkStarts(chunks), chunkEnds(chunks); if (chunks==1) { chunkEnds[0] = M; } else { for (int c = 0; c < chunks; c++) { chunkStarts[c] = (Mchunk-minOverlap)*c - c*(Mcovered-M)/(chunks-1); chunkEnds[c] = chunkStarts[c] + Mchunk; printf("chr %2d chunk %d bpStart %9d bpEnd %9d\n", chr, c+1, bps[chunkStarts[c]], bps[chunkEnds[c]-1]); } } }