
| 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. |
|
|
|
| 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. |
|
|
|
| An alphabet of amino acid symbols. |
|
| AminoAlphabet(); | constructor |
| static AminoAlphabet global; | Global instance of this class. |
|
|
|
| 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. |
|
|
|
|
|
|
| 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. |
|
|
|
| Alphabet containing symbols {A,T,C,G,N}. |
|
| DnaAlphabet(); | constructor |
| static DnaAlphabet global; | Global instance of this object. |
|
|
|
| Alphabet containing symbols {a,t,c,g,n} |
|
| LowercaseDnaAlphabet(); | constructor |
| static LowercaseDnaAlphabet global; | Global instance of this object. |
|
|
|
| Allows access to UNIX environment variables. |
|
| static TigrString lookup(const TigrString &); | Look up given environment
variable. |
|
|
|
|
|
|
| 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 |
|
|
|
|
|
|
| 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 |
|
|
|
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
|
|
|
| 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 |
|
|
|
|
|
|
| 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 |
|
|
|
|
|
|
| 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 |
|
|
|
|
|
|
| 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 |
|
|
|
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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) |
|
|
|
|
|
|
| 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? |
|
|
|
|
|
|
| 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? |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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); | |