The Bioinformatics Template Library (BTL) Documentation

BTL logoThe Bioinformatics Template Library (BTL)Birkbeck Shield


Version 2.0 alpha

Description

The focus of this library is on the data structures and algorithms used within the fields of bioinformatics and molecular modelling. The approach used closely follows that of the Standard Template Library (STL) which is part of ISO/ANSI standard C++. This library uses templates to implement generic programming. Templates allow the development of efficient generic programming modules using compile-time mechanisms. Although the BTL has been designed with biomolecular applications in mind it contains classes of more general utility. For instance, the Matrix class could be used for matrix algebra in many contexts. There are many freely available matrix classes that pre-date the one we have written but non are well suited to our needs. Most provide many functions that unlikely to be used by bioinformatics and molecular modelling applications. We aim to provide an extremely simple matrix class to be used by people who may not have a particularly strong mathematical background.

Floating Point Precision

The floating point precision of the library as a whole is defined as the user defined type BTL_REAL. A typedef statement in the BTL.h. e.g.

typedef double BTL_REAL;

To change the precision used simply alter this statement and recompile the library. Of course not all floating point variables in the library are of type BTL_REAL, some, for instance, are fixed at type double to avoid large round off errors. In spite of this, setting BTL_REAL to be of type float may well result significant round off problems in certain calculations such as those used by the Matrix::Eigens() method.

Debugging Version of Library

If the DEBUG_VERSION symbol is defined then the library will carry out extra error checking such as some array bounds checking. This checking will obviously make the library more robust but will also increase excecution times. Simply comment the define statement in the BTL.h file out if the extra checking is not required.

Classes

Files


BTL_Vector


his class represents a mathematical vector of any dimension.

V = xi + yj + zk + ...

However, its primary use will probably in representing the position of atoms in three dimensions. The default contructor contructs a 3D BTL_Vector.

There are several types associated with this class:

value_type : same as the type BTL_REAL which is defined in BTL.h

iterator : this is a STL type iterator. It can be used to sequentailly access the elements of the BTL_Vector e.g.

BTL_Vector v1; ... for (BTL_Vector::iterator i = v1.begin(); i != v1.end(); i++) cout << *i;

const_iterator : used to access const BTL_Vector.

size_type : this is an unsigned integer type that represents the size of any BTL_Vector object.
Authors: W.R.Pitt, D.S.Moss
Files: Vector.h, Vector.cpp
Friends: Friend equivalents to some functions are available and are documented with these functions. Also available is: friend ostream& operator<<(ostream &os, const BTL_Vector &m);
Dependencies: BTL_NumericLimits BTL_NumericUtilities

Operations

back


BTL_Matrix


This class represents a mathematical Matrix of any dimension. Matrices where one of the two dimensions is unity are more efficiently modelled using the BTL_Vector class.

There are two types associated with this class:

value_type : this type is the same as the BTL_Vector::value_type and defines the type of the elements of the Matrix.

size_type : this type is the same as the BTL_Vector::size_type and defines the type of the Matrix indexes. It should always be an unsigned integer type.
Authors: D.S.Moss, W.R.Pitt, I.Tickle.
Files: Matrix.h, Matrix.cpp
Friends: Friend equivalents to some functions are available and are documented with these functions. Also available is: friend ostream& operator<<(ostream &os, const BTL_Matrix &m);
Dependencies: BTL_Vector, BTL_NumericLimits, BTL_NumericUtilities

Operations

back


BTL_CholeskyInverse


Inverts a symmetric positive definite matrix. Employs Cholesky decomposition in step (1). (1)M=LL(tr) (2)compute L(-1) (3)M(-1)=L(-1)(tr)L(-1)

Input should be a symmetric positive definite matrix. Only the lower triangular matrix containing the lower triangle of M and overwritten with L then with L(-1) and finally with the lower triangle of M(-1)
Authors: D.S.Moss, W.R.Pitt
Files: CholeskyInverse.h
Dependencies: BTL_NumericLimits
Prerequisites: The matrix class used as the template parameter must contain the following features:

1. value_type - the type of elements in a matrix

2. size_type - the subscript type

3. size_type num_rows(); - function to return the number of rows

4. size_type num_cols(); - function to return the number of columns

5. value_type operator()(size_type,size_type); - return individual elements of the matrix by the index of the row then the column. Indices should start at 1.

Operations

back


BTL_FFT


This routine may be used to carry out a One-dimensional, Two-dimensional, or Three-dimensional Fast Fourier Transform. The basic algorithm has been adapted from freely-distributed code issued by the HP Reference Library It is based on the Cooley-Tukey algorihm (decimation in time), and it caters for sizes of the input array which are not a power of two.

The input parameters are;

First Input Parameter: A one, two or three-dimensional object, from the Fastft class. Second Input Parameter: A boolean variable. When set to 'true', this gives the 'forward' transform.

Note: in the comments following, the term 'array' is used to refer to the object created using the Fastft class.

Operation: The routine carries out the standard Fast Fourier Transform. It checks to see if the size of the array is divisible by any of the first 12 primes. If it is it continues using the usual algorithm. It copies z1 to z2 as it proceeds, and the next time around uses z2 as the input array. Each iteration the variable 'arg' is set to 1, and 'omega' is set to the appropriate value. Arg is then multiplied by omega to give the relevant roots of unity. (For example, if n=8, in the first iteration -1 and 1 is used, then -i, 1, i, and -1, then in the last iteration the 8 '8th roots' are used). The routine should still work if the array size contains a factor which is not one of the first 12 primes. However it may be preferable to increase the number of primes in this case (in the 'prime' array), or alternatively pad the array with extra data points to ensure it is divisible by one of the 12 primes, or preferably a power of a prime.

Warnings: 1. This routine does divide by n when doing the 'forward' transform. This is useful if the routine is used to transform forward and then back again. Most routines seem to leave this 'division by n' to the calling routine, however it is more sensible to let the calling routine 'multiply by n' if there is ever a need to do so. (E.g. (1, 0, 0, 0) will 'forward' transform to (.25, .25, .25, .25), and will then transform back to (1, 0, 0, 0).)

2. The calculation will leave small 'epsilon' values in the array where the value is calculated as zero. The calling routine should take whatever action is required.

Acknowledgements: This routine was originally adapted from code which has been circulated freely from the standard Hewlett-Packard Reference Library. It is essentially the same routine with the addition of the 'esign' variable, which allows 'reverse' transforms as well as 'forward' transforms; and with 'division by n' during the forward transform. The HP code was initially transcribed from Fortran as presented in 'FFT as Nested Multiplication, with a Twist' by Carl de Boor in SIAM Sci. Stat. Comput., Vol 1 No 1, March 1980.
Authors: B.Sweeney, W.R.Pitt
Files: FFT.h
Dependencies: none

Operations

back


BTL_Vertex


This class encapsulates a graph vertex and is designed for use with the BTL_Graph class. Each vertex contains a reference to a data object and pointers to other vertices. It is a template class the single template parameter is a type of dereferencer.
Authors: W.R.Pitt
Files: Graph.h
Dependencies: BTL_II, and BTL_IteratorDerefencer, or BTL_InDencer

Generalizations

Specializations

Operations

back


BTL_Graph


Graph container with any type of data at vertices of the graph and no data associated with edges. The default behaviour is have undirected edges. This can be changed to directed if specified in the constructor. No self links (edges from one vertex to itself) are allowed.
Authors: W.R.Pitt
Files: Graph.h
Friends: operator<<
Dependencies: BTL_VertexBase and its subclasses.

Specializations

Operations

back


BTL_VertexWithEdges


This class represents an vertex that has links to edge objects. It is to be used in combination with class BTL_GraphWithEdges.
Authors: W.R.Pitt
Files: GraphWithEdges.h
Friends: friend class BTL_GraphWithEdges<T1,T2>>;

friend ostream& operator<<(ostream &os, const BTL_VertexWithEdges &m);
Dependencies: None, except by inheritance.

Generalizations

Operations

back


BTL_Edge


This class represents an edge of a graph. It is to be used in combination with class BTL_GraphWithEdges.
Authors: W.R.Pitt
Files: GraphWithEdges.h
Friends: friend class BTL_GraphWithEdges<T1,T2>>;

friend ostream& operator<<(ostream &os, const BTL_Edge &m);
Dependencies: BTL_VertexWithEdges

Generalizations

Operations

back


BTL_GraphWithEdges


Graph container with any type of data at the vertices of the graph and any type of data at the edges. The default behaviour is have undirected edges. This can be changed to directed if specified in the constructor. No self links (edges from one vertex to itself) are allowed.
Authors: W.R.Pitt
Files: GraphWithEdges.h
Friends: friend ostream& operator<<<(ostream &os, const BTL_GraphWithEdges &m);
Dependencies: BTL_Vertex, BTL_II

Generalizations

Specializations

Operations

back


BTL_DFSIterator


This is a an iterator for iterating over a connected sub-graph in depth first order. It is designed to work with the BTL_Graph and BTL_GraphWithEdges but takes that type of graph as its template parameter and could be used on any graph and vertex type if they have a given set of functions.
Authors: W.R.Pitt
Files: DFSIterator.h
Dependencies: None

Operations

back


BTL_ConstDFSIterator


The const version of the BTL_DFSIterator.
Authors: W.R.Pitt
Files: DFSIterator.h
Dependencies: None

Operations

back


BTL_LeastSquaresFit


This class contains methods for calculating the applying the least squares fit of one set of x,y,z coordinates onto another. The method used is that of Simon K. Kearsley (Acta Cryst.'89, A45, 208-10).
Usage: All members in this class are static and therefore an object need not be create before the members can be used. The methods in this class are generic algorithms and can be used with a wide range of container types. This flexibility is achieved through the use of iterators. Any container used must have an appropriate iterator type that can be used to traverse through its elements. Most methods require two iterators per container, marking the first and last element to be processed. This style of function is designed to be the same as used in the Standard Template Library.

e.g.

// Set up aliases of the type to be used

typedef vector::iterator iterator;
typedef vector::const_iterator const_iterator;
typedef LeastSquaresFit<iterator,const_iterator> Fitter;

// Construct two empty vectors

vector v1,v2;

// Put some coordinates into these vector

....

// Do least squares fit on these coodinates

BTL_REAL rmsd = Fitter::Fit(v1.begin(),v1.end(),v2.begin(),v2.end());


Files: LeastSquaresFit.h
Dependencies: BTL_Matrix, BTL_NumericLimits
Authors: W.R.Pitt, D.S.Moss

Operations

back


BTL_PDBSort


This class defines a functor or function object which can be used by a generic sort routine to sort atoms into the order used in Brookhaven pdb format files. Order is defined by strings, 2 or 3 characters long.
Authors: W.R.Pitt
Files: PDBSort.h, PDBSort.cpp
Dependencies: none

Operations

back


BTL_AminoAcidProperty


This class defines a function object that will, given an amino acid single letter code with return a property value for that residue type.
Authors: W.R.Pitt
Files: AminoAcidProperty.h, AminoAcidProperty.cpp
Dependencies: none

Operations

back


BTL_NumericLimits


This is a template class that can be used to return standard floating point constants. N.B. This file will become obsolete when the standard C++ file climits becomes more widely available. It contains a numeric_limits class which will replace BTL_NumericLimits defined below.
Usage: e.g. const float EPSILON = BTL_NumericLimits<float>::epsilon();
Restrictions: This template class only works for float, double, and long double types.
Authors: W.R.Pitt
Files: NumericLimits.h
Friends: None
Dependencies: None

Operations

back


BTL_NumericUtilities


This template class contains members which preform certain numerical functions. The design of this class is not object-oriented and the member functions could easily be provided as stand alone functions. The reasons for containing the functions within a class is to put them into a namespace and to make documentation easier. Standand C++ namespaces are not still not implemented in many C++ compilers but otherwise this method may well be better than putting the functions into a class. Most C++ design and automatic documentation tools do not deal with non-class parts of a library. We use Together/C++ for our documentation and this tool only produces documentation for classes and class members.
Usage: e.g. unsigned int error = BTL_NumericUtilities<float>::AreNotEqual(a,b);
Restrictions: This template class only works for float, double, and long double types.
Authors: W.R.Pitt
Files: NumericUtilities.h
Friends: None
Dependencies: BTL_NumericLimits

Operations

back


BTL_XYZProcessor


This is simple class for reading xyz format files. It is really only included in the library so that real data can be used in the test programs.
Friends: an output operator
Authors: W.R.Pitt
Files: XYZProcessor.h
Dependencies: None

Operations

back


BTL_PIRProcessor


This class is a simple PIR sequence file processor. It is not complete and is only included for use by the demo programs that come with this library. It can parse a PIR format containing any number of sequences and provide the data as a vector or as individual strings.
Authors: W.R.Pitt
Files: PIRProcessor.h, PIRProcessor.cpp
Dependencies: none

Operations

back


BTL_PPMProcessor


This class is a simple ascii PPM image file processor. It is not complete and is only included for use by the demo programs that come with this library.
Authors: W.R.Pitt
Friends: ostream operator
Files: PPMProcessor.h, PPMProcessor.cpp
Dependencies: none

Operations

back


back up BTL_Vector


back up BTL_Matrix


back up BTL_CholeskyInverse


back up BTL_FFT


back up BTL_Vertex


back up BTL_Graph


back up BTL_VertexWithEdges


back up BTL_Edge


back up BTL_GraphWithEdges


back up BTL_DFSIterator


back up BTL_ConstDFSIterator


back up BTL_LeastSquaresFit


back up BTL_PDBSort


back up BTL_AminoAcidProperty


back up BTL_NumericLimits


back up BTL_NumericUtilities


back up BTL_XYZProcessor


back up BTL_PIRProcessor


back up BTL_PPMProcessor


Go Back to the Software Engineering Home Page Questions or comments are welcome, please send them to Will Pitt.

This page was created automatically using Together/C++ Information Export in conjunction with the Borland C++ development suite.