bpp-seq3  3.0.0
SimpleScore.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_SIMPLESCORE_H
6 #define BPP_SEQ_ALPHABETINDEX_SIMPLESCORE_H
7 
8 
9 // from the STL:
10 #include <string>
11 
12 #include "AlphabetIndex2.h"
13 #include "../Alphabet/Alphabet.h"
14 #include "../Alphabet/AlphabetExceptions.h"
15 #include <Bpp/Exceptions.h>
17 
18 namespace bpp
19 {
23 class SimpleScore :
24  public virtual AlphabetIndex2
25 {
26 private:
28  std::shared_ptr<const Alphabet> alphabet_;
29 
30 public:
38  SimpleScore(const Alphabet* alphabet, double match, double mismatch);
39 
40  SimpleScore(const SimpleScore& sc) :
43  {}
44 
46  {
48  alphabet_ = sc.alphabet_;
49  return *this;
50  }
51 
52  virtual ~SimpleScore() {}
53 
54  SimpleScore* clone() const override { return new SimpleScore(*this); }
55 
56 public:
62  double getIndex(int state1, int state2) const override;
63  double getIndex(const std::string& state1, const std::string& state2) const override;
64  std::shared_ptr<const Alphabet> getAlphabet() const override { return alphabet_; }
65  const Alphabet& alphabet() const override { return *alphabet_; }
66  const Matrix<double>& getIndexMatrix() const override { return distanceMatrix_; }
67  bool isSymmetric() const override { return true; }
69 };
70 } // end of namespace bpp.
71 #endif // BPP_SEQ_ALPHABETINDEX_SIMPLESCORE_H
Two dimensionnal alphabet index interface.
The Alphabet interface.
Definition: Alphabet.h:99
Simple Substitution Matrix, with match and mismatch penalties.
Definition: SimpleScore.h:25
virtual ~SimpleScore()
Definition: SimpleScore.h:52
SimpleScore * clone() const override
Definition: SimpleScore.h:54
std::shared_ptr< const Alphabet > getAlphabet() const override
Get the alphabet associated to this index.
Definition: SimpleScore.h:64
double getIndex(int state1, int state2) const override
Get the index associated to a pair of states.
Definition: SimpleScore.cpp:29
const Matrix< double > & getIndexMatrix() const override
Definition: SimpleScore.h:66
SimpleScore(const Alphabet *alphabet, double match, double mismatch)
Build a new simpleScore object.
Definition: SimpleScore.cpp:14
std::shared_ptr< const Alphabet > alphabet_
Definition: SimpleScore.h:28
const Alphabet & alphabet() const override
Get the alphabet associated to this index.
Definition: SimpleScore.h:65
bool isSymmetric() const override
Definition: SimpleScore.h:67
LinearMatrix< double > distanceMatrix_
Definition: SimpleScore.h:27
SimpleScore & operator=(const SimpleScore &sc)
Definition: SimpleScore.h:45
SimpleScore(const SimpleScore &sc)
Definition: SimpleScore.h:40
This alphabet is used to deal NumericAlphabet.