1 // ***************************************************************************
2 // SamReadGroupDictionary.h (c) 2010 Derek Barnett
3 // Marth Lab, Department of Biology, Boston College
4 // ---------------------------------------------------------------------------
5 // Last modified: 10 October 2011 (DB)
6 // ---------------------------------------------------------------------------
7 // Provides methods for operating on a collection of SamReadGroup entries.
8 // ***************************************************************************
10 #ifndef SAM_READGROUP_DICTIONARY_H
11 #define SAM_READGROUP_DICTIONARY_H
13 #include "api/api_global.h"
14 #include "api/SamReadGroup.h"
20 typedef std::vector<SamReadGroup> SamReadGroupContainer;
21 typedef SamReadGroupContainer::iterator SamReadGroupIterator;
22 typedef SamReadGroupContainer::const_iterator SamReadGroupConstIterator;
24 class API_EXPORT SamReadGroupDictionary {
28 SamReadGroupDictionary(void);
29 SamReadGroupDictionary(const SamReadGroupDictionary& other);
30 ~SamReadGroupDictionary(void);
32 // query/modify read group data
35 void Add(const SamReadGroup& readGroup);
36 void Add(const std::string& readGroupId);
38 // adds multiple read groups
39 void Add(const SamReadGroupDictionary& readGroups);
40 void Add(const std::vector<SamReadGroup>& readGroups);
41 void Add(const std::vector<std::string>& readGroupIds);
43 // clears all read group entries
46 // returns true if dictionary contains this read group
47 bool Contains(const SamReadGroup& readGroup) const;
48 bool Contains(const std::string& readGroupId) const;
50 // returns true if dictionary is empty
51 bool IsEmpty(void) const;
53 // removes read group, if found
54 void Remove(const SamReadGroup& readGroup);
55 void Remove(const std::string& readGroupId);
57 // removes multiple read groups
58 void Remove(const std::vector<SamReadGroup>& readGroups);
59 void Remove(const std::vector<std::string>& readGroupIds);
61 // returns number of read groups in dictionary
64 // retrieves a modifiable reference to the SamReadGroup object associated with this ID
65 SamReadGroup& operator[](const std::string& readGroupId);
67 // retrieve STL-compatible iterators
69 SamReadGroupIterator Begin(void); // returns iterator to begin()
70 SamReadGroupConstIterator Begin(void) const; // returns const_iterator to begin()
71 SamReadGroupConstIterator ConstBegin(void) const; // returns const_iterator to begin()
72 SamReadGroupIterator End(void); // returns iterator to end()
73 SamReadGroupConstIterator End(void) const; // returns const_iterator to end()
74 SamReadGroupConstIterator ConstEnd(void) const; // returns const_iterator to end()
78 int IndexOf(const std::string& readGroupId) const;
82 SamReadGroupContainer m_data;
85 } // namespace BamTools
87 #endif // SAM_READGROUP_DICTIONARY_H