@@ -39,8 +39,7 @@ unordered_map<chrom_id_type, string> SimpleGenomicRegion::fw_table_out;
3939
4040chrom_id_type
4141SimpleGenomicRegion::assign_chrom (const std::string &c) {
42- unordered_map<string, chrom_id_type>::const_iterator
43- chr_id (fw_table_in.find (c));
42+ auto chr_id (fw_table_in.find (c));
4443 if (chr_id == fw_table_in.end ()) {
4544 const chrom_id_type r = fw_table_in.size ();
4645 fw_table_in[c] = r;
@@ -54,38 +53,15 @@ SimpleGenomicRegion::assign_chrom(const std::string &c) {
5453
5554string
5655SimpleGenomicRegion::retrieve_chrom (chrom_id_type i) {
57- unordered_map<chrom_id_type, string>::const_iterator chr_name (fw_table_out.find (i));
58- assert (chr_name != fw_table_out.end ());
56+ auto chr_name (fw_table_out.find (i));
57+ // assert(chr_name != fw_table_out.end());
5958 return chr_name->second ;
6059}
6160
6261
6362SimpleGenomicRegion::SimpleGenomicRegion (const GenomicRegion &r) :
6463 chrom(assign_chrom(r.get_chrom())), start(r.get_start()), end(r.get_end()) {}
6564
66- // SimpleGenomicRegion::SimpleGenomicRegion(string string_representation) {
67- // vector<string> parts = smithlab::split_whitespace_quoted(string_representation);
68-
69- // // make sure there is the minimal required info
70- // if (parts.size() < 3)
71- // throw runtime_error("Invalid string representation: " +
72- // string_representation);
73- // // set the chromosome name
74- // chrom = assign_chrom(parts[0]);
75-
76- // // set the start position
77- // const int checkChromStart = atoi(parts[1].c_str());
78- // if (checkChromStart < 0)
79- // throw runtime_error("Invalid start: " + parts[1]);
80- // else start = static_cast<size_t>(checkChromStart);
81-
82- // // set the end position
83- // const int checkChromEnd = atoi(parts[2].c_str());
84- // if (checkChromEnd < 0)
85- // throw runtime_error("Invalid end: " + parts[2]);
86- // else end = static_cast<size_t>(checkChromEnd);
87- // }
88-
8965SimpleGenomicRegion::SimpleGenomicRegion (const char *s, const size_t len) {
9066 size_t i = 0 ;
9167
@@ -182,7 +158,7 @@ unordered_map<chrom_id_type, string> GenomicRegion::fw_table_out;
182158
183159chrom_id_type
184160GenomicRegion::assign_chrom (const std::string &c) {
185- unordered_map<string, chrom_id_type>::const_iterator chr_id (fw_table_in.find (c));
161+ auto chr_id (fw_table_in.find (c));
186162 if (chr_id == fw_table_in.end ()) {
187163 const chrom_id_type r = fw_table_in.size ();
188164 fw_table_in[c] = r;
@@ -200,38 +176,6 @@ GenomicRegion::retrieve_chrom(chrom_id_type i) {
200176}
201177
202178
203- // GenomicRegion::GenomicRegion(string string_representation) : strand('+') {
204- // vector<string> parts(smithlab::split_whitespace_quoted(string_representation));
205-
206- // // make sure there is the minimal required info
207- // if (parts.size() < 3)
208- // throw runtime_error("Invalid string representation: " +
209- // string_representation);
210- // // set the chromosome name
211- // chrom = assign_chrom(parts[0]);
212-
213- // // set the start position
214- // const int checkChromStart = atoi(parts[1].c_str());
215- // if (checkChromStart < 0)
216- // throw runtime_error("Invalid start: " + parts[1]);
217- // else start = static_cast<size_t>(checkChromStart);
218-
219- // // set the end position
220- // const int checkChromEnd = atoi(parts[2].c_str());
221- // if (checkChromEnd < 0)
222- // throw runtime_error("Invalid end: " + parts[2]);
223- // else end = static_cast<size_t>(checkChromEnd);
224-
225- // if (parts.size() > 3)
226- // name = parts[3];
227-
228- // if (parts.size() > 4)
229- // score = atof(parts[4].c_str());
230-
231- // if (parts.size() > 5)
232- // strand = parts[5][0];
233- // }
234-
235179GenomicRegion::GenomicRegion (const char *s, const size_t len) {
236180 size_t i = 0 ;
237181
@@ -300,33 +244,6 @@ GenomicRegion::tostring() const {
300244 return s.str ();
301245}
302246
303- // std::ostream&
304- // operator<<(std::ostream& s, const GenomicRegion& region) {
305- // return s << region.tostring();
306- // }
307-
308- // std::istream&
309- // operator>>(std::istream& s, GenomicRegion& region) {
310- // string chrom, name;
311- // size_t start = 0ul, end = 0ul;
312- // double score = 0.0;
313- // char strand = '\0';
314-
315- // if (s >> chrom >> start >> end >> name >> score >> strand)
316- // region = GenomicRegion(chrom, start, end, name, score, strand);
317- // else region = GenomicRegion();
318-
319- // char c;
320- // while ((c = s.get()) != '\n' && s);
321-
322- // if (c != '\n')
323- // s.setstate(std::ios::badbit);
324-
325- // if (s.eof())
326- // s.setstate(std::ios::badbit);
327-
328- // return s;
329- // }
330247
331248bool
332249GenomicRegion::contains (const GenomicRegion& other) const {
@@ -438,8 +355,6 @@ separate_chromosomes(const vector<GenomicRegion>& regions,
438355}
439356
440357
441-
442-
443358static bool
444359is_header_line (const string& line) {
445360 static const char *browser_label = " browser" ;
0 commit comments