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

Detailed Description

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>

Inheritance diagram for AbstractBlockAligner:
AbstractAligner IAligner

List of all members.

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_tgetScoreParameters ()
 Returns the match/mismatch parameters and the gap penalties used by this IAligner.
virtual IAlignerParametersgetParameters ()
 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

GridconfigureGrid (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

BlockAlignerParametersparams
 Parameter used in this aligner.
score_t ** grid_scores
 Stores the score of each grid.
AbstractBlockProcessorblockProcessor
 Processor that computes a single block.
BlockPruningGenericN2blockPruner
 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.

Constructor & Destructor Documentation

Constructor.

AbstractBlockAligner Constructor.

Parameters:
blockProcessorthe block processor to be used. If NULL, the default processor will be used.
paramsthe aligner parameters. If NULL, the default param class will be used.

Definition at line 73 of file AbstractBlockAligner.cpp.

Destructor.

AbstractBlockAligner destructor.

Definition at line 119 of file AbstractBlockAligner.cpp.


Member Function Documentation

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.

Parameters:
bxhorizontal block coordinate
byvertical block coordinate
i0vertical first row of the block
j0horizontal first column of the block
i1vertical last row of the block
j1horizontal 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.

Parameters:
bxhorizontal coordinate of the block in the grid
byvertical 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.

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

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.

clear all internal statistics of the aligner.

Implements IAligner.

Definition at line 492 of file AbstractBlockAligner.cpp.

Configures the grid for the given partition.

Parameters:
partitionpartition 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.

Returns the capabilities of the aligner.

Returns:
the capabilities.
See also:
aligner_capabilities_t

Implements IAligner.

Definition at line 128 of file AbstractBlockAligner.cpp.

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.

Returns:
The customized parameters for this IAligner.
See also:
The IAlignerParameters class presents the details to customize these parameters.

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.

Returns:
the number of processed cells.

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).

Returns:
a single line progress strings without '\n'.

Implements IAligner.

Definition at line 522 of file AbstractBlockAligner.cpp.

Returns the match/mismatch parameters and the gap penalties used by this IAligner.

Returns:
the score parameters of 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.

Parameters:
bxhorizontal block coordinate
byvertical block coordinate

Definition at line 397 of file AbstractBlockAligner.cpp.

void AbstractBlockAligner::increaseBlockStat ( const bool  pruned) [protected, virtual]

Increased statistics about block processing.

Parameters:
prunedindicates if the block was pruned.

Definition at line 405 of file AbstractBlockAligner.cpp.

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.

Parameters:
bxhorizontal block coordinate
byvertical block coordinate
Returns:
true if the block can be pruned
Parameters:
bxhorizontal block coordinate
byvertical block coordinate
Returns:
pruned status of the block.

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.

Parameters:
bxthe column of blocks.
Returns:
true if the last column of the block will be stored (special column).

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.

Parameters:
bythe row of blocks.
Returns:
true if the last row of the block will be stored (special row).

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.

Parameters:
fileThe 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.

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

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.

Parameters:
fileThe 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.

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

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.

Parameters:
bxhorizontal block coordinate
byvertical block coordinate
i0vertical first row of the block
j0horizontal first column of the block
i1vertical last row of the block
j1horizontal last column of the block
trueif 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.

Parameters:
bxhorizontal block coordinate
byvertical block coordinate
scorethe 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.

Parameters:
grid_widthwidth of the grid in blocks.
grid_heightheight 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.

Parameters:
preferredBlockSizethe preferred maximum size of a block. Must be greater than 0.
preferredGridSizethe preferred minimum grid size. Must be greater than 0.

Used as a hint.

Parameters:
preferredBlockSizethe preferred maximum size of a block.
preferredGridSizethe 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.

Parameters:
seq0trimmed vertical sequence data
seq1trimmed horizontal sequence data
seq0_lenlength of the trimmed vertical sequence.
seq1_lenlength of the trimmed horizontal sequence.

Implements IAligner.

Definition at line 261 of file AbstractBlockAligner.cpp.

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.


Member Data Documentation

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.

Chunk of columns used to pass cells from left to right blocks.

Definition at line 99 of file AbstractBlockAligner.hpp.

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.

Preferred maximum size of a block.

Definition at line 194 of file AbstractBlockAligner.hpp.

Preferred minimum grid size.

Definition at line 197 of file AbstractBlockAligner.hpp.

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.

Maintains the maximum blockHeight used.

Definition at line 206 of file AbstractBlockAligner.hpp.

Maintains the maximum blockWidth used.

Definition at line 202 of file AbstractBlockAligner.hpp.

Maintains the maximum gridHeight used.

Definition at line 214 of file AbstractBlockAligner.hpp.

Maintains the maximum gridWidth used.

Definition at line 210 of file AbstractBlockAligner.hpp.

Maintains the minimum blockHeight used.

Definition at line 204 of file AbstractBlockAligner.hpp.

Maintains the minimum blockWidth used.

Definition at line 200 of file AbstractBlockAligner.hpp.

Maintains the minimum gridHeight used.

Definition at line 212 of file AbstractBlockAligner.hpp.

Maintains the minimum gridWidth used.

Definition at line 208 of file AbstractBlockAligner.hpp.

Number of pruned blocks.

Definition at line 219 of file AbstractBlockAligner.hpp.

Total number of blocks processed in the grid.

Definition at line 217 of file AbstractBlockAligner.hpp.


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