Skip to content
Snippets Groups Projects
Commit c7e86f51 authored by Studer Gabriel's avatar Studer Gabriel
Browse files

proper check of indices in getter and setter of frequencies in HMMColumn

parent 8b484de7
Branches
Tags
No related merge requests found
......@@ -60,6 +60,22 @@ Real HMMColumn::GetEntropy() const {
return entropy;
}
Real HMMColumn::GetFreq(char ch) const{
int idx = this->GetIndex(ch);
if(idx == -1){
throw std::runtime_error("Invalid One Letter Code observed when getting frequency in HMMColumn!");
}
return freq_[idx];
}
void HMMColumn::SetFreq(char ch, Real freq){
int idx = this->GetIndex(ch);
if(idx == -1){
throw std::runtime_error("Invalid One Letter Code observed when setting frequency in HMMColumn!");
}
freq_[idx] = freq;
}
HMMPtr HMM::Load(const std::string& filename) {
HMMPtr hmm(new HMM);
boost::iostreams::filtering_stream<boost::iostreams::input> in;
......
......@@ -59,13 +59,9 @@ class HMMColumn {
Real GetNEffDel() const { return n_eff_del_; }
Real GetFreq(char ch) const {
return freq_[this->GetIndex(ch)];
}
Real GetFreq(char ch) const;
void SetFreq(char ch, Real freq) {
freq_[this->GetIndex(ch)]=freq;
}
void SetFreq(char ch, Real freq);
bool operator==(const HMMColumn& rhs) const {
return !memcmp(freq_, rhs.freq_, sizeof(freq_)) &&
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment