bpp-seq3  3.0.0
ProbabilisticSequence.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: The Bio++ Development Group
2 //
3 // SPDX-License-Identifier: CECILL-2.1
4 
5 #ifndef BPP_SEQ_PROBABILISTICSEQUENCE_H
6 #define BPP_SEQ_PROBABILISTICSEQUENCE_H
7 
8 
9 #include "CoreSequence.h"
11 #include <Bpp/Numeric/Table.h>
12 
13 // From the STL :
14 #include <string>
15 
16 namespace bpp
17 {
31  public virtual CoreSequenceInterface,
33 {
34 public:
35  typedef std::vector<double> ElementType;
36 
37 public:
39 
40 public:
41  virtual ProbabilisticSequenceInterface* clone() const = 0;
42 };
43 
57  public virtual ProbabilisticSequenceInterface,
58  public AbstractCoreSequence,
59  public virtual ProbabilisticSymbolList // Diamond inheritance
60 {
61 public:
71  ProbabilisticSequence(std::shared_ptr<const Alphabet>& alphabet) :
73  {}
74 
84  const std::string& name,
85  const std::vector<ProbabilisticSequence::SymbolType>& sequence,
86  std::shared_ptr<const Alphabet>& alphabet) :
88  {}
89 
101  const std::string& name,
102  const DTable& sequence,
103  std::shared_ptr<const Alphabet>& alphabet) :
106  {}
107 
118  const std::string& name,
119  const std::vector<ProbabilisticSequence::SymbolType>& sequence,
120  const Comments& comments,
121  std::shared_ptr<const Alphabet>& alphabet) :
123  AbstractCoreSequence(name, comments)
124  {}
125 
138  const std::string& name,
139  const DTable& sequence,
140  const Comments& comments,
141  std::shared_ptr<const Alphabet>& alphabet) :
143  AbstractCoreSequence(name, comments)
144  {}
145 
150  ProbabilisticSymbolList(sequence),
151  AbstractCoreSequence(sequence)
152  {}
153 
154 
161  {
164  return *this;
165  }
166 
167 
173  ProbabilisticSequence* clone() const override
174  {
175  return new ProbabilisticSequence(*this);
176  }
177 
182  // class destructor
184 
185 public:
186  /*
187  * @brief append or remove lines at the bottom (ie end of the
188  * sequence) to fit newSize.
189  *
190  * Additional characters are gaps, ie vectors of 0
191  */
192 
193  void setToSizeR(size_t newSize) override;
194 
195  /*
196  * @brief append or remove lines at the top (ie start of the
197  * sequence) to fit newSize.
198  *
199  * Additional characters are gaps, ie vectors of 0
200  */
201 
202  void setToSizeL(size_t newSize) override;
203 
204  double getStateValueAt(size_t sitePosition, int state) const override
205  {
206  if (sitePosition >= size()) throw IndexOutOfBoundsException("ProbabilisticSequence::getStateValueAt.", sitePosition, 0, size() - 1);
207  return (*this)[sitePosition][static_cast<size_t>(state)];
208  }
209 };
210 } // end of namespace bpp
211 #endif // BPP_SEQ_PROBABILISTICSEQUENCE_H
A partial implementation of the CoreSequence interface.
Definition: CoreSequence.h:98
AbstractCoreSequence & operator=(const AbstractCoreSequence &s)
Definition: CoreSequence.h:134
The core sequence interface.
Definition: CoreSequence.h:28
The probabilistic sequence interface.
virtual ProbabilisticSequenceInterface * clone() const =0
A basic implementation of the ProbabilisticSequence interface.
void setToSizeL(size_t newSize) override
Set up the size of a sequence from the left side.
ProbabilisticSequence(const ProbabilisticSequence &sequence)
The copy constructor.
double getStateValueAt(size_t sitePosition, int state) const override
get value of a state at a position
ProbabilisticSequence(const std::string &name, const std::vector< ProbabilisticSequence::SymbolType > &sequence, const Comments &comments, std::shared_ptr< const Alphabet > &alphabet)
Direct constructor : build a ProbabilisticSequence object from a vector.
ProbabilisticSequence(const std::string &name, const DTable &sequence, const Comments &comments, std::shared_ptr< const Alphabet > &alphabet)
Direct constructor : build a ProbabilisticSequence object from a DTable.
void setToSizeR(size_t newSize) override
Set up the size of a sequence from the right side.
ProbabilisticSequence & operator=(const ProbabilisticSequence &sequence)
The assignment operator.
ProbabilisticSequence(std::shared_ptr< const Alphabet > &alphabet)
Empty constructor : build a void ProbabilisticSequence with just an Alphabet.
ProbabilisticSequence(const std::string &name, const std::vector< ProbabilisticSequence::SymbolType > &sequence, std::shared_ptr< const Alphabet > &alphabet)
Direct constructor : build a ProbabilisticSequence object from a vector.
ProbabilisticSequence * clone() const override
ProbabilisticSequence(const std::string &name, const DTable &sequence, std::shared_ptr< const Alphabet > &alphabet)
Direct constructor : build a ProbabilisticSequence object from Table<double>.
The ProbabilisticSymbolList interface.
ProbabilisticSymbolList object.
ProbabilisticSymbolList & operator=(const ProbabilisticSymbolListInterface &list)
The generic assignment operator.
size_t size() const override
Get the number of elements in the list.
const Alphabet & alphabet() const override
Get the alphabet associated to the list.
This alphabet is used to deal NumericAlphabet.
std::vector< std::string > Comments
Declaration of Comments type.
Definition: Commentable.h:21