StochHMM  v0.34
Flexible Hidden Markov Model C++ Library and Application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Attributes
StochHMM::matrixPosition Class Reference

#include <pwm.h>

List of all members.

Public Member Functions

 matrixPosition ()
 ~matrixPosition ()
bool parse (std::string &txt, track *trk, stringList &names)
float getEmissionValue (sequences *, size_t)
float getEmissionValue (sequence *, size_t)
emmgetEmission ()
void addTransition (emm *trans)
std::vector< std::string > & getTransitionNames ()
void setThreshold (float thresh)
float * getThresholdPtr ()
float getThreshold ()
size_t transitionsSize ()
bool isThresholdSet ()
std::string stringify ()

Private Attributes

emmpositionMatrix
bool thresholdSet
float threshold
std::vector< emm * > transitions
std::vector< std::string > transition_names
std::string name

Detailed Description

Stores weight information for a position in the position weight matrix

Definition at line 122 of file pwm.h.


Constructor & Destructor Documentation

StochHMM::matrixPosition::matrixPosition ( )

Definition at line 217 of file pwm.cpp.

References positionMatrix, threshold, and thresholdSet.

{
thresholdSet = false;
threshold = -INFINITY;
}
StochHMM::matrixPosition::~matrixPosition ( )

Definition at line 223 of file pwm.cpp.

References positionMatrix.

{
}

Member Function Documentation

void StochHMM::matrixPosition::addTransition ( emm trans)
inline

Definition at line 130 of file pwm.h.

References transitions.

{transitions.push_back(trans);}
emm* StochHMM::matrixPosition::getEmission ( )
inline

Definition at line 129 of file pwm.h.

References positionMatrix.

{return positionMatrix;};
float StochHMM::matrixPosition::getEmissionValue ( sequences seqs,
size_t  pos 
)

Definition at line 397 of file pwm.cpp.

References StochHMM::emm::get_emission(), and positionMatrix.

{
return positionMatrix->get_emission(*seqs, pos);
}
float StochHMM::matrixPosition::getEmissionValue ( sequence seq,
size_t  pos 
)

Definition at line 401 of file pwm.cpp.

References StochHMM::emm::get_emission(), and positionMatrix.

{
return positionMatrix->get_emission(*seq, pos);
}
float StochHMM::matrixPosition::getThreshold ( )
inline

Definition at line 134 of file pwm.h.

References threshold.

{return threshold;}
float* StochHMM::matrixPosition::getThresholdPtr ( )
inline

Definition at line 133 of file pwm.h.

References threshold.

{return &threshold;}
std::vector<std::string>& StochHMM::matrixPosition::getTransitionNames ( )
inline

Definition at line 131 of file pwm.h.

References transition_names.

bool StochHMM::matrixPosition::isThresholdSet ( )
inline

Definition at line 136 of file pwm.h.

References thresholdSet.

{return thresholdSet;}
bool StochHMM::matrixPosition::parse ( std::string &  txt,
track trk,
stringList names 
)

Parses the emission for each position from a string

Parameters:
txtString representation of emissions
namesstringList of all state names defined in the model
trksTracks defined in the model
wtsWeight defined of the model
funcsStateFunction defined for the model

Definition at line 235 of file pwm.cpp.

References StochHMM::clear_whitespace(), name, StochHMM::emm::parse(), positionMatrix, StochHMM::stringList::size(), StochHMM::stringList::splitND(), StochHMM::stringList::splitString(), threshold, thresholdSet, and transition_names.

Referenced by StochHMM::PWM::_parsePositions().

{
size_t nameHeader = txt.find("NAME:");
size_t transHeader = txt.find("TRANSITION:");
size_t thresholdHeader = txt.find("THRESHOLD:");
//size_t emmHeader = txt.find("EMISSION:");
size_t end = txt.find("//END");
if (end != std::string::npos){
txt = txt.substr(0,end);
}
//Parse Name
if (nameHeader != std::string::npos){
size_t endline = txt.find("\n",nameHeader);
std::string temp_name = txt.substr(nameHeader,endline-nameHeader);
stringList tmp;
tmp.splitString(temp_name, ":");
clear_whitespace(tmp[1], "\t\n ");
name = tmp[1];
}
else{
std::cerr << "Position is missing NAME definition\n"<< txt << std::endl;
exit(2);
}
//Parse Transitions
if (transHeader != std::string::npos){
std::string temp;
size_t endline = txt.find("\n",transHeader);
temp = txt.substr(transHeader, endline - transHeader);
stringList transi;
transi.splitString(temp,":,");
for(size_t i = 1; i < transi.size(); i++){
clear_whitespace(transi[i], " \t\n");
transition_names.push_back(transi[i]);
}
}
//Parse Thresholds
if (thresholdHeader != std::string::npos){
size_t endline = txt.find("\n",thresholdHeader);
std::string temp = txt.substr(thresholdHeader, endline-thresholdHeader);
stringList tmp;
tmp.splitString(temp, ":");
clear_whitespace(tmp[1], "\t\n ");
threshold = atof(tmp[1].c_str());
thresholdSet = true;
}
stringList lst;
lst.splitND(txt,"EMISSION:");
emm* temp_emm = new(std::nothrow) emm;
if (temp_emm==NULL){
std::cerr << "OUT OF MEMORY\nFile" << __FILE__ << "Line:\t"<< __LINE__ << std::endl;
exit(1);
}
if (!temp_emm->parse(lst[0],trk)){
return false;
}
positionMatrix = temp_emm;
return true;
}
void StochHMM::matrixPosition::setThreshold ( float  thresh)
inline

Definition at line 132 of file pwm.h.

References threshold.

{threshold = thresh;}
std::string StochHMM::matrixPosition::stringify ( )

Definition at line 353 of file pwm.cpp.

References StochHMM::double_to_string(), StochHMM::join(), name, positionMatrix, StochHMM::emm::stringify(), threshold, thresholdSet, and transition_names.

{
std::string mat;
mat = "NAME:\t" + name + "\n";
mat+= "THRESHOLD:\t" + double_to_string(threshold) + "\n";
}
if (transition_names.size() > 0){
mat += "TRANSITIONS:" + join(transition_names, ',') + "\n";
}
return mat;
}
size_t StochHMM::matrixPosition::transitionsSize ( )
inline

Definition at line 135 of file pwm.h.

References transitions.

{return transitions.size();}

Member Data Documentation

std::string StochHMM::matrixPosition::name
private

Definition at line 145 of file pwm.h.

Referenced by parse(), and stringify().

emm* StochHMM::matrixPosition::positionMatrix
private

Definition at line 140 of file pwm.h.

Referenced by getEmission(), getEmissionValue(), matrixPosition(), parse(), stringify(), and ~matrixPosition().

float StochHMM::matrixPosition::threshold
private

Definition at line 142 of file pwm.h.

Referenced by getThreshold(), getThresholdPtr(), matrixPosition(), parse(), setThreshold(), and stringify().

bool StochHMM::matrixPosition::thresholdSet
private

Definition at line 141 of file pwm.h.

Referenced by isThresholdSet(), matrixPosition(), parse(), and stringify().

std::vector<std::string> StochHMM::matrixPosition::transition_names
private

Definition at line 144 of file pwm.h.

Referenced by getTransitionNames(), parse(), and stringify().

std::vector<emm*> StochHMM::matrixPosition::transitions
private

Definition at line 143 of file pwm.h.

Referenced by addTransition(), and transitionsSize().


The documentation for this class was generated from the following files: