bpp-seq3  3.0.0
CaseMaskedAlphabet.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_ALPHABET_CASEMASKEDALPHABET_H
6 #define BPP_SEQ_ALPHABET_CASEMASKEDALPHABET_H
7 
8 
9 #include "LetterAlphabet.h"
10 
11 // From the STL:
12 #include <string>
13 
14 namespace bpp
15 {
25  public LetterAlphabet
26 {
27 public:
28  std::shared_ptr<const LetterAlphabet> nocaseAlphabet_;
29 
30 public:
31  CaseMaskedAlphabet(std::shared_ptr<const LetterAlphabet> nocaseAlphabet);
32 
35 
37  {
40  return *this;
41  }
42 
43  CaseMaskedAlphabet* clone() const override
44  {
45  return new CaseMaskedAlphabet(*this);
46  }
47 
48 public:
49  unsigned int getSize() const override { return nocaseAlphabet_->getSize(); }
50  unsigned int getNumberOfTypes() const override { return nocaseAlphabet_->getNumberOfTypes(); }
51  std::string getAlphabetType() const override { return "CaseMasked"; }
52  int getUnknownCharacterCode() const override { return nocaseAlphabet_->getUnknownCharacterCode(); }
53  bool isUnresolved(int state) const override { return nocaseAlphabet_->isUnresolved(state); }
54  bool isUnresolved(const std::string& state) const override { return nocaseAlphabet_->isUnresolved(state); }
55 
56  std::shared_ptr<const Alphabet> getUnmaskedAlphabet() const { return nocaseAlphabet_; }
57 
58  bool isMasked(int state) const { return state >= 100; }
59  bool isMasked(const std::string& state) const
60  {
61  char c = state.c_str()[0];
62  return isMasked(c);
63  }
64  bool isMasked(char state) const
65  {
66  return isalpha(state) && !isupper(state);
67  }
68 
76  int getMaskedEquivalentState(int state) const;
85  const std::string getMaskedEquivalentState(const std::string& state) const;
86 };
87 } // end of namespace bpp
88 #endif // BPP_SEQ_ALPHABET_CASEMASKEDALPHABET_H
Case-sensitive letter alphabet.
std::shared_ptr< const LetterAlphabet > nocaseAlphabet_
CaseMaskedAlphabet & operator=(const CaseMaskedAlphabet &cma)
bool isMasked(const std::string &state) const
int getMaskedEquivalentState(int state) const
Get the masked state equivalent to the input one.
unsigned int getNumberOfTypes() const override
Get the number of distinct states in alphabet (e.g. return 15 for DNA alphabet). This is the number o...
bool isUnresolved(int state) const override
std::shared_ptr< const Alphabet > getUnmaskedAlphabet() const
unsigned int getSize() const override
Get the number of resolved states in the alphabet (e.g. return 4 for DNA alphabet)....
CaseMaskedAlphabet(const CaseMaskedAlphabet &cma)
bool isUnresolved(const std::string &state) const override
int getUnknownCharacterCode() const override
CaseMaskedAlphabet(std::shared_ptr< const LetterAlphabet > nocaseAlphabet)
std::string getAlphabetType() const override
Identification method.
bool isMasked(char state) const
bool isMasked(int state) const
CaseMaskedAlphabet * clone() const override
Specialized partial implementation of Alphabet using single letters.
LetterAlphabet & operator=(const LetterAlphabet &bia)
This alphabet is used to deal NumericAlphabet.