bpp-seq  2.2.0
Sequence.h
Go to the documentation of this file.
1 //
2 // File: Sequence.h
3 // Created by: Guillaume Deuchst
4 // Julien Dutheil
5 // Created on: Tue Aug 21 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 _SEQUENCE_H_
42 #define _SEQUENCE_H_
43 
44 #include "SymbolList.h"
45 #include "SequenceExceptions.h"
46 
47 // From the STL:
48 #include <string>
49 #include <vector>
50 
51 namespace bpp
52 {
53 
60 typedef std::vector<std::string> Comments;
61 
74 class Sequence:
75  public virtual SymbolList
76 {
77  public:
78  virtual ~Sequence() {}
79 
80  public:
81 
82 #ifndef NO_VIRTUAL_COV
83  Sequence* clone() const = 0;
84 #endif
85 
97  virtual const std::string& getName() const = 0;
98 
104  virtual void setName(const std::string& name) = 0;
118  virtual const Comments& getComments() const = 0;
119 
125  virtual void setComments(const Comments& comments) = 0;
126 
141  virtual void setContent(const std::string& sequence) throw (BadCharException) = 0;
142  virtual void setContent(const std::vector<int>& list) throw (BadIntException) = 0;
143  virtual void setContent(const std::vector<std::string>& list) throw (BadCharException) = 0;
144 
153  virtual void setToSizeR(size_t newSize) = 0;
154 
163  virtual void setToSizeL(size_t newSize) = 0;
164 
171  virtual void append(const std::vector<int>& content) throw (BadIntException) = 0;
172 
179  virtual void append(const std::vector<std::string>& content) throw (BadCharException) = 0;
180 
187  virtual void append(const std::string& content) throw (BadCharException) = 0;
190 };
191 
192 
208  public Sequence,
209  public BasicSymbolList
210 {
211  private:
212 
216  std::string name_;
217 
222 
223  public:
224 
233  BasicSequence(const Alphabet* alpha);
234 
247  BasicSequence(const std::string& name, const std::string& sequence, const Alphabet* alpha) throw (BadCharException);
248 
263  BasicSequence(const std::string& name, const std::string& sequence, const Comments& comments, const Alphabet* alpha) throw (BadCharException);
264 
275  BasicSequence(const std::string& name, const std::vector<std::string>& sequence, const Alphabet* alpha) throw (BadCharException);
276 
288  BasicSequence(const std::string& name, const std::vector<std::string>& sequence, const Comments& comments, const Alphabet* alpha) throw (BadCharException);
289 
297  BasicSequence(const std::string& name, const std::vector<int>& sequence, const Alphabet* alpha) throw (BadIntException);
298 
307  BasicSequence(const std::string& name, const std::vector<int>& sequence, const Comments& comments, const Alphabet* alpha) throw (BadIntException);
308 
312  BasicSequence(const Sequence& s);
313 
317  BasicSequence(const BasicSequence& s);
318 
324  BasicSequence& operator=(const Sequence& s);
325 
332 
333  virtual ~BasicSequence() {}
334 
335  public:
336 
342  BasicSequence* clone() const { return new BasicSequence(*this); }
357  const std::string& getName() const { return name_; }
358 
364  void setName(const std::string& name) { name_ = name; }
365 
379  const Comments& getComments() const { return comments_; }
380 
386  void setComments(const Comments& comments) { comments_ = comments; }
387 
403  virtual void setContent(const std::string& sequence) throw (BadCharException);
404  void setContent(const std::vector<int>& list) throw (BadIntException)
405  {
407  }
408  void setContent(const std::vector<std::string>& list) throw (BadCharException)
409  {
411  }
412 
413 
422  virtual void setToSizeR(size_t newSize);
423 
432  virtual void setToSizeL(size_t newSize);
433 
440  virtual void append(const std::vector<int>& content) throw (BadIntException);
441 
448  virtual void append(const std::vector<std::string>& content) throw (BadCharException);
449 
456  virtual void append(const std::string& content) throw (BadCharException);
457 
460 };
461 
462 } //end of namespace bpp.
463 
464 #endif // _SEQUENCE_H_
465 
const Comments & getComments() const
Get the comments associated to this sequence.
Definition: Sequence.h:379
An alphabet exception thrown when trying to specify a bad char to the alphabet.
std::vector< std::string > Comments
Declaration of Comments type.
Definition: Sequence.h:60
The SymbolList interface.
Definition: SymbolList.h:60
void setContent(const std::vector< std::string > &list)
Set the whole content of the list.
Definition: Sequence.h:408
Sequence * clone() const =0
This alphabet is used to deal NumericAlphabet.
virtual void setToSizeL(size_t newSize)
Set up the size of a sequence from the left side.
Definition: Sequence.cpp:172
The Alphabet interface.
Definition: Alphabet.h:130
virtual void setComments(const Comments &comments)=0
Set the comments associated to this sequence.
virtual const std::string & getName() const =0
Get the name of this sequence.
virtual void setName(const std::string &name)=0
Set the name of this sequence.
virtual ~BasicSequence()
Definition: Sequence.h:333
virtual ~Sequence()
Definition: Sequence.h:78
virtual void setContent(const std::vector< int > &list)
Set the whole content of the list.
Definition: SymbolList.cpp:101
Comments comments_
The sequence comments.
Definition: Sequence.h:221
std::string name_
The sequence name.
Definition: Sequence.h:216
BasicSequence * clone() const
Definition: Sequence.h:342
virtual void append(const std::vector< int > &content)=0
Append the specified content to the sequence.
A basic SymbolList object.
Definition: SymbolList.h:264
void setComments(const Comments &comments)
Set the comments associated to this sequence.
Definition: Sequence.h:386
virtual void setContent(const std::string &sequence)
Set the whole content of the sequence.
Definition: Sequence.cpp:144
virtual const Comments & getComments() const =0
Get the comments associated to this sequence.
BasicSequence & operator=(const Sequence &s)
The Sequence generic assignment operator. This does not perform a hard copy of the alphabet object...
Definition: Sequence.cpp:126
BasicSequence(const Alphabet *alpha)
Empty constructor: build a void Sequence with just an Alphabet.
Definition: Sequence.cpp:56
A basic implementation of the Sequence interface.
Definition: Sequence.h:207
const std::string & getName() const
Get the name of this sequence.
Definition: Sequence.h:357
virtual void append(const std::vector< int > &content)
Append the specified content to the sequence.
Definition: Sequence.cpp:193
virtual void setContent(const std::string &sequence)=0
Set the whole content of the sequence.
virtual void setToSizeR(size_t newSize)=0
Set up the size of a sequence from the right side.
The sequence interface.
Definition: Sequence.h:74
void setName(const std::string &name)
Set the name of this sequence.
Definition: Sequence.h:364
An alphabet exception thrown when trying to specify a bad int to the alphabet.
void setContent(const std::vector< int > &list)
Set the whole content of the list.
Definition: Sequence.h:404
virtual void setToSizeR(size_t newSize)
Set up the size of a sequence from the right side.
Definition: Sequence.cpp:153
virtual void setToSizeL(size_t newSize)=0
Set up the size of a sequence from the left side.