BamTools  2.5.1
SamReadGroupDictionary.h
Go to the documentation of this file.
1 // ***************************************************************************
2 // SamReadGroupDictionary.h (c) 2010 Derek Barnett
3 // Marth Lab, Department of Biology, Boston College
4 // ---------------------------------------------------------------------------
5 // Last modified: 16 October 2011 (DB)
6 // ---------------------------------------------------------------------------
7 // Provides methods for operating on a collection of SamReadGroup entries.
8 // ***************************************************************************
9 
10 #ifndef SAM_READGROUP_DICTIONARY_H
11 #define SAM_READGROUP_DICTIONARY_H
12 
13 #include <cstddef>
14 #include <map>
15 #include <string>
16 #include <vector>
17 #include "api/SamReadGroup.h"
18 #include "api/api_global.h"
19 
20 namespace BamTools {
21 
22 typedef std::vector<SamReadGroup> SamReadGroupContainer;
23 typedef SamReadGroupContainer::iterator SamReadGroupIterator;
24 typedef SamReadGroupContainer::const_iterator SamReadGroupConstIterator;
25 
27 {
28 
29  // ctor & dtor
30 public:
34 
35  // query/modify read group data
36 public:
37  // adds a read group
38  void Add(const SamReadGroup& readGroup);
39  void Add(const std::string& readGroupId);
40 
41  // adds multiple read groups
42  void Add(const SamReadGroupDictionary& readGroups);
43  void Add(const std::vector<SamReadGroup>& readGroups);
44  void Add(const std::vector<std::string>& readGroupIds);
45 
46  // clears all read group entries
47  void Clear();
48 
49  // returns true if dictionary contains this read group
50  bool Contains(const SamReadGroup& readGroup) const;
51  bool Contains(const std::string& readGroupId) const;
52 
53  // returns true if dictionary is empty
54  bool IsEmpty() const;
55 
56  // removes read group, if found
57  void Remove(const SamReadGroup& readGroup);
58  void Remove(const std::string& readGroupId);
59 
60  // removes multiple read groups
61  void Remove(const std::vector<SamReadGroup>& readGroups);
62  void Remove(const std::vector<std::string>& readGroupIds);
63 
64  // returns number of read groups in dictionary
65  int Size() const;
66 
67  // retrieves a modifiable reference to the SamReadGroup object associated with this ID
68  SamReadGroup& operator[](const std::string& readGroupId);
69 
70  // retrieve STL-compatible iterators
71 public:
72  SamReadGroupIterator Begin(); // returns iterator to begin()
73  SamReadGroupConstIterator Begin() const; // returns const_iterator to begin()
74  SamReadGroupConstIterator ConstBegin() const; // returns const_iterator to begin()
75  SamReadGroupIterator End(); // returns iterator to end()
76  SamReadGroupConstIterator End() const; // returns const_iterator to end()
77  SamReadGroupConstIterator ConstEnd() const; // returns const_iterator to end()
78 
79  // data members
80 private:
81  SamReadGroupContainer m_data;
82  std::map<std::string, std::size_t> m_lookupData;
83 };
84 
85 } // namespace BamTools
86 
87 #endif // SAM_READGROUP_DICTIONARY_H
#define API_EXPORT
Definition: api_global.h:18
Container of SamReadGroup entries.
Definition: SamReadGroupDictionary.h:27
Contains all BamTools classes & methods.
Definition: Sort.h:24
SamReadGroupContainer::const_iterator SamReadGroupConstIterator
Definition: SamReadGroupDictionary.h:24
std::vector< SamReadGroup > SamReadGroupContainer
Definition: SamReadGroupDictionary.h:22
SamReadGroupContainer::iterator SamReadGroupIterator
Definition: SamReadGroupDictionary.h:23
Represents a SAM read group entry.
Definition: SamReadGroup.h:21