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