Egglib 2.1.11
C++ library reference manual
Container.hpp
1 /*
2  Copyright 2008-2009 Stéphane De Mita, Mathieu Siol
3 
4  This file is part of the EggLib library.
5 
6  EggLib is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  EggLib is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with EggLib. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 
21 #ifndef EGGLIB_CONTAINER_HPP
22 #define EGGLIB_CONTAINER_HPP
23 
24 
25 namespace egglib {
26 
45  class Container {
46 
47  public:
48 
52  Container();
53 
54 
58  Container(const Container& source);
59 
60 
64  Container& operator= (const Container& source);
65 
66 
83  Container(unsigned int number_of_sequences, char const* const* const cstring_array);
84 
85 
89  virtual ~Container();
90 
91 
95  virtual void clear();
96 
97 
107  virtual unsigned int append(const char* name, const char* sequence, unsigned int group=0);
108 
109 
116  virtual unsigned int remove(unsigned int pos);
117 
118 
125  virtual void name(unsigned int pos, const char* name);
126 
127 
134  virtual void sequence(unsigned int pos, const char* sequence);
135 
136 
144  virtual void appendSequence(unsigned int pos, const char* sequence);
145 
146 
156  virtual void set(unsigned int sequence, unsigned position, char ch);
157 
158 
169  virtual char get(unsigned int s, unsigned int p) const;
170 
171 
178  virtual void group(unsigned int pos, unsigned int group);
179 
180 
200  Container hslice(unsigned int a, unsigned int b) const;
201 
202 
206  unsigned int ns() const;
207 
208 
216  virtual unsigned int ls(unsigned int pos) const ;
217 
218 
226  virtual const char* name(unsigned int pos) const;
227 
228 
236  virtual const char* sequence(unsigned int pos) const;
237 
238 
239 
247  virtual unsigned int group(unsigned int pos) const;
248 
249 
256  bool isEqual() const;
257 
258 
270  unsigned int equalize(char ch='?');
271 
272 
288  int find(const char* string, bool strict=true) const;
289 
290 
291  protected:
292  // The number of sequences
293  unsigned int _ns;
294 
295  // The array of name lengths
296  unsigned int* lnames;
297 
298  // The array of names
299  char** names;
300 
301  // The array of sequences (as c-strings)
302  char** sequences;
303 
304  // The array of groups
305  unsigned int* groups;
306 
307  // Imports an array of c-strings
308  virtual void setFromSource(unsigned int number_of_sequences, const char* const* const cstring_array);
309 
310  // Constructor helper
311  virtual void copyObject(const Container&);
312 
313  // Constructor partial helper
314  virtual void getNamesAndGroups(const Container&);
315 
316  private:
317 
318  // The array of sequence lengths
319  unsigned int* lsequences;
320 
321  // Setup a valid empty object
322  virtual void init();
323  };
324 }
325 
326 #endif
virtual ~Container()
Destructor.
Definition: Container.cpp:56
virtual void set(unsigned int sequence, unsigned position, char ch)
Changes a character.
Definition: Container.cpp:281
Container hslice(unsigned int a, unsigned int b) const
Extracts a range of sequences.
Definition: Container.cpp:311
int find(const char *string, bool strict=true) const
Finds a sequence by its name.
Definition: Container.cpp:220
Handles a set of sequence alignment (aligned or not)
Definition: Container.hpp:45
Container()
Creates an empty object.
Definition: Container.cpp:32
unsigned int equalize(char ch='?')
Equalizes sequence lengths.
Definition: Container.cpp:298
virtual void clear()
Clears all content of the object.
Definition: Container.cpp:111
unsigned int ns() const
Gets the number of sequences.
Definition: Container.cpp:209
bool isEqual() const
Checks if all lengths are equal.
Definition: Container.cpp:290
virtual void name(unsigned int pos, const char *name)
Changes the name of a given sequence.
Definition: Container.cpp:259
virtual unsigned int append(const char *name, const char *sequence, unsigned int group=0)
Adds a sequence to the object.
Definition: Container.cpp:133
Container & operator=(const Container &source)
Assignment operator.
Definition: Container.cpp:43
virtual void sequence(unsigned int pos, const char *sequence)
Changes the sequence string of a given sequence.
Definition: Container.cpp:273
virtual unsigned int ls(unsigned int pos) const
Gets the length of a given sequence.
Definition: Container.cpp:214
Definition: ABC.cpp:37
virtual void appendSequence(unsigned int pos, const char *sequence)
Appends a string to the a given sequence.
Definition: Container.cpp:197
virtual void group(unsigned int pos, unsigned int group)
Changes the group index of a given sequence.
Definition: Container.cpp:267

Hosted by 
Get EggLib at SourceForge.net. Fast, secure and Free Open Source software downloads