5 #ifndef BPP_SEQ_ALPHABET_ALLELICALPHABET_H
6 #define BPP_SEQ_ALPHABET_ALLELICALPHABET_H
14 #include "../Transliterator.h"
53 std::shared_ptr<const Alphabet>
alph_;
70 AllelicAlphabet(std::shared_ptr<const Alphabet> alph,
unsigned int nbAlleles);
92 int charToInt(
const std::string& state)
const override
113 bool isResolvedIn(
int state1,
int state2)
const override;
148 std::vector<int>
getAlias(
int state)
const override;
150 std::vector<std::string>
getAlias(
const std::string& state)
const override;
152 int getGeneric(
const std::vector<int>& states)
const override
157 std::string
getGeneric(
const std::vector<std::string>& states)
const override
165 std::shared_ptr<const AllelicAlphabet>
alph_;
174 return alph_->getStateAlphabet();
178 std::string
translate(
const std::string& state)
const override
234 auto x = 2 * ((
unsigned int)
alph_->getStateCodingSize() + (
unsigned int)std::to_string(
nbAlleles_).size());
A partial implementation of the Alphabet interface.
unsigned int getNumberOfChars() const
Get the number of supported characters in this alphabet, including generic characters (e....
int charToInt(const std::string &state) const
Give the int description of a state given its string description.
Partial implementation of the Transliterator interface.
int translate(int state) const override=0
Translate a given state coded as a int from source alphabet to target alphabet.
AllelicTransliterator(std::shared_ptr< const AllelicAlphabet > alph)
std::unique_ptr< Sequence > translate(const SequenceInterface &sequence) const override
Translate a whole sequence from source alphabet to target alphabet.
int translate(int state) const override
States of the original alphabet are the first ones of the allelic alphabet.
std::shared_ptr< const Alphabet > getTargetAlphabet() const override
Get the target alphabet.
std::shared_ptr< const Alphabet > getSourceAlphabet() const override
Get the source alphabet.
std::string translate(const std::string &state) const override
Translate a given state coded as a string from source alphabet to target alphabet.
std::shared_ptr< const AllelicAlphabet > alph_
The base class for allelic alphabets.
unsigned int nbAlleles_
the number of alleles.
AllelicAlphabet * clone() const override
const Alphabet & stateAlphabet() const
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...
std::unique_ptr< ProbabilisticSequence > convertFromStateAlphabet(const CoreSequenceInterface &sequence) const
Convert a CoreSequence in StateAlphabet to a ProbabilisticSequence of the likelihoods of the di-allel...
std::shared_ptr< const Alphabet > getStateAlphabet() const
Returns Base Alphabet.
void computeLikelihoods(const Vdouble &counts, Vdouble &likelihoods) const
Fills the vector of the likelihoods of a vector of counts in the states alphabet, given the di-allele...
std::string getGeneric(const std::vector< std::string > &states) const override
Get the generic state that match a set of states.
std::string getAlphabetType() const override
Identification method.
int getUnknownCharacterCode() const override
int nbUnknown_
the unknown state number
std::shared_ptr< const Alphabet > alph_
std::vector< int > getAlias(int state) const override
Get all resolved states that match a generic state.
unsigned int getStateCodingSize() const override
Get the size of the string coding a state.
AllelicAlphabet(std::shared_ptr< const Alphabet > alph, unsigned int nbAlleles)
Builds a new word alphabet from an Alphabet.
bool isUnresolved(int state) const override
AllelicAlphabet(const AllelicAlphabet &bia)
unsigned int getNbAlleles() const
Returns the number of alleles.
int charToInt(const std::string &state) const override
Give the int description of a state given its string description.
bool isResolvedIn(int state1, int state2) const override
Tells if a given (potentially unresolved) state can be resolved in another resolved state.
bool isUnresolved(const std::string &state) const override
unsigned int getSize() const override
Get the number of resolved states in the alphabet (e.g. return 4 for DNA alphabet)....
virtual ~AllelicAlphabet()
int getGeneric(const std::vector< int > &states) const override
Get the generic state that match a set of states.
An alphabet exception thrown when trying to specify a bad char to the alphabet.
The core sequence interface.
This alphabet is used to deal NumericAlphabet.
std::vector< double > Vdouble