A toolkit for working with phylogenetic data.
v0.20.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 // Abundance
80 // -----------------------------------------------------
81 
82 size_t Sequence::abundance() const
83 {
84  return abundance_;
85 }
86 
87 void Sequence::abundance( size_t value )
88 {
89  abundance_ = value;
90 }
91 
92 // -----------------------------------------------------
93 // Clear
94 // -----------------------------------------------------
95 
97 {
98  label_ = "";
99  sites_ = "";
100 }
101 
102 // ================================================================================================
103 // Accessors
104 // ================================================================================================
105 
106 size_t Sequence::length() const
107 {
108  return sites_.size();
109 }
110 
111 size_t Sequence::size() const
112 {
113  return sites_.size();
114 }
115 
116 char& Sequence::site_at( size_t index )
117 {
118  return sites_.at(index);
119 }
120 
121 char Sequence::site_at( size_t index ) const
122 {
123  return sites_.at(index);
124 }
125 
126 char& Sequence::operator [] (size_t index)
127 {
128  return sites_[index];
129 }
130 
131 char Sequence::operator [] (size_t index) const
132 {
133  return sites_[index];
134 }
135 
136 // =============================================================================
137 // Iterators
138 // =============================================================================
139 
141 {
142  return sites_.begin();
143 }
144 
146 {
147  return sites_.end();
148 }
149 
151 {
152  return sites_.cbegin();
153 }
154 
156 {
157  return sites_.cend();
158 }
159 
161 {
162  return sites_.cbegin();
163 }
164 
166 {
167  return sites_.cend();
168 }
169 
170 } // namespace sequence
171 } // namespace genesis
size_t abundance() const
Definition: sequence.cpp:82
size_t size() const
Alias for length().
Definition: sequence.cpp:111
std::string::const_iterator const_iterator
size_t length() const
Return the length (number of sites) of this sequence.
Definition: sequence.cpp:106
std::string const & sites() const
Definition: sequence.cpp:58
const_iterator cbegin() const
Definition: sequence.cpp:160
std::string const & label() const
Definition: sequence.cpp:44
const_iterator cend() const
Definition: sequence.cpp:165
char & site_at(size_t index)
Definition: sequence.cpp:116
std::string::iterator iterator
char & operator[](size_t index)
Definition: sequence.cpp:126