Ignore:
Timestamp:
Mar 9, 2016, 9:26:38 AM (7 years ago)
Author:
Peter
Message:

add functionality to access which RG IDs that are present in a BamHeader?

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/yat/omic/BamHeader.cc

    r3423 r3477  
    8181                                      const std::string& id,
    8282                                      const std::string& key) const
     83  {
     84    update_group(table, type);
     85    strMap2::const_iterator line_table = table.find(id);
     86    if (line_table == table.end()) {
     87      std::string msg = "@" + type + ": unknown ID: '" + id + "'";
     88      throw utility::runtime_error(msg);
     89    }
     90    strMap::const_iterator it = line_table->second.find(key);
     91    if (it == line_table->second.end()) {
     92      std::string msg = "@" + type + ": unknown KEY: '" + key + "'";
     93      throw utility::runtime_error(msg);
     94    }
     95    return it->second;
     96  }
     97
     98
     99  void BamHeader::update_group(strMap2& table, const std::string& type) const
    83100  {
    84101    assert(type.size()==2);
     
    101118      }
    102119    }
    103     strMap2::const_iterator line_table = table.find(id);
    104     if (line_table == table.end()) {
    105       std::string msg = "@" + type + ": unknown ID: '" + id + "'";
    106       throw utility::runtime_error(msg);
    107     }
    108     strMap::const_iterator it = line_table->second.find(key);
    109     if (it == line_table->second.end()) {
    110       std::string msg = "@" + type + ": unknown KEY: '" + key + "'";
    111       throw utility::runtime_error(msg);
    112     }
    113     return it->second;
    114120  }
    115121
     
    156162  {
    157163    return group(read_group_, "RG", id, key);
     164  }
     165
     166
     167  const std::map<std::string, std::string>&
     168  BamHeader::read_group(const std::string& id) const
     169  {
     170    update_group(read_group_, "RG");
     171    strMap2::const_iterator line_table = read_group_.find(id);
     172    if (line_table == read_group_.end()) {
     173      std::string msg = "@RG: unknown ID: '" + id + "'";
     174      throw utility::runtime_error(msg);
     175    }
     176    return line_table->second;
     177  }
     178
     179
     180  BamHeader::read_group_iterator BamHeader::read_group_begin(void) const
     181  {
     182    update_group(read_group_, "RG");
     183    BamHeader::strMap2::const_iterator it(read_group_.begin());
     184    return utility::pair_first_iterator(it);
     185  }
     186
     187
     188  BamHeader::read_group_iterator BamHeader::read_group_end(void) const
     189  {
     190    update_group(read_group_, "RG");
     191    BamHeader::strMap2::const_iterator it(read_group_.end());
     192    return utility::pair_first_iterator(it);
    158193  }
    159194
Note: See TracChangeset for help on using the changeset viewer.