Egglib 2.1.11
C++ library reference manual
Align.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_ALIGN_HPP
22 #define EGGLIB_ALIGN_HPP
23 
24 #include "Container.hpp"
25 #include "CharMatrix.hpp"
26 #include <vector>
27 
51 namespace egglib {
52 
53 
76  class Align : public Container, public CharMatrix {
77  public:
78 
82  Align();
83 
84 
101  Align(unsigned int number_of_sequences, unsigned int alignment_length, char const * const * const cstring_array);
102 
103 
117  Align(unsigned int number_of_sequences, unsigned int alignment_length);
118 
119 
123  Align(const Align& align);
124 
125 
132  Align(const Container& container);
133 
134 
138  Align& operator=(const Align& align);
139 
140 
147  Align& operator=(const Container& container);
148 
149 
153  virtual ~Align();
154 
155 
168  virtual unsigned int append(const char* name, const char* sequence, unsigned int group=0);
169 
170 
177  virtual unsigned int removePosition(unsigned int pos);
178 
179 
186  virtual unsigned int remove(unsigned int pos);
187 
188 
198  virtual void sequence(unsigned int seq, const char* sequence);
199 
200 
208  virtual inline const char* sequence(unsigned int pos) const { return Container::sequence(pos); }
209 
210 
216  virtual unsigned int ls() const;
217 
218 
230  virtual unsigned int ls(unsigned int pos) const;
231 
232 
242  inline char character(unsigned int s, unsigned int p) const { return sequences[s][p]; }
243 
244 
255  virtual char get(unsigned int sequence, unsigned int position) const;
256 
257 
267  virtual void set(unsigned int sequence, unsigned position, char ch);
268 
269 
276  void binSwitch(unsigned int pos);
277 
278 
294  Align vslice(std::vector<unsigned int> list_of_sites);
295 
296 
315  Align vslice(unsigned int a, unsigned int b);
316 
317 
321  virtual void clear();
322 
323 
327  inline unsigned int numberOfSequences() const {
328  return _ns;
329  }
330 
331 
335  inline unsigned int numberOfSites() const {
336  return _ls;
337  }
338 
339 
343  inline unsigned int populationLabel(unsigned int sequenceIndex) const {
344  return groups[sequenceIndex];
345  }
346 
347 
351  inline double sitePosition(unsigned int position) const {
352  return (double) position;
353  }
354 
355 
356  protected:
357 
359  virtual void appendSequence(unsigned int pos, const char* sequence) {}
360 
361  // Initializer (creates a valid empty alignment)
362  virtual void init();
363 
364  // Makes a deep copy of the specified data matrix - if cstring_array is NULL, then ignores it and pads with ?'s
365  virtual void setFromSource(unsigned int number_of_sequences, unsigned int alignment_length, const char* const * const cstring_array);
366 
367  // Copies from a Container
368  virtual void copyObject(const Container&);
369 
370  // Copies from an Align
371  virtual void copyObject(const Align&);
372 
373  // Alignment length
374  unsigned int _ls;
375  };
376 }
377 
378 #endif
Align & operator=(const Align &align)
Copy operator.
Definition: Align.cpp:72
unsigned int numberOfSequences() const
Same as ns()
Definition: Align.hpp:327
virtual void set(unsigned int sequence, unsigned position, char ch)
Sets a matrix position to a new character.
Definition: Align.cpp:184
Handles a set of sequence alignment (aligned or not)
Definition: Container.hpp:45
virtual const char * sequence(unsigned int pos) const
Gets the name of a given sequence.
Definition: Align.hpp:208
Align()
Creates an empty alignment.
Definition: Align.cpp:33
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.
Definition: Align.cpp:217
virtual unsigned int removePosition(unsigned int pos)
Removes a position (column) of the alignment.
Definition: Align.cpp:283
virtual void clear()
Deletes all the content of the object.
Definition: Align.cpp:141
virtual unsigned int ls() const
Alignment length.
Definition: Align.cpp:162
unsigned int numberOfSites() const
Same as ls()
Definition: Align.hpp:335
Align vslice(std::vector< unsigned int > list_of_sites)
Extracts specified positions (columns) of the alignment.
Definition: Align.cpp:298
virtual ~Align()
Destructor.
Definition: Align.cpp:62
unsigned int populationLabel(unsigned int sequenceIndex) const
Gets a group label (insecure)
Definition: Align.hpp:343
double sitePosition(unsigned int position) const
Just return the passed value.
Definition: Align.hpp:351
virtual void sequence(unsigned int pos, const char *sequence)
Changes the sequence string of a given sequence.
Definition: Container.cpp:273
Definition: ABC.cpp:37
Handles a sequence alignment.
Definition: Align.hpp:76
char character(unsigned int s, unsigned int p) const
Fast and unsecure accessor.
Definition: Align.hpp:242
void binSwitch(unsigned int pos)
Reverse a given column in binary data.
Definition: Align.cpp:198
virtual void appendSequence(unsigned int pos, const char *sequence)
This function is not available for alignments.
Definition: Align.hpp:359
Interface for classes usable as a square matrix of characters.
Definition: CharMatrix.hpp:31
virtual void group(unsigned int pos, unsigned int group)
Changes the group index of a given sequence.
Definition: Container.cpp:267
virtual void sequence(unsigned int seq, const char *sequence)
Replace a sequence string.
Definition: Align.cpp:191

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