20 #ifndef OST_SEQ_ALG_HMM_PSEUDO_COUNTS_HH
21 #define OST_SEQ_ALG_HMM_PSEUDO_COUNTS_HH
25 namespace ost{
namespace seq{
namespace alg{
41 memcpy(&data_[0], data, data_.size() *
sizeof(
Real));
46 throw Error(
"Tried to access invalid pos in ContextProfile");
50 data_[pos*20 + olc_idx] = weight;
52 throw Error(
"Invalid one letter code in ContextProfile");
59 data_[length_*20 + olc_idx] = count;
61 throw Error(
"Invalid one letter code in ContextProfile");
69 throw Error(
"Tried to access invalid pos in ContextProfile");
71 return &data_[pos*20];
76 throw Error(
"Tried to access invalid pos in ContextProfile");
80 return data_[pos*20 + olc_idx];
82 throw Error(
"Invalid one letter code in ContextProfile");
91 return data_[length_*20 + olc_idx];
93 throw Error(
"Invalid one letter code in ContextProfile");
99 const std::vector<Real>&
GetData()
const {
return data_; }
103 static int DataSize(
int length) {
return (length+1)*20+1; }
111 std::vector<Real> data_;
130 if(!profiles_.empty()) {
131 if(profile.
GetLength() != profiles_[0].GetLength()) {
132 throw Error(
"Require all profiles to be of same length");
135 profiles_.push_back(profile);
139 return profiles_[idx];
143 return profiles_.at(idx);
147 return profiles_.size();
151 if(profiles_.empty()) {
152 throw Error(
"DB must contain profiles to get profile length");
154 return profiles_[0].GetLength();
158 std::vector<ContextProfile> profiles_;
169 const ContextProfileDB& db,
const Real * GetPseudoCounts() const
void AddNullPseudoCounts(ost::seq::ProfileHandle &profile)
void AddTransitionPseudoCounts(ost::seq::ProfileHandle &profile, Real gapb=1.0, Real gabd=0.15, Real gape=1.0)
ContextProfile(int length, Real *data)
ContextProfile(int length)
boost::shared_ptr< ContextProfileDB > ContextProfileDBPtr
static int DataSize(int length)
static ContextProfileDBPtr FromCRF(const String &filename)
static int GetIndex(char ch)
Translate one-letter-code to index (0-indexing).
void SetWeight(int pos, char olc, Real weight)
Provides a profile for a sequence.
const Real * GetWeights(int pos) const
size_t profile_length() const
void SetPseudoCount(char olc, Real count)
const ContextProfile & at(int idx) const
static ContextProfileDBPtr Load(const String &filename)
const std::vector< Real > & GetData() const
void AddProfile(const ContextProfile &profile)
void AddAAPseudoCounts(ost::seq::ProfileHandle &profile, Real a=1.0, Real b=1.5, Real c=1.0)
void Save(const String &filename) const
Real GetWeight(int pos, char olc)
Real GetPseudoCount(char olc)
const ContextProfile & operator[](int idx) const