]> git.donarmstrong.com Git - bamtools.git/blob - src/api/SamReadGroupDictionary.h
Merge branches 'master' and 'iodevice' into iodevice
[bamtools.git] / src / api / SamReadGroupDictionary.h
1 // ***************************************************************************
2 // SamReadGroupDictionary.h (c) 2010 Derek Barnett
3 // Marth Lab, Department of Biology, Boston College
4 // ---------------------------------------------------------------------------
5 // Last modified: 18 April 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 <api/api_global.h>
14 #include <api/SamReadGroup.h>
15 #include <string>
16 #include <vector>
17
18 namespace BamTools {
19
20 typedef std::vector<SamReadGroup>             SamReadGroupContainer;
21 typedef SamReadGroupContainer::iterator       SamReadGroupIterator;
22 typedef SamReadGroupContainer::const_iterator SamReadGroupConstIterator;
23
24 class API_EXPORT SamReadGroupDictionary {
25
26     // ctor & dtor
27     public:
28         SamReadGroupDictionary(void);
29         SamReadGroupDictionary(const SamReadGroupDictionary& other);
30         ~SamReadGroupDictionary(void);
31
32     // query/modify read group data
33     public:
34         // adds a read group
35         void Add(const SamReadGroup& readGroup);
36         void Add(const std::string& readGroupId);
37
38         // adds multiple read groups
39         void Add(const std::vector<SamReadGroup>& readGroups);
40         void Add(const std::vector<std::string>& readGroupIds);
41
42         // clears all read group entries
43         void Clear(void);
44
45         // returns true if dictionary contains this read group
46         bool Contains(const SamReadGroup& readGroup) const;
47         bool Contains(const std::string& readGroupId) const;
48
49         // returns true if dictionary is empty
50         bool IsEmpty(void) const;
51
52         // removes read group, if found
53         void Remove(const SamReadGroup& readGroup);
54         void Remove(const std::string& readGroupId);
55
56         // removes multiple read groups
57         void Remove(const std::vector<SamReadGroup>& readGroups);
58         void Remove(const std::vector<std::string>& readGroupIds);
59
60         // returns number of read groups in dictionary
61         int Size(void) const;
62
63         // retrieves a modifiable reference to the SamReadGroup object associated with this ID
64         SamReadGroup& operator[](const std::string& readGroupId);
65
66     // retrieve STL-compatible iterators
67     public:
68         SamReadGroupIterator      Begin(void);              // returns iterator to begin()
69         SamReadGroupConstIterator Begin(void) const;        // returns const_iterator to begin()
70         SamReadGroupConstIterator ConstBegin(void) const;   // returns const_iterator to begin()
71         SamReadGroupIterator      End(void);                // returns iterator to end()
72         SamReadGroupConstIterator End(void) const;          // returns const_iterator to end()
73         SamReadGroupConstIterator ConstEnd(void) const;     // returns const_iterator to end()
74
75     // internal methods
76     private:
77         int IndexOf(const std::string& readGroupId) const;
78
79     // data members
80     private:
81         SamReadGroupContainer m_data;
82 };
83
84 } // namespace BamTools
85
86 #endif // SAM_READGROUP_DICTIONARY_H