A toolkit for working with phylogenetic data.
v0.19.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
sequence.cpp
Go to the documentation of this file.
1 /*
2  Genesis - A toolkit for working with phylogenetic data.
3  Copyright (C) 2014-2018 Lucas Czech and HITS gGmbH
4 
5  This program is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18  Contact:
19  Lucas Czech <lucas.czech@h-its.org>
20  Exelixis Lab, Heidelberg Institute for Theoretical Studies
21  Schloss-Wolfsbrunnenweg 35, D-69118 Heidelberg, Germany
22 */
23 
32 
33 namespace genesis {
34 namespace sequence {
35 
36 // ================================================================================================
37 // Properties
38 // ================================================================================================
39 
40 // -----------------------------------------------------
41 // Label
42 // -----------------------------------------------------
43 
44 std::string const& Sequence::label() const
45 {
46  return label_;
47 }
48 
49 void Sequence::label( std::string const& value )
50 {
51  label_ = value;
52 }
53 
54 // -----------------------------------------------------
55 // Sites
56 // -----------------------------------------------------
57 
58 std::string const& Sequence::sites() const
59 {
60  return sites_;
61 }
62 
63 void Sequence::sites( std::string const& value )
64 {
65  sites_ = value;
66 }
67 
68 void Sequence::sites( std::string && value )
69 {
70  sites_ = std::move(value);
71 }
72 
73 std::string& Sequence::sites()
74 {
75  return sites_;
76 }
77 
78 // -----------------------------------------------------
79 // Clear
80 // -----------------------------------------------------
81 
83 {
84  label_ = "";
85  sites_ = "";
86 }
87 
88 // ================================================================================================
89 // Accessors
90 // ================================================================================================
91 
92 size_t Sequence::length() const
93 {
94  return sites_.size();
95 }
96 
97 size_t Sequence::size() const
98 {
99  return sites_.size();
100 }
101 
102 char& Sequence::site_at( size_t index )
103 {
104  return sites_.at(index);
105 }
106 
107 char Sequence::site_at( size_t index ) const
108 {
109  return sites_.at(index);
110 }
111 
112 char& Sequence::operator [] (size_t index)
113 {
114  return sites_[index];
115 }
116 
117 char Sequence::operator [] (size_t index) const
118 {
119  return sites_[index];
120 }
121 
122 // =============================================================================
123 // Iterators
124 // =============================================================================
125 
127 {
128  return sites_.begin();
129 }
130 
132 {
133  return sites_.end();
134 }
135 
137 {
138  return sites_.cbegin();
139 }
140 
142 {
143  return sites_.cend();
144 }
145 
147 {
148  return sites_.cbegin();
149 }
150 
152 {
153  return sites_.cend();
154 }
155 
156 } // namespace sequence
157 } // namespace genesis
size_t size() const
Alias for length().
Definition: sequence.cpp:97
std::string::const_iterator const_iterator
size_t length() const
Return the length (number of sites) of this sequence.
Definition: sequence.cpp:92
std::string const & sites() const
Definition: sequence.cpp:58
const_iterator cbegin() const
Definition: sequence.cpp:146
std::string const & label() const
Definition: sequence.cpp:44
const_iterator cend() const
Definition: sequence.cpp:151
char & site_at(size_t index)
Definition: sequence.cpp:102
std::string::iterator iterator
char & operator[](size_t index)
Definition: sequence.cpp:112