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{
28 class ContextProfileDB;
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_;
static int GetIndex(char ch)
Translate one-letter-code to index (0-indexing).
Provides a profile for a sequence.
void AddProfile(const ContextProfile &profile)
static ContextProfileDBPtr FromCRF(const String &filename)
const ContextProfile & at(int idx) const
const ContextProfile & operator[](int idx) const
void Save(const String &filename) const
size_t profile_length() const
static ContextProfileDBPtr Load(const String &filename)
ContextProfile(int length)
ContextProfile(int length, Real *data)
const Real * GetWeights(int pos) const
void SetWeight(int pos, char olc, Real weight)
Real GetWeight(int pos, char olc)
const Real * GetPseudoCounts() const
void SetPseudoCount(char olc, Real count)
static int DataSize(int length)
Real GetPseudoCount(char olc)
const std::vector< Real > & GetData() const
void AddAAPseudoCounts(ost::seq::ProfileHandle &profile, Real a=1.0, Real b=1.5, Real c=1.0)
void AddNullPseudoCounts(ost::seq::ProfileHandle &profile)
void AddTransitionPseudoCounts(ost::seq::ProfileHandle &profile, Real gapb=1.0, Real gabd=0.15, Real gape=1.0)
boost::shared_ptr< ContextProfileDB > ContextProfileDBPtr