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 Member Functions | Private Attributes | Friends
StochHMM::track Class Reference

#include <track.h>

List of all members.

Public Member Functions

 track ()
 Create a track.
 track (TrackFuncs *)
 track (std::vector< std::string > &)
bool parse (std::string &)
bool parseAmbiguous (std::string &)
void setName (std::string &nm)
void setDescription (std::string &desc)
void setIndex (size_t indx)
void setAlphaType (trackType typ)
bool addAlphabetChar (std::string &)
bool addAlphabetChar (const char *)
bool addAlphabetChar (std::vector< std::string > &)
bool addAlphabetChar (size_t chSize, const char *characters[])
bool addAlphabetChar (std::string &character, std::string &complement)
bool addAlphabetChar (size_t chSize, const char *characters[], const char *complements[])
bool addAlphabetChar (std::vector< std::string > &characters, std::vector< std::string > &complements)
void addComplement (std::string &, std::string &)
void addComplement (const char *, const char *)
bool addComplement (std::vector< std::string > &characters, std::vector< std::string > &complements)
void setAmbiguous ()
void addAmbiguous (std::string &, std::vector< std::string > &)
std::string getName ()
std::string getDescription ()
size_t getIndex ()
trackType getAlphaType ()
size_t getAlphaSize ()
size_t getTotalAlphabetSize ()
 Get alphabet size including ambiguous characters.
size_t getAlphaMax ()
std::string getAlpha (int)
std::string getAlpha (size_t)
uint8_t symbolIndex (const std::string &)
uint8_t symbolIndex (unsigned char)
uint8_t getComplementIndex (uint8_t val)
uint8_t getComplementIndex (std::string &)
std::string getComplementSymbol (std::string &character)
std::string getComplementSymbol (uint8_t value)
bool isComplementDefined ()
bool isAmbiguousSet ()
bool isAlpha ()
size_t getAmbiguousSize ()
std::string getAmbiguousCharacter (size_t)
std::vector< size_t > & getAmbiguousSet (uint8_t val)
std::vector< size_t > & getUnambiguousSet ()
std::string stringify ()
std::string stringifyAmbig ()
void print ()
 Print the string representation of the track to stdout.
std::string convertIndexToWord (size_t, size_t)
void convertIndexToDigital (size_t, size_t, uint8_t *)
bool isTrackFuncDefined ()
std::string getTrackFunction ()
std::string getTrackToUse ()
 Get name of Track to use for trackFunc.
uint8_t getMaxUnambiguous ()
uint8_t getMaxAmbiguous ()

Private Member Functions

void _splitAmbiguousList (std::vector< std::pair< std::string, std::vector< std::string > > > &, const std::string &)

Private Attributes

std::string name
std::string description
size_t trackIndex
trackType alpha_type
bool trackFunctionDefined
 Track Functions for defining Real Number Tracks.
bool complementSet
std::string trackToUse
std::string trackFunction
std::vector< std::string > alphabet
std::map< uint8_t, uint8_t > complementAlphabet
size_t maxSize
uint8_t max_unambiguous
uint8_t max_ambiguous
std::vector< size_t > unambiguous
bool ambiguous
int defaultAmbiguous
std::vector< ambigCharacterambiguousSymbols
std::map< std::string, uint8_t > symbolIndices
std::vector< uint8_t > * charIndices

Friends

class state
class model
class tracks

Detailed Description

Defines types of data (real-value, text-sequence) used in the model and the alphabet that a text-sequence uses. Tracks are used to digitize the sequence before decoding in HMM

Definition at line 86 of file track.h.


Constructor & Destructor Documentation

StochHMM::track::track ( )
StochHMM::track::track ( TrackFuncs )
StochHMM::track::track ( std::vector< std::string > &  characters)

Member Function Documentation

void StochHMM::track::_splitAmbiguousList ( std::vector< std::pair< std::string, std::vector< std::string > > > &  results,
const std::string &  text 
)
private

Definition at line 471 of file track.cpp.

References StochHMM::clear_whitespace(), and StochHMM::split_line().

Referenced by parseAmbiguous().

{
size_t opening;
size_t closing;
size_t start=0;
opening=text.find_first_of('[');
while(opening!=std::string::npos){
std::pair<std::string,std::vector<std::string> > amb;
amb.first=text.substr(start,opening-start);
clear_whitespace(amb.first, "\t ");
closing=text.find_first_of(']',opening);
if (closing!=std::string::npos){
std::string tempString=text.substr(opening+1,closing-opening-1);
split_line(amb.second, tempString);
}
start=text.find_first_not_of(',',closing+1);
results.push_back(amb);
opening=text.find_first_of('[',closing);
}
return;
}
bool StochHMM::track::addAlphabetChar ( std::string &  character)

Add a letter/word symbol to the track

Parameters:
characterWord or symbol used in undigitized sequence

Definition at line 109 of file track.cpp.

References StochHMM::ALPHA_NUM, alphabet, max_unambiguous, maxSize, setAlphaType(), symbolIndices, and unambiguous.

Referenced by addAlphabetChar(), parse(), and track().

{
if (alphabet.size() >= 255){
std::cerr << "Alphabet limit reached. Unable to add additional characters to the track:\t" << character << std::endl;
return false;
}
if (character.size()>maxSize){maxSize=character.size();};
alphabet.push_back(character);
size_t index = alphabet.size()-1;
symbolIndices[character]=index;
max_unambiguous = index;
unambiguous.push_back(index);
return true;
}
bool StochHMM::track::addAlphabetChar ( const char *  character)

Definition at line 132 of file track.cpp.

References addAlphabetChar(), StochHMM::ALPHA_NUM, maxSize, and setAlphaType().

{
std::string string_character(character);
if (string_character.size()>maxSize){maxSize=string_character.size();};
return addAlphabetChar(string_character);
}
bool StochHMM::track::addAlphabetChar ( std::vector< std::string > &  characters)

Definition at line 141 of file track.cpp.

References addAlphabetChar(), StochHMM::ALPHA_NUM, and setAlphaType().

{
for(size_t i=0;i<characters.size();i++){
addAlphabetChar(characters[i]);
}
return true;
}
bool StochHMM::track::addAlphabetChar ( size_t  chSize,
const char *  characters[] 
)

Definition at line 152 of file track.cpp.

References addAlphabetChar().

{
for(size_t i =0; i < chSize; i++ ){
addAlphabetChar(characters[i]);
}
return true;
}
bool StochHMM::track::addAlphabetChar ( std::string &  character,
std::string &  complement 
)

Definition at line 160 of file track.cpp.

References addAlphabetChar(), addComplement(), StochHMM::ALPHA_NUM, complementSet, and setAlphaType().

{
addAlphabetChar(character);
addComplement(character, complement);
complementSet = true;
return true;
}
bool StochHMM::track::addAlphabetChar ( size_t  chSize,
const char *  characters[],
const char *  complements[] 
)

Definition at line 168 of file track.cpp.

References addAlphabetChar(), addComplement(), StochHMM::ALPHA_NUM, complementSet, and setAlphaType().

{
for(size_t i=0;i<chSize;i++){
addAlphabetChar(characters[i]);
addComplement(characters[i], complements[i]);
}
complementSet = true;
return true;
}
bool StochHMM::track::addAlphabetChar ( std::vector< std::string > &  characters,
std::vector< std::string > &  complements 
)

Definition at line 183 of file track.cpp.

References addAlphabetChar(), addComplement(), StochHMM::ALPHA_NUM, complementSet, and setAlphaType().

{
if (characters.size() != complements.size()){
//Error Message
std::cerr << "Number of Complement characters and Characters don't match.\n";
return false;
}
for(size_t i=0;i<characters.size();i++){
addAlphabetChar(characters[i]);
addComplement(characters[i], complements[i]);
}
complementSet = true;
return true;
}
void StochHMM::track::addAmbiguous ( std::string &  ambChar,
std::vector< std::string > &  defs 
)

Add an ambiguous character/word definition to the track

Parameters:
ambCharword/symbol fore the ambiguous character

Definition at line 237 of file track.cpp.

References ambiguousSymbols, defaultAmbiguous, max_ambiguous, max_unambiguous, and symbolIndices.

Referenced by parseAmbiguous().

{
if (defaultAmbiguous==-1){
}
ambigCharacter amb(this,ambChar,defs);
ambiguousSymbols.push_back(amb);
int index = (int) symbolIndices.size(); //Get the index position and new digital reference value
if (index >= 255){
std::cerr << "Maximum number of discrete symbols reached at 255\n";
exit(2);
}
symbolIndices[ambChar]=index;
max_ambiguous = index;
return;
}
void StochHMM::track::addComplement ( std::string &  character,
std::string &  complement 
)

Definition at line 203 of file track.cpp.

References complementAlphabet, complementSet, and symbolIndex().

Referenced by addAlphabetChar(), and addComplement().

{
int index = symbolIndex(character);
int comp = symbolIndex(complement);
complementAlphabet[index]=comp;
complementSet = true;
return;
}
void StochHMM::track::addComplement ( const char *  character,
const char *  complement 
)

Definition at line 212 of file track.cpp.

References addComplement().

{
std::string string_character(character);
std::string string_complement(complement);
addComplement(string_character, string_complement);
return;
}
bool StochHMM::track::addComplement ( std::vector< std::string > &  characters,
std::vector< std::string > &  complements 
)

Definition at line 220 of file track.cpp.

References addComplement().

{
if (characters.size() != complements.size()){
std::cerr << "Number of Complement characters and Characters don't match.\n";
return false;
}
for(size_t i=0;i<characters.size();i++){
addComplement(characters[i], complements[i]);
}
return true;
}
void StochHMM::track::convertIndexToDigital ( size_t  ,
size_t  ,
uint8_t *   
)

Definition at line 429 of file track.cpp.

References alphabet, and StochHMM::POWER.

{
if (order == 0){
word[0]=wordIndex;
return;
}
std::cout << alphabet.size() << std::endl;
size_t currentOrder = order;
while (currentOrder>1){
double dreg=POWER[currentOrder-1][alphabet.size()-1];
size_t temp = floor ((double) wordIndex / dreg);
word[currentOrder-1] = temp;
wordIndex-=temp*dreg;
currentOrder--;
}
word[0] = wordIndex;
return;
}
std::string StochHMM::track::convertIndexToWord ( size_t  wordIndex,
size_t  order 
)

Definition at line 402 of file track.cpp.

References alphabet, maxSize, and StochHMM::POWER.

{
std::string output="";
if (order == 0){
return "";
}
size_t currentOrder = order;
while (currentOrder>1){
double dreg=POWER[currentOrder-1][alphabet.size()-1];
size_t temp = floor ((double) wordIndex / dreg);
output+=alphabet[temp];
if (maxSize!=1){
output += ",";
}
wordIndex-=temp*dreg;
currentOrder--;
}
output+=alphabet[wordIndex];
return output;
}
std::string StochHMM::track::getAlpha ( int  iter)

Get the letter/word that has a given digitized value

Parameters:
iterinteger value of digital symbol
Returns:
std::string The string value in the undigitized sequence that is associated with the integer digitized value;

Definition at line 79 of file track.cpp.

References alphabet, getAmbiguousCharacter(), max_ambiguous, and max_unambiguous.

Referenced by getComplementSymbol(), StochHMM::sequence::getSymbol(), StochHMM::random_sequence(), and StochHMM::sequence::undigitize().

{
if (iter<=max_unambiguous){
return alphabet[iter];
}
else if (iter <= max_ambiguous){
return getAmbiguousCharacter(iter);
}
else{
return "";
}
}
std::string StochHMM::track::getAlpha ( size_t  iter)

Get the letter/word that has a given digitized value

Parameters:
iterinteger value of digital symbol
Returns:
std::string The string value in the undigitized sequence that is associated with the integer digitized value;

Definition at line 94 of file track.cpp.

References alphabet, getAmbiguousCharacter(), max_ambiguous, and max_unambiguous.

{
if (iter<=max_unambiguous){
return alphabet[iter];
}
else if (iter <= max_ambiguous){
return getAmbiguousCharacter(iter);
}
else{
return "";
}
}
size_t StochHMM::track::getAlphaMax ( )
inline

Get the size of the largest alphabet word

Returns:
size_t

Definition at line 180 of file track.h.

References maxSize.

Referenced by StochHMM::sequence::_digitize(), StochHMM::sequence::complement(), StochHMM::sequence::reverse(), StochHMM::trellis::transitionFuncTraceback(), and StochHMM::sequence::undigitize().

{return maxSize;};
size_t StochHMM::track::getAlphaSize ( )
inline

Get the number of characters defined in the track

Returns:
size_t Number of characters/words defined in the track

Definition at line 173 of file track.h.

References alphabet.

Referenced by StochHMM::lexicalTable::addTrack(), StochHMM::Counter::initializeTable(), and StochHMM::random_sequence().

{return alphabet.size();};
trackType StochHMM::track::getAlphaType ( )
inline

Get the alphabet type of the track

Returns:
trackType Alphabet type of the track
See also:
enum trackType

Definition at line 169 of file track.h.

References alpha_type.

Referenced by StochHMM::seqTracks::_initImportTrackInfo(), and StochHMM::emm::isReal().

{return alpha_type;}
std::string StochHMM::track::getAmbiguousCharacter ( size_t  val)

Get the string representation of the ambigous character defined by integer value If ambiguous character isn't defined, return value is "*"

Parameters:
valInteger value representing the ambiguous character

Definition at line 500 of file track.cpp.

References ambiguousSymbols, getAmbiguousSize(), and max_unambiguous.

Referenced by getAlpha(), and stringifyAmbig().

{
if (getAmbiguousSize()==0){
return "*";
}
return ambiguousSymbols[(val-max_unambiguous)-1].getSymbol();
}
std::vector<size_t>& StochHMM::track::getAmbiguousSet ( uint8_t  val)
inline

Get the indices of characters that an ambiguous character represents

Returns:
std::vector<int>

Definition at line 220 of file track.h.

References ambiguousSymbols, and max_unambiguous.

Referenced by stringifyAmbig().

{return ambiguousSymbols[(val-max_unambiguous)-1].getDef();}
size_t StochHMM::track::getAmbiguousSize ( )
inline

Get the number of ambiguous characters that are defined

Returns:
size_t Number of ambiguous characters/words defined

Definition at line 213 of file track.h.

References ambiguousSymbols.

Referenced by getAmbiguousCharacter().

{return ambiguousSymbols.size();};
uint8_t StochHMM::track::getComplementIndex ( uint8_t  val)

Get the complement alphabet character digitized value given a value

Parameters:
valValue of character to get complement of
Returns:
int value of complement

Definition at line 593 of file track.cpp.

References complementAlphabet, and complementSet.

Referenced by StochHMM::sequence::complement().

{
if (complementAlphabet.count(val)){
return complementAlphabet[val];
}
else{
std::cerr<< "Complement of " << val << " is not set in track\n";
return -1;
}
}
else{
std::cerr << "No complements are set in the track\n";
exit(1);
}
}
uint8_t StochHMM::track::getComplementIndex ( std::string &  character)

Get the complement alphabet character digitized value given the string

Parameters:
characterString of alphanumerical symbol
Returns:
int Defined complement string symbol of symbol

Definition at line 614 of file track.cpp.

References complementAlphabet, complementSet, symbolIndex(), and symbolIndices.

{
if (symbolIndices.count(character)){
int characterIndex = symbolIndex(character);
return complementAlphabet[characterIndex];
}
else{
std::cerr<< "Complement of " << character << " is not set in track\n";
return -1;
}
}
else{
std::cerr << "No complements are set in the track\n";
exit(1);
}
}
std::string StochHMM::track::getComplementSymbol ( std::string &  character)

Get the compelment alphabet character digitized value given the string

Parameters:
characterString of alphanumerical symbol
Returns:
std::string Defined complement string symbol

Definition at line 657 of file track.cpp.

References complementAlphabet, complementSet, getAlpha(), symbolIndex(), and symbolIndices.

Referenced by StochHMM::sequence::complement().

{
if (symbolIndices.count(character)){
int characterIndex = symbolIndex(character);
int complement_value = complementAlphabet[characterIndex];
return getAlpha(complement_value);
}
else{
std::cerr<< "Complement of " << character << " is not set in track\n";
return " ";
}
}
else{
std::cerr << "No complements are set in the track\n";
exit(1);
}
}
std::string StochHMM::track::getComplementSymbol ( uint8_t  value)

Get the complement alphanumerical string of a given integer value;

Parameters:
valueInteger value of a symbol
Returns:
std::string Defined complement string symbol of symbol with digitized value

Definition at line 635 of file track.cpp.

References complementAlphabet, complementSet, and getAlpha().

{
if (complementAlphabet.count(value)){
int complement_value = complementAlphabet[value];
return getAlpha(complement_value);
}
else{
std::cerr<< "Complement of " << value << " is not set in track\n";
return " ";
}
}
else{
std::cerr << "No complements are set in the track\n";
exit(1);
}
}
std::string StochHMM::track::getDescription ( )
inline

Get the description of the track

Returns:
std::string Description of the track

Definition at line 154 of file track.h.

References description.

{return description;};
size_t StochHMM::track::getIndex ( )
inline

Get the index of the track

Returns:
int Index of the track

Definition at line 158 of file track.h.

References StochHMM::max(), and trackIndex.

Referenced by StochHMM::sequences::addSeq(), StochHMM::emissionFuncParam::emissionFuncParam(), StochHMM::emm::get_emission(), StochHMM::emissionFuncParam::parse(), and StochHMM::trellis::transitionFuncTraceback().

{
return trackIndex;
}
std::cerr << "Track Index is not set in track. Set the track index with setIndex(size_t indx) before calling.\n";
exit(1);
};
uint8_t StochHMM::track::getMaxAmbiguous ( )
inline

Definition at line 247 of file track.h.

References max_ambiguous.

{return max_ambiguous;}
uint8_t StochHMM::track::getMaxUnambiguous ( )
inline

Definition at line 246 of file track.h.

References max_unambiguous.

{return max_unambiguous;}
std::string StochHMM::track::getName ( )
inline

Get the name of the track

Returns:
std::string Name of the track

Definition at line 150 of file track.h.

References name.

Referenced by StochHMM::emissionFuncParam::emissionFuncParam(), StochHMM::tracks::push_back(), StochHMM::emm::stringify(), StochHMM::sequences::stringify(), StochHMM::transition::stringify(), and StochHMM::sequences::undigitize().

{return name;};
size_t StochHMM::track::getTotalAlphabetSize ( )
inline

Get alphabet size including ambiguous characters.

Definition at line 176 of file track.h.

References symbolIndices.

{return symbolIndices.size();}
std::string StochHMM::track::getTrackFunction ( )
inline

Get name of TrackFunc defined for track

Returns:
std::string Name of trackFunc defined

Definition at line 241 of file track.h.

References trackFunction.

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

{return trackFunction;}
std::string StochHMM::track::getTrackToUse ( )
inline

Get name of Track to use for trackFunc.

Definition at line 244 of file track.h.

References trackToUse.

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

{return trackToUse;}
std::vector<size_t>& StochHMM::track::getUnambiguousSet ( )
inline

Definition at line 222 of file track.h.

References unambiguous.

{ return unambiguous; }
bool StochHMM::track::isAlpha ( )
inline

Check to see if the track is AlphaNum type and not a REAL Track

Returns:
true if it is AlphaNum type
false if it is a REAL type

Definition at line 209 of file track.h.

References StochHMM::ALPHA_NUM, and alpha_type.

Referenced by StochHMM::trellis::transitionFuncTraceback().

{if (alpha_type == ALPHA_NUM){return true;} else {return false;}};
bool StochHMM::track::isAmbiguousSet ( )
inline

Check to see if ambiguous flag is set for the track

Returns:
true if ambiguous flag is set to handle ambig. characters
false if not set

Definition at line 203 of file track.h.

References ambiguous.

{return ambiguous;};
bool StochHMM::track::isComplementDefined ( )
inline

Definition at line 197 of file track.h.

References complementSet.

{return complementSet;}
bool StochHMM::track::isTrackFuncDefined ( )
inline

Check if the TrackFunction is defined for this track

Returns:
true if the track has a trackFunc defined

Definition at line 237 of file track.h.

References trackFunctionDefined.

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

bool StochHMM::track::parse ( std::string &  txt)

Parse a string representation of track to define a tracks parameters

Parameters:
txtLine from model that describes a track
Returns:
true if the track was parsed properly

Definition at line 310 of file track.cpp.

References addAlphabetChar(), StochHMM::ALPHA_NUM, StochHMM::stringList::contains(), StochHMM::extractTag(), StochHMM::stringList::fromNext(), StochHMM::stringList::getComment(), StochHMM::stringList::indexOf(), StochHMM::REAL, setAlphaType(), setDescription(), setName(), StochHMM::stringList::size(), StochHMM::stringList::stringify(), trackFunction, trackFunctionDefined, and trackToUse.

Referenced by StochHMM::PWM::_parseTrack(), and StochHMM::model::_parseTracks().

{
stringList lst;
stringList tag = extractTag(txt);
size_t index;
lst.fromNext(txt);
setName(lst[0]);
setDescription(lst.getComment());
if (lst[1].compare("REAL_NUMBER")==0){
if (tag.size()>0){
if (tag.contains("FUNCTION")){
index=tag.indexOf("FUNCTION");
trackFunction=tag[index+1];
}
else{
std::cerr << "Real number track function tag must contain FUNCTION: and USE: . Please check the formatting of your tag. Here is the tag as parsed: " << tag.stringify() << std::endl;
return false;
}
if (tag.contains("USE")){
index=tag.indexOf("USE");
trackToUse=tag[index+1];
}
else{
std::cerr << "Real number track tag must contain FUNCTION: and USE: . Please check the formatting of your tag. Here is the tag as parsed: " << tag.stringify() << std::endl;
return false;
}
}
}
else{
for(size_t i=1;i<lst.size();i++){
if (!addAlphabetChar(lst[i])){
std::cerr << "Track import failed, because number of symbols exceeded 255. Alternatively, you can create a real number track for different emissions" << std::endl;
return false;
}
}
}
return true;
}
bool StochHMM::track::parseAmbiguous ( std::string &  txt)

Parse the ambiguous character definitions from model file

Parameters:
txtString representation of ambiguous character definition as in model file
Returns:
true if the ambiguous characters were properly parsed

Definition at line 456 of file track.cpp.

References _splitAmbiguousList(), addAmbiguous(), and setAmbiguous().

Referenced by StochHMM::PWM::_parseAmbiguous(), and StochHMM::model::_parseAmbiguous().

{
std::vector<std::pair<std::string,std::vector<std::string> > > temp;
_splitAmbiguousList(temp, txt);
if (temp.size()==0){
return false;
}
for (size_t i=0;i<temp.size();i++){
addAmbiguous(temp[i].first, temp[i].second);
}
return true;
}
void StochHMM::track::print ( )
inline

Print the string representation of the track to stdout.

Definition at line 229 of file track.h.

References stringify().

{ std::cout << stringify() << std::endl;}
void StochHMM::track::setAlphaType ( trackType  typ)
inline

Set the alphabet type of the track (Real or alphanum)

Parameters:
typenum trackType

Definition at line 124 of file track.h.

References alpha_type.

Referenced by addAlphabetChar(), parse(), and track().

{alpha_type=typ;};
void StochHMM::track::setAmbiguous ( )
inline

Set ambiguous character flag to true This will allow ambiguous characters to be processed in sequence Without this flag, only strict track characters or values are allowed

Definition at line 142 of file track.h.

References ambiguous.

Referenced by parseAmbiguous().

{ambiguous=true; return;};
void StochHMM::track::setDescription ( std::string &  desc)
inline

Set the Description of the track

Parameters:
descDescription of track

Definition at line 108 of file track.h.

References description.

Referenced by parse().

{description=desc;};
void StochHMM::track::setIndex ( size_t  indx)
inline

Set the integer index value of the track in tracks

Parameters:
indxUser defined index value;

Definition at line 112 of file track.h.

References StochHMM::max(), and trackIndex.

Referenced by StochHMM::PWM::_parseTrack(), and StochHMM::model::_parseTracks().

{
trackIndex=indx;
return;
}
std::cerr << "Track index: " << indx << " is OUT_OF_RANGE\n";
exit(1);
}
void StochHMM::track::setName ( std::string &  nm)
inline

Set the name of the track

Parameters:
nmName of the track

Definition at line 104 of file track.h.

References name.

Referenced by parse().

{name=nm;};
std::string StochHMM::track::stringify ( )

Get the string representation of the track

Returns:
std::string Definition of the track as in model

Definition at line 360 of file track.cpp.

References StochHMM::ALPHA_NUM, alpha_type, alphabet, StochHMM::join(), name, trackFunction, trackFunctionDefined, and trackToUse.

Referenced by print(), and StochHMM::PWM::stringify().

{
std::string output;
output+=name + ":\t";
output+=join(alphabet,',');
}
else{
output+="REAL_NUMBER";
output+="\t[FUNCTION:\t" + trackFunction;
output+="\tUSE:\t" + trackToUse + "]";
}
}
output+="\n";
return output;
}
std::string StochHMM::track::stringifyAmbig ( )

Get the string representation of the ambiguous character definitions as in model file

Returns:
std::string

Definition at line 381 of file track.cpp.

References alphabet, getAmbiguousCharacter(), getAmbiguousSet(), max_ambiguous, max_unambiguous, and name.

{
std::string output;
output+=name + ":\t";
for (size_t i = max_unambiguous+1; i <= max_ambiguous; i++){
if (i > (size_t) max_unambiguous+1){ output+= ",";}
output+="[";
std::vector<size_t>& regChar = getAmbiguousSet(i);
for(size_t k = 0; k<regChar.size();k++){
if (k>0){output+=",";}
output+=alphabet[regChar[k]];
}
output+="]";
}
return output;
}
uint8_t StochHMM::track::symbolIndex ( const std::string &  symbol)

Get symbol assigned integer value

Parameters:
symbolword/letter/symbol that we want to get it's assigned integer value

Definition at line 259 of file track.cpp.

References ambiguous, defaultAmbiguous, and symbolIndices.

Referenced by StochHMM::sequence::_digitize(), addComplement(), StochHMM::ambigCharacter::ambigCharacter(), getComplementIndex(), and getComplementSymbol().

{
if (symbolIndices.count(symbol)==0){ //If isn't found in the hash
if (ambiguous){ //Return default character if ambiguous is set
std::cerr << symbol << "not found in HMM definitions. Using default ambiguous character.\n";
}
else{
std::cerr << "Encountered an ambiguous character in the sequence. No ambiguous characters are allowed because they weren't set in the model. To allow ambiguous characters, please add an \" Ambiguous Character Definition\" to the model" << std::endl;
exit(1);
}
}
else{
return symbolIndices[symbol];
}
}
uint8_t StochHMM::track::symbolIndex ( unsigned char  symbol)

Get symbol assigned integer value

Parameters:
symbolword/letter/symbol that we want to get it's assigned integer value

Definition at line 277 of file track.cpp.

References ambiguous, charIndices, defaultAmbiguous, maxSize, and symbolIndices.

{
if (maxSize != 1){
std::cerr << "Track Max Symbols Size:\t" << maxSize << "\t Must use function track::symbolIndex(const std::string& symbol)\n";
}
if (charIndices == NULL){
charIndices = new (std::nothrow) std::vector<uint8_t>(255,255);
for(std::map<std::string,uint8_t>::iterator it = symbolIndices.begin(); it != symbolIndices.end(); it++){
(*charIndices)[(it->first)[0]] = it->second;
}
}
if ((*charIndices)[symbol]==255){ //If isn't found in the array
if (ambiguous){ //Return default character if ambiguous is set
}
else{
std::cerr << "Encountered an ambiguous character in the sequence. No ambiguous characters are allowed because they weren't set in the model. To allow ambiguous characters, please add an \" Ambiguous Character Definition\" to the model" << std::endl;
exit(1);
}
}
else{
return (*charIndices)[symbol];
}
}

Friends And Related Function Documentation

friend class model
friend

Definition at line 95 of file track.h.

friend class state
friend

Definition at line 94 of file track.h.

friend class tracks
friend

Definition at line 96 of file track.h.


Member Data Documentation

trackType StochHMM::track::alpha_type
private

Definition at line 254 of file track.h.

Referenced by getAlphaType(), isAlpha(), setAlphaType(), stringify(), and track().

std::vector<std::string> StochHMM::track::alphabet
private
bool StochHMM::track::ambiguous
private

Definition at line 272 of file track.h.

Referenced by isAmbiguousSet(), setAmbiguous(), symbolIndex(), and track().

std::vector<ambigCharacter> StochHMM::track::ambiguousSymbols
private

Definition at line 277 of file track.h.

Referenced by addAmbiguous(), getAmbiguousCharacter(), getAmbiguousSet(), and getAmbiguousSize().

std::vector<uint8_t>* StochHMM::track::charIndices
private

Definition at line 281 of file track.h.

Referenced by symbolIndex(), and track().

std::map<uint8_t,uint8_t> StochHMM::track::complementAlphabet
private

Definition at line 264 of file track.h.

Referenced by addComplement(), getComplementIndex(), and getComplementSymbol().

bool StochHMM::track::complementSet
private
int StochHMM::track::defaultAmbiguous
private

Definition at line 273 of file track.h.

Referenced by addAmbiguous(), symbolIndex(), and track().

std::string StochHMM::track::description
private

Definition at line 251 of file track.h.

Referenced by getDescription(), and setDescription().

uint8_t StochHMM::track::max_ambiguous
private

Definition at line 269 of file track.h.

Referenced by addAmbiguous(), getAlpha(), getMaxAmbiguous(), stringifyAmbig(), and track().

uint8_t StochHMM::track::max_unambiguous
private
size_t StochHMM::track::maxSize
private

Definition at line 266 of file track.h.

Referenced by addAlphabetChar(), convertIndexToWord(), getAlphaMax(), symbolIndex(), and track().

std::string StochHMM::track::name
private

Definition at line 250 of file track.h.

Referenced by getName(), StochHMM::tracks::push_back(), setName(), stringify(), and stringifyAmbig().

std::map<std::string,uint8_t> StochHMM::track::symbolIndices
private
std::string StochHMM::track::trackFunction
private

Definition at line 261 of file track.h.

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

bool StochHMM::track::trackFunctionDefined
private

Track Functions for defining Real Number Tracks.

Definition at line 257 of file track.h.

Referenced by isTrackFuncDefined(), parse(), stringify(), and track().

size_t StochHMM::track::trackIndex
private

Definition at line 252 of file track.h.

Referenced by getIndex(), setIndex(), and track().

std::string StochHMM::track::trackToUse
private

Definition at line 260 of file track.h.

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

std::vector<size_t> StochHMM::track::unambiguous
private

Definition at line 270 of file track.h.

Referenced by addAlphabetChar(), and getUnambiguousSet().


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