|
MASA-Core
|
00001 /******************************************************************************* 00002 * 00003 * Copyright (c) 2010-2015 Edans Sandes 00004 * 00005 * This file is part of MASA-Core. 00006 * 00007 * MASA-Core is free software: you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation, either version 3 of the License, or 00010 * (at your option) any later version. 00011 * 00012 * MASA-Core is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with MASA-Core. If not, see <http://www.gnu.org/licenses/>. 00019 * 00020 ******************************************************************************/ 00021 00022 class AbstractAligner; 00023 00024 #ifndef ABSTRACTALIGNER_HPP_ 00025 #define ABSTRACTALIGNER_HPP_ 00026 00027 #include <string.h> 00028 #include <string> 00029 #include <map> 00030 using namespace std; 00031 00032 //#include "libmasa.hpp" 00033 #include "../IManager.hpp" 00034 #include "../Partition.hpp" 00035 #include "../IAligner.hpp" 00036 #include "../Grid.hpp" 00037 #include "../pruning/AbstractBlockPruning.hpp" 00038 00039 /** @brief Abstract class that executes the %Alignment procedure. 00040 * 00041 * The AbstractAligner class is the basic implementation of the interface 00042 * between the portable code and the non-portable code of MASA (Malleable Architecture 00043 * for Sequence Aligners). Each MASA extension must create its own Aligner 00044 * class that extend the AbstractAligner class. The Aligner class has 3 group of methods: 00045 * 00046 * 00047 * <ul> 00048 * <li>Public Methods. They are used between the MASA framework and the MASA 00049 * the public methods; 00050 * <li>Virtual methods. They must be implemented by the non-portable code; 00051 * <li>Protected methods. Simplifies routines common to all aligners. 00052 * <li>Delegate methods. Are methods with protected C++ visibility that may 00053 * be used to obtain or send information between the Aligner subclass and 00054 * the MASA framework. 00055 * </ul> 00056 * 00057 * 00058 * Although all the abstract methods must be implemented, the Aligner must 00059 * also be compliant with many requirements in order to produce a proper 00060 * integration. If the Aligner is fully compliant with a given requirement, 00061 * we say that the Aligner has that capability. See the aligner_capabilities_t struct 00062 * to see all the proposed requirements. 00063 */ 00064 class AbstractAligner : public IAligner { 00065 public: 00066 /* Constructors */ 00067 00068 AbstractAligner(); 00069 virtual ~AbstractAligner(); 00070 00071 /* Implemented virtual methods inherited from IAligner */ 00072 00073 virtual void setManager(IManager* manager); 00074 virtual const int* getForkWeights(); 00075 virtual match_result_t matchLastColumn(const cell_t* buffer, const cell_t* base, int len, int goalScore); 00076 00077 protected: 00078 00079 /* Methods to simplify the aligner implementation */ 00080 00081 void setForkCount(const int forkCount, const int* forkWeights = NULL); 00082 Grid* createGrid(Partition partition); 00083 virtual const Grid* getGrid() const; 00084 void initializeBlockPruning(AbstractBlockPruning* blockPruner); 00085 00086 /* Delegate-pattern to the IManger methods */ 00087 00088 int getRecurrenceType() const; 00089 int getSpecialRowInterval() const; 00090 int getSpecialColumnInterval() const; 00091 int getFirstColumnInitType(); 00092 Partition getSuperPartition(); 00093 int getFirstRowInitType(); 00094 00095 void receiveFirstRow(cell_t* buffer, int len); 00096 void receiveFirstColumn(cell_t* buffer, int len); 00097 void dispatchColumn(int j, const cell_t* buffer, int len); 00098 void dispatchRow(int i, const cell_t* buffer, int len); 00099 void dispatchScore(score_t score, int bx=-1, int by=-1); 00100 00101 bool mustContinue(); 00102 bool mustDispatchLastCell(); 00103 bool mustDispatchLastRow(); 00104 bool mustDispatchLastColumn(); 00105 bool mustDispatchSpecialRows(); 00106 bool mustDispatchSpecialColumns(); 00107 bool mustDispatchScores(); 00108 bool mustPruneBlocks(); 00109 00110 cell_t getFirstColumnTail() const; 00111 cell_t getFirstRowTail() const; 00112 00113 private: 00114 /** Manager object that receives calls from Aligner to MASA-Core. */ 00115 IManager* manager; 00116 00117 /** The computational power weights of each forked processes */ 00118 int* forkWeights; 00119 00120 /** Maximum number of forked proceess */ 00121 int forkCount; 00122 00123 /** The processing grid */ 00124 Grid* grid; 00125 00126 /** Last cell read in the first column */ 00127 cell_t firstColumnTail; 00128 00129 /** Last cell read in the first row */ 00130 cell_t firstRowTail; 00131 }; 00132 00133 #endif /* ABSTRACTALIGNER_HPP_ */
1.7.6.1