|
MASA-Core
|
Abstract class that processes blocks individually considering some schedule mechanism.
This class implements some common behavior to simplify the implementation of block aligners. These aligners process blocks individually using a customized schedule mechanism that processes block through an AbstractBlockProcessor object.
Use the AbstractBlockProcessor if you want to create a CPU block scheduler that processes a single block in the specific hardware/software architecture.
In order to extend an AbstractDiagonalAligner, the class must implement two methods.
Definition at line 56 of file AbstractBlockAligner.hpp.
#include <AbstractBlockAligner.hpp>
Public Member Functions | |
| AbstractBlockAligner (AbstractBlockProcessor *blockProcessor=NULL, BlockAlignerParameters *params=NULL) | |
| Constructor. | |
| virtual | ~AbstractBlockAligner () |
| Destructor. | |
| virtual void | initialize () |
| Initializes the Aligner before the execution of the alignment procedure. | |
| virtual void | alignPartition (Partition partition) |
| Aligns the given partition, processing it block by block using a customized scheduler. | |
| virtual void | finalize () |
| Finalizes the execution of this IAligner. | |
| virtual aligner_capabilities_t | getCapabilities () |
| Returns the capabilities of the aligner. | |
| virtual const score_params_t * | getScoreParameters () |
| Returns the match/mismatch parameters and the gap penalties used by this IAligner. | |
| virtual IAlignerParameters * | getParameters () |
| Get the command line parameters of the IAligner class. | |
| virtual void | setSequences (const char *seq0, const char *seq1, int seq0_len, int seq1_len) |
| This method is called in the beginning of each stage to inform the aligner about the sequence to be aligned. | |
| virtual void | unsetSequences () |
| Defines that the sequence will not be used anymore and the Aligner should deallocate the memory used for them. | |
| virtual void | clearStatistics () |
| virtual void | printInitialStatistics (FILE *file) |
| Prints the runtime parameters. | |
| 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 used range. | |
| virtual const char * | getProgressString () const |
| Returns a string that will be appended into some intermediate statistics information of stage 1. | |
| virtual long long | getProcessedCells () |
| Returns the number of cells that have been processed since the last call to clearStatistics. | |
Protected Member Functions | |
| virtual void | scheduleBlocks (int grid_width, int grid_height)=0 |
| Schedules all the blocks for execution. | |
| virtual void | alignBlock (int bx, int by, int i0, int j0, int i1, int j1)=0 |
| This method is called by AbstractBlockAligner::alignBlock(int,int) with additional information about block coordinates. | |
| void | ignoreBlock (int bx, int by) |
| Ignore the computation of a block. | |
| bool | isBlockPruned (int bx, int by) const |
| Check for pruned blocks. | |
| virtual void | increaseBlockStat (const bool pruned) |
| Increased statistics about block processing. | |
| void | alignBlock (int bx, int by) |
| This method aligns block (bx,by). | |
| bool | processBlock (int bx, int by, int i0, int j0, int i1, int j1) |
| This method calls AbstractBlockProcessor::processBlock(int,int,int,int,int,int,int) to execute the recurrence relation for a block. | |
| bool | isSpecialRow (int by) |
| Indicates if the blocks on row $by$ must dispatch its last row. | |
| bool | isSpecialColumn (int by) |
| Indicates if the blocks on column $bx$ must dispatch its last column. | |
| void | setPreferredSizes (int preferredBlockSize, int preferredGridSize) |
| Defines the preferred size of a block and the preferred number of blocks in the grid. | |
| virtual void | allocateStructures () |
| Allocate vectors after sequence is set. | |
| virtual void | deallocateStructures () |
| Deallocate vectors after sequence is unset. | |
Protected Attributes | |
| cell_t ** | row |
| Chunk of rows used to pass cells from up to bottom blocks. | |
| cell_t ** | col |
| Chunk of columns used to pass cells from left to right blocks. | |
Private Member Functions | |
| Grid * | configureGrid (Partition partition) |
| Configures the grid for the given partition. | |
| void | pruningUpdate (int bx, int by, int score) |
| Updates the pruning status accordingly to the block score. | |
Private Attributes | |
| BlockAlignerParameters * | params |
| Parameter used in this aligner. | |
| score_t ** | grid_scores |
| Stores the score of each grid. | |
| AbstractBlockProcessor * | blockProcessor |
| Processor that computes a single block. | |
| BlockPruningGenericN2 * | blockPruner |
| Block Pruner object. | |
| int | preferredBlockSize |
| Preferred maximum size of a block. | |
| int | preferredGridSize |
| Preferred minimum grid size. | |
| int | statMinBlockWidth |
| Maintains the minimum blockWidth used. | |
| int | statMaxBlockWidth |
| Maintains the maximum blockWidth used. | |
| int | statMinBlockHeight |
| Maintains the minimum blockHeight used. | |
| int | statMaxBlockHeight |
| Maintains the maximum blockHeight used. | |
| int | statMinGridWidth |
| Maintains the minimum gridWidth used. | |
| int | statMaxGridWidth |
| Maintains the maximum gridWidth used. | |
| int | statMinGridHeight |
| Maintains the minimum gridHeight used. | |
| int | statMaxGridHeight |
| Maintains the maximum gridHeight used. | |
| int | statTotalBlocks |
| Total number of blocks processed in the grid. | |
| int | statPrunedBlocks |
| Number of pruned blocks. | |
| score_params_t | score_params |
| Score parameters. | |
| AbstractBlockAligner::AbstractBlockAligner | ( | AbstractBlockProcessor * | blockProcessor = NULL, |
| BlockAlignerParameters * | params = NULL |
||
| ) |
Constructor.
AbstractBlockAligner Constructor.
| blockProcessor | the block processor to be used. If NULL, the default processor will be used. |
| params | the aligner parameters. If NULL, the default param class will be used. |
Definition at line 73 of file AbstractBlockAligner.cpp.
| AbstractBlockAligner::~AbstractBlockAligner | ( | ) | [virtual] |
Destructor.
AbstractBlockAligner destructor.
Definition at line 119 of file AbstractBlockAligner.cpp.
| virtual void AbstractBlockAligner::alignBlock | ( | int | bx, |
| int | by, | ||
| int | i0, | ||
| int | j0, | ||
| int | i1, | ||
| int | j1 | ||
| ) | [protected, pure virtual] |
This method is called by AbstractBlockAligner::alignBlock(int,int) with additional information about block coordinates.
Then, this method must receive/dispatch rows and columns from/to MASA-Core and call the processBlock(int,int,int,int,int,int) method.
| bx | horizontal block coordinate |
| by | vertical block coordinate |
| i0 | vertical first row of the block |
| j0 | horizontal first column of the block |
| i1 | vertical last row of the block |
| j1 | horizontal last column of the block |
| void AbstractBlockAligner::alignBlock | ( | int | bx, |
| int | by | ||
| ) | [protected] |
This method aligns block (bx,by).
This method calls the AbstractBlockAligner::alignBlock(int,int,int,int,int,int) with additional information about block coordinates.
| bx | horizontal coordinate of the block in the grid |
| by | vertical coordinate of the block in the grid |
Definition at line 338 of file AbstractBlockAligner.cpp.
| void AbstractBlockAligner::alignPartition | ( | Partition | partition | ) | [virtual] |
Aligns the given partition, processing it block by block using a customized scheduler.
| partition | partition to be aligned. |
Implements IAligner.
Definition at line 276 of file AbstractBlockAligner.cpp.
| void AbstractBlockAligner::allocateStructures | ( | ) | [protected, virtual] |
Allocate vectors after sequence is set.
Definition at line 536 of file AbstractBlockAligner.cpp.
| void AbstractBlockAligner::clearStatistics | ( | ) | [virtual] |
clear all internal statistics of the aligner.
Implements IAligner.
Definition at line 492 of file AbstractBlockAligner.cpp.
| Grid * AbstractBlockAligner::configureGrid | ( | Partition | partition | ) | [private] |
Configures the grid for the given partition.
| partition | partition to be aligned. |
Definition at line 198 of file AbstractBlockAligner.cpp.
| void AbstractBlockAligner::deallocateStructures | ( | ) | [protected, virtual] |
Deallocate vectors after sequence is unset.
Definition at line 573 of file AbstractBlockAligner.cpp.
| void AbstractBlockAligner::finalize | ( | ) | [virtual] |
Finalizes the execution of this IAligner.
Use this method to free any allocated memory during the life time of the IAligner.
Implements IAligner.
Definition at line 187 of file AbstractBlockAligner.cpp.
| aligner_capabilities_t AbstractBlockAligner::getCapabilities | ( | ) | [virtual] |
Returns the capabilities of the aligner.
Implements IAligner.
Definition at line 128 of file AbstractBlockAligner.cpp.
| IAlignerParameters * AbstractBlockAligner::getParameters | ( | ) | [virtual] |
Get the command line parameters of the IAligner class.
The IAlignerParameters interface is used by MASA to present extra command line parameters to each IAligner subclass. Be warned that the MASA-Core is responsible to present all the command line options, so, any attempt to modify the command line parameters must be done by the IAlignerParameters class, otherwise the behavior of the entire MASA-Core may be compromised. The AbstractAlignerParameters implements the base operations of the IAlignerParameters interface.
Implements IAligner.
Definition at line 164 of file AbstractBlockAligner.cpp.
| long long AbstractBlockAligner::getProcessedCells | ( | ) | [virtual] |
Returns the number of cells that have been processed since the last call to clearStatistics.
Implements IAligner.
Definition at line 529 of file AbstractBlockAligner.cpp.
| const char * AbstractBlockAligner::getProgressString | ( | ) | const [virtual] |
Returns a string that will be appended into some intermediate statistics information of stage 1.
Basically, the aligner should present how many steps have been calculated, giving an idea of conclusion percentage, and some quick information about pruning status. All the string should reside in a line (around 80 characters).
Implements IAligner.
Definition at line 522 of file AbstractBlockAligner.cpp.
| const score_params_t * AbstractBlockAligner::getScoreParameters | ( | ) | [virtual] |
Returns the match/mismatch parameters and the gap penalties used by this IAligner.
Implements IAligner.
Definition at line 157 of file AbstractBlockAligner.cpp.
| void AbstractBlockAligner::ignoreBlock | ( | int | bx, |
| int | by | ||
| ) | [protected] |
Ignore the computation of a block.
This method must be called for statistical purposes only.
| bx | horizontal block coordinate |
| by | vertical block coordinate |
Definition at line 397 of file AbstractBlockAligner.cpp.
| void AbstractBlockAligner::increaseBlockStat | ( | const bool | pruned | ) | [protected, virtual] |
Increased statistics about block processing.
| pruned | indicates if the block was pruned. |
Definition at line 405 of file AbstractBlockAligner.cpp.
| void AbstractBlockAligner::initialize | ( | ) | [virtual] |
Initializes the Aligner before the execution of the alignment procedure.
The IManager associated with this IAligner may only be called to obtain the command line parameters, specially the AbstractAlignerParameters::getForkId() in multi-process executions.
The IManager is not set and must not be queried. The initialize() method is called only once per process. Here, we may initialize the hardware and allocate some global structures that are not associated with the sequence sizes.
The initialize() method will be called once for each MASA stage and the sequences will not be changed until the finalize method be called. Meanwhile, the alignPartition() method may be called multiple times before the finalize() method is called.
The initialize() method may be used to process and allocated the sequences in memory. Note that the MASA stages may change the direction of the sequences, so consider that each call to the initialize method will change the sequence data.
Implements IAligner.
Definition at line 176 of file AbstractBlockAligner.cpp.
| bool AbstractBlockAligner::isBlockPruned | ( | int | bx, |
| int | by | ||
| ) | const [protected] |
Check for pruned blocks.
Returns true if block (bx, by) can be pruned.
| bx | horizontal block coordinate |
| by | vertical block coordinate |
| bx | horizontal block coordinate |
| by | vertical block coordinate |
Definition at line 610 of file AbstractBlockAligner.cpp.
| bool AbstractBlockAligner::isSpecialColumn | ( | int | bx | ) | [protected] |
Indicates if the blocks on column $bx$ must dispatch its last column.
| bx | the column of blocks. |
Definition at line 448 of file AbstractBlockAligner.cpp.
| bool AbstractBlockAligner::isSpecialRow | ( | int | by | ) | [protected] |
Indicates if the blocks on row $by$ must dispatch its last row.
| by | the row of blocks. |
Definition at line 419 of file AbstractBlockAligner.cpp.
| void AbstractBlockAligner::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 516 of file AbstractBlockAligner.cpp.
| void AbstractBlockAligner::printInitialStatistics | ( | FILE * | file | ) | [virtual] |
Prints the runtime parameters.
| file | handler to print out the statistics. |
Implements IAligner.
Definition at line 478 of file AbstractBlockAligner.cpp.
| void AbstractBlockAligner::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 510 of file AbstractBlockAligner.cpp.
| void AbstractBlockAligner::printStatistics | ( | FILE * | file | ) | [virtual] |
Prints the pruning statistics and grid used range.
| file | handler to print out the statistics. |
Implements IAligner.
Definition at line 457 of file AbstractBlockAligner.cpp.
| bool AbstractBlockAligner::processBlock | ( | int | bx, |
| int | by, | ||
| int | i0, | ||
| int | j0, | ||
| int | i1, | ||
| int | j1 | ||
| ) | [protected] |
This method calls AbstractBlockProcessor::processBlock(int,int,int,int,int,int,int) to execute the recurrence relation for a block.
| bx | horizontal block coordinate |
| by | vertical block coordinate |
| i0 | vertical first row of the block |
| j0 | horizontal first column of the block |
| i1 | vertical last row of the block |
| j1 | horizontal last column of the block |
| true | if the block was processed or false if it was pruned. |
Definition at line 362 of file AbstractBlockAligner.cpp.
| void AbstractBlockAligner::pruningUpdate | ( | int | bx, |
| int | by, | ||
| int | score | ||
| ) | [private] |
Updates the pruning status accordingly to the block score.
| bx | horizontal block coordinate |
| by | vertical block coordinate |
| score | the score of block at coordinate $(bx,by)$ |
Definition at line 621 of file AbstractBlockAligner.cpp.
| virtual void AbstractBlockAligner::scheduleBlocks | ( | int | grid_width, |
| int | grid_height | ||
| ) | [protected, pure virtual] |
Schedules all the blocks for execution.
As soon as one block is ready to be executed, this method must call the AbstractBlockAligner::alignBlock(int,int) function in order to prepare this block for real execution.
| grid_width | width of the grid in blocks. |
| grid_height | height of the grid in blocks. |
| void AbstractBlockAligner::setPreferredSizes | ( | int | preferredBlockSize, |
| int | preferredGridSize | ||
| ) | [protected] |
Defines the preferred size of a block and the preferred number of blocks in the grid.
Defines the preferred block/grid sizes.
This values are used as a hint for the automatic grid/block configuration.
| preferredBlockSize | the preferred maximum size of a block. Must be greater than 0. |
| preferredGridSize | the preferred minimum grid size. Must be greater than 0. |
Used as a hint.
| preferredBlockSize | the preferred maximum size of a block. |
| preferredGridSize | the preferred minimum grid size. |
Definition at line 633 of file AbstractBlockAligner.cpp.
| void AbstractBlockAligner::setSequences | ( | const char * | seq0, |
| const char * | seq1, | ||
| int | seq0_len, | ||
| int | seq1_len | ||
| ) | [virtual] |
This method is called in the beginning of each stage to inform the aligner about the sequence to be aligned.
The MASA stages alternates the direction of the sequences in each stage, possibly trimming if the beginning and end of the sequences will not be used in this stage. So consider that each call to the onSequenceChange() method may completely change the sequence data for the further calls to alignPartition.
Note that the seq0_len and seq1_len parameters are not the sizes of the original sequences, but the sizes of the trimmed sequences.
| seq0 | trimmed vertical sequence data |
| seq1 | trimmed horizontal sequence data |
| seq0_len | length of the trimmed vertical sequence. |
| seq1_len | length of the trimmed horizontal sequence. |
Implements IAligner.
Definition at line 261 of file AbstractBlockAligner.cpp.
| void AbstractBlockAligner::unsetSequences | ( | ) | [virtual] |
Defines that the sequence will not be used anymore and the Aligner should deallocate the memory used for them.
This method is called in the end of each stage.
Implements IAligner.
Definition at line 265 of file AbstractBlockAligner.cpp.
Processor that computes a single block.
Definition at line 188 of file AbstractBlockAligner.hpp.
Block Pruner object.
Definition at line 191 of file AbstractBlockAligner.hpp.
cell_t** AbstractBlockAligner::col [protected] |
Chunk of columns used to pass cells from left to right blocks.
Definition at line 99 of file AbstractBlockAligner.hpp.
score_t** AbstractBlockAligner::grid_scores [private] |
Stores the score of each grid.
Definition at line 185 of file AbstractBlockAligner.hpp.
Parameter used in this aligner.
Definition at line 182 of file AbstractBlockAligner.hpp.
int AbstractBlockAligner::preferredBlockSize [private] |
Preferred maximum size of a block.
Definition at line 194 of file AbstractBlockAligner.hpp.
int AbstractBlockAligner::preferredGridSize [private] |
Preferred minimum grid size.
Definition at line 197 of file AbstractBlockAligner.hpp.
cell_t** AbstractBlockAligner::row [protected] |
Chunk of rows used to pass cells from up to bottom blocks.
Definition at line 97 of file AbstractBlockAligner.hpp.
Score parameters.
Definition at line 223 of file AbstractBlockAligner.hpp.
int AbstractBlockAligner::statMaxBlockHeight [private] |
Maintains the maximum blockHeight used.
Definition at line 206 of file AbstractBlockAligner.hpp.
int AbstractBlockAligner::statMaxBlockWidth [private] |
Maintains the maximum blockWidth used.
Definition at line 202 of file AbstractBlockAligner.hpp.
int AbstractBlockAligner::statMaxGridHeight [private] |
Maintains the maximum gridHeight used.
Definition at line 214 of file AbstractBlockAligner.hpp.
int AbstractBlockAligner::statMaxGridWidth [private] |
Maintains the maximum gridWidth used.
Definition at line 210 of file AbstractBlockAligner.hpp.
int AbstractBlockAligner::statMinBlockHeight [private] |
Maintains the minimum blockHeight used.
Definition at line 204 of file AbstractBlockAligner.hpp.
int AbstractBlockAligner::statMinBlockWidth [private] |
Maintains the minimum blockWidth used.
Definition at line 200 of file AbstractBlockAligner.hpp.
int AbstractBlockAligner::statMinGridHeight [private] |
Maintains the minimum gridHeight used.
Definition at line 212 of file AbstractBlockAligner.hpp.
int AbstractBlockAligner::statMinGridWidth [private] |
Maintains the minimum gridWidth used.
Definition at line 208 of file AbstractBlockAligner.hpp.
int AbstractBlockAligner::statPrunedBlocks [private] |
Number of pruned blocks.
Definition at line 219 of file AbstractBlockAligner.hpp.
int AbstractBlockAligner::statTotalBlocks [private] |
Total number of blocks processed in the grid.
Definition at line 217 of file AbstractBlockAligner.hpp.
1.7.6.1