bpp-seq  2.2.0
AlignedSequenceContainer.h
Go to the documentation of this file.
1 //
2 // File AlignedSequenceContainer.h
3 // Created by: Guillaume Deuchst
4 // // Julien Dutheil
5 // Last modification : Friday August 22 2003
6 //
7 
8 /*
9 Copyright or © or Copr. Bio++ Development Team, (November 17, 2004)
10 
11 This software is a computer program whose purpose is to provide classes
12 for sequences analysis.
13 
14 This software is governed by the CeCILL license under French law and
15 abiding by the rules of distribution of free software. You can use,
16 modify and/ or redistribute the software under the terms of the CeCILL
17 license as circulated by CEA, CNRS and INRIA at the following URL
18 "http://www.cecill.info".
19 
20 As a counterpart to the access to the source code and rights to copy,
21 modify and redistribute granted by the license, users are provided only
22 with a limited warranty and the software's author, the holder of the
23 economic rights, and the successive licensors have only limited
24 liability.
25 
26 In this respect, the user's attention is drawn to the risks associated
27 with loading, using, modifying and/or developing or reproducing the
28 software by the user in light of its specific status of free software,
29 that may mean that it is complicated to manipulate, and that also
30 therefore means that it is reserved for developers and experienced
31 professionals having in-depth computer knowledge. Users are therefore
32 encouraged to load and test the software's suitability as regards their
33 requirements in conditions enabling the security of their systems and/or
34 data to be ensured and, more generally, to use and operate it in the
35 same conditions as regards security.
36 
37 The fact that you are presently reading this means that you have had
38 knowledge of the CeCILL license and that you accept its terms.
39 */
40 
41 #ifndef _ALIGNEDSEQUENCECONTAINER_H_
42 #define _ALIGNEDSEQUENCECONTAINER_H_
43 
44 #include "../Site.h"
45 #include "SiteContainer.h"
48 #include <Bpp/Exceptions.h>
49 
50 // From the STL:
51 #include <string>
52 
53 namespace bpp
54 {
55 
69  public virtual VectorSequenceContainer,
70  public virtual SiteContainer
71 {
72  private:
73  // Integer std::vector that contains sites's positions
74  std::vector<int> positions_;
75 
76  size_t length_; // Number of sites for verifications before sequence's insertion in sequence container
77 
87  mutable std::vector<Site*> sites_;
88 
89  public:
97  positions_(),
98  length_(0),
99  sites_()
100  {
101  reindexSites();
102  }
103 
112  length_(asc.getNumberOfSites()),
113  sites_(asc.getNumberOfSites())
114  {}
115 
126  {}
127 
137 
141 
142  virtual ~AlignedSequenceContainer();
143 
144  public:
145 
159  const Site& getSite(size_t siteIndex) const throw (IndexOutOfBoundsException);
160  void setSite(size_t siteIndex, const Site& site, bool checkPosition = true) throw (Exception);
161  Site * removeSite(size_t siteIndex) throw (IndexOutOfBoundsException);
162  void deleteSite(size_t siteIndex) throw (IndexOutOfBoundsException);
163  void deleteSites(size_t siteIndex, size_t length) throw (IndexOutOfBoundsException, Exception);
164  void addSite(const Site& site, bool checkPosition = true) throw (Exception);
165  void addSite(const Site& site, int position, bool checkPosition = true) throw (Exception);
166  void addSite(const Site& site, size_t siteIndex, bool checkPosition = true) throw (Exception);
167  void addSite(const Site& site, size_t siteIndex, int position, bool checkPosition = true) throw (Exception);
168  size_t getNumberOfSites() const { return length_; }
169  Vint getSitePositions() const { return positions_; }
170  void reindexSites();
171  void clear();
180  void setSequence(const std::string& name, const Sequence& sequence, bool checkName = true) throw (Exception);
181  void setSequence(size_t sequenceIndex, const Sequence& sequence, bool checkName = true) throw (Exception);
182 
183  void addSequence(const Sequence& sequence, bool checkName = true) throw (Exception);
184  void addSequence(const Sequence& sequence, size_t sequenceIndex, bool checkName = true) throw (Exception);
188  protected:
195  bool checkSize_(const Sequence& sequence) { return (sequence.size() == length_); }
196 
197 };
198 
199 } //end of namespace bpp.
200 
201 #endif // _ALIGNEDSEQUENCECONTAINER_H_
202 
Vint getSitePositions() const
Get all position attributes of sites.
const Site & getSite(size_t siteIndex) const
Get a site from the container.
AlignedSequenceContainer * clone() const
void addSite(const Site &site, bool checkPosition=true)
Add a site in the container.
The SiteContainer interface.
Definition: SiteContainer.h:63
The OrderedSequenceContainer interface.
Aligned sequences container.
This alphabet is used to deal NumericAlphabet.
void deleteSite(size_t siteIndex)
Delete a site in the container.
bool checkSize_(const Sequence &sequence)
Check sequence&#39;s size before insertion in sequence container.
The VectorSequenceContainer class.
void deleteSites(size_t siteIndex, size_t length)
Delete a continuous range of sites in the container.
The Alphabet interface.
Definition: Alphabet.h:130
size_t getNumberOfSites() const
Get the number of sites in the container.
AlignedSequenceContainer & operator=(const AlignedSequenceContainer &asc)
void setSequence(const std::string &name, const Sequence &sequence, bool checkName=true)
Replace a sequence in the container.
AlignedSequenceContainer(const AlignedSequenceContainer &asc)
Copy constructor.
void clear()
Delete all sequences in the container.
void setSite(size_t siteIndex, const Site &site, bool checkPosition=true)
Set a site in the container.
void addSequence(const Sequence &sequence, bool checkName=true)
Add a sequence at the end of the container.
Site * removeSite(size_t siteIndex)
Remove a site from the container.
AlignedSequenceContainer(const SiteContainer &sc)
Convert any SiteContainer object into a AlignedSequenceContainer object.
AlignedSequenceContainer * createEmptyContainer() const
Return a copy of this container, but with no sequence inside.
AlignedSequenceContainer(const Alphabet *alpha)
Build a new empty container with the specified alphabet.
The sequence interface.
Definition: Sequence.h:74
The Site class.
Definition: Site.h:61
void reindexSites()
Set all positions attributes.
Exception thrown when a sequence is not align with others.