1 // ***************************************************************************
2 // SamSequenceDictionary.h (c) 2010 Derek Barnett
3 // Marth Lab, Department of Biology, Boston College
4 // All rights reserved.
5 // ---------------------------------------------------------------------------
6 // Last modified: 18 April 2011
7 // ---------------------------------------------------------------------------
8 // Provides methods for operating on a collection of SamSequence entries.
9 // ***************************************************************************
11 #ifndef SAM_SEQUENCE_DICTIONARY_H
12 #define SAM_SEQUENCE_DICTIONARY_H
14 #include <api/api_global.h>
15 #include <api/SamSequence.h>
22 typedef std::vector<SamSequence> SamSequenceContainer;
23 typedef SamSequenceContainer::iterator SamSequenceIterator;
24 typedef SamSequenceContainer::const_iterator SamSequenceConstIterator;
26 class API_EXPORT SamSequenceDictionary {
30 SamSequenceDictionary(void);
31 SamSequenceDictionary(const SamSequenceDictionary& other);
32 ~SamSequenceDictionary(void);
34 // query/modify sequence data
37 void Add(const SamSequence& sequence);
38 void Add(const std::string& name, const int& length);
40 // adds multiple sequences
41 void Add(const std::vector<SamSequence>& sequences);
42 void Add(const std::map<std::string, int>& sequenceMap);
44 // clears all sequence entries
47 // returns true if dictionary contains this sequence
48 bool Contains(const SamSequence& sequence) const;
49 bool Contains(const std::string& sequenceName) const;
51 // returns true if dictionary is empty
52 bool IsEmpty(void) const;
54 // removes sequence, if found
55 void Remove(const SamSequence& sequence);
56 void Remove(const std::string& sequenceName);
58 // removes multiple sequences
59 void Remove(const std::vector<SamSequence>& sequences);
60 void Remove(const std::vector<std::string>& sequenceNames);
62 // returns number of sequences in dictionary
65 // retrieves a modifiable reference to the SamSequence object associated with this name
66 SamSequence& operator[](const std::string& sequenceName);
68 // retrieve STL-compatible iterators
70 SamSequenceIterator Begin(void); // returns iterator to begin()
71 SamSequenceConstIterator Begin(void) const; // returns const_iterator to begin()
72 SamSequenceConstIterator ConstBegin(void) const; // returns const_iterator to begin()
73 SamSequenceIterator End(void); // returns iterator to end()
74 SamSequenceConstIterator End(void) const; // returns const_iterator to end()
75 SamSequenceConstIterator ConstEnd(void) const; // returns const_iterator to end()
79 int IndexOf(const std::string& name) const;
83 SamSequenceContainer m_data;
86 } // namespace BamTools
88 #endif // SAM_SEQUENCE_DICTIONARY_H