1 // ***************************************************************************
2 // SamReadGroupDictionary.h (c) 2010 Derek Barnett
3 // Marth Lab, Department of Biology, Boston College
4 // All rights reserved.
5 // ---------------------------------------------------------------------------
6 // Last modified: 23 December 2010 (DB)
7 // ---------------------------------------------------------------------------
8 // Provides container operations for collection of read group entries
9 // *************************************************************************
11 #ifndef SAM_READGROUP_DICTIONARY_H
12 #define SAM_READGROUP_DICTIONARY_H
14 #include <api/api_global.h>
15 #include <api/SamReadGroup.h>
21 typedef std::vector<SamReadGroup> SamReadGroupContainer;
22 typedef SamReadGroupContainer::iterator SamReadGroupIterator;
23 typedef SamReadGroupContainer::const_iterator SamReadGroupConstIterator;
26 // can access read groups using SamReadGroup object or (std::string) read group ID tag
27 class API_EXPORT SamReadGroupDictionary {
31 SamReadGroupDictionary(void);
32 ~SamReadGroupDictionary(void);
34 // query/modify read group data
37 void Add(const SamReadGroup& readGroup);
38 void Add(const std::string& readGroupIds);
40 // add multiple read groups
41 void Add(const std::vector<SamReadGroup>& readGroups);
42 void Add(const std::vector<std::string>& readGroupIds);
44 // clear all read groups records
47 // returns true if dictionary contains this read group
48 bool Contains(const SamReadGroup& readGroup) const;
49 bool Contains(const std::string& readGroupId) const;
51 // returns true if dictionary is empty
52 bool IsEmpty(void) const;
54 // remove a single read group (does nothing if read group not found)
55 void Remove(const SamReadGroup& readGroup);
56 void Remove(const std::string& readGroupId);
58 // remove multiple read groups
59 void Remove(const std::vector<SamReadGroup>& readGroups);
60 void Remove(const std::vector<std::string>& readGroupIds);
62 // returns size of dictionary (number of current elements)
65 // retrieves the SamReadGroup object associated with this ID
66 // if readGroupId is unknown, a new SamReadGroup is created with this ID (and no other data)
67 // and a reference to this new read group entry is returned (like std::map)
69 // * To avoid these partial entries being created, it is recommended to check
70 // for existence first using Contains()
71 SamReadGroup& operator[](const std::string& readGroupId);
73 // retrieve read group iterators
74 // these are typedefs for STL iterators and thus are compatible with STL containers/algorithms
76 SamReadGroupIterator Begin(void);
77 SamReadGroupConstIterator Begin(void) const;
78 SamReadGroupConstIterator ConstBegin(void) const;
79 SamReadGroupIterator End(void);
80 SamReadGroupConstIterator End(void) const;
81 SamReadGroupConstIterator ConstEnd(void) const;
85 int IndexOf(const SamReadGroup& readGroup) const;
86 int IndexOf(const std::string& readGroupId) const;
90 SamReadGroupContainer m_data;
93 } // namespace BamTools
95 #endif // SAM_READGROUP_DICTIONARY