Initial check in of c++ short read programming library. These classes give functional...
[htsworkflow.git] / htswanalysis / src / SRLib / chrom_list.cpp
1 /* ChromList:
2  * Reads in a tab delimited file of the format:
3  * <chromosome> <filename>
4  */
5
6 #include <iostream>
7 #include <fstream>
8 #include <string>
9 #include <vector>
10
11 #include "chrom_list.h"
12 #include "util.h"
13
14 using namespace std;
15
16 ChromList::ChromList(char* filename) {
17   char buffer[1024]; string delim("\t");
18   ifstream chrom_file(filename);
19   while(chrom_file.getline(buffer, 1024)) {
20     string temp(buffer); 
21     vector<string> words;
22     split(temp, delim,words);
23     if(words.size() != 2) { cerr << "Error in chrom list." << endl; exit(1); }
24     (*this)[ words[0] ] = words[1]; 
25   }
26   chrom_file.close();
27 }