StochHMM
v0.34
Flexible Hidden Markov Model C++ Library and Application
|
Stringlist is an list of strings that contains parsed comments and can be used to split string or remove whitespace from a string. More...
#include <text.h>
Public Member Functions | |
stringList () | |
stringList (std::string &, std::string &, std::string &, bool) | |
void | setRemoveWS () |
Set remove whitespace flag. When splitting string it will remove Whitespace first and then split the string. | |
void | unsetRemoveWS () |
Unset remove whitespace flag. When splitting string it will remove Whitespace first and then split the string. | |
void | setWhitespace (const std::string &txt) |
void | setDelimiters (const std::string &txt) |
void | getLine (std::istream &) |
void | processString (std::string &) |
void | splitString (const std::string &) |
void | splitString (const std::string &, const std::string &) |
void | splitString (const std::string &, size_t) |
void | splitND (const std::string &, const std::string &) |
void | removeLWS (const std::string &) |
void | removeComments () |
void | clear () |
Clears all values from the stringList, including comments, whitespace, and delimiters. | |
bool | fromTable (std::string &) |
bool | fromTable (std::istream &) |
bool | fromTrack (std::string &) |
bool | fromTrack (std::istream &) |
bool | fromAlpha (const std::string &, size_t) |
bool | fromAlpha (std::istream &, size_t) |
bool | fromTxt (std::string &) |
bool | fromTxt (std::istream &) |
bool | fromNext (std::string &) |
bool | fromNext (std::istream &) |
bool | fromDef (std::string &, std::string &, std::string &) |
bool | fromDef (std::istream &, std::string &, std::string &) |
void | operator<< (std::string &txt) |
void | push_back (std::string &txt) |
std::string | pop_ith (size_t) |
void | operator= (stringList &lst) |
std::string & | operator[] (size_t iter) |
std::string & | getComment () |
Return any comments parsed from the line. | |
std::vector< double > | toVecDouble () |
Returns the list as a Vector of Doubles. | |
void | toVecInt (std::vector< int > &) |
Returns the values in the stringList as std::vector of integers. | |
size_t | indexOf (const std::string &) |
size_t | indexOf (const std::string &, size_t) |
bool | contains (const std::string &) |
bool | containsExact (const std::string &txt) |
void | print () |
Print each line to stdout. | |
std::string | stringify () |
size_t | size () |
Return the amount of strings in the stringList. |
Private Member Functions | |
void | _splitIndividual (std::string &, size_t) |
bool | foundAlphaDelimiter (const std::string &) |
Private Attributes | |
std::vector< std::string > | line |
std::string | comment |
bool | removeWS |
std::string | whitespace |
std::string | delimiters |
Stringlist is an list of strings that contains parsed comments and can be used to split string or remove whitespace from a string.
StochHMM::stringList::stringList | ( | ) |
Create a new stringList Remove whitespace set to true by default.
Definition at line 32 of file text.cpp.
References removeWS.
StochHMM::stringList::stringList | ( | std::string & | txt, |
std::string & | ws, | ||
std::string & | del, | ||
bool | remove | ||
) |
Create a new StringList
txt | String to be split |
ws | Whitespace characters to remove from string before splitting |
del | Delimiter characters to use to split string |
remove | True will remove whitespace, False will leave whitespace |
Definition at line 43 of file text.cpp.
References splitString().
|
private |
|
inline |
Clears all values from the stringList, including comments, whitespace, and delimiters.
Definition at line 86 of file text.h.
References comment, delimiters, line, and whitespace.
Referenced by StochHMM::splitString().
bool StochHMM::stringList::contains | ( | const std::string & | txt | ) |
Searches for the string and returns bool if found or not
txt | String to search stringList |
Definition at line 51 of file text.cpp.
References line.
Referenced by StochHMM::PWM::_getOrderedPositionNames(), StochHMM::transition::_parseDuration(), StochHMM::state::_parseHeader(), StochHMM::model::_parseHeader(), StochHMM::transition::_parseLexical(), StochHMM::transition::_parseStandard(), StochHMM::state::_parseTransition(), StochHMM::model::_processTemplateState(), StochHMM::transitionFuncParam::parse(), StochHMM::emm::parse(), StochHMM::track::parse(), and StochHMM::emissionFuncParam::parse().
bool StochHMM::stringList::containsExact | ( | const std::string & | txt | ) |
|
private |
Returns true if text delimiters ":,[space]\\t" are found in the string
txt | String used to find delimiter |
Definition at line 284 of file text.cpp.
Referenced by fromAlpha().
bool StochHMM::stringList::fromAlpha | ( | const std::string & | txt, |
size_t | alpha | ||
) |
Remove whitespace characters '' and then splits string by delimiters ':' or '
'
txt | String to be split |
Definition at line 264 of file text.cpp.
References comment, foundAlphaDelimiter(), line, size(), and splitString().
Referenced by fromAlpha().
bool StochHMM::stringList::fromAlpha | ( | std::istream & | in, |
size_t | alpha | ||
) |
Remove whitespace characters '' and then splits string by delimiters ':' or '
'
in | std::istream stream |
alpha | Size of alphabet |
Definition at line 308 of file text.cpp.
References fromAlpha().
bool StochHMM::stringList::fromDef | ( | std::string & | txt, |
std::string & | ws, | ||
std::string & | del | ||
) |
Splits a definition from model file
txt | string to split |
ws | Whitespace characters to use |
del | Delimiters characters to use |
Definition at line 319 of file text.cpp.
References delimiters, processString(), size(), and whitespace.
Referenced by fromDef(), and StochHMM::ExDefSequence::parse().
bool StochHMM::stringList::fromDef | ( | std::istream & | in, |
std::string & | ws, | ||
std::string & | del | ||
) |
Splits a definition from model file
in | std::istream to get line from |
ws | Whitespace characters to use |
del | Delimiters characters to use |
Definition at line 337 of file text.cpp.
References delimiters, fromDef(), and whitespace.
bool StochHMM::stringList::fromNext | ( | std::string & | txt | ) |
Remove whitespace characters '','
' or space and then splits string by delimiters ':' or comma
txt | String to be split |
Definition at line 241 of file text.cpp.
References processString(), setDelimiters(), setWhitespace(), and size().
Referenced by fromNext(), and StochHMM::track::parse().
bool StochHMM::stringList::fromNext | ( | std::istream & | in | ) |
Remove whitespace characters '','
' or space and then splits string by delimiters ':' or comma
txt | std::istream reference |
Definition at line 255 of file text.cpp.
References fromNext().
bool StochHMM::stringList::fromTable | ( | std::string & | ) |
bool StochHMM::stringList::fromTable | ( | std::istream & | ) |
bool StochHMM::stringList::fromTrack | ( | std::string & | txt | ) |
Remove whitespace characters '' and then splits string by delimiters ':', '
', comma or space
txt | String to be split |
Definition at line 220 of file text.cpp.
References processString(), setDelimiters(), setWhitespace(), and size().
Referenced by fromTrack().
bool StochHMM::stringList::fromTrack | ( | std::istream & | in | ) |
Remove whitespace characters '' and then splits string by delimiters ':', '
', comma or space
in | std::istream reference |
Definition at line 233 of file text.cpp.
References fromTrack().
bool StochHMM::stringList::fromTxt | ( | std::string & | txt | ) |
Remove whitespace characters '\t' and then splits string by delimiters ':' or '\n'
txt | String to be split |
Definition at line 195 of file text.cpp.
References processString(), setDelimiters(), setWhitespace(), and size().
Referenced by StochHMM::model::_parseHeader(), and fromTxt().
bool StochHMM::stringList::fromTxt | ( | std::istream & | in | ) |
|
inline |
Return any comments parsed from the line.
Definition at line 121 of file text.h.
References comment.
Referenced by StochHMM::track::parse().
void StochHMM::stringList::getLine | ( | std::istream & | ) |
size_t StochHMM::stringList::indexOf | ( | const std::string & | txt | ) |
Searches the stringList for matching string and returns the index position of first match
txt | String to search stringList for |
Definition at line 71 of file text.cpp.
References line, and SIZE_MAX.
Referenced by StochHMM::transition::_parseDuration(), StochHMM::state::_parseHeader(), StochHMM::model::_parseHeader(), StochHMM::transition::_parseLexical(), StochHMM::model::_processTemplateState(), StochHMM::transitionFuncParam::parse(), StochHMM::emm::parse(), StochHMM::track::parse(), and StochHMM::emissionFuncParam::parse().
size_t StochHMM::stringList::indexOf | ( | const std::string & | txt, |
size_t | pos | ||
) |
Searches the stringList for matching string and returns the index position of a given string from the starting position
txt | String to search stringList for |
pos | Position to start search from |
|
inline |
Add string to StringList
txt | String to add to the stringList |
Definition at line 103 of file text.h.
References line.
|
inline |
Copy StringList
lst | stringList to copy |
Definition at line 113 of file text.h.
References comment, delimiters, line, and whitespace.
|
inline |
std::string StochHMM::stringList::pop_ith | ( | size_t | pos | ) |
Definition at line 346 of file text.cpp.
References line.
Referenced by StochHMM::transition::_parseLexical(), and StochHMM::emm::parse().
void StochHMM::stringList::print | ( | ) |
void StochHMM::stringList::processString | ( | std::string & | txt | ) |
Removes Comments, Removes Whitespace, and splits the string Whitespace and Split delimiters are required to be previously set in stringList
Definition at line 94 of file text.cpp.
References StochHMM::clear_whitespace(), comment, line, StochHMM::parseComment(), removeWS, splitString(), and whitespace.
Referenced by fromDef(), fromNext(), fromTrack(), and fromTxt().
|
inline |
Add string to StringList
txt | String to add to the stringList |
Definition at line 107 of file text.h.
References line.
Referenced by StochHMM::PWM::_getOrderedPositionNames(), StochHMM::model::_getOrderedStateNames(), StochHMM::transition::_parseLexical(), StochHMM::PWM::_splitPositions(), StochHMM::model::_splitStates(), StochHMM::emm::parse(), StochHMM::weight::parse(), and trainingSeqs::setAlphabet().
void StochHMM::stringList::removeComments | ( | ) |
Parses out the comments and stores the comment delimited by "#" *Comment can be accessed by command getComment();
Definition at line 414 of file text.cpp.
References comment, line, and StochHMM::parseComment().
Referenced by StochHMM::state::_parseTransition().
void StochHMM::stringList::removeLWS | ( | const std::string & | ws | ) |
Remove leading whitespace *Removes the leading whitespace from the sequence
ws | String of whitespace characters to remove |
Definition at line 185 of file text.cpp.
References StochHMM::removeLeadingWS(), and size().
Referenced by StochHMM::state::_parseTransition().
|
inline |
Set delimiter characters. String will be split on these characters
txt | String of text-delimiters to use in splitting string |
Definition at line 74 of file text.h.
References delimiters.
Referenced by fromNext(), fromTrack(), and fromTxt().
|
inline |
|
inline |
Set whitespace character. When splitting string it will remove defined whitespace characters before splitting the string.
txt | String of whitespace characters to remove from sequence |
Definition at line 70 of file text.h.
References whitespace.
Referenced by fromNext(), fromTrack(), and fromTxt().
|
inline |
Return the amount of strings in the stringList.
Definition at line 137 of file text.h.
References line.
Referenced by StochHMM::sequence::_digitize(), StochHMM::PWM::_getOrderedPositionNames(), StochHMM::model::_getOrderedStateNames(), StochHMM::ExDefSequence::_parseAbsDef(), StochHMM::PWM::_parseAmbiguous(), StochHMM::model::_parseAmbiguous(), StochHMM::transition::_parseDuration(), StochHMM::state::_parseEmission(), StochHMM::state::_parseHeader(), StochHMM::model::_parseHeader(), StochHMM::transition::_parseLexical(), StochHMM::PWM::_parsePositions(), StochHMM::model::_parseScaling(), StochHMM::PWM::_parseSpacer(), StochHMM::transition::_parseStandard(), StochHMM::model::_parseStates(), StochHMM::model::_parseTracks(), StochHMM::state::_parseTransition(), StochHMM::ExDefSequence::_parseWeightDef(), StochHMM::emm::_processTags(), StochHMM::transition::_processTags(), StochHMM::model::_processTemplateState(), StochHMM::model::_splitStates(), fromAlpha(), fromDef(), fromNext(), fromTrack(), fromTxt(), StochHMM::sequence::getMaskedFasta(), StochHMM::emm::parse(), StochHMM::track::parse(), StochHMM::matrixPosition::parse(), StochHMM::weight::parse(), removeLWS(), and trainingSeqs::setAlphabet().
void StochHMM::stringList::splitND | ( | const std::string & | txt, |
const std::string & | del | ||
) |
Non-destructive string split Splits the string up using an additional string as the delimiter. Unlike stringSplit the delimiter isn't deleted from the returned value;
txt | String to be split |
del | Delimiter string to use to split |
Definition at line 163 of file text.cpp.
Referenced by StochHMM::state::_parseEmission(), StochHMM::model::_parseScaling(), StochHMM::state::_parseTransition(), and StochHMM::matrixPosition::parse().
void StochHMM::stringList::splitString | ( | const std::string & | txt | ) |
Split string using delimiter Splits the string up according to character delimiters defined in stringList. The char delimiters are deleted from the returned value. Delimiters allows you supply multiple delimiters in a single string.
txt | String to be split |
Definition at line 116 of file text.cpp.
References comment, delimiters, line, and SIZE_MAX.
Referenced by StochHMM::sequence::_digitize(), StochHMM::PWM::_parseAmbiguous(), StochHMM::model::_parseAmbiguous(), StochHMM::transition::_parseDuration(), StochHMM::transition::_parseLexical(), StochHMM::PWM::_parseSpacer(), StochHMM::transition::_parseStandard(), StochHMM::PWM::_parseTrack(), StochHMM::model::_parseTracks(), StochHMM::model::_processTemplateState(), StochHMM::extractTag(), fromAlpha(), StochHMM::getKeyValue(), StochHMM::sequence::getMaskedFasta(), StochHMM::sequence::getReal(), StochHMM::emm::parse(), StochHMM::matrixPosition::parse(), StochHMM::weight::parse(), processString(), splitString(), StochHMM::splitString(), and stringList().
void StochHMM::stringList::splitString | ( | const std::string & | txt, |
const std::string & | del | ||
) |
Split string using delimiter Splits the string up according to character delimiters supplied in the delimiter string. The char delimiters are deleted from the returned value. Delimiters allows you supply multiple delimiters in a single string.
txt | String to be split |
del | Delimiters to use to split evaluated as single characters, not whole string |
Definition at line 145 of file text.cpp.
References delimiters, and splitString().
void StochHMM::stringList::splitString | ( | const std::string & | txt, |
size_t | charSize | ||
) |
std::string StochHMM::stringList::stringify | ( | ) |
Joins the stringList into string using "\t" and return string
Definition at line 402 of file text.cpp.
References comment, StochHMM::join(), and line.
Referenced by StochHMM::transition::_parseDuration(), StochHMM::transition::_parseLexical(), StochHMM::emm::_processTags(), StochHMM::model::_processTemplateState(), and StochHMM::track::parse().
std::vector< double > StochHMM::stringList::toVecDouble | ( | ) |
Returns the list as a Vector of Doubles.
Returns the values in the stringList as std::vector of doubles.
Definition at line 358 of file text.cpp.
References line, and StochHMM::stringToDouble().
Referenced by StochHMM::transition::_parseLexical(), StochHMM::sequence::getReal(), and StochHMM::emm::parse().
void StochHMM::stringList::toVecInt | ( | std::vector< int > & | ret_val | ) |
Returns the values in the stringList as std::vector of integers.
Definition at line 371 of file text.cpp.
References line, and StochHMM::stringToInt().
Referenced by StochHMM::sequence::getMaskedFasta().
|
inline |
|
private |
Definition at line 145 of file text.h.
Referenced by clear(), fromAlpha(), getComment(), operator=(), print(), processString(), removeComments(), splitND(), splitString(), and stringify().
|
private |
Definition at line 149 of file text.h.
Referenced by clear(), fromDef(), operator=(), setDelimiters(), and splitString().
|
private |
Definition at line 144 of file text.h.
Referenced by clear(), contains(), containsExact(), fromAlpha(), indexOf(), operator<<(), operator=(), operator[](), pop_ith(), print(), processString(), push_back(), removeComments(), size(), splitND(), splitString(), stringify(), toVecDouble(), and toVecInt().
|
private |
Definition at line 147 of file text.h.
Referenced by processString(), setRemoveWS(), stringList(), and unsetRemoveWS().
|
private |
Definition at line 148 of file text.h.
Referenced by clear(), fromDef(), operator=(), processString(), and setWhitespace().