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::models Class Reference

#include <hmm.h>

List of all members.

Public Member Functions

modeloperator[] (size_t iter)
size_t size ()
modelgetModel (size_t)
void importModels (std::string &, StateFuncs *)
void addModel (model *)

Private Attributes

std::vector< model * > hmms
weightsscaling
templatesmodelTemplates

Detailed Description

models is a class to store multiple models. This allows StochMM the ability, to load multiple models, then select the model that appropriate for the sequence based on a used-defined attribute. Stores multiple HMM models and contains the get functions for specific models

Definition at line 445 of file hmm.h.


Member Function Documentation

void StochHMM::models::addModel ( model )
model * StochHMM::models::getModel ( size_t  iter)

Get pointer to model at index position

Parameters:
iterIndex iterator for position
Returns:
pointer to model

Definition at line 144 of file hmm.cpp.

References hmms, and size().

Referenced by StochHMM::seqTracks::loadSeqs().

{
if (iter<this->size()) {
return hmms[iter];
}
else{
return NULL;
}
}
void StochHMM::models::importModels ( std::string &  modelFile,
StateFuncs funcs 
)

Import multiple models

Parameters:
modelFilePath to multiple model file
funcsPointer to state Functions

Definition at line 33 of file hmm.cpp.

References hmms.

{
std::ifstream MOD;
MOD.open(modelFile.c_str());
if (MOD.fail()){
std::string info = "Model file not found: " + modelFile;
std::cerr << info << std::endl;
exit(1);
}
//Input is assigned to "input" & get first line
std::string input;
//Check file header for correct type
getline(MOD, input, '\n');
#ifdef DEBUG_MODEL
std::cout << input <<std::endl;
#endif
if (input.compare("#STOCHHMM MODEL FILE")==0){
MOD.close();
model* temp= new(std::nothrow) model;
if (temp==NULL){
std::cerr << "OUT OF MEMORY\nFile" << __FILE__ << "Line:\t"<< __LINE__ << std::endl;
exit(1);
}
hmms.push_back(temp);
hmms[0]->import(modelFile,funcs);
}
else if (input.compare("#STOCHHMM MODELS")==0){
std::vector<std::string> filenames;
while (getline(MOD,input,'\n')){
#ifdef DEBUG_MODEL
sd::cout << input <<endl;
#endif
//Need to check input to make sure its valid;
//cout << input <<endl;
if (input.compare("")==0){
break;
}
else{
filenames.push_back(input);
}
}
MOD.close();
for(size_t i=0;i<filenames.size();i++){
model* temp=new(std::nothrow) model;
if (temp==NULL){
std::cerr << "OUT OF MEMORY\nFile" << __FILE__ << "Line:\t"<< __LINE__ << std::endl;
exit(1);
}
hmms.push_back(temp);
}
for(size_t i=0;i<filenames.size();i++){
hmms[i]->import(filenames[i],funcs);
hmms[i]->print();
}
}
else{
std::cerr << "Header for " << modelFile << "does not indicate that it is a StochHMM model file.\n";
std::cerr << "Header should be: #STOCHHMM MODEL FILE \n" << "Header given: " << input <<std::endl;
}
return;
}
model* StochHMM::models::operator[] ( size_t  iter)
inline

Get model located at index

Parameters:
iterIndex iterator for model
Returns:
pointer to model

Definition at line 455 of file hmm.h.

References hmms.

{
if (iter>hmms.size()-1){
return NULL;
}
return hmms[iter];
};
size_t StochHMM::models::size ( )
inline

Get the number of model

Returns:
size_t

Definition at line 465 of file hmm.h.

References hmms.

Referenced by getModel(), and StochHMM::seqTracks::getNext().

{return hmms.size();};

Member Data Documentation

std::vector<model*> StochHMM::models::hmms
private

Definition at line 477 of file hmm.h.

Referenced by getModel(), importModels(), operator[](), and size().

templates* StochHMM::models::modelTemplates
private

Definition at line 479 of file hmm.h.

weights* StochHMM::models::scaling
private

Definition at line 478 of file hmm.h.


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