Classes | |
class | ColumnStream |
class | CommandLine |
Class for parsing the command line. More... | |
class | Container2D |
Concept check for Container2D. More... | |
class | Mutable_Container2D |
Concept check for Mutable Container2D. More... | |
class | TrivialIterator |
Concept check for Trivial Iterator. More... | |
class | DataIteratorConcept |
Concept check for Data Iterator. More... | |
class | DistanceConcept |
Concept check for a Distance. More... | |
class | Container2DIterator |
Iterator for a Container2D. More... | |
class | DataIterator |
DataIterator. More... | |
class | DataWeight |
Holds a pair of data and associated weight. More... | |
class | DataWeightProxy |
Proxy class for DataWeight. More... | |
class | runtime_error |
Class used for all runtime error detected within yat library. More... | |
class | cmd_error |
Class used for error reported from Commandline or Option. More... | |
class | errno_error |
Class that contains information reported via global variable errno. More... | |
class | GSL_error |
Class for errors reported from underlying GSL calls. More... | |
class | IO_error |
Class to report errors associated with IO operations. More... | |
class | FileUtil |
Checking file/directory existence and access permissions. More... | |
class | GetlineIterator |
Read from std::istream with std::getline. More... | |
class | Index |
Class for storing indices of, e.g., a MatrixLookup. More... | |
struct | unweighted_iterator_tag |
struct | weighted_iterator_tag |
struct | weighted_iterator_traits |
struct | weighted_if_any2 |
struct | weighted_if_any3 |
struct | iterator_traits |
class | KernelPCA |
Principal Component Analysis on a Kernel Matrix. More... | |
class | kNNI |
kNNimpute More... | |
class | Matrix |
Interface to GSL matrix. More... | |
class | MatrixWeighted |
Weighted Matrix. More... | |
class | NNI |
Interface class for nearest neighbour imputation (NNI) algorithms. More... | |
class | Option |
Container of variables for an option. More... | |
class | OptionArg |
Option with argument. More... | |
class | OptionFile |
Class for file related options. More... | |
class | OptionInFile |
Class for file related options. More... | |
class | OptionOutFile |
Class for file related options. More... | |
class | OptionHelp |
Class for help option. More... | |
class | OptionSwitch |
Class for switch option. More... | |
class | PCA |
Principal Component Analysis. More... | |
class | Segment |
a class for a Segment or Interval More... | |
struct | SegmentCompare |
functor using compare More... | |
class | SegmentMap |
a map of Segments More... | |
class | SegmentSet |
a set of Segments More... | |
class | SegmentTree |
Base Class for SegmentSet and SegmentMap. More... | |
class | SmartPtr |
class | BasicStreamRedirect |
Redirect a stream to another stream. More... | |
class | Range |
A class for storing a shallow copy of a Range. More... | |
struct | abs |
struct | Dereferencer |
Adaptor between pointer and pointee interface. More... | |
class | compose_f_gx_hy |
class | compose_f_gxy |
class | compose_f_gx |
struct | Exp |
struct | Identity |
Identity functor that returns its argument. More... | |
struct | less_nan |
Functor that behaves like std::less with the exception that it treates NaN as a number larger than infinity. More... | |
struct | less_nan< DataWeight > |
Specialization for DataWeight. More... | |
class | Log |
struct | pair_value_compare |
Functor comparing pairs using second. More... | |
struct | PairFirst |
Functor that return std::pair.first. More... | |
struct | PairSecond |
Functor that return std::pair.second. More... | |
class | StrideIterator |
Adaptor using a stride on underlying iterator. More... | |
class | SVD |
Singular Value Decomposition. More... | |
class | TypeInfo |
Wrapper class for storing std::type_info. More... | |
class | Vector |
This is the yat interface to GSL vector. More... | |
class | VectorBase |
This is the yat interface to GSL vector. More... | |
class | VectorConstView |
Read-only view. More... | |
class | VectorMutable |
This is the mutable interface to GSL vector. More... | |
class | VectorView |
This is the yat interface to gsl_vector_view. More... | |
class | WeightedIterator |
WeightedIterator. More... | |
class | WeightIterator |
WeightIterator. More... | |
class | WeNNI |
Weighted Nearest Neighbour Imputation. More... | |
Typedefs | |
typedef BasicStreamRedirect< char > | StreamRedirect |
typedef BasicStreamRedirect < wchar_t > | wStreamRedirect |
Functions | |
double | NeedlemanWunsch (const utility::Matrix &s, std::vector< std::pair< size_t, size_t > > &path, const double gap) |
double | SmithWaterman (const utility::Matrix &s, double gap, double open_gap) |
Local alignment following the Smith-Waterman algorithm. | |
double | ssearch (std::string first, std::string second, double gap, double open_gap) |
template<class Iter > | |
void | check_iterator_is_unweighted (Iter iter) |
check (at compile time) that iterator is unweighted. | |
Vector | operator* (const VectorBase &, const Matrix &) |
Matrix Vector multiplication. | |
template<class Container2D > | |
void | merge (const Container2D &x, std::vector< std::string > &labels, Matrix &y) |
merge rows in a Container2D | |
template<class Container2D , class Functor > | |
void | merge (const Container2D &x, std::vector< std::string > &labels, Matrix &y, Functor func) |
merge rows in a Container2D using a Functor | |
template<class Container2D , class Functor1 , class Functor2 > | |
void | merge (const Container2D &x, std::vector< std::string > &labels, MatrixWeighted &y, Functor1 data_func, Functor2 weight_func) |
merge rows in a Container2D to a MatrixWeighted | |
template<typename ForwardIterator > | |
void | sort_index (ForwardIterator first, ForwardIterator last, std::vector< size_t > &sort_index) |
void | sort_index (StrideIterator< double * > first, StrideIterator< double * > last, std::vector< size_t > &sort_index) |
void | sort_index (StrideIterator< const double * > first, StrideIterator< const double * > last, std::vector< size_t > &sort_index) |
void | sort_index (std::vector< double >::iterator first, std::vector< double >::iterator last, std::vector< size_t > &sort_index) |
void | sort_index (std::vector< double >::const_iterator first, std::vector< double >::const_iterator last, std::vector< size_t > &sort_index) |
void | split (std::vector< std::string > &result, const std::string &str, char delim) |
split a string into several substrings | |
template<typename T1 , typename T2 > | |
bool | operator== (const Range< T1 > &, const Range< T2 > &) |
Equality comparison. | |
template<typename T1 , typename T2 > | |
bool | operator!= (const Range< T1 > &, const Range< T2 > &) |
Based on operator==. | |
template<typename T1 , typename T2 > | |
bool | operator< (const Range< T1 > &lhs, const Range< T2 > &rhs) |
Ordering relation. | |
template<typename T1 , typename T2 > | |
bool | operator<= (const Range< T1 > &lhs, const Range< T2 > &rhs) |
template<typename T1 , typename T2 > | |
bool | operator> (const Range< T1 > &, const Range< T2 > &) |
template<typename T1 , typename T2 > | |
bool | operator>= (const Range< T1 > &, const Range< T2 > &) |
template<typename Key , typename Tp , typename Compare , typename Alloc > | |
const Tp & | get (const std::map< Key, Tp, Compare, Alloc > &m, const Key &k) |
template<typename InputIterator , typename Key , typename Comp > | |
void | inverse (InputIterator first, InputIterator last, std::map< Key, std::vector< size_t >, Comp > &m) |
template<typename Key , typename InputIterator , typename Comp > | |
void | inverse (InputIterator first, InputIterator last, std::multimap< Key, size_t, Comp > &m) |
template<typename T > | |
T | max (const T &a, const T &b, const T &c) |
template<typename T > | |
T | max (const T &a, const T &b, const T &c, const T &d) |
template<typename T > | |
T | max (const T &a, const T &b, const T &c, const T &d, const T &e) |
template<typename T > | |
T | max (const T &a, const T &b, const T &c, const T &d, const T &e, const T &f) |
template<class Iter > | |
boost::transform_iterator < PairFirst< typename boost::remove_reference < typename std::iterator_traits< Iter > ::reference >::type >, Iter > | pair_first_iterator (Iter i) |
template<class Iter > | |
boost::transform_iterator < PairSecond< typename boost::remove_reference < typename std::iterator_traits< Iter > ::reference >::type >, Iter > | pair_second_iterator (Iter i) |
template<typename Pointer , class Compare > | |
compose_f_gx_hy< Compare, Dereferencer< Pointer > , Dereferencer< Pointer > > | make_ptr_compare (Pointer p, Compare compare) |
template<typename Pointer > | |
compose_f_gx_hy< std::less < typename std::iterator_traits< Pointer > ::value_type >, Dereferencer < Pointer >, Dereferencer < Pointer > > | make_ptr_compare (Pointer p) |
std::string & | to_lower (std::string &s) |
Function converting a string to lower case. | |
std::string & | to_upper (std::string &s) |
Function converting a string to upper case. | |
template<typename InputIterator , typename OutputIterator > | |
bool | binary_weight (InputIterator first, InputIterator last, OutputIterator result) |
template<typename T > | |
T | convert (const std::string &s) |
convert string to (numerical) type | |
template<typename T > | |
bool | is (const std::string &s) |
check if string is convertible to (numerical) type | |
bool | is_double (const std::string &) |
bool | is_equal (std::string s, std::string other) |
bool | is_float (const std::string &) |
bool | is_int (const std::string &) |
bool | is_nan (const std::string &s) |
template<typename T > | |
void | load (std::istream &is, std::vector< std::vector< T > > &vec, char sep='\0', char line_sep='\n', bool ignore_empty=false, bool rectangle=true) |
template<typename T > | |
void | load (std::istream &is, std::vector< T > &vec, char sep='\0') |
Fill a vector<T> with elements from istream. | |
void | sort_index (std::vector< size_t > &sort_index, const VectorBase &invec) |
void | sort_smallest_index (std::vector< size_t > &sort_index, size_t k, const VectorBase &invec) |
void | sort_largest_index (std::vector< size_t > &sort_index, size_t k, const VectorBase &invec) |
void | shuffle (VectorMutable &invec) |
void | sort (VectorMutable &vec) |
template<class X > | |
void | yat_assert (bool assertion, std::string msg) |
yat_assert is similar to assert in std. | |
unsigned int | major_version (void) |
unsigned int | minor_version (void) |
unsigned int | patch_version (void) |
std::string | version (void) |
Needed yat functionality that we don't know where to put usually ends up in the utility namespace until we figure out their proper namespace location.
typedef BasicStreamRedirect<char> theplu::yat::utility::StreamRedirect |
typedef BasicStreamRedirect<wchar_t> theplu::yat::utility::wStreamRedirect |
bool theplu::yat::utility::binary_weight | ( | InputIterator | first, | |
InputIterator | last, | |||
OutputIterator | result | |||
) | [inline] |
For each element in resulting range assign it to 0.0 if corresponding element in input range is NaN else assign it to 1.0.
void theplu::yat::utility::check_iterator_is_unweighted | ( | Iter | iter | ) | [inline] |
check (at compile time) that iterator is unweighted.
This function only compiles if iterator iter is unweighted.
T theplu::yat::utility::convert | ( | const std::string & | s | ) | [inline] |
const Tp & theplu::yat::utility::get | ( | const std::map< Key, Tp, Compare, Alloc > & | m, | |
const Key & | k | |||
) | [inline] |
Same functionality as map::operator[] but the function does not modify the map and the function throws if key does not exist in the map.
void theplu::yat::utility::inverse | ( | InputIterator | first, | |
InputIterator | last, | |||
std::multimap< Key, size_t, Comp > & | m | |||
) | [inline] |
In the created multimap each element e will fulfill:
Requirement: InputIterator's value type is assignable to Key
void theplu::yat::utility::inverse | ( | InputIterator | first, | |
InputIterator | last, | |||
std::map< Key, std::vector< size_t >, Comp > & | m | |||
) | [inline] |
Creating a map from a range [first, last) such that m[key] returns a vector with indices of which element in [first, last) that is equal to key, or more technically: m[element].size() returns number of elements equal to element, and m[*element][i] = distance(first, element) for every element in [first, last) and i smaller than m[element].size().
Requirement: InputIterator's value type is assignable to Key
bool theplu::yat::utility::is | ( | const std::string & | s | ) | [inline] |
bool theplu::yat::utility::is_double | ( | const std::string & | ) |
bool theplu::yat::utility::is_equal | ( | std::string | s, | |
std::string | other | |||
) |
This function takes the first word (separated by whitespace) in s, replaces all upper case with lower case, and compares it with other.
bool theplu::yat::utility::is_float | ( | const std::string & | ) |
bool theplu::yat::utility::is_int | ( | const std::string & | ) |
bool theplu::yat::utility::is_nan | ( | const std::string & | s | ) |
void theplu::yat::utility::load | ( | std::istream & | is, | |
std::vector< T > & | vec, | |||
char | sep = '\0' | |||
) | [inline] |
Fill a vector<T> with elements from istream.
Element separation has two modes depending on the value of sep.
void theplu::yat::utility::load | ( | std::istream & | is, | |
std::vector< std::vector< T > > & | vec, | |||
char | sep = '\0' , |
|||
char | line_sep = '\n' , |
|||
bool | ignore_empty = false , |
|||
bool | rectangle = true | |||
) | [inline] |
The std::istream will be interpreted as outlined here:
Lines are separated by character line_sep and rows are separated by character sep.
The first line is read into a stringstream, which is used to load the first vector (vec[0]) with elements using load(stringstream, vec[0], sep).
Therefore, column elements separation has two modes depending on the value of sep.
If rectangle is true, rows must contain same number of elements or function will throw.
If ignore_empty is true empty lines are ignored.
unsigned int theplu::yat::utility::major_version | ( | void | ) |
compose_f_gx_hy<std::less<typename std::iterator_traits<Pointer>::value_type>, Dereferencer<Pointer>, Dereferencer<Pointer> > theplu::yat::utility::make_ptr_compare | ( | Pointer | p | ) | [inline] |
compose_f_gx_hy<Compare, Dereferencer<Pointer>, Dereferencer<Pointer> > theplu::yat::utility::make_ptr_compare | ( | Pointer | p, | |
Compare | compare | |||
) | [inline] |
Convenient function that creates a binary predicate that can be used to compare pointers when you want to compare them with respect to the objects they point to.
Example:
std::vector<MyClass*> vec(18); ... std::sort(vec.begin(), vec.end(), make_ptr_compare(vec[0], std::greater<MyClass>());
Type Requirement:
F
is defined by compare and both G
and H
are Dereferencer
functors.T theplu::yat::utility::max | ( | const T & | a, | |
const T & | b, | |||
const T & | c, | |||
const T & | d, | |||
const T & | e, | |||
const T & | f | |||
) | [inline] |
T theplu::yat::utility::max | ( | const T & | a, | |
const T & | b, | |||
const T & | c, | |||
const T & | d, | |||
const T & | e | |||
) | [inline] |
T theplu::yat::utility::max | ( | const T & | a, | |
const T & | b, | |||
const T & | c, | |||
const T & | d | |||
) | [inline] |
T theplu::yat::utility::max | ( | const T & | a, | |
const T & | b, | |||
const T & | c | |||
) | [inline] |
void theplu::yat::utility::merge | ( | const Container2D & | x, | |
std::vector< std::string > & | labels, | |||
MatrixWeighted & | y, | |||
Functor1 | data_func, | |||
Functor2 | weight_func | |||
) | [inline] |
merge rows in a Container2D to a MatrixWeighted
When two (or several) elements in labels are found, the corresponding rows in x are merged into one row vector. The vector of labels are modified to reflect the rows in the resulting container y.
The data value of each element is calculated as defined by data_func and and the weight value is calculated as defined by weight_func.
x must be a Container2D. If Functor1 and Functor2 work on both unweighted and weighted iterators, merge works on both unweighted and weighted Container2D.
x | input container to be merged. | |
labels | telling which rows to merge. | |
y | resulting merged container. | |
data_func | defines how data values are calculated | |
weight_func | defines how weight values are calculated |
void theplu::yat::utility::merge | ( | const Container2D & | x, | |
std::vector< std::string > & | labels, | |||
Matrix & | y, | |||
Functor | func | |||
) | [inline] |
merge rows in a Container2D using a Functor
Same as utility::merge(const Container2D&, std::vector<std::string>&, Matrix&) but instead of calculating the merged element as the (weighted) arithmetic mean, the merged element is calculated as defined by func.
If Functor works on both unweighted and weighted iterators, merge works on both unweighted and weighted Container2D.
void theplu::yat::utility::merge | ( | const Container2D & | x, | |
std::vector< std::string > & | labels, | |||
Matrix & | y | |||
) | [inline] |
merge rows in a Container2D
When two (or several) elements in labels are found, the corresponding rows in x are merged into one row vector. The vector of labels are modified to reflect the rows in the resulting container y. In this default implementation the merge is calculated as the (weighted) arithmetic mean.
x must be a Container2D and it works for both weighted and unweighted containers.
x | input container to be merged. | |
labels | telling which rows to merge. | |
y | resulting merged container. |
unsigned int theplu::yat::utility::minor_version | ( | void | ) |
double theplu::yat::utility::NeedlemanWunsch | ( | const utility::Matrix & | s, | |
std::vector< std::pair< size_t, size_t > > & | path, | |||
const double | gap | |||
) |
Function performing alignment following the Needleman-Wunch algorithm. The algorithm starts from the dot-matrix, s, where describes how well element
in the first sequence match to element
in the second sequence. A path through this matrix corresponds to an alignment of the two sequences, in which a diagonal step over a matrix element corresponds to a match between the corresponding sequnce elements and a vertical or a horizontal step corresponds to inserting a gap in one of the sequnces. The function maximizes
gap, where the first sum goes over all matches and the second term is a penalty term for inserting
gaps. Default is to have the gap cost set to zero. The vector path contains information about which elements that were matched. If the first element in the first sequence was matched to the first element in the second sequence, the last element in path is pair(0,0).
bool theplu::yat::utility::operator!= | ( | const Range< T1 > & | lhs, | |
const Range< T2 > & | rhs | |||
) | [inline] |
bool theplu::yat::utility::operator< | ( | const Range< T1 > & | lhs, | |
const Range< T2 > & | rhs | |||
) | [inline] |
Ordering relation.
Using std::lexicographical_compare
bool theplu::yat::utility::operator<= | ( | const Range< T1 > & | lhs, | |
const Range< T2 > & | rhs | |||
) | [inline] |
bool theplu::yat::utility::operator== | ( | const Range< T1 > & | lhs, | |
const Range< T2 > & | rhs | |||
) | [inline] |
bool theplu::yat::utility::operator> | ( | const Range< T1 > & | lhs, | |
const Range< T2 > & | rhs | |||
) | [inline] |
bool theplu::yat::utility::operator>= | ( | const Range< T1 > & | lhs, | |
const Range< T2 > & | rhs | |||
) | [inline] |
boost::transform_iterator< PairFirst<typename boost::remove_reference< typename std::iterator_traits<Iter>::reference >::type>, Iter> theplu::yat::utility::pair_first_iterator | ( | Iter | i | ) | [inline] |
Creates a transform_iterator that transforms an iterator with value type std::pair to an iterator with value type std::pair::first_type. This can be used, for example, to communicate between a std::map and std::vector
std::map<std::string, int> map; ... std::vector<std::string> vec; vec.resize(map.size()); std::copy(pair_first_iterator(map.begin()), pair_first_iterator(map.end()), vec.begin());
boost::transform_iterator< PairSecond<typename boost::remove_reference< typename std::iterator_traits<Iter>::reference >::type>, Iter> theplu::yat::utility::pair_second_iterator | ( | Iter | i | ) | [inline] |
Creates a transform_iterator that transforms an iterator with value type std::pair to an iterator with value type std::pair::second_type. This can be used, for example, to communicate between a std::map and std::vector
std::map<std::string, int> map; ... std::vector<int> vec(map.size(),0); std::copy(vec.begin(), vec.end(), pair_second_iterator(map.begin()));
unsigned int theplu::yat::utility::patch_version | ( | void | ) |
void theplu::yat::utility::shuffle | ( | VectorMutable & | invec | ) |
Randomly shuffles the elements in VectorMutable invec
double theplu::yat::utility::SmithWaterman | ( | const utility::Matrix & | s, | |
double | gap, | |||
double | open_gap | |||
) |
Local alignment following the Smith-Waterman algorithm.
The original paper can be found here: http://gel.ym.edu.tw/~chc/AB_papers/03.pdf
Instead of looking at each sequence in its entirety the S-W algorithm compares segment of all possible lengths (LOCAL alignment) and chooses whichever maximises the similarity measure.
s | score matrix in which element ![]() ![]() ![]() | |
gap | cost for having a gap (insertion or deletion) | |
open_gap | cost for open up a gap in sequence, in other words, for a gap of length ![]() ![]() |
void theplu::yat::utility::sort | ( | VectorMutable & | vec | ) |
Sort the elements in the VectorMutable vec
NaNs are treated as infinity
void sort_index | ( | std::vector< size_t > & | sort_index, | |
const VectorBase & | invec | |||
) |
Create a vector sort_index containing the indeces of elements in a another VectorBase invec. The elements of sort_index give the index of the VectorBase element which would have been stored in that position if the VectorBase had been sorted in place. The first element of sort_index gives the index of the least element in invec, and the last element of sort_index gives the index of the greatest element in invec . The VectorBase invec is not changed.
void theplu::yat::utility::sort_index | ( | std::vector< double >::const_iterator | first, | |
std::vector< double >::const_iterator | last, | |||
std::vector< size_t > & | sort_index | |||
) |
void theplu::yat::utility::sort_index | ( | std::vector< double >::iterator | first, | |
std::vector< double >::iterator | last, | |||
std::vector< size_t > & | sort_index | |||
) |
void theplu::yat::utility::sort_index | ( | StrideIterator< const double * > | first, | |
StrideIterator< const double * > | last, | |||
std::vector< size_t > & | sort_index | |||
) |
void theplu::yat::utility::sort_index | ( | StrideIterator< double * > | first, | |
StrideIterator< double * > | last, | |||
std::vector< size_t > & | sort_index | |||
) |
void theplu::yat::utility::sort_index | ( | ForwardIterator | first, | |
ForwardIterator | last, | |||
std::vector< size_t > & | sort_index | |||
) | [inline] |
Create a vector sort_index containing the indeces of elements in a range [first, last). The elements of sort_index give the index of the range element which would have been stored in that position if the range had been sorted in place. The first element of sort_index gives the index of the least element in the range, and the last element of sort_index gives the index of the greatest element in the range. The function will not affect the range, i.e., ForwardIterator can be read-only.
void sort_largest_index | ( | std::vector< size_t > & | sort_index, | |
size_t | k, | |||
const VectorBase & | invec | |||
) |
Similar to sort_index but creates a VectorBase with indices to the k largest elements in invec.
void sort_smallest_index | ( | std::vector< size_t > & | sort_index, | |
size_t | k, | |||
const VectorBase & | invec | |||
) |
Similar to sort_index but creates a VectorBase with indices to the k smallest elements in invec.
void theplu::yat::utility::split | ( | std::vector< std::string > & | result, | |
const std::string & | str, | |||
char | delim | |||
) |
split a string into several substrings
Split str with respect to delim and place result in result. If str contains N delim, the resulting result will hold N+1 elements (given that it was empty to start with). If first or loast character in str is delim, corresponding element in result will be empty string ("").
double theplu::yat::utility::ssearch | ( | std::string | first, | |
std::string | second, | |||
double | gap, | |||
double | open_gap | |||
) |
SSearch does a rigorous Smith-Waterman search for similarity between sequnces. For long sequences this may be very expensive (both in time and space) and BLAST or FASTA is preferable.
std::string theplu::yat::utility::version | ( | void | ) |
void theplu::yat::utility::yat_assert | ( | bool | assertion, | |
std::string | msg | |||
) | [inline] |
yat_assert is similar to assert in std.
For internal use only.
If YAT_DEBUG is enabled and assertion is false, an exception X is thrown using constructor X(msg ).