MASA-Core
capabilities.hpp
Go to the documentation of this file.
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 #ifndef CAPABILITIES_HPP_
00023 #define CAPABILITIES_HPP_
00024 
00025 /**
00026  * Use this constant for the unsupported capabilities by the Aligner.
00027  */
00028 #define NOT_SUPPORTED   (0)
00029 
00030 /**
00031  * Use this constant for the supported capabilities by the Aligner.
00032  */
00033 #define SUPPORTED               (1)
00034 
00035 /** @brief Struct that informs to the MASA framework which capabilities
00036  * the MASA extension implements.
00037  *
00038  * It is a development choice to implement or not all the capabilities,
00039  * but there are some MASA features that will not work if some capability
00040  * is missing (or if it is incorrectly implemented).
00041  *
00042  * Each capability is associated with a requirement of the IAligner interface.
00043  * If the IAligner implementation is fully compliant with a given requirement,
00044  * we say that it implements that capability. In this case, set the
00045  * boolean attributes to SUPPORTED, otherwise set it to NOT_SUPPORTED.
00046  *
00047  * Note that even if the IAligner implements a given capability, it must only
00048  * execute that capability if some conditional test is true.
00049  * Each capability has its own conditional requirement that may be obtained
00050  * by the associated IManager interface (see IAligner::setManager) or by the
00051  * AbstractAligner protected methods.
00052  *
00053  * Besides the boolean attributes, there are other parameters that indicates
00054  * limits of other aligner properties.
00055  *
00056  * See the description of each capability in this page, with its requirements
00057  * and conditional tests.
00058  */
00059 typedef struct aligner_capabilities_t {
00060         /**
00061          * Initializes the first column with custom data. The customized column
00062          * data is obtained by the IManager::receiveFirstColumn method.
00063          *
00064          * <b>condition:</b> <tt>always true</tt>
00065          */
00066         bool customize_first_column;
00067 
00068         /**
00069          * Initializes the first row with custom data. The customized column
00070          * data is obtained by the IManager::receiveFirstRow method.
00071          *
00072          * <b>condition:</b> <tt>always true</tt>
00073          */
00074         bool customize_first_row;
00075 
00076         /**
00077          * Dispatches the last column of the partition using the
00078          * IManager::dispatchColumn method.
00079          *
00080          * <b>condition:</b> <tt>IManager::mustDispatchLastColumn() == true</tt>
00081          */
00082         bool dispatch_last_column;
00083 
00084         /**
00085          * Dispatches the last row of the partition using the
00086          * IManager::dispatchRow method.
00087          *
00088          * <b>condition:</b> <tt>IManager::mustDispatchLastRow() == true</tt>
00089          */
00090         bool dispatch_last_row;
00091 
00092         /**
00093          * Dispatches the last cell of the partition using the
00094          * IManager::dispatchScore method.
00095          *
00096          * <b>condition:</b> <tt>IManager::mustDispatchLastCell() == true</tt>
00097          */
00098         bool dispatch_last_cell;
00099 
00100         /**
00101          * Dispatches special columns using the IManager::dispatchColumn method.
00102          * The distance between two special columns must be greater than
00103          * IManager::getSpecialColumnInterval.
00104          *
00105          * <b>condition:</b> <tt>IManager::mustDispatchSpecialColumns() == true</tt>
00106          */
00107         bool dispatch_special_column;
00108 
00109         /**
00110          * Dispatches special rows using the IManager::dispatchRow method.
00111          * The distance between two special rows must be greater than
00112          * IManager::getSpecialRowInterval.
00113          *
00114          * <b>condition:</b> <tt>IManager::mustDispatchSpecialRows() == true</tt>
00115          */
00116         bool dispatch_special_row;
00117 
00118         /**
00119          * Dispatches the best score using the IManager::dispatchScore method.
00120          * There is no problem to call IManager::dispatchScore many times, since
00121          * the best best score be dispatched in one of these calls.
00122          *
00123          * <b>condition:</b> <tt>IManager::mustDispatchScores() == true</tt>
00124          */
00125         bool dispatch_best_score;
00126 
00127         /**
00128          * Dispatches more than one score using the IManager::dispatchScore method.
00129          * If the method IManager::dispatchScore is called more than one time, set
00130          * this capability to <tt>SUPPORTED</tt>. If the method
00131          * IManager::dispatchScore is called only once in the end of the partition,
00132          * set this capability to <tt>NOT_SUPPORTED</tt>.
00133          *
00134          * <b>condition:</b> <tt>IManager::mustDispatchScores() == true</tt>
00135          */
00136         bool dispatch_scores;
00137 
00138         /**
00139          * Dispatches scores in a regular block pattern. The matrix must
00140          * be divided in \f$m\times{}n\f$ blocks and the best score of each block
00141          * must be dispatched using the IManager::dispatchScore with the
00142          * \f$(bx,by)\f$ block coordinate parameters.
00143          *
00144          * <b>condition:</b> <tt>IManager::mustDispatchScores() == true</tt>
00145          */
00146         bool dispatch_block_scores;
00147 
00148         /**
00149          * Aligns only the region delimited by the partition \f$(i0,j0)-(i1,j1)\f$.
00150          * Use methods IManager::getI0(), IManager::getJ0(), IManager::getI1()
00151          * and IManager::getJ1() to obtain the partition boundaries.
00152          *
00153          * <b>condition:</b> <tt>always true</tt>
00154          */
00155         bool process_partition;
00156 
00157         /**
00158          * Aligns using variable penalties. The variable penalties must be returned
00159          * by the IAligner::getScoreParameters() method. If the parameters are
00160          * constants, set this capability to <tt>NOT_SUPORTED</tt>.
00161          *
00162          * <b>condition:</b> <tt>always true</tt>
00163          */
00164         bool variable_penalties;
00165 
00166         /**
00167          * Implements the block pruning optimization. If the method
00168          * IManager::dispatchScore() is called for a pruned block, its best score
00169          * must be set to \f$-\infty\f$. Moreover, the last row and last column
00170          * of a pruned block must be dispatched considering \f$-\infty\f$ cell
00171          * values.
00172          *
00173          * <b>condition:</b> <tt>IManager::mustPruneBlocks() == true</tt>
00174          */
00175         bool block_pruning;
00176 
00177         /**
00178          * Aligns with the Needleman Wunsch (NW) recurrence function.
00179          *
00180          * \f[   H_{i,j}=\max\{ 0, E_{i,j}, F_{i,j}, H_{i-1,j-1} - p(i,j) \} \f]
00181          *
00182          * <b>condition:</b> <tt>IManager::getRecurrenceType() == NEEDLEMAN_WUNSCH</tt>
00183          */
00184         bool needleman_wunsch;
00185 
00186         /**
00187          * Aligns with the Smith wWaterman (SW) recurrence function.
00188          *
00189          * \f[   H_{i,j}=\max\{ 0, E_{i,j}, F_{i,j}, H_{i-1,j-1} - p(i,j) \} \f]
00190          *
00191          * <b>condition:</b> <tt>IManager::getRecurrenceType() == SMITH_WATERMAN</tt>
00192          */
00193         bool smith_waterman;
00194 
00195         /**
00196          * Allows the execution of many forked processes in parallel. The aligner
00197          * must return the weights of each forked process in the
00198          * IAligner::getForkWeights() methods. Moreover, the aligner may use
00199          * the AbstractAlignerParameters::getForkId() to identify uniquely each
00200          * process and set different resources for each one of them.
00201          *
00202          * <b>condition:</b> <tt>AbstractAlignerParameters::getForkId() != NOT_FORKED_PROCESS</tt>
00203          */
00204         bool fork_processes;
00205 
00206         /**
00207          * Indicates the maximum allowed size for the vertical sequence (seq0).
00208          * Zero-value means unlimited size.
00209          */
00210         int maximum_seq0_len;
00211 
00212         /**
00213          * Indicates the maximum allowed size for the horizontal sequence (seq1)
00214          * Zero-value means unlimited size.
00215          */
00216         int maximum_seq1_len;
00217 
00218         /**
00219          * Constructor that creates a new struct with all capabilities set to
00220          * NOT_SUPPORTED
00221          */
00222         aligner_capabilities_t() {
00223                 memset(this, 0, sizeof(aligner_capabilities_t));
00224         }
00225 } aligner_capabilities_t;
00226 
00227 
00228 #endif /* CAPABILITIES_HPP_ */