bpp-seq3  3.0.0
AlphabetIndex2.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_ALPHABETINDEX2_H
6 #define BPP_SEQ_ALPHABETINDEX_ALPHABETINDEX2_H
7 
8 #include <Bpp/Clonable.h>
10 
11 #include "../Alphabet/Alphabet.h"
12 #include "../Alphabet/AlphabetTools.h"
13 #include "../Alphabet/ProteicAlphabet.h"
14 
15 // From the STL:
16 #include <string>
17 
18 namespace bpp
19 {
25 class AlphabetIndex2 : public Clonable
26 {
27 public:
29  virtual ~AlphabetIndex2() {}
30 
31 public:
32  virtual AlphabetIndex2* clone() const = 0;
33 
41  virtual double getIndex(int state1, int state2) const = 0;
42 
50  virtual double getIndex(const std::string& state1, const std::string& state2) const = 0;
51 
57  virtual std::shared_ptr<const Alphabet> getAlphabet() const = 0;
58 
64  virtual const Alphabet& alphabet() const = 0;
65 
69  virtual const Matrix<double>& getIndexMatrix() const = 0;
70 
74  virtual bool isSymmetric() const = 0;
75 };
76 
81  virtual public AlphabetIndex2
82 {
83 private:
84  std::shared_ptr<const ProteicAlphabet> alpha_;
85 
86 public:
87  ProteicAlphabetIndex2() : alpha_(AlphabetTools::PROTEIN_ALPHABET) {}
89 
90  virtual ProteicAlphabetIndex2* clone() const override = 0;
91 
93  alpha_(pt.alpha_)
94  {}
95 
97  {
98  alpha_ = pt.alpha_;
99  return *this;
100  }
101 
102  std::shared_ptr<const Alphabet> getAlphabet() const override { return alpha_; }
103 
104  const Alphabet& alphabet() const override { return *alpha_; }
105 };
106 } // end of namespace bpp.
107 #endif // BPP_SEQ_ALPHABETINDEX_ALPHABETINDEX2_H
Two dimensionnal alphabet index interface.
virtual const Matrix< double > & getIndexMatrix() const =0
virtual const Alphabet & alphabet() const =0
Get the alphabet associated to this index.
virtual double getIndex(const std::string &state1, const std::string &state2) const =0
Get the index associated to a pair of states.
virtual bool isSymmetric() const =0
virtual double getIndex(int state1, int state2) const =0
Get the index associated to a pair of states.
virtual std::shared_ptr< const Alphabet > getAlphabet() const =0
Get the alphabet associated to this index.
virtual AlphabetIndex2 * clone() const =0
virtual ~AlphabetIndex2()
Utilitary functions dealing with alphabets.
Definition: AlphabetTools.h:32
The Alphabet interface.
Definition: Alphabet.h:99
Virtual AlphabetIndex2 for proteic alphabet.
ProteicAlphabetIndex2(const ProteicAlphabetIndex2 &pt)
std::shared_ptr< const Alphabet > getAlphabet() const override
Get the alphabet associated to this index.
std::shared_ptr< const ProteicAlphabet > alpha_
virtual ProteicAlphabetIndex2 * clone() const override=0
const Alphabet & alphabet() const override
Get the alphabet associated to this index.
ProteicAlphabetIndex2 & operator=(const ProteicAlphabetIndex2 &pt)
This alphabet is used to deal NumericAlphabet.