TIGR++
Class Reference


Overview


*
Classes by Category *


Alphabetical Class Listing













Overview


Most of these classes have been extensively used for a number of years. Several TIGR gene-finders were constructed using this class library, including TigrScan and Unveil.

This software is available as open source under the ARTISTIC LICENSE. The regular expression classes are offered as wrappers for the GNU regex library, which has its own license. See the source code for details.

Changes and additions are welcome. Please contact bmajoros@tigr.org.






















Classes By Category


Strings & Sequences


Math & Statistics

GFF / Gene Models


Data Structures

I/O


System

Iteration


Sorting


Strings & Sequences
Math & Statistics
Alphabet BinomialDistribution
AminoAlphabet TigrChi2FitTest
DnaAlphabet TigrChi2IndepTest
LowercaseDnaAlphabet TigrChi2Table
Sequence TigrComplexNum
Symbol TigrContingencyTbl
TigrFastaReader TigrDblMatrix
TigrFastaWriter TigrEntropy
TigrHugeFastaReader TigrGaussJordan
TigrMemStream TigrTriangMatrix
TigrProteinTrans TigrInversionMatrix
TigrRegex TigrJointDistr
TigrString TigrLinearFunc
TigrStrTokenizer TigrLinRegressor
TigrStringMap TigrMultRegress
StringMapIterator TigrMutInfo

TigrRealVector

TigrSparseGraph

TigrStandardDev

TigrSummaryStats
GFF / Gene Models
Data Structures
TigrGffTranscript BoundedSortedArray
TigrGffExon TigrBinaryTree
TigrGffFeature FixedSizePriorityList
TigrGffReader FixedSizePriorityQueue
TigrGffTranscript TigrArray1D

TigrArray2D

TigrPriorityTree

TigrBitSet

TigrElasVector

TigrElasDblVect

TigrElasFloatVect

TigrElasIntVect

TigrElasCharVect

TigrElasLongVect

TigrFastBinTree

TigrList

TigrListQueue

TigrMap

TigrSet

TigrStack

TigrVector

TigrWindowedQueue
I/O
System
TigrFile Environment
TigrConfigFile MemoryProfiler

TigrCommandLine

TigrPipe

RootException

FileErrorException

ArrayIndexException

TigrProgress

TigrSmartPointer

TigrStacktrace

TigrTime
Iteration
Sorting
TigrIterator TigrVectorSorter
FSPLIterator TigrArray1DSorter
TigrBinTreeIter TigrComparator

DirectComparator

TranscriptComparator





Class Index (Alphabetical)
1. Alphabet
2. AminoAlphabet
3. BinomialDistribution
4. BoundedSortedArray
5. DnaAlphabet
6. LowercaseDnaAlphabet
7. Environment
8. FSPLIterator
9. FixedSizePriorityList
10. FixedSizePriorityQueue
11. MemoryProfiler
12. Sequence
13. Symbol
14. TigrArray1D
15. TigrArray1DSorter
16. TigrArray2D
18. TigrBinaryTree
19. TigrBinTreeIter
20. TigrBitSet
21. TigrChi2FitTest
22. TigrChi2IndepTest
23. TigrChi2Table
24. TigrCommandLine
25. TigrComparator
26. DirectComparator
27. TigrComplexNum
28. TigrConfigFile
29. TigrContingencyTbl
30. TigrDblMatrix;
31. TigrElasVector
32. TigrElasDblVect
33. TigrElasFloatVect
34. TigrElasIntVect
35. TigrElasCharVect
36. TigrElasLongVect
37. TigrEntropy
38. RootException
39. FileErrorException
40. ArrayIndexException
41. TigrFastaReader
42. TigrFastaWriter
44. TigrFastBinTree
45. TigrFile
46. TigrGaussJordan
48. TigrGffExon
49. TigrGffFeature
50. TranscriptComparator
51. TigrGffReader
52. TigrGffTranscript
53. TigrHugeFastaReader
55. TigrInversionMatrix
56. TigrIterator
57. TigrJointDistr
58. TigrLinearFunc
59. TigrLinRegressor
60. TigrList
61. TigrListQueue
63. TigrMap
64. TigrMemStream
65. TigrMultRegress
66. TigrMutInfo
67. TigrPipe
68. TigrPriorityTree
69. TigrProgress
70. TigrProteinTrans
71. TigrRealVector
72. TigrRegex
73. TigrSet
74. TigrSmartPointer
75. TigrSparseGraph
76. TigrStack
78. TigrStacktrace
79. TigrStandardDev
80. TigrString
81. StringMapIterator
82. TigrStringMap
83. TigrStrTokenizer
84. TigrSummaryStats
85. TigrTime
86. TigrTriangMatrix
87. TigrVector
88. TigrVectorSorter
89. TigrWindowedQueue






class Alphabet
Represents an arbitrary alphabet of discrete symbols, whether DNA, amino acids, or other.  Consists of Symbol objects (which are interchangeable with native ints).
Alphabet(const char * = NULL); constructor
int add(char); Add a character to the alphabet.
bool load(istream &); Load alphabet from file.
int getNumElements() const; Size of alphabet.
inline char lookup(int) const; Get the ith symbol in the alphabet.
inline int lookup(char) const; Get the index of a given symbol.
void printOn(ostream &); Display alphabet on stream.
char complement(char); Crick-Watson DNA complement of symbol
Symbol complement(Symbol); Crick-Watson DNA complement of symbol
bool save(ostream &); Write alphabet into file.
bool isDefined(char) const; Check whether symbol is present in alphabet.



class AminoAlphabet : public Alphabet
An alphabet of amino acid symbols.
AminoAlphabet(); constructor
static AminoAlphabet global; Global instance of this class.



class BinomialDistribution
Represents a binomial distribution.
static inline double density(int exactNumSuccesses, int numTrials, double probSuccess);
Returns P(s|n,p)=probability of observing exactly s successes in n bernoulli trials, given probability of sucess p.
static double rightTailedPValue(int thisManyOrMoreSuccesses,int numTrials, double probabilityOfSuccess); Returns P(s|n,p)=probability of observing s or more successes in n bernoulli trials, given probability of sucess p.



template<class ObjectType,class ScalarType>
class BoundedSortedArray
An array that has a fixed size.  Elements are kept sorted.  If you add too many things to the array, elements are lost out the left or right side.
BoundedSortedArray(int size,KeepType); constructor.  KeepType= {KEEP_LOW_VALUES, KEEP_HIGH_VALUES}.  ScalarType should be int,float,double, etc. for maintaining the ordering of the array.
bool add(const ObjectType &,ScalarType); Insert an element into the array, with a value for maintaining sorted order.
ObjectType &operator[](int); Access element of array.
const ObjectType &operator[](int) const; Access element of const array.
ScalarType getValue(int i) const; Access the scalar value of array element.



class DnaAlphabet : public Alphabet
Alphabet containing symbols {A,T,C,G,N}.
DnaAlphabet(); constructor
static DnaAlphabet global; Global instance of this object.



class LowercaseDnaAlphabet : public Alphabet
Alphabet containing symbols {a,t,c,g,n}
LowercaseDnaAlphabet(); constructor
static LowercaseDnaAlphabet global; Global instance of this object.



class Environment
Allows access to UNIX environment variables.
static TigrString lookup(const TigrString &); Look up given environment variable.



template <class T>
class FSPLIterator : public TigrIterator<T>
Iterator for FixedSizePriorityList.  Defined in FixedSizePriorityList.H.
FSPLIterator(typename TigrList<T>::iterator); constructor
FSPLIterator(); constructor
virtual void operator++(); Advance to next element
virtual void operator++(int); Advance to next element
virtual T &operator*(); Access this element
virtual bool operator==(const TigrIterator<T> &) const; Compare iterators
virtual bool operator!=(const TigrIterator<T> &i) const Compare iterators
virtual TigrIterator<T> &clone(); Clone iterator
operator typename TigrList<T>::iterator(); Cast this iterator to a TigrList::iterator



template <class T>
class FixedSizePriorityList
A linked list having a maximum size.  If you insert too many elements, the smallest elements are deleted to maintain the size restriction.
FixedSizePriorityList(int capacity, TigrComparator<T>& = *new DirectComparator<T>()); constructor
int getCapacity() const; Returns maximum size of list
int size() const; Returns current size of list
bool empty() const; Returns true if list is empty
bool insert(T); Adds element to list
bool push_back(T t); Adds element to list (same as insert)
T &getMin(); Returns smallest element
T &getMax(); Returns largest element
FSPLIterator<T> begin(); Starting iterator
FSPLIterator<T> end(); Ending iterator
void erase(FSPLIterator<T>); Remove an element from the list
void clear(); Remove all elements ffrom the list



template <class T>
class FixedSizePriorityQueue
A priority queue implemented as a fast binary tree (i.e., nodes have pointers to children and parent) and with a fixed capacity, so that when the queue is full, each insertion causes the smallest element to fall out of the queue.
FixedSizePriorityQueue(int capacity, TigrComparator<T>& = *new DirectComparator<T>()); constructor
int getCapacity() const; Returns maximum# elements that will fit
int getNumElements() const; Returns number of elements in the queue
bool isEmpty() const; True iff queue is empty
bool insert(T); Add element to queue
T &peekMin() const; Returns minimum element, no removal
T &peekMax() const; Returns max element; no removal
TigrFastBinTree<T>:: iterator begin(); Starting iterator
TigrFastBinTree<T>:: iterator end(); Ending iterator



class MemoryProfiler
LINUX-specific class for monitoring memory usage of the current program during execution.
static void report(const TigrString &label,ostream & =cout); Prints a message to the ostream reporting current memory usage



class Sequence
A sequence of discrete Symbols.
static Sequence *load(const TigrString &filename,Alphabet &, TigrString &substrateId); Loads the sequence with the given substrateId (after the '>' on the defline) from the given file
static Sequence *load(const TigrString &filename,Alphabet &); Loads the first sequence from the given file
Sequence(const TigrString &,Alphabet &); constructor - builds a Sequence from the given string under the given alphabet
Sequence(); constructor - builds an empty Sequence
Sequence(const char *,Alphabet &); constructor - builds a Sequence from the given string under the given alphabet
virtual ~Sequence(); destructor
void copyFrom(const TigrString &,Alphabet &); Make this sequence identical to that sequence
void setPhase(int); Associate a phase value with this sequence
int getPhase() const; Get the phase value that was previous set via setPhase()
void append(Symbol); Append a single symbol to the sequence
void append(const Sequence &); Append another sequence to the end of this sequence
void prepend(Symbol); Prepend a single symbol to the beginning of this sequence
Symbol operator [](int) const; Access the const symbol at the given index
Symbol &operator [](int); Access the symbol at the given index
const Sequence &operator=(const Sequence &); copy assignment operator
int getLength() const; Returns length of sequence
void printOn(ostream &) const; Prints sequence on an ostream as a sequence of integers (using the int encoding internal to the alphabet)
void printOn(ostream &,Alphabet &) const; Prints sequence on ostream as sequence of characters, as defined by alphabet
TigrString *toString(Alphabet &,int startingAt=0) const; Convert sequence object to string, with optional offset index
void clear(); Become the empty sequence
virtual void getSubsequence(int begin,int len,Sequence &s) const; Copies subsequence of this sequence into s
bool subsequenceOccursAt(const Sequence &s,int pos) const; True iff s occurs as a substring of this sequence at position pos
Sequence *reverseComplement(Alphabet &) const; Returns the Watson-Crick reverse complementary sequence of this one
void reverseComplement(Alphabet &,Sequence &) const; Computes reverse complement into the provided sequence
bool isEmpty() const; True iff this sequence is empty



class Symbol
A single symbol in an Alphabet.  Represented as an int value.  Requires use of Alphabet to translate into char lexeme.  Can be stored in Sequences.
Symbol(int =0); constructor
bool operator==(const Symbol &); Same as that symbol?
operator int() const; Get underlying int representation.
int getIndex() const; Get underlying int representation.
Symbol &operator++(); Get symbol with next higher in value



template<class T>
class TigrArray1D
Single-dimensional fixed-size array of objects of type T.  Define DEBUG to turn on bounds-checking.
TigrArray1D(int size); constructor - build array of given size
TigrArray1D(const TigrArray1D &); copy constructor
virtual ~TigrArray1D(); destructor - deallocates array (but not objects pointed to if T is a pointer!)
T &operator[](int); Access element at given index.
const T &operator[](int) const; Access element at given index.
int size() const; Returns capacity of array (# elements)
void printOn(ostream &os); Print on ostream (used by operator <<)
void resize(int newSize); Delete array and reallocate to given size
void setAllTo(T); Store given value at all locations
void saveBytes(TigrFile &); Write raw byte representation into file
void loadBytes(TigrFile &); Read raw byte representation from file
TigrArray1D<T> &operator=(const TigrArray1D<T> &); Copy assignment operator



template <class T>
class TigrArray1DSorter
A class that can sort the elements of a TigrArray1D<T>, given a TigrComparator for T.
TigrArray1DSorter(TigrArray1D<T> &,TigrComparator<T> &); constructor - the comparator must define the desired ordering
TigrArray1D<T> *sortAscending(); Sort the elements in ascending order and return the resulting array (original array unmodifed)
TigrArray1D<T> *sortDescending(); Sort the elements in descending order and return the resulting array (original array unmodified)
TigrArray1D<int> *sortAscendByIndex(); Returns array of indices of progressive elements in sorted order (ascending), without modifying the original array
TigrArray1D<int> *sortDescendByIndex(); Returns array of indices of progressive elements in sorted order (descending), without modifying the original array
void sortAscendInPlace(); Sort in place; ascending
void sortDescendInPlace(); Sort in place; descending



template<class T>
class TigrArray2D
Two-dimensional array of objects of type T.  Fixed dimensions.  Define DEBUG to turn on bounds-checking.  Use standard A[i][j] notation to access elements (by reference).  First dimension is rows, second dimension is columns.
TigrArray2D(int rows,int cols); constructor
TigrArray2D(const TigrArray2D &); copy constructor
virtual ~TigrArray2D(); destructor
RowIn2DArray<T> operator[](int); Using a single index (i.e. array[i]) returns a RowIn2DArray object, which can then accept a second index.  Thus, array[i][j] gives you a reference to an object of type T.
const RowIn2DArray<T> operator[](int) const; Const version of []
T &index(int,int); Same as array[i][j]
int getFirstDim() const; Returns first dimension size
int getSecondDim() const; Returns second dimension size
void printOn(ostream &) const; Print on ostream (used by operator <<)
void readFrom(istream &); Reads an array from an istream, filling up rows before columns (first index increases faster than second)
void setAllTo(T); Store given object at all locations
void resize(int rows,int cols); Delete array and resize to given dimensions
void saveBytes(TigrFile &); Write raw bytes into file
void loadBytes(TigrFile &); Read raw bytes from fil




template<class T>
class TigrBinaryTree
Binary tree in which each node has a pointer to its children but not to its parent.  If you want faster performance, use TigrFastBinTree, which stores a parent pointer in each node.  T is the stored data type (not the node type -- a node type is defined within the binary tree that has a T member).
TigrBinaryTree(TigrComparator<T>& = *new DirectComparator<T>()); constructor - requires a comparator over T's to defined the ordering
virtual ~TigrBinaryTree(); destructor
virtual bool insert(T); Insert an element
virtual T &maximum() const; Get the largest element
virtual T &minimum() const; Get the smallest element
virtual unsigned getCardinality(); Find out how many elements are in the tree
bool isEmpty() const; True iff tree is currently empty
virtual void purge(); Remove all objects from the tree
TigrBinTreeIter<T> begin(); Get begin iterator
TigrBinTreeIter<T> end(); Get ending iterator
void remove(T); Remove object from tree
bool getPredecessor(T X,T &Y); Find predecessor of X and store that in Y; returns false iff none found
bool getSuccessor(T X,T &Y); Find successor of X and store that in Y; returns false iff none found
TigrComparator<T> &getComparator(); Returns comparator supplied in constructor



template<class T>
class TigrBinTreeIter
Iterator for binary trees (TigrBinaryTree).  Three iteration types: PREORDER, POSTORDER, INORDER.
TigrBinTreeIter(TigrBinaryTree<T> *,IterationType=INORDER); constructor; defaults to INORDER
T &operator*(); Returns current element
operator bool();
True iff iteration is not finished
TigrBinTreeIter<T> &operator++(); Advance iterator to next element
bool operator==(const TigrBinTreeIter<T> &) const; True iff this iterator points to same element as the other iterator



class TigrBitSet
A set represented by a bit-vector, with one bit per element.
TigrBitSet(unsigned long Size=0); constructor - build set with given max size
virtual ~TigrBitSet(); virtual destructor
void operator =(TigrBitSet &); copy assignment operator
void operator -=(TigrBitSet &); Subtract other set from this one and store the result here
void operator +=(TigrBitSet &); Store union of this set and that set here
void operator *=(TigrBitSet &); Store intersection of that set and this set here
bool operator ==(TigrBitSet &); True iff this set has same elements as that one
TigrBitSet *operator -(TigrBitSet &); Subtract other set from this one and return resulting set
TigrBitSet *operator +(TigrBitSet &); Compute union of this set and that set and return the result
TigrBitSet *operator *(TigrBitSet &); Compute intersection of this set and that set and return the result
bool isMember(unsigned long index); True iff given bit is set (element is present)
unsigned long cardinality(); Return number of elements in set
unsigned long getMaxSize(); Return max capacity of this set
void addAll(); Become the universal set (all bits on)
void addMember(unsigned long index);
Insert element into set
void complement(); Complement all bits
void getRawBytes(unsigned char *&,unsigned long &maxSize, unsigned long &numBytes); Returns underlying representation
void load(FILE *fp); Loads set from file that was previous saved  via save(FILE*)
void purge(); Become the empty set
void removeMember(unsigned long index); Remove element from set
void replaceRawBytes(unsigned char *,unsigned long maxSize, unsigned long numBytes); Replace underlying bytes - useful if you just want to use this class to manipulate long bit vectors
void save(FILE *fp); Store raw bytes in file
void setSize(unsigned long Size); Delete set and reallocate to new size



class TigrChi2FitTest
Computes a chi-squared goodness-of-fit test.
TigrChi2FitTest(TigrVector<int> &observedCounts, TigrVector<int> &expectedCounts, TigrChi2Table &); constructor - takes observed counts and expected counts for paired data, and a chi-squared distribution object, and performs the goodness-of-fit test
bool goodFit(); Ttrue if good fit
double getChiSquared(); Returns chi-squared statistic
double getP(); Returns P-value associated with chi-squared statistic



class TigrChi2IndepTest
Computes a chi-squared test of independence.
TigrChi2IndepTest(TigrArray2D<int> &contingencyTable,TigrChi2Table &); constructor - takes a contingency table of observed counts and a chi-squared distribution, and performs the test
bool areIndependent(); True iff variables are probably independent
double getChiSquared(); Returns chi-squared statistic
double getP(); Returns P-value associated with chi-squared statistic
inline bool areDependent(); True iff variables are probably not independent



class TigrChi2Table
Stores chi-squared distribution table.  DEFAULT_PATH="tigr++/chi-squared.txt".  Employs linear interpolation.
TigrChi2Table(TigrString filename=DEFAULT_PATH); constructor - takes path to file containing chi-squared distribution table
float lookupChi(int df,float alpha); Get chi-squared value for given degrees of freedom df and alpha level
float lookupP(int df,float chiSquared); Get alpha level for given chi-squared value and degrees of freedom



class TigrCommandLine
Parses command line and provides access to arguments and options.
TigrCommandLine(int argc,char *argv[],const char *options); constructor - options are of the form "a:bc:" where a and c take parameters and b does not
TigrString arg(int); Return ith argument; first argument has index 0
TigrString optParm(char); Return the parameter supplied with the given option
bool option(char); True iff the user specified "-c" for char c
int numArgs(); Number of args on command line (not including options)



template <class T>
class TigrComparator
Abstract base class for comparators.  Used in sorting and in sorted data structures.  Subclass this class and override the operators for your data type.
virtual bool equal(T &a,T &b)=0; a==b?
virtual bool greater(T &a,T &b)=0; a>b?
virtual bool less(T &a,T &b)=0; a<b?



template <class T>
class DirectComparator : public TigrComparator<T>
A comparator for type T that compares T objects using the native <, >, and == operators.
virtual bool equal(T &a,T &b); a==b?
virtual bool greater(T &a,T &b); a>b?
virtual bool less(T &a,T &b); a<b?



class TigrComplexNum
Complex number having a real part and an imaginary part
TigrComplexNum(double real=0.0,double imag=0.0); constructor
TigrComplexNum operator+(const TigrComplexNum &); complex addition
TigrComplexNum operator*(const TigrComplexNum &); complex multiplication
TigrComplexNum getConjugate(); returns (r,-i)
double &getImag(); access to imaginary part
double &getReal(); access to real part
double getImag() const; returns imaginary part
double getModulus() const; sqrt(r*r + i*i)
double getReal() const; returns real part



class TigrConfigFile
Parses a configuration file consisting of lines of the form X=Y. # starts a comment line.  X and Y may be surrounded by spaces but may not contain spaces within them.  X is the "attribute" and Y is the "value".  This class stores (attribute,value) pairs and supports queries on attribute values.
TigrConfigFile(TigrString fname); constructor - loads configuration file
virtual TigrString lookup(TigrString attr); returns the value associated with the given attribute, or the empty string if not defined in the config file
virtual TigrString lookupOrDie(TigrString attr); returns value of given attribute, or throws exception if not found in config file
virtual double getDoubleOrDie(TigrString attr); looks up attribute and converts value to double, or throws exception if undefined
virtual float getFloatOrDie(TigrString attr); looks up attribute and converts value to float, or throws exception if undefined
virtual int getIntOrDie(TigrString attr); looks up attribute and converts value to int, or throws exception if undefined
virtual long getLongOrDie(TigrString attr); looks up attribute and converts to long, or throws exception if undefined



class TigrContingencyTbl : public TigrIntArray2D
A contingency table of counts for use with TigrChi2IndepTest (chi-squared test of independence) or TigrMutInfo (mutual information)
TigrContingencyTbl(int width,int height); constructor
int getColumnTotal(int column); Returns sum of a column (call computeTotals() first!)
int getGrandTotal(); Returns grand total (call computeTotals() first!)
int getRowTotal(int row); Returns sum of a row (call computeTotals() first!)
void computeTotals(); Computes all totals



class TigrDblMatrix;
A matrix of doubles.  Provides many matrix operations for linear algebra.  Used by the regression package.
TigrDblMatrix(int rows,int columns); constructor
TigrDblMatrix(const TigrDblMatrix &other); copy constructor
virtual double operator()(int row,int col) const; access const element
virtual double &operator()(int row,int col); access element
TigrDblMatrix &operator=(TigrDblMatrix &); copy assignment operator
bool invert(TigrDblMatrix &resultingMatrix) const; compute inverse of this matrix and store it in the given matrix -- returns false if noninvertible
virtual int getNumColumns() const; returns number of columns in matrix
virtual int getNumRows() const; returns number of rows in matrx
void addRowMultiple(int sourceRow,int destinationRow,double factor); add a multiple of one row to another row (used by TigrGaussJordan)
void getColumn(int column,TigrDblArray1D &into) const; copy a column into an array
void getRow(int row,TigrDblArray1D &into) const; copy a row into an array
void multiplyRowBy(int whichRow,double factor); multiply a row by some factor and store the resulting row back in its place
void printOn(ostream &); used by operator <<
void setAllTo(double d); store the given value at all locations
void swapRows(int r1,int r2); swap to rows in this matrix
void times(const TigrDblMatrix &,TigrDblMatrix &resultMatrix) const; matrix multiplication
void transpose(TigrDblMatrix &resultMatrix) const; matrix transposition (original matrix is not modified)



template<class T>
class TigrElasVector
A wrapper for TigrVector that allows you to index into undefined parts of the vector safely.  Any nonnegative index which was previous undefined will be automatically defined and the vector extended to include this index.
TigrElasVector(const T &nullInitializer); constructor - initializer is for initializing the intervening elements when an undefined index is specified
T &operator[](int); access element at given index
int size(); return current size of vector



class TigrElasDblVect : public TigrElasVector<double>
shorthand for TigrElasVector<double>
TigrElasDblVect(); constructor



class TigrElasFloatVect : public TigrElasVector<float>
shorthand for TigrElasVector<float>
TigrElasFloatVect(); constructor



class TigrElasIntVect : public TigrElasVector<int>
shorthand for TigrElasVector<int>
TigrElasIntVect(); constructor



class TigrElasCharVect : public TigrElasVector<char>
shorthand for TigrElasVector<char>
TigrElasCharVect(); constructor



class TigrElasLongVect : public TigrElasVector<long>
shorthand for TigrElasVector<long>
TigrElasLongVect(); constructor



class TigrEntropy
Provides computation of entropy, cross entropy, and relative entropy
static double crossEntropy(TigrVector<double> &P,TigrVector<double> &Q); -sum(P*log(Q)) = uncertainty about next symbol from source Q, given that our understanding of Q is actually based on P
static double entropy(TigrVector<double> &); -sum(P*log(P)) = expected number of bits per symbol to encode data source P
static double relativeEntropy(TigrVector<double> &,TigrVector<double> &); -sum(P*log(P/Q)) = uncertainty about P after discounting for cross entropy between P and Q



class RootException
An exception with a string message.
RootException(const char *); constructor
RootException(const TigrString &); constructor
const TigrString &getMessage() const; get message



class FileErrorException : public RootException
Exception to indicate a file error has occurred
FileErrorException(TigrString filename,TigrString message) constructor



class ArrayIndexException : public RootException
Exception to indicate an out-of-bounds error
ArrayIndexException(long index,const TigrString &message); constructor



class TigrFastaReader
Reads sequences from a multi-FASTA file
TigrFastaReader(const TigrString &filename, Alphabet & =DnaAlphabet::global); constructor - default alphabet is DNA
TigrVector< pair<TigrString,TigrString> > *readAll(); Reads all sequences from multi-FASTA file and returns a vector of pairs: (defline, sequence)
bool nextSequence(TigrString &defline,TigrString &sequence); Read the next sequence and store the defline and sequence in the given strings, or return false if end-of-file
static void parseDefline(const TigrString &defline,TigrString &id, TigrString &remainder); Parse a defline to extract the identifier (id) occurring immediately after the '>'.  Everything after that is stored in remainder
static TigrString getId(const TigrString &defline); like parseDefline, but ignores the remainder



class TigrFastaWriter
Writes sequences into a multi-FASTA file with a fixed-with format (default 60 chars)
TigrFastaWriter(int width=60); constructor
void writeFasta(const TigrString &defline,const TigrString &sequence, const TigrString &filename); Create a file, write the given sequence & defline into it, and close the file
void writeFastaFromCharPtr(const TigrString &defline,const char *sequence, const TigrString &filename); same as writeFasta() but with char*
void addToFasta(const TigrString &defline,const char *sequence, ostream &); Append a sequence (char*) to an already-open multi-FASTA file
void addToFasta(const TigrString &defline,const TigrString &sequence, ostream &); Append a sequence (TigrString) to an already-open multi-FASTA file




template <class T>
class TigrFastBinTree : public TigrBinaryTree<T>
A subclass of TigrBinaryTree that has faster parent lookup, because each node has a pointer to its parent (don't have to search down from the root when searching for parent or successor/predecessor).  Also allows duplicate elements (if desired).
TigrFastBinTree(TigrComparator<T>& = *new DirectComparator<T>()); constructor
virtual bool insert(T); insert element
void enableDuplicates(); enable the insertion of duplicate elements



class TigrFile
A convenient wrapper for native FILE*, fopen, fclose, fread, fwrite, etc.
TigrFile(const TigrString &filename,const TigrString &mode="r"); constructor - mode "r" is for reading, "w" is for writing
TigrFile(FILE *fp); constructor
TigrFile(); constructor
virtual ~TigrFile(); destructor
operator FILE*(); get underlying FILE*
long countLines(); count lines in a file that is open for reading; does not rewind first
static TigrString getFilenameNoPath(const TigrString &filename); gets the part of a filename after the path specification
static bool copy(const TigrString &from,const TigrString &to); UNIX cp command
static bool exists(const TigrString &filename); true iff file exists
TigrString getline(); read next line
inline TigrString readLine(); read next line
bool eof(); true iff end-of-file
bool isOpen() const; true iff this file is currently open
bool open(); open this file
bool open(const TigrString &filename,const TigrString &mode="r"); open a file with a given name; mode "r" is for reading, "w" is for writing
long read(long bytes,void *buffer); fread the given number of bytes into the given buffer
bool seek(long offset); fseek to the given absolute file offset (i.e., bytes from the beginning of the file)
bool write(long bytes,const void *buffer); write a given number of bytes from the given buffer into this file
long getPosition(); return current file position; ftell()
long getSize(); returns size of file, as of the time it was opened or the last time updateStats() was called
time_t lastAccessTime(); returns last access time as of last call to updateStats() or file open
time_t lastChangeTime(); returns last change time as of last call to updateStats() or file open
time_t lastModifyTime(); returns last modify time as of last call to updateStats() or file open
virtual void close(); close this file
void print(const TigrString &); write a string into a file
void rewind(); rewind file to beginning
void updateStats(); update stats (size, last access time, last change time, last modify time)
void write(const int &); write int into binary file
void write(const short &); write short into binary file
void write(const long &); write long into binary file
void write(char); write char into binary file
void write(const float &); write float into binary file
void write(const double &); write double into binary file
void write(const TigrString &); write string into binary file, preceded by length
void write(const char *); write string into binary file, preceded by length
int readInt(); read int from binary file
short readShort(); read short from binary file
long readLong(); read long from binary file
char readChar(); read char from binary file
float readFloat(); read float from binary file
double readDouble(); read double from binary file
TigrString readString(); read string from binary file (saved previously with write(TigrString)
char *readCharString(); read string from binary file (saved previously with write(char*); caller should delete [] the returned char array
void readString(TigrString &); like readString() but with supplied buffer
TigrString *readStringPtr(); .like readString, but returning pointer to string object (which caller should delete)



class TigrGaussJordan
Performs Gauss-Jordan elimination in order to invert a square matrix
static bool invert(TigrDblMatrix &thisMatrix,TigrDblMatrix &intoHere); inverts the "thisMatrix" into the "intoHere" matrix, or returns false if noninvertible




class TigrGffExon
An exon read from a GFF file by TigrGffReader.  ExonType is {ET_EXON, ET_INITIAL_EXON, ET_INTERNAL_EXON, ET_FINAL_EXON, ET_SINGLE_EXON}.  Note that while GFF coordanates are 1-based, within this software they are automatically converted for you, so use zero-based coordinates.
TigrGffExon(TigrGffFeature &,TigrGffTranscript &); constructor - builds an exon from a generic TigrGffFeature object and inserts into the given transcript
TigrGffExon(ExonType,int begin,int end,TigrGffTranscript &parent, bool hasScore,double score,bool hasFrame,int frame); constructor - builds an exon object from the given attributes
ExonType getExonType() const; returns exon type
void changeExonType(ExonType); changes exon type
TigrGffTranscript &getParent(); returns transcript to which exon belongs
char getStrand() const; returns strand
const TigrString &getSource() const; returns name of organism or program which predicted this exon
const TigrString &getSubstrate() const; identifier of sequence to which this exon's coordinates refer
int getBegin(); zero-based coordinate of leftmost base in exon
int getEnd(); zero-based coordinate of the base immediately following the rightmost base of the exon
void toGff(ostream &); generate the GFF record for this exon and write it to the ostream



class TigrGffFeature
A generic GFF feature.  Produced by TigrGffReader.
TigrGffFeature(const TigrString &rawLine,const TigrString &substrate, const TigrString &source,const TigrString &featureType, int begin,int end,double score,bool hasScore,char strand, int frame,bool hasFrame); constructor
TigrGffFeature(const TigrString &rawLine); constructor - parses raw line into a TigrGffFeature object
TigrString toGff() const; generates GFF record for this feature
TigrVector<TigrString> &getExtraFields(); returns "extra" fields at the end of the GFF record (usually separated by semi-colons)
bool hasExtraFields() const; true iff this feature has "extra" fields at the end
bool isFramed() const; true iff this feature has a specified frame or phase
bool isScored() const; true iff this feature has a score
bool isStranded() const; true iff this feature has a specified strand
char getStrand() const; get strand; '+' or '-'
const TigrString &getFeatureType() const; get feature type as specified in the GFF file
const TigrString &getRawField(int index); get the raw text of any field from the original GFF record
const TigrString &getRawLine() const; get the original line for this GFF record
const TigrString &getSource() const; usu. organism or name of program which predicted this feature
const TigrString &getSubstrate() const; identifier of sequence to which this feature's coordinates refer
double getScore() const; feature's score
int getBegin() const; zero-based coordinate of leftmost base in feature
int getEnd() const; zero-based coordinate of the base immediately following the rightmost base of the feature
int getFrame() const; get phase or frame of the feature



class TranscriptComparator : public TigrComparator<TigrGffTranscript*>
Compares transcripts, to allow sorting by begin coordinate.
bool less(TigrGffTranscript *&,TigrGffTranscript *&); a<b?
bool greater(TigrGffTranscript *&,TigrGffTranscript *&); a>b?
bool equal(TigrGffTranscript *&,TigrGffTranscript *&); a==b?



class TigrGffReader
Reads features from a GFF file.
TigrGffReader(const TigrString &filename); constructor - loads GFF file
TigrGffFeature *nextFeature(); loads next GFF record and parses it into a generic feature
TigrVector<TigrGffTranscript*> *loadTranscripts(); loads all transcripts from GFF file
TigrMap<TigrString, TigrVector<TigrGffTranscript*>*> *loadByContig(); loads all transcripts from a GFF file and hashes them into a TigrMap<> by the substrate ID, so those on the same substrate (i.e., contig) can be processed together



class TigrGffTranscript
A single transcript in a GFF file.  These are produced by TigrGffReader.  The exons are sorted by translation order (5' to 3').
TigrGffTranscript(const TigrString &transcriptId, const TigrString &substrate, char strand,const TigrString &source); constructor - used by TigrGffReader
virtual ~TigrGffTranscript(); destructor
TigrGffExon &getIthExon(int); returns exon at given index
TigrGffFeature *getStartCodon(); returns start codon object, if one has been previously set via setStartCodon(), or NULL otherwise
TigrGffFeature *getStopCodon(); returns stop codon object, if one has been previously set via setStopCodon(), or NULL otherwise
char getStrand(); returns strand ('+' or '-')
const TigrString &getSource() const; usu. organism name or name of program which predicted this transcript
const TigrString &getSubstrate() const; identifier of sequence to which this transcript's exons' coordinates refer
const TigrString &getTranscriptId() const; transcript id (from the transcript_id or transgrp field at the end of the GFF record)
double getScore() const; score, as previously set via setScore()
int getBegin() const; zero-based coordinate of the leftmost base of the leftmost exon in this transcript
int getEnd() const; zero-based coordinate of the base immediattely following the rightmost base of the rightmost exon in this transcript
int getNumExons() const; number of exons in this transcript
void addExon(TigrGffExon *); insert exon into this transcript
void printOn(ostream &) const; used by operator <<
void setScore(double); set transcript score
void setStartCodon(TigrGffFeature *); associate a start codon object with this transcript
void setStopCodon(TigrGffFeature *); associate a stop codon object with this transcript
void setStrand(char); set transcript strand (should be + or -)
void sortExons(); sort the exons by increasing begin coordinate
void setExonTypes(); resolve exon types into {ET_INITIAL_EXON, ET_INTERNAL_EXON, ET_FINAL_EXON, ET_SINGLE_EXON}
void toGff(ostream &); generate GFF record and write to ostream
TigrVector<TigrGffExon*>::iterator getExons(); returns begin iterator for exons
TigrVector<TigrGffExon*>::iterator getExonsEnd(); returns end iterator for exons



class TigrHugeFastaReader
Allows reading of truly immense FASTA files on a computer with limited RAM by reading only one chunk at a time.  The chunks can overlap, which is useful if you want to slide a window over the sequence and not miss regions around chunk boundaries.
TigrHugeFastaReader(const TigrString &filename,int chunkSize, int overlapSize=0); constructor
virtual ~TigrHugeFastaReader(); destructor
const char *getBuffer(); The first chunks read will be here.  If the overlapSize is zero, all subsequent chunks will also be here.  Otherwise, subsequent overlap regions will start here, and the actual chunk will at getRemainder()
const char *getRemainder(); For use only when chunkSize>0.  Then, for all chunks after the first, getBuffer() will return a pointer to the last overlapSize bases of the previous chunk followed by the chunkSize-overlapSize bases of the next chunk.  getRemainder() returns a direct pointer to the latter, new bases.
bool loadNextChunk(); loads the next chunk into memory
bool isMore(); true iff loadNextChunk() actually read some data
const TigrString &getDefline(); returns defline




class TigrInversionMatrix : public TigrDblMatrix
Used by TigrGaussJordan to invert a square matrix.  Initialized to [I | M] for identity matrix I and matrix M, and then subjected to GJ-elimination until the augmented matrix is [Minv | I] for Minv the inverse of matrix M.
TigrInversionMatrix(int rows); constructor - builds a square matrix of size RxR, with an identically-sized matrix conjoined with this that is initialized to the identity matrix
virtual double &operator()(int row,int col); access element of matrix
bool detectNonInvertible(); returns true if there is a complete row of zeros -- a sign that the matrix is noninvertible
virtual int getNumColumns(); number of columns in (unaugmented) matrix
void getInverted(TigrDblMatrix &); Returns the inverse of the original matrix installed via install()
void install(TigrDblMatrix &); Copy a square matrix into



template <class T>
class TigrIterator
Base iterator class
virtual void operator++()=0; advance to next element
virtual void operator++(int)=0; advance to next element (post-increment)
virtual T &operator*()=0; access current element
virtual bool operator==(const TigrIterator<T> &) const=0; true iff these two iterators point to the same element
virtual bool operator!=(const TigrIterator<T> &i) const true iff these two iterators do not point to the same element
virtual TigrIterator<T> &clone()=0; clone this iterator



class TigrJointDistr : public TigrArray2D<double>
A joint distribution.  Derived from TigrArray2D<double>, so use the [][] operator to access individual joint probabilities.
TigrJointDistr(int X,int Y); constructor
double getMarginalX(int x); prior P[x==X]
double getMarginalY(int y); prior P[y==Y]
void computeMarginals(); compute marginal distributions



class TigrLinearFunc
A function of the form y=mx+b.  Used in the regression package.
TigrLinearFunc(double slope,double intercept, double coefOfDeterm); constructor - requires slope, y-intercept, and coeffient of determination (or ignore the latter if you won't be calling getCoefDeterm())
TigrLinearFunc(); constructor
double operator()(double x) const; get the y for a given x
TigrLinearFunc &operator=(const TigrLinearFunc &); copy assignment operator
double getCoefDeterm() const; coefficient of determination (r2)



class TigrLinRegressor
Computes univariate linear regression of Y on X.
TigrLinearFunc regress(TigrVector<pair<double,double>> &); Perform regression on the given set of pairs
TigrLinearFunc regress(TigrVector<double> &); Regress the given set of Y values on the sequence of nonnegative integers 0..N (i.e., their indices in the vector)



template<class T>
class TigrList : public list<T>
Just a wrapper for the STL list<>.  No functionality added yet.
TigrList(); constructor



template<class T>
class TigrListQueue
A queue implemented as a linked list.
TigrListQueue(); constructor
T &back(); element at back of queue (most recent)
T &front(); element at front of queue (oldest)
typename list<T>::iterator begin(); begin iterator
typename list<T>::iterator end(); end iterator
typename list<T>::reverse_iterator rbegin(); begin reverse iterator
typename list<T>::reverse_iterator rend(); end reverse iterator
void enqueue(const T &); add an element at the back of the queue
T dequeue(); remove element from front of queue
void pop_back(); remove element from back of queue
void pop_front(); remove element from front of queue
int size(); number of elements currently in queue
void clear(); make the queue empty
bool isEmpty(); true iff the queue is empty




template<class KeyType,class ValueType,
class TigrMap : public map<KeyType,ValueType,Comp>
Wrapper for STL map<T>
bool isDefined(const KeyType &key); true iff key is defined in the map
void undefine(const KeyType &key); remove key from the map
inline int numElements(); number of keys defined in the map
inline bool isEmpty(); true iff the map is empty



class TigrMemStream
Allows reading of successive newline-delimited lines from a string of text stored in memory.
TigrMemStream(const char *data); constructor
TigrString readLine(); returns next newline-delimited line (newlines are removed)
bool eof(); true iff end of the entire string has been reached



class TigrMultRegress
Performs multiple regression (i.e., regression of one variable on one or more others). 
bool regress(const TigrDblMatrix &Y,const TigrDblMatrix &X, TigrDblMatrix &coefficients); given the matrix X of observations (rows) of several variables (columns) and the matrix Y of observed y-values for those observations, compute a set of coefficients for X.



class TigrMutInfo
Computes mutual information from a contingency table or joint distribution.  Mutual information = sum Pxy * log[ Pxy / (Px*Py) ].
static double compute(const TigrContingencyTbl &); Compute mutual information from a contingency table of counts
static double compute(const TigrJointDistr &); Compute mutual information from a joint distribution



class TigrPipe : public TigrFile
UNIX pipe using a file interface
TigrPipe(const TigrString &command,const TigrString &mode); constructor -- executes the given command and then either pipes the output from that command into this process through the file (when mode="r") or pipes this process' output through the file into the command (when mode="w")
virtual void close(); close the pipe



class TigrPriorityTree
A priority queue implemented as a TigrFastBinTree (binary tree).  Allows rapid, repeated extraction of the minimum value.
TigrPriorityTree(); constructor
TigrFastBinNode *extractMin(); remove smallest value from queue
TigrFastBinNode *peekMin(); access smallest value without returning it
void insert(TigrFastBinNode *); insert an element into the tree



class TigrProgress
Computes progress based on time elapsed and amount of work remaining to do.
TigrProgress(); constructor
TigrString getProgress(unsigned long workDone); Get a progress message to display to the user.
void start(unsigned long totalWork); Start the timer and register how much total work needs to be done



class TigrProteinTrans
Provides protein translation and DNA reverse complementation functionality.
static TigrString reverseComplement(const TigrString &); compute Watson-Crick reverse-complement of a string of DNA
static TigrString translate(const TigrString &transcript); translate DNA into protein sequence
static Sequence *translate(const Sequence &,Alphabet &dnaAlphabet, Alphabet &proteinAlphabet); translate a DNA Sequence object into a protein Sequence object
static void translate(const Sequence &source,Alphabet &dnaAlphabet, Alphabet &proteinAlphabet,Sequence &dest); same as previous, but with user-supplied buffer for output
static char mapCodon(const char *codon); map a single codon to an amino acid



class TigrRealVector
A vector of real values, useful for linear algbra.
TigrRealVector(int dimensions); constructor
double operator[](int index) const; access ith dimension
double &operator[](int index); access ith dimension
double distanceTo(const TigrRealVector &other); Euclidean distance between end-points of two vectors
double dotProduct(const TigrRealVector &with); vector dot product
double getAngle(const TigrRealVector &from); angle between two vectors
double getMagnitude(); vectr magnitude (also called the norm, and denoted ||V||)
inline int getDimension(); number of dimensions
void scale(double factor); multiply all dimensions by given factor
void unitize(); convert vector to a unit vector (i.e., having magnitude 1)



class TigrRegex
Regular expressions.  Very similar to Perl's regular expressions.  Wrapper for GNU regular expression library.
TigrRegex(const TigrString &regex); constructor
~TigrRegex(); constructor
TigrString operator[](int whichSubexpression); like $1, $2, $3, etc. in perl
TigrString getEntireMatch(); returns entire subexpression matched by regex
TigrString substitute(const TigrString &substrate, const TigrString &replacement); like s/// in perl
TigrVector<TigrString*> *split(const TigrString &substrate); like split//,$_ in perl
bool match(const TigrString &); try to match the regex to the entire string, from beginning to end
bool search(const TigrString &); try to match the regex to any part of the string
int getNumSubexpressions() const; how many pairs of parentheses are there in the regex?
static TigrString substitute(const TigrString &regex, const TigrString &replacement, const TigrString &substrate); static version of above substitute() -- regex is given as a char string
static TigrVector<TigrString*> *split(const TigrString &regex, const TigrString &substrate); static version of above split() -- regex is given as a char string
static bool match(const TigrString &regex,const TigrString &substrate); static version of above match() -- regex is given as a char string
static bool search(const TigrString &regex,const TigrString &substrate); static version of above searc() -- regex is given as a char string
void getMatchIndices(int regNum,int &start,int &end); for a given matched subexpression (denoted by parentheses in the regex), get the indices within the string of that match



template< class T, class C = less<T> >
class TigrSet : public set<T,C>
Wrapper for STL set<T>
TigrSet(); constructor
bool operator+=(const TigrSet<T,C> &); add all elements of other set to this set (UNION)
bool operator+=(const T &); as above but without const
bool isMember(const T &); true iff the given object is an element of this set
void remove(const T &t); remove the given element from this set
TigrSet<T,C> *intersectWith(TigrSet<T,C> &); set intersection; this set is unmodified
void intersectWith(TigrSet<T,C> &,TigrSet<T,C> &destination); set intersection with user-provided result location; this set is unmodifed.
inline bool isEmpty() const; true iff this set is empty



template<class T>
class TigrSmartPointer
Replacement for pointers that keeps track of reference counts to decide when to delete an object.  Type T must be a class having an int referenceCount member, and you *must* defined USE_SMART_POINTERS before including TigrSmartPointer.H.  If you do not defined USE_SMART_POINTERS, no reference counting will occur.
TigrSmartPointer(T *p=NULL) constructor
TigrSmartPointer(const TigrSmartPointer<T> &o) copy constructor
~TigrSmartPointer() destructor
TigrSmartPointer<T> &operator=(const TigrSmartPointer<T> &) copy assignment operator
TigrSmartPointer<T> &operator=(T *t) assignment operator
T *operator ->() arrow operator



class TigrSparseGraph
An *undirected* graph having relatively few edges.  For each vertex (represented only by an integer index) it maintains a set of adjacent vertices.  VertexId is an unsigned int.
TigrSparseGraph(int numVertices=0); constructor
TigrSet<VertexId> &getNeighborsOf(VertexId); Returns vertices adjacent to the given one
VertexId addVertex(); add a vertex to the graph
bool areAdjecent(VertexId,VertexId); true iff the given vertices are connected by an edge
int getDegree(VertexId); number of neighbors of given vertex
int getNumEdges(); number of edges in graph
int getNumVertices(); number of vertices in graph
void addEdge(VertexId from,VertexId to); add an undirected edge between two vertices
void removeEdge(VertexId from,VertexId to); remove edge from graph



template<class T>
class TigrStack
Wrapper class for STL stack<T>
TigrStack(); constructor
void push(const T &); push element onto stack
const T &pop(); pop top element & return it (differs from STL)
const T &top(); return top element
int size() const; number of elements in stack
bool isEmpty() const; true iff stack is empty




class TigrStacktrace
Displays a message and then initiates a core dump so that a debugger can be used to get a stack trace.
TigrStacktrace(const char *message); constructor
TigrStacktrace(const TigrString &); constructor




class TigrString : public string
Wrapper for STL string class.  Makes it more convenient to build strings using the + operator, as well as other common tasks.
TigrString(unsigned); construct string representation of number
TigrString(unsigned long); construct string representation of number
TigrString(long); construct string representation of number
TigrString(int); construct string representation of number
TigrString(float); construct string representation of number
TigrString(double); construct string representation of number
TigrString(const char *,unsigned len); construct string from pointer and length
TigrString(const char *); construct string from null-terminated char*
TigrString(const TigrString &); copy constructor
TigrString(const string &); copy constructor
TigrString(char); construct string consisting of single char
TigrString(); constructor -- empty string
virtual ~TigrString(); destructor
TigrString operator+(unsigned); concatenate number and return result
TigrString operator+(unsigned long); concatenate number and return result
TigrString operator+(long); concatenate number and return result
TigrString operator+(int); concatenate number and return result
TigrString operator+(float); concatenate number and return result
TigrString operator+(double); concatenate number and return result
TigrString operator+(const char *p); concatenate string and return result
TigrString operator+(const string &s); concatenate string and return result
TigrString operator+(const TigrString &s); concatenate string and return result
TigrString operator+(char c); concatenate char and return result
operator float(); interpret this string as a number
operator double(); interpret this string as a number
operator int(); interpret this string as a number
operator long(); interpret this string as a number
operator unsigned(); interpret this string as a number
TigrString &tolower(); convert to lowercase and return result
TigrString &toupper(); convert to uppercase and return result
TigrString substitute(const TigrString &changeThis, const TigrString &toThis) const; substitute all instances of changeThis with toThis
TigrString substring(int start,int length) const; extract substring beginning at 'start' and running for 'length' bytes (zero-based coordinates)
TigrVector<TigrString> *getFields(const char *separators=" \t\n\r") const; split this string at all instances of given separator chars and return vector of resulting substrings
bool contains(const TigrString &searchString) const; true iff this string contains the given search string
bool containsWordChar(); true iff this string contains [a-zA-Z]
inline bool isWordChar(char c); true iff c matches /[a-zA-Z]/
bool stricmp(const TigrString &) const; true iff a case-insensitive comparison between this string and that string found a difference
char lastChar() const; returns the last char in this string
double asDouble(); interpret this string as a number
float asFloat(); interpret this string as a number
int asInt(); interpret this string as a number
long asLong(); interpret this string as a number
unsigned asUnsigned(); interpret this string as a number
void chop(); remove the last char from this string
void trimWhitespace(); remove whitespace chars from beginning and end of this string
inline bool isEmpty(); true iff this string is empty
void getline(istream &is); get a line of text from the given stream


template<class T>
struct StringMapElem
Element of a TigrStringMap.  An (attribute,value) pair.
int len; length of 'first' string
char *first;
string attribute
T second;
T value


template<class T>
class StringMapIterator
For iterating through the (attribute,value) pairs of a TigrStringMap<T>.  The pairs are StringMapElem<T> structs.
inline bool operator!=(const StringMapIterator<T> &); true iff this iterator does not equal that iterator (are not pointing at same elements)
bool operator==(const StringMapIterator<T> &); true iff this iterator equals that iterator (pointing at same elements)
StringMapIterator<T> &operator++(int); advance to next (attribute,value) pair
StringMapIterator<T> &operator++(); advance to next (attribute,value) pair
StringMapElem<T> &operator*(); access current



template<class T>
class TigrStringMap
Provides a very fast and memory-efficient map for large numbers of strings to an arbitrary data type T.  For efficiency reasons, native char* strings are used, not STL strings.  This eliminates all unnecessary initialization overhead.  Strings are specified with three parts: a char* to the beginning of a buffer, an offset into that buffer where the interesting substring begins, and the length of the interesting substring.
typedef StringMapElem<T> ElemType; ElemType type
typedef StringMapIterator<T> iterator; iterator type
typedef StringMapIterator<T> const_iterator; const_iterator type
TigrStringMap(int tableSize); constructor -- tableSize should be prime for best performance
TigrStringMap(const TigrStringMap<T> &); copy constructor
virtual ~TigrStringMap(); destructor
T &lookup(const char *,int index,int len); finds the value assocated with the given string attribute, given buffer beginning, offset into that buffer, and length of substring which occurs there
T &lookup(const char *,int len); same as above, but for offset=0
bool isDefined(const char *,int index,int len); true iff the given string occurs in the string map.  parms are buffer pointer, offset within buffer and length of substring which occurs there
bool isDefined(const char *,int len); as above, but for offset=0
int size(); number of entries in the map
iterator begin(); begin iterator
iterator end(); end iterator
const_iterator begin() const; const begin iterator
const_iterator end() const; const end iterator
void clear(); remove all entries from the map
void remove(const char *,int index,int len); remove a given string from the map.  parms are buffer pointer, offset within buffer and length of substring which occurs there
void remove(const char *,int len); as above, with offset=0
TigrStringMap<T> &operator=(const TigrStringMap &); copy assignment operator



class TigrStrTokenizer
For tokenizing strings into arrays of substrings.  DEFAULT_WHITESPACE is " \t\n\r" (space, tab, newline, carriage return).
TigrStrTokenizer(const char *wspace=DEFAULT_WHITESPACE); constructor -- use tokenizeThis() or getTokensAndSeparators() next
TigrStrTokenizer(const char *source, const char *wspace=DEFAULT_WHITESPACE); constructor -- will set up the tokenizer to tokenize the given source string
TigrStrTokenizer(const TigrString &source, const char *wspace=DEFAULT_WHITESPACE); constructor -- will set up the tokenizer to tokenize the given source string
TigrVector<TigrString*> *getAllTokens(); performs tokenization and returns vector of tokens
TigrVector<TigrString> *getTokenStrings(); same as above, but returning strings rather than pointers
bool hasMoreTokens(); true iff there are more tokens
const char *nextToken(); returns the next token (do not delete)
pair<TigrVector<TigrString>, TigrVetor<TigrString>> *getTokensAndSeparators(const TigrString &); returns a vector of tokens and a vector of separator regions between them
static TigrVector<TigrString*> *tokenize(const char *source, const char *wspace=DEFAULT_WHITESPACE); static version of getAllTokens()
void tokenizeThis(const TigrString &s); change the source string specified in the constructor
void tokenizeThis(const char *p); as above, but for char*



class TigrSummaryStats
Computes summary statistics (mean, min, max, standard deviation)
TigrSummaryStats(const TigrVector<int> &); constructor
TigrSummaryStats(const TigrVector<float> &); constructor
TigrSummaryStats(const TigrVector<double> &); constructor
double getMax(); maximum
double getMean(); mean
double getMin(); minimum
double getStdDev(); standard deviation
int getN(); number of data elements



class TigrTime
For keeping track of elapsed time.
TigrString elapsedTime(); returns the elapsed time in a user-readable message string
float elapsedSeconds(); elapsed seconds
void startCounting(); start counting
void stopCounting(); stop counting



template<class T>
class TigrTriangMatrix
An upper-triangular matrix, in which only values above or on the main diagonal are explicitly stored.  Thus, the second index must always be greater than or equal to the first index.  This saves space for large matrices.
TigrTriangMatrix(int n); constructor
T &operator()(int i,int j); requires i<=j
int getN() const; length of each dimension of the matrix



template<class T>
class TigrVector : public vector<T>
Subclass of STL vector<T>, with a few added features for convenience.
TigrVector(); constructor
TigrVector(int size); constructor - allocate fixed size
TigrVector<T> *getSubrange(int from,int to); return new vector containing subrange of this vector
void getSubrange(int from,int to,TigrVector<T> &); get subrange of this vector and store it in given vector
bool isMember(const T &); searches linearly along vector for the specified datum
void append(const TigrVector<T> &); append the given vector's elements to this vector
void push_front(const T &); push element onto front of vector & shift everything to the right
void removeFirst(const T &x); remove the leftmost element which equals x, and shift everything to the left to fill in the gap
bool isEmpty() const; true iff vector size is zero
T getFirst(); returns first datum
T getLast(); returns last datum
void resize(int n); delete and reallocate to given size
void cut(int index); remove the element at the given index and slide everything over to fill in the gap
void cut(int startIndex,int howMany); remove the elements in the given subrange and slide everything over to fill in the gap



template <class T>
class TigrVectorSorter
For sorting a TigrVector<T> via quicksort.
TigrVectorSorter(TigrVector<T> &,TigrComparator<T> &); constructor
TigrVector<T> *sortAscending(); sorts out-of-place and returns sorted vector
TigrVector<T> *sortDescending(); as above, but descending
TigrVector<int> *sortAscendByIndex(); sorts out-of-place, producing an array of indices into the original array, which is unmodified
TigrVector<int> *sortDescendByIndex(); as above, but descending
void sortAscendInPlace(); sort ascending in place
void sortDescendInPlace(); sort descending in place



template<class T>
class TigrWindowedQueue
A very specialized queue that separates the elements into two subqueues, the "window" and the "reservoir".  Elements pushed into the queue actually go into the "window" until they are shift()'ed into the "reservoir."
TigrWindowedQueue(); constructor
bool isEmpty(); true iff both queues are empty
list<T> &getReservoir(); returns reservervoir queue
list<T> &getWindow(); returns window queue
void enqueue(T); enqueues element in "window" queue
void shift(); shifts front element from "window" queue into "reservoir" queue


Contact: bmajoros@tigr.org