NVBIO
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Generic Programming
Most of NVBIO's functions and data structures are C++ templates providing the flexibility and compile-time code generation needed to accomodate the exponential amount of type combinations possible in typical bioinformatics applications.
Just as an example, consider the problem of string alignment: one user might want to use Smith-Waterman to perform local alignment between two ASCII strings. Another, might want to use Edit-Distance to align two 4-bit encoded strings semi-globally. Yet another might want to perform banded alignment using Gotoh's affine gap penalties, this time globally between an ASCII pattern and a 2-bit text.
Now consider the cross product of all the possible combinations:
AlignerAlignment Type DP AlgorithmPattern TypeText Type
Edit-Distance Global Full Matrix ASCII ASCII
Smith-Waterman Semi-Global Banded 2-bit 2-bit
Gotoh Local 4-bit 4-bit
Hard-coding them would result in 3 x 3 x 2 x 3 x 3 = 54 almost equivalent code paths!
Templates instead allow:
  • to express all these alignment problems elegantly using a single interface;
  • while at the same time not imposing any constraints on the user's possibilities who might for example easily experiment switching from ASCII to 2-bit encodings or perhaps yet another custom representation of his choice;
  • and to optimize the generated code at compile-time, specializing behaviour for an important subset of the exponentially (or even infinitely) sized cross product of all possible combinations.
And obviously, the same story goes for FM-indices, Bloom filters, and so on and so on...

Next: Host & Device Top: NVBIO