|
MASA-Core
|
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>
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_t * | getSpecialRow (int j, int len)=0 |
| Returns the bottom-most cells of a block computed from the previous computed diagonal. | |
| virtual const cell_t * | getLastRow (int j, int len)=0 |
| Returns the cells in the interval $[j,j+len)$ of the bottom-most row. | |
| virtual const cell_t * | getLastColumn (int i, int len)=0 |
| Returns the cells in the interval $[i,i+len)$ of the bottom-most row. | |
| virtual const score_t * | getBlockScores ()=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 | |
| Grid * | configureGrid (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_t * | h_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. | |
| BlockPruningDiagonal * | pruner |
| 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. | |
AbstractDiagonalAligner constructor.
Definition at line 40 of file AbstractDiagonalAligner.cpp.
| AbstractDiagonalAligner::~AbstractDiagonalAligner | ( | ) | [virtual] |
AbstractDiagonalAligner destructor.
Definition at line 48 of file AbstractDiagonalAligner.cpp.
| void AbstractDiagonalAligner::alignPartition | ( | Partition | partition | ) | [virtual] |
Aligns the given partition, processing it by antidiagonals.
| partition | partition to be aligned. |
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.
| b0 | first block to be cleared (inclusive). |
| b1 | last block to be cleared (exclusive) |
| void AbstractDiagonalAligner::clearStatistics | ( | ) | [virtual] |
clear all internal statistics of the aligner.
Implements IAligner.
Definition at line 203 of file AbstractDiagonalAligner.cpp.
| Grid * AbstractDiagonalAligner::configureGrid | ( | Partition | partition | ) | [private] |
Configures the grid for the given partition.
| partition | partition 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.
| void AbstractDiagonalAligner::finalizeIterations | ( | ) | [private] |
Finalizes the execution of the partition.
Definition at line 172 of file AbstractDiagonalAligner.cpp.
| void AbstractDiagonalAligner::flushBlockScores | ( | ) | [private] |
This function reads the block scores from aligner and dispatch them to the MASA-Core.
Definition at line 392 of file AbstractDiagonalAligner.cpp.
| void AbstractDiagonalAligner::flushLastCell | ( | ) | [private] |
This function reads the bottom-left cell from aligner and dispatch it to the MASA-Core.
Definition at line 375 of file AbstractDiagonalAligner.cpp.
| void AbstractDiagonalAligner::flushLastColumn | ( | ) | [private] |
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.
| void AbstractDiagonalAligner::flushLastRow | ( | ) | [private] |
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.
| void AbstractDiagonalAligner::flushSpecialRows | ( | ) | [private] |
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.
| virtual const score_t* AbstractDiagonalAligner::getBlockScores | ( | ) | [protected, pure virtual] |
Returns the best scores of the blocks from the last computed diagonal.
| 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.
| width | the width of the partition to be aligned. |
| 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.
| i | the start column of the cells to be returned. |
| len | the number of cells to be returned. |
| 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.
| l | the start column of the cells to be returned. |
| len | the number of cells to be returned. |
| Partition AbstractDiagonalAligner::getPartition | ( | ) | const [protected] |
Returns the partition currently being processed.
Definition at line 484 of file AbstractDiagonalAligner.cpp.
| long long AbstractDiagonalAligner::getProcessedCells | ( | ) | [virtual] |
Returns the number of processed cells since the last call to AbstractDiagonalAligner::clearStatistics method.
Implements IAligner.
Definition at line 260 of file AbstractDiagonalAligner.cpp.
| const char * AbstractDiagonalAligner::getProgressString | ( | ) | const [virtual] |
MASA-Core prints this string periodically.
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.
| j | the start column of the cells to be returned. |
| len | the number of cells to be returned. |
| bool AbstractDiagonalAligner::hasMoreIterations | ( | ) | [private] |
Tests if we have more diagonals to be processed.
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.
| by | the block's row id |
Definition at line 466 of file AbstractDiagonalAligner.cpp.
| void AbstractDiagonalAligner::loadFirstColumn | ( | ) | [private] |
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.
| void AbstractDiagonalAligner::loadFirstRow | ( | ) | [private] |
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.
| void AbstractDiagonalAligner::prepareIterations | ( | ) | [private] |
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.
| file | The 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.
| file | The 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.
| file | handler to print out the statistics. |
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$.
| diagonal | the diagonal number to be processed. |
| windowLeft | the first block to be processed (inclusive). |
| windowRight | the last block to be processed (inclusive). |
| void AbstractDiagonalAligner::processNextIteration | ( | ) | [private] |
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.
| void AbstractDiagonalAligner::pruneBlocks | ( | ) | [private] |
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.
| cells | the vector containing the cells. |
| i | the start column of the cells to be initialized. |
| len | the 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.
| cells | the vector containing the cells. |
| j | the start column of the cells to be initialized. |
| len | the number of cells to be initialized. |
int AbstractDiagonalAligner::currentExternalDiagonal [private] |
The id of the current external diagonal being processed.
Definition at line 202 of file AbstractDiagonalAligner.hpp.
int AbstractDiagonalAligner::externalDiagonalCount [private] |
Number of external diagonals to be processed in the current partition.
Definition at line 200 of file AbstractDiagonalAligner.hpp.
int AbstractDiagonalAligner::gridHeight [private] |
number of rows of blocks
Definition at line 197 of file AbstractDiagonalAligner.hpp.
int AbstractDiagonalAligner::gridWidth [private] |
number of columns of blocks
Definition at line 195 of file AbstractDiagonalAligner.hpp.
cell_t* AbstractDiagonalAligner::h_loadColumn [private] |
Vector used to store the cells of the first column.
Definition at line 192 of file AbstractDiagonalAligner.hpp.
Partition AbstractDiagonalAligner::partition [private] |
The partition currently being processed.
Definition at line 205 of file AbstractDiagonalAligner.hpp.
Block Pruner object.
Definition at line 207 of file AbstractDiagonalAligner.hpp.
int AbstractDiagonalAligner::statMaxGridWidth [private] |
Maintains the maximum gridWidth used.
Definition at line 228 of file AbstractDiagonalAligner.hpp.
int AbstractDiagonalAligner::statMinGridWidth [private] |
Maintains the minimum gridWidth used.
Definition at line 226 of file AbstractDiagonalAligner.hpp.
int AbstractDiagonalAligner::statPrunedBlocksLeft [private] |
Number of pruned blocks in the left side of the grid.
Definition at line 220 of file AbstractDiagonalAligner.hpp.
int AbstractDiagonalAligner::statPrunedBlocksRight [private] |
Number of pruned blocks in the left side of the grid.
Definition at line 222 of file AbstractDiagonalAligner.hpp.
int AbstractDiagonalAligner::statTotalBlocks [private] |
Total number of blocks containing in the grid.
Definition at line 218 of file AbstractDiagonalAligner.hpp.
long long AbstractDiagonalAligner::statTotalCells [private] |
Total number of cells in the grid.
Definition at line 224 of file AbstractDiagonalAligner.hpp.
int AbstractDiagonalAligner::windowEnd [private] |
Last block of non-pruned window.
Definition at line 212 of file AbstractDiagonalAligner.hpp.
int AbstractDiagonalAligner::windowStart [private] |
First block of non-pruned window.
Definition at line 210 of file AbstractDiagonalAligner.hpp.
1.7.6.1