bpp-seq3  3.0.0
AlphabetIndex1.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_ALPHABETINDEX_ALPHABETINDEX1_H
6 #define BPP_SEQ_ALPHABETINDEX_ALPHABETINDEX1_H
7 
8 #include <Bpp/Clonable.h>
9 
10 #include "../Alphabet/Alphabet.h"
11 #include "../Alphabet/AlphabetTools.h"
12 #include "../Alphabet/ProteicAlphabet.h"
13 
14 // From the STL:
15 #include <string>
16 
17 namespace bpp
18 {
25  public virtual Clonable
26 {
27 public:
29  virtual ~AlphabetIndex1() {}
30 
31 public:
32  virtual AlphabetIndex1* clone() const override = 0;
33 
40  virtual double getIndex(int state) const = 0;
41 
48  virtual double getIndex(const std::string& state) const = 0;
49 
55  virtual std::shared_ptr<const Alphabet> getAlphabet() const = 0;
56 
62  virtual const Alphabet& alphabet() const = 0;
63 
67  virtual const std::vector<double>& indexVector() const = 0;
68 };
69 
70 /*
71  * @brief Virtual AlphabetIndex1 for proteic alphabet
72  *
73  */
74 
76  public virtual AlphabetIndex1
77 {
78 private:
79  std::shared_ptr<const ProteicAlphabet> alpha_;
80 
81 public:
82  ProteicAlphabetIndex1() : alpha_(AlphabetTools::PROTEIN_ALPHABET) {}
84 
85  virtual ProteicAlphabetIndex1* clone() const override = 0;
86 
88  alpha_(pt.alpha_)
89  {}
90 
92  {
93  alpha_ = pt.alpha_;
94  return *this;
95  }
96 
97  std::shared_ptr<const Alphabet> getAlphabet() const override { return alpha_; }
98 
99  const Alphabet& alphabet() const override { return *alpha_; }
100 };
101 } // end of namespace bpp.
102 #endif // BPP_SEQ_ALPHABETINDEX_ALPHABETINDEX1_H
One dimensionnal alphabet index interface.
virtual const Alphabet & alphabet() const =0
Get the alphabet associated to this index.
virtual double getIndex(const std::string &state) const =0
Get the index associated to a state.
virtual const std::vector< double > & indexVector() const =0
virtual double getIndex(int state) const =0
Get the index associated to a state.
virtual ~AlphabetIndex1()
virtual std::shared_ptr< const Alphabet > getAlphabet() const =0
Get the alphabet associated to this index.
virtual AlphabetIndex1 * clone() const override=0
Utilitary functions dealing with alphabets.
Definition: AlphabetTools.h:32
The Alphabet interface.
Definition: Alphabet.h:99
ProteicAlphabetIndex1(const ProteicAlphabetIndex1 &pt)
virtual ProteicAlphabetIndex1 * clone() const override=0
std::shared_ptr< const Alphabet > getAlphabet() const override
Get the alphabet associated to this index.
ProteicAlphabetIndex1 & operator=(const ProteicAlphabetIndex1 &pt)
const Alphabet & alphabet() const override
Get the alphabet associated to this index.
std::shared_ptr< const ProteicAlphabet > alpha_
This alphabet is used to deal NumericAlphabet.