A toolkit for working with phylogenetic data.
v0.18.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-2017 Lucas Czech
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 // Metadata
56 // -----------------------------------------------------
57 
58 std::string const& Sequence::metadata() const
59 {
60  return metadata_;
61 }
62 
63 void Sequence::metadata( std::string const& value )
64 {
65  metadata_ = value;
66 }
67 
68 // -----------------------------------------------------
69 // Sites
70 // -----------------------------------------------------
71 
72 std::string const& Sequence::sites() const
73 {
74  return sites_;
75 }
76 
77 void Sequence::sites( std::string const& value )
78 {
79  sites_ = value;
80 }
81 
82 void Sequence::sites( std::string && value )
83 {
84  sites_ = std::move(value);
85 }
86 
87 std::string& Sequence::sites()
88 {
89  return sites_;
90 }
91 
92 // -----------------------------------------------------
93 // Clear
94 // -----------------------------------------------------
95 
97 {
98  label_ = "";
99  metadata_ = "";
100  sites_ = "";
101 }
102 
103 // ================================================================================================
104 // Accessors
105 // ================================================================================================
106 
107 size_t Sequence::length() const
108 {
109  return sites_.size();
110 }
111 
112 size_t Sequence::size() const
113 {
114  return sites_.size();
115 }
116 
117 char Sequence::site_at( size_t index ) const
118 {
119  return sites_.at(index);
120 }
121 
122 char Sequence::operator [] (size_t index) const
123 {
124  return sites_[index];
125 }
126 
127 // =============================================================================
128 // Iterators
129 // =============================================================================
130 
132 {
133  return sites_.begin();
134 }
135 
137 {
138  return sites_.end();
139 }
140 
142 {
143  return sites_.cbegin();
144 }
145 
147 {
148  return sites_.cend();
149 }
150 
152 {
153  return sites_.cbegin();
154 }
155 
157 {
158  return sites_.cend();
159 }
160 
161 } // namespace sequence
162 } // namespace genesis
size_t size() const
Alias for length().
Definition: sequence.cpp:112
std::string::const_iterator const_iterator
size_t length() const
Return the length (number of sites) of this sequence.
Definition: sequence.cpp:107
std::string const & sites() const
Definition: sequence.cpp:72
const_iterator cbegin() const
Definition: sequence.cpp:151
char site_at(size_t index) const
Definition: sequence.cpp:117
std::string const & label() const
Definition: sequence.cpp:44
const_iterator cend() const
Definition: sequence.cpp:156
char operator[](size_t index) const
Definition: sequence.cpp:122
std::string::iterator iterator
std::string const & metadata() const
Definition: sequence.cpp:58