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 explicit SamReadGroupDictionary(const SamReadGroupDictionary& other);
33 ~SamReadGroupDictionary(void);
35 // query/modify read group data
38 void Add(const SamReadGroup& readGroup);
39 void Add(const std::string& readGroupIds);
41 // add multiple read groups
42 void Add(const std::vector<SamReadGroup>& readGroups);
43 void Add(const std::vector<std::string>& readGroupIds);
45 // clear all read groups records
48 // returns true if dictionary contains this read group
49 bool Contains(const SamReadGroup& readGroup) const;
50 bool Contains(const std::string& readGroupId) const;
52 // returns true if dictionary is empty
53 bool IsEmpty(void) const;
55 // remove a single read group (does nothing if read group not found)
56 void Remove(const SamReadGroup& readGroup);
57 void Remove(const std::string& readGroupId);
59 // remove multiple read groups
60 void Remove(const std::vector<SamReadGroup>& readGroups);
61 void Remove(const std::vector<std::string>& readGroupIds);
63 // returns size of dictionary (number of current elements)
66 // retrieves the SamReadGroup object associated with this ID
67 // if readGroupId is unknown, a new SamReadGroup is created with this ID (and no other data)
68 // and a reference to this new read group entry is returned (like std::map)
70 // * To avoid these partial entries being created, it is recommended to check
71 // for existence first using Contains()
72 SamReadGroup& operator[](const std::string& readGroupId);
74 // retrieve read group iterators
75 // these are typedefs for STL iterators and thus are compatible with STL containers/algorithms
77 SamReadGroupIterator Begin(void);
78 SamReadGroupConstIterator Begin(void) const;
79 SamReadGroupConstIterator ConstBegin(void) const;
80 SamReadGroupIterator End(void);
81 SamReadGroupConstIterator End(void) const;
82 SamReadGroupConstIterator ConstEnd(void) const;
86 int IndexOf(const SamReadGroup& readGroup) const;
87 int IndexOf(const std::string& readGroupId) const;
91 SamReadGroupContainer m_data;
94 } // namespace BamTools
96 #endif // SAM_READGROUP_DICTIONARY