MASA-Core
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
AbstractDiagonalAligner Class Reference

Detailed Description

Abstract class that processes diagonal of blocks.

This class implements some common behavior to simplify the implementation of diagonal aligners. Use the AbstractDiagonalAligner if you want to compute all blocks inside the diagonal at once inside the architecture hardware/software. Differently from the AbstractBlockAligner, the AbstractDiagonalAligner does not use an AbstractBlockProcessor object, what means that the Aligner must compute the blocks by themselves.

In order to extend an AbstractDiagonalAligner, the class must implement two group of methods.

The memory related methods are called considering the order of the executed iteration, so we guarantee that a special row/column will only be issued when it is already computed.

Definition at line 56 of file AbstractDiagonalAligner.hpp.

#include <AbstractDiagonalAligner.hpp>

Inheritance diagram for AbstractDiagonalAligner:
AbstractAligner IAligner

List of all members.

Public Member Functions

 AbstractDiagonalAligner ()
 AbstractDiagonalAligner constructor.
virtual ~AbstractDiagonalAligner ()
 AbstractDiagonalAligner destructor.
virtual void alignPartition (Partition partition)
 Aligns the given partition, processing it by antidiagonals.
virtual void clearStatistics ()
virtual void printInitialStatistics (FILE *file)
 Empty stub for the superclass virtual method.
virtual void printStageStatistics (FILE *file)
 Empty stub for the superclass virtual method.
virtual void printFinalStatistics (FILE *file)
 Empty stub for the superclass virtual method.
virtual void printStatistics (FILE *file)
 Prints the pruning statistics and grid width used range.
virtual long long getProcessedCells ()
 Returns the number of processed cells since the last call to AbstractDiagonalAligner::clearStatistics method.
virtual const char * getProgressString () const
 MASA-Core prints this string periodically.

Protected Member Functions

virtual int getGridWidth (int width)=0
 Returns the number of horizontal blocks that the grid must have for a given width partition.
virtual int getBlockHeight ()=0
 Returns the default height of each block.
virtual const cell_tgetSpecialRow (int j, int len)=0
 Returns the bottom-most cells of a block computed from the previous computed diagonal.
virtual const cell_tgetLastRow (int j, int len)=0
 Returns the cells in the interval $[j,j+len)$ of the bottom-most row.
virtual const cell_tgetLastColumn (int i, int len)=0
 Returns the cells in the interval $[i,i+len)$ of the bottom-most row.
virtual const score_tgetBlockScores ()=0
 Returns the best scores of the blocks from the last computed diagonal.
virtual void setFirstRow (const cell_t *cells, int j, int len)=0
 Initializes the cells in the range $[j,j+len)$ of the first row.
virtual void setFirstColumn (const cell_t *cells, int i, int len)=0
 Initializes the cells in the range $[i,i+len)$ of the first column.
virtual void clearPrunedBlocks (int b0, int b1)=0
 Clear the rows of the pruned blocks, in range $[b0,b1)$.
virtual void initializeDiagonals ()=0
 Executes initialization procedures before the first diagonal be processed.
virtual void processDiagonal (int diagonal, int windowLeft, int windowRight)=0
 Executes one diagonal with the blocks from $[windowLeft, windowRight]$.
virtual void finalizeDiagonals ()=0
 Executes finalization procedures after the last diagonal is processed.
Partition getPartition () const
 Returns the partition currently being processed.

Private Member Functions

GridconfigureGrid (Partition partition)
 Configures the grid for the given partition.
void prepareIterations ()
 Configures the grid and initializes other structures before the beginning of the diagonal iterations.
void processNextIteration ()
 Processes the next diagonal and loads/flushes the rows and columns necessary for the MASA-Core integration.
bool hasMoreIterations ()
 Tests if we have more diagonals to be processed.
void finalizeIterations ()
 Finalizes the execution of the partition.
void flushSpecialRows ()
 Iterates on the blocks and check if any of them must flush its last row in the disk.
void flushLastRow ()
 This function reads a chunk of the last row from the aligner and dispatch it to the MASA-Core.
void flushLastColumn ()
 This function reads a chunk of the last column from the aligner and dispatch it to the MASA-Core.
void flushLastCell ()
 This function reads the bottom-left cell from aligner and dispatch it to the MASA-Core.
void flushBlockScores ()
 This function reads the block scores from aligner and dispatch them to the MASA-Core.
void loadFirstRow ()
 Initialize the first row of the aligner with the cells received from the MASA-Core.
void loadFirstColumn ()
 Initialize the first column of the aligner with the cells received from the MASA-Core.
bool isSpecialRow (int by)
 Defines if the blocks in row $by$ must flush their last row.
void pruneBlocks ()
 Updates the pruning window accordingly to the last block scores.

Private Attributes

cell_th_loadColumn
 Vector used to store the cells of the first column.
int gridWidth
 number of columns of blocks
int gridHeight
 number of rows of blocks
int externalDiagonalCount
 Number of external diagonals to be processed in the current partition.
int currentExternalDiagonal
 The id of the current external diagonal being processed.
Partition partition
 The partition currently being processed.
BlockPruningDiagonalpruner
 Block Pruner object.
int windowStart
 First block of non-pruned window.
int windowEnd
 Last block of non-pruned window.
int statTotalBlocks
 Total number of blocks containing in the grid.
int statPrunedBlocksLeft
 Number of pruned blocks in the left side of the grid.
int statPrunedBlocksRight
 Number of pruned blocks in the left side of the grid.
long long statTotalCells
 Total number of cells in the grid.
int statMinGridWidth
 Maintains the minimum gridWidth used.
int statMaxGridWidth
 Maintains the maximum gridWidth used.

Constructor & Destructor Documentation

AbstractDiagonalAligner constructor.

Definition at line 40 of file AbstractDiagonalAligner.cpp.

AbstractDiagonalAligner destructor.

Definition at line 48 of file AbstractDiagonalAligner.cpp.


Member Function Documentation

void AbstractDiagonalAligner::alignPartition ( Partition  partition) [virtual]

Aligns the given partition, processing it by antidiagonals.

Parameters:
partitionpartition to be aligned.
See also:
IAligner::alignPartition

Implements IAligner.

Definition at line 59 of file AbstractDiagonalAligner.cpp.

virtual void AbstractDiagonalAligner::clearPrunedBlocks ( int  b0,
int  b1 
) [protected, pure virtual]

Clear the rows of the pruned blocks, in range $[b0,b1)$.

The rows must be cleared with very small numbers (-INF) in order to avoid garbage data in the special rows or in future non-pruned blocks that may use the same area in memory.

Parameters:
b0first block to be cleared (inclusive).
b1last block to be cleared (exclusive)

clear all internal statistics of the aligner.

Implements IAligner.

Definition at line 203 of file AbstractDiagonalAligner.cpp.

Configures the grid for the given partition.

Parameters:
partitionpartition to be aligned.

Definition at line 183 of file AbstractDiagonalAligner.cpp.

virtual void AbstractDiagonalAligner::finalizeDiagonals ( ) [protected, pure virtual]

Executes finalization procedures after the last diagonal is processed.

Finalizes the execution of the partition.

Definition at line 172 of file AbstractDiagonalAligner.cpp.

This function reads the block scores from aligner and dispatch them to the MASA-Core.

Definition at line 392 of file AbstractDiagonalAligner.cpp.

This function reads the bottom-left cell from aligner and dispatch it to the MASA-Core.

Definition at line 375 of file AbstractDiagonalAligner.cpp.

This function reads a chunk of the last column from the aligner and dispatch it to the MASA-Core.

This method is called once for each external diagonal, since the last block is always calculating a new chunk of the last column.

Definition at line 358 of file AbstractDiagonalAligner.cpp.

This function reads a chunk of the last row from the aligner and dispatch it to the MASA-Core.

This method is called multiple times during the last external diagonals, since each of the bottom-most blocks calculates a range of the last row.

Definition at line 325 of file AbstractDiagonalAligner.cpp.

Iterates on the blocks and check if any of them must flush its last row in the disk.

If so, the row is copied from the aligner and dispatched to the MASA-Core. Note that the blocks are disposed in a diagonal, so there may be a maximum of one block per special row.

Definition at line 286 of file AbstractDiagonalAligner.cpp.

virtual int AbstractDiagonalAligner::getBlockHeight ( ) [protected, pure virtual]

Returns the default height of each block.

All the blocks will have the same height except the bottom most rows, that may be truncated.

Returns:
the default height of each block.
virtual const score_t* AbstractDiagonalAligner::getBlockScores ( ) [protected, pure virtual]

Returns the best scores of the blocks from the last computed diagonal.

Returns:
the best scores of each blocks (ordered from left to right).
virtual int AbstractDiagonalAligner::getGridWidth ( int  width) [protected, pure virtual]

Returns the number of horizontal blocks that the grid must have for a given width partition.

Parameters:
widththe width of the partition to be aligned.
Returns:
the recommended grid width for that partition.
virtual const cell_t* AbstractDiagonalAligner::getLastColumn ( int  i,
int  len 
) [protected, pure virtual]

Returns the cells in the interval $[i,i+len)$ of the bottom-most row.

Parameters:
ithe start column of the cells to be returned.
lenthe number of cells to be returned.
Returns:
the vector containing the special cells.
virtual const cell_t* AbstractDiagonalAligner::getLastRow ( int  j,
int  len 
) [protected, pure virtual]

Returns the cells in the interval $[j,j+len)$ of the bottom-most row.

Parameters:
lthe start column of the cells to be returned.
lenthe number of cells to be returned.
Returns:
the vector containing the special cells.

Returns the partition currently being processed.

Returns:
the partition currently being processed.

Definition at line 484 of file AbstractDiagonalAligner.cpp.

Returns the number of processed cells since the last call to AbstractDiagonalAligner::clearStatistics method.

Returns:
number of processed cells

Implements IAligner.

Definition at line 260 of file AbstractDiagonalAligner.cpp.

const char * AbstractDiagonalAligner::getProgressString ( ) const [virtual]

MASA-Core prints this string periodically.

Returns:
the string to be printed.

Implements IAligner.

Definition at line 268 of file AbstractDiagonalAligner.cpp.

virtual const cell_t* AbstractDiagonalAligner::getSpecialRow ( int  j,
int  len 
) [protected, pure virtual]

Returns the bottom-most cells of a block computed from the previous computed diagonal.

The block cells range is in the interval $[j,j+len)$. Since we are processing in diagonals, only one block can reside in this range. The cells will be saved in a special row by MASA-Core.

Parameters:
jthe start column of the cells to be returned.
lenthe number of cells to be returned.
Returns:
the vector containing the special cells.

Tests if we have more diagonals to be processed.

Returns:
true if we have more diagonals.

Definition at line 165 of file AbstractDiagonalAligner.cpp.

virtual void AbstractDiagonalAligner::initializeDiagonals ( ) [protected, pure virtual]

Executes initialization procedures before the first diagonal be processed.

bool AbstractDiagonalAligner::isSpecialRow ( int  by) [private]

Defines if the blocks in row $by$ must flush their last row.

The top-most and bottom-most rows are never special rows.

Parameters:
bythe block's row id
Returns:
true if the blocks inr row $by$ must save their last row.

Definition at line 466 of file AbstractDiagonalAligner.cpp.

Initialize the first column of the aligner with the cells received from the MASA-Core.

The first column is read in chunks, which size is defined by the getBlockHeight() function.

Definition at line 433 of file AbstractDiagonalAligner.cpp.

Initialize the first row of the aligner with the cells received from the MASA-Core.

The first row is read all at once.

Definition at line 409 of file AbstractDiagonalAligner.cpp.

Configures the grid and initializes other structures before the beginning of the diagonal iterations.

Definition at line 76 of file AbstractDiagonalAligner.cpp.

void AbstractDiagonalAligner::printFinalStatistics ( FILE *  file) [virtual]

Empty stub for the superclass virtual method.

This method is called immediately after finalize(), allowing the aligner to print some finalization information.

Parameters:
fileThe log file where the statistics will be written.

Implements IAligner.

Definition at line 228 of file AbstractDiagonalAligner.cpp.

void AbstractDiagonalAligner::printInitialStatistics ( FILE *  file) [virtual]

Empty stub for the superclass virtual method.

clear all internal statistics of the aligner.

Implements IAligner.

Definition at line 216 of file AbstractDiagonalAligner.cpp.

void AbstractDiagonalAligner::printStageStatistics ( FILE *  file) [virtual]

Empty stub for the superclass virtual method.

This method is called immediately after onSequenceChange(), allowing the aligner to print some information before a new stage.

Parameters:
fileThe log file where the statistics will be written.

Implements IAligner.

Definition at line 222 of file AbstractDiagonalAligner.cpp.

void AbstractDiagonalAligner::printStatistics ( FILE *  file) [virtual]

Prints the pruning statistics and grid width used range.

Parameters:
filehandler to print out the statistics.
See also:
IAligner::printStatistics

Implements IAligner.

Definition at line 236 of file AbstractDiagonalAligner.cpp.

virtual void AbstractDiagonalAligner::processDiagonal ( int  diagonal,
int  windowLeft,
int  windowRight 
) [protected, pure virtual]

Executes one diagonal with the blocks from $[windowLeft, windowRight]$.

The diagonals are numbered from 0, but the first diagonal (0) is not expected to compute any block. Diagonal 1 is expected to compute block $(0,0)$, diagonal 2 is expected to compute blocks $(1,0)$ and $(0,1)$, and so on. Generically speaking, diagonal $d$ is expected to compute all blocks $(bx,by)$ that $bx+by=d$.

Parameters:
diagonalthe diagonal number to be processed.
windowLeftthe first block to be processed (inclusive).
windowRightthe last block to be processed (inclusive).

Processes the next diagonal and loads/flushes the rows and columns necessary for the MASA-Core integration.

Definition at line 110 of file AbstractDiagonalAligner.cpp.

Updates the pruning window accordingly to the last block scores.

Definition at line 491 of file AbstractDiagonalAligner.cpp.

virtual void AbstractDiagonalAligner::setFirstColumn ( const cell_t cells,
int  i,
int  len 
) [protected, pure virtual]

Initializes the cells in the range $[i,i+len)$ of the first column.

Parameters:
cellsthe vector containing the cells.
ithe start column of the cells to be initialized.
lenthe number of cells to be initialized.
virtual void AbstractDiagonalAligner::setFirstRow ( const cell_t cells,
int  j,
int  len 
) [protected, pure virtual]

Initializes the cells in the range $[j,j+len)$ of the first row.

Parameters:
cellsthe vector containing the cells.
jthe start column of the cells to be initialized.
lenthe number of cells to be initialized.

Member Data Documentation

The id of the current external diagonal being processed.

Definition at line 202 of file AbstractDiagonalAligner.hpp.

Number of external diagonals to be processed in the current partition.

Definition at line 200 of file AbstractDiagonalAligner.hpp.

number of rows of blocks

Definition at line 197 of file AbstractDiagonalAligner.hpp.

number of columns of blocks

Definition at line 195 of file AbstractDiagonalAligner.hpp.

Vector used to store the cells of the first column.

See also:
AbstractDiagonalAligner::loadFirstColumn() method.

Definition at line 192 of file AbstractDiagonalAligner.hpp.

The partition currently being processed.

Definition at line 205 of file AbstractDiagonalAligner.hpp.

Block Pruner object.

Definition at line 207 of file AbstractDiagonalAligner.hpp.

Maintains the maximum gridWidth used.

Definition at line 228 of file AbstractDiagonalAligner.hpp.

Maintains the minimum gridWidth used.

Definition at line 226 of file AbstractDiagonalAligner.hpp.

Number of pruned blocks in the left side of the grid.

Definition at line 220 of file AbstractDiagonalAligner.hpp.

Number of pruned blocks in the left side of the grid.

Definition at line 222 of file AbstractDiagonalAligner.hpp.

Total number of blocks containing in the grid.

Definition at line 218 of file AbstractDiagonalAligner.hpp.

Total number of cells in the grid.

Definition at line 224 of file AbstractDiagonalAligner.hpp.

Last block of non-pruned window.

Definition at line 212 of file AbstractDiagonalAligner.hpp.

First block of non-pruned window.

Definition at line 210 of file AbstractDiagonalAligner.hpp.


The documentation for this class was generated from the following files: