bpp-seq  2.2.0
AbstractSequenceContainer.h
Go to the documentation of this file.
1 //
2 // File AbstractSequenceContainer.h
3 // Created by: Guillaume Deuchst
4 // Julien Dutheil
5 //
6 
7 /*
8 Copyright or © or Copr. Bio++ Development Team, (November 17, 2004)
9 
10 This software is a computer program whose purpose is to provide classes
11 for sequences analysis.
12 
13 This software is governed by the CeCILL license under French law and
14 abiding by the rules of distribution of free software. You can use,
15 modify and/ or redistribute the software under the terms of the CeCILL
16 license as circulated by CEA, CNRS and INRIA at the following URL
17 "http://www.cecill.info".
18 
19 As a counterpart to the access to the source code and rights to copy,
20 modify and redistribute granted by the license, users are provided only
21 with a limited warranty and the software's author, the holder of the
22 economic rights, and the successive licensors have only limited
23 liability.
24 
25 In this respect, the user's attention is drawn to the risks associated
26 with loading, using, modifying and/or developing or reproducing the
27 software by the user in light of its specific status of free software,
28 that may mean that it is complicated to manipulate, and that also
29 therefore means that it is reserved for developers and experienced
30 professionals having in-depth computer knowledge. Users are therefore
31 encouraged to load and test the software's suitability as regards their
32 requirements in conditions enabling the security of their systems and/or
33 data to be ensured and, more generally, to use and operate it in the
34 same conditions as regards security.
35 
36 The fact that you are presently reading this means that you have had
37 knowledge of the CeCILL license and that you accept its terms.
38 */
39 
40 #ifndef _ABSTRACTSEQUENCECONTAINER_H_
41 #define _ABSTRACTSEQUENCECONTAINER_H_
42 
43 #include "../Alphabet/Alphabet.h"
44 #include "../Sequence.h"
45 #include "SequenceContainer.h"
47 #include <Bpp/Exceptions.h>
48 
49 namespace bpp
50 {
51 
58  public virtual OrderedSequenceContainer
59 {
60  private:
61 
66 
71 
72  public:
73 
82  alphabet_(alpha), comments_() {}
83 
86 
88  {
89  alphabet_ = sc.alphabet_;
90  comments_ = sc.comments_;
91  return *this;
92  }
93 
101 
108  {
109  alphabet_ = sc.getAlphabet();
111  return *this;
112  }
113 
115 
116  public:
117 
123  const Alphabet* getAlphabet() const { return alphabet_; }
124  const std::vector<int>& getContent(const std::string& name) const throw (SequenceNotFoundException)
125  {
126  return getSequence(name).getContent();
127  }
128 
129  std::string toString(const std::string& name) const throw (SequenceNotFoundException)
130  {
131  return getSequence(name).toString();
132  }
133 
134  const Comments& getComments(const std::string& name) const throw (SequenceNotFoundException)
135  {
136  return getSequence(name).getComments();
137  }
138 
139  void setComments(const std::string& name, const Comments& comments) throw (SequenceNotFoundException);
141  {
142  return comments_;
143  }
144 
145  void setGeneralComments(const Comments& comments)
146  {
147  comments_ = comments;
148  }
149 
151  {
152  comments_.clear();
153  }
154 
162  virtual const std::string& getName(size_t sequenceIndex) const throw (IndexOutOfBoundsException)
163  {
164  return getSequence(sequenceIndex).getName();
165  }
166 
167  virtual const std::vector<int>& getContent(size_t sequenceIndex) const throw (IndexOutOfBoundsException)
168  {
169  return getSequence(sequenceIndex).getContent();
170  }
171 
172  virtual std::string toString(size_t sequenceIndex) const throw (IndexOutOfBoundsException)
173  {
174  return getSequence(sequenceIndex).toString();
175  }
176 
177  virtual const Comments& getComments(size_t sequenceIndex) const throw (IndexOutOfBoundsException)
178  {
179  return getSequence(sequenceIndex).getComments();
180  }
181 
182  virtual void setComments(size_t sequenceIndex, const Comments& comments) throw (IndexOutOfBoundsException) = 0;
185 };
186 
187 } //end of namespace bpp.
188 
189 #endif // _ABSTRACTSEQUENCECONTAINER_H_
190 
Exception thrown when a sequence is not found The sequence not found exception base class...
std::vector< std::string > Comments
Declaration of Comments type.
Definition: Sequence.h:60
void setComments(const std::string &name, const Comments &comments)
Set the comments of a particular sequence.
const std::vector< int > & getContent(const std::string &name) const
Get the content of a sequence.
The OrderedSequenceContainer interface.
This alphabet is used to deal NumericAlphabet.
const Alphabet * getAlphabet() const
Get sequence container&#39;s alphabet.
The Alphabet interface.
Definition: Alphabet.h:130
AbstractSequenceContainer(const AbstractSequenceContainer &sc)
virtual const Comments & getComments(size_t sequenceIndex) const
Get comments of a particular sequence.
void deleteGeneralComments()
Delete the comments associated to this container.
AbstractSequenceContainer & operator=(const AbstractSequenceContainer &sc)
Partial implementation of the OrderedSequenceContainer interface.
virtual const std::string & getName() const =0
Get the name of this sequence.
const Comments & getGeneralComments() const
Get the comments of this container.
virtual const Sequence & getSequence(size_t sequenceIndex) const =0
Retrieve a sequence object from the container.
virtual std::string toString(size_t sequenceIndex) const
Convert a particular sequence to a string.
virtual const std::vector< int > & getContent(size_t sequenceIndex) const
Get the content of a sequence.
virtual const Comments & getGeneralComments() const =0
Get the comments of this container.
virtual const Comments & getComments() const =0
Get the comments associated to this sequence.
AbstractSequenceContainer(const Alphabet *alpha)
This constructor initialize the alphabet pointer.
virtual const std::string & getName(size_t sequenceIndex) const
Get the name of a particular sequence.
virtual const std::vector< int > & getContent() const =0
Get the whole content of the list as a vector of int.
Comments comments_
The container&#39;s comments.
virtual std::string toString() const =0
Convert the list as a string.
AbstractSequenceContainer(const SequenceContainer &sc)
Copy constructor from any SequenceContainer object.
virtual const Alphabet * getAlphabet() const =0
Get sequence container&#39;s alphabet.
std::string toString(const std::string &name) const
Convert a particular sequence to a string.
const Alphabet * alphabet_
The container&#39;s alphabet.
The SequenceContainer interface.
void setGeneralComments(const Comments &comments)
Set the comments of this container.
AbstractSequenceContainer & operator=(const SequenceContainer &sc)
Assignation operator from any SequenceContainer object.
const Comments & getComments(const std::string &name) const
Get comments of a particular sequence.