annotate egglib/egglib-2.1.5/include/egglib-cpp/Container.hpp @ 15:31c23d943c29 draft default tip

Uploaded
author dereeper
date Tue, 08 Jan 2019 08:47:56 -0500
parents 420b57c3c185
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
1 /*
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
2 Copyright 2008-2009 Stéphane De Mita, Mathieu Siol
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
3
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
4 This file is part of the EggLib library.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
5
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
6 EggLib is free software: you can redistribute it and/or modify
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
7 it under the terms of the GNU General Public License as published by
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
8 the Free Software Foundation, either version 3 of the License, or
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
9 (at your option) any later version.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
10
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
11 EggLib is distributed in the hope that it will be useful,
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
14 GNU General Public License for more details.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
15
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
17 along with EggLib. If not, see <http://www.gnu.org/licenses/>.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
18 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
19
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
20
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
21 #ifndef EGGLIB_CONTAINER_HPP
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
22 #define EGGLIB_CONTAINER_HPP
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
23
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
24
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
25 namespace egglib {
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
26
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
27 /** \brief Handles a set of sequence alignment (aligned or not)
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
28 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
29 * \ingroup core
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
30 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
31 * Creation from a file or string stream should be performed using
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
32 * the class Fasta.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
33 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
34 * Sequences are represented by two strings (name and sequence) and
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
35 * an integer (group) that can be accessed or modified by index.The
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
36 * order of sequences is guaranteed to be conserved, as if Container
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
37 * was a list of triplets (name, sequence, group).
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
38 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
39 * The data matrix is implemented as continuous arrays (char**) and
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
40 * allows efficient access and modification of data. For very large
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
41 * data matrices you might claim immediately the required memory
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
42 * using the constructor Container(unsigned int, char**).
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
43 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
44 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
45 class Container {
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
46
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
47 public:
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
48
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
49 /** \brief Creates an empty object
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
50 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
51 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
52 Container();
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
53
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
54
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
55 /** \brief Copy constructor
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
56 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
57 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
58 Container(const Container& source);
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
59
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
60
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
61 /** \brief Assignment operator
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
62 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
63 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
64 Container& operator= (const Container& source);
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
65
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
66
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
67 /** \brief Creates an object from a data matrix
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
68 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
69 * Allows you to create an object from data stored in a char*
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
70 * array. The array's size must be passed to the constructor.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
71 * Since sequences can have different lengths, you need to
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
72 * terminate each sequence by a NULL character. This constructor
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
73 * is dedicated to very performance-critical tasks. For usual
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
74 * tasks, using the default constructor and subsequently adding
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
75 * sequences with addSeq should be enough.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
76 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
77 * \param number_of_sequences the number of sequences (the length
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
78 * of the first dimension of the array).
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
79 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
80 * \param cstring_array the pointer to the data matrix.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
81 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
82 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
83 Container(unsigned int number_of_sequences, char const* const* const cstring_array);
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
84
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
85
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
86 /** \brief Destructor
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
87 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
88 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
89 virtual ~Container();
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
90
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
91
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
92 /** \brief Clears all content of the object
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
93 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
94 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
95 virtual void clear();
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
96
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
97
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
98 /** \brief Adds a sequence to the object
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
99 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
100 * \param name the name of the sequence, as a c-string.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
101 * \param sequence the sequence string, as a c-string.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
102 * \param group the group index of the sequence.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
103 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
104 * \return The new number of sequences.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
105 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
106 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
107 virtual unsigned int append(const char* name, const char* sequence, unsigned int group=0);
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
108
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
109
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
110 /** \brief Removes a sequence from the object
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
111 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
112 * \param pos the index of the sequence to remove.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
113 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
114 * \return The new number of sequences.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
115 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
116 virtual unsigned int remove(unsigned int pos);
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
117
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
118
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
119 /** \brief Changes the name of a given sequence
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
120 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
121 * \param pos the sequence index.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
122 * \param name the new name as a C-like string.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
123 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
124 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
125 virtual void name(unsigned int pos, const char* name);
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
126
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
127
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
128 /** \brief Changes the sequence string of a given sequence
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
129 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
130 * \param pos the sequence index.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
131 * \param sequence the new sequence as a C-like string.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
132 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
133 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
134 virtual void sequence(unsigned int pos, const char* sequence);
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
135
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
136
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
137 /** \brief Appends a string to the a given sequence
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
138 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
139 * \param pos the sequence index.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
140 * \param sequence the sequence to append at the end of the
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
141 * current one.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
142 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
143 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
144 virtual void appendSequence(unsigned int pos, const char* sequence);
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
145
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
146
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
147 /** \brief Changes a character
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
148 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
149 * \param sequence the sequence index.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
150 * \param position the character index.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
151 * \param ch the new character value.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
152 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
153 * The positions must fit in the current ranges.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
154 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
155 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
156 virtual void set(unsigned int sequence, unsigned position, char ch);
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
157
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
158
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
159 /** \brief Gets a given character
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
160 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
161 * \param s the sequence index.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
162 * \param p the character index.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
163 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
164 * \return the character value.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
165 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
166 * The positions must fit in the current ranges.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
167 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
168 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
169 virtual char get(unsigned int s, unsigned int p) const;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
170
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
171
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
172 /** \brief Changes the group index of a given sequence
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
173 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
174 * \param pos the sequence index.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
175 * \param group the new group index value.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
176 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
177 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
178 virtual void group(unsigned int pos, unsigned int group);
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
179
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
180
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
181 /** \brief Extracts a range of sequences
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
182 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
183 * \param a the index of the first sequence.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
184 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
185 * \param b the index immediately passed the last sequence to
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
186 * extract.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
187 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
188 * \return A copy of the object containing the specified
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
189 * range of sequences.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
190 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
191 * Sequences a to b-1 are extracted, provided that the
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
192 * indices fit in the current number of sequences. To extract
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
193 * all sequences, use container.hslice(0, container.ns()).
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
194 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
195 * Note: invalid ranges will be silently supported. If
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
196 * a>=ls or b<=a, an empty object is returned. If b>ns,
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
197 * ls will be substituted to a.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
198 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
199 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
200 Container hslice(unsigned int a, unsigned int b) const;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
201
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
202
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
203 /** \brief Gets the number of sequences
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
204 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
205 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
206 unsigned int ns() const;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
207
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
208
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
209 /** \brief Gets the length of a given sequence
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
210 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
211 * \param pos the index of the sequence.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
212 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
213 * \return The length of that particular sequence.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
214 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
215 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
216 virtual unsigned int ls(unsigned int pos) const ;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
217
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
218
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
219 /** \brief Gets the name of the a given sequence
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
220 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
221 * \param pos the index of the sequence.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
222 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
223 * \return The name of that particular sequence.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
224 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
225 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
226 virtual const char* name(unsigned int pos) const;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
227
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
228
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
229 /** \brief Gets the name of a given sequence
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
230 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
231 * \param pos the index of the sequence.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
232 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
233 * \return The sequence string for that particular sequence.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
234 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
235 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
236 virtual const char* sequence(unsigned int pos) const;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
237
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
238
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
239
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
240 /** \brief Gets the group index of a given sequence
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
241 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
242 * \param pos the index of the sequence.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
243 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
244 * \return The group index of that particular sequence.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
245 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
246 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
247 virtual unsigned int group(unsigned int pos) const;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
248
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
249
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
250 /** \brief Checks if all lengths are equal
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
251 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
252 * Returns true if the length of all sequences are equal or
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
253 * if there is less thant two sequences.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
254 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
255 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
256 bool isEqual() const;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
257
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
258
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
259 /** \brief Equalizes sequence lengths
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
260 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
261 * Extends sequences as need to ensure that all sequences
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
262 * have the same length.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
263 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
264 * \param ch the character to use for padding.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
265 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
266 * \return The final length obtained, which is the length of
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
267 * the longest sequence before the operation.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
268 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
269 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
270 unsigned int equalize(char ch='?');
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
271
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
272
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
273 /** \brief Finds a sequence by its name
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
274 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
275 * Gets the position of the first sequence with the specified
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
276 * name.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
277 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
278 * \param string a sequence name.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
279 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
280 * \param strict if true, seeks an exact match. If false,
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
281 * compares only until the end of the requested name (for
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
282 * example: ATCFF will match ATCFF_01 if strict is false).
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
283 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
284 * \return The lowest index where the name matches, -1 if no
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
285 * sequence has such name.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
286 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
287 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
288 int find(const char* string, bool strict=true) const;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
289
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
290
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
291 protected:
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
292 // The number of sequences
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
293 unsigned int _ns;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
294
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
295 // The array of name lengths
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
296 unsigned int* lnames;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
297
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
298 // The array of names
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
299 char** names;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
300
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
301 // The array of sequences (as c-strings)
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
302 char** sequences;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
303
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
304 // The array of groups
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
305 unsigned int* groups;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
306
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
307 // Imports an array of c-strings
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
308 virtual void setFromSource(unsigned int number_of_sequences, const char* const* const cstring_array);
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
309
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
310 // Constructor helper
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
311 virtual void copyObject(const Container&);
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
312
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
313 // Constructor partial helper
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
314 virtual void getNamesAndGroups(const Container&);
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
315
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
316 private:
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
317
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
318 // The array of sequence lengths
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
319 unsigned int* lsequences;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
320
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
321 // Setup a valid empty object
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
322 virtual void init();
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
323 };
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
324 }
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
325
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
326 #endif