|
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 #ifndef CROSSPOINT_HPP_ 00023 #define CROSSPOINT_HPP_ 00024 00025 // TODO esse include foi colocado somente por causa do TYPE. Talvez valha a pena mover essa definição de lugar. 00026 #include "biology/Alignment.hpp" 00027 00028 /** @brief Represents a crosspoint between the optimal alignment and a special row. 00029 * 00030 * A crosspoint is a coordinate of the optimal alignment that crosses some 00031 * special row or special column. A crosspoint is represented by a tuple 00032 * (i, j, score, type), where score is the score of the alignment in position 00033 * (i,j) and type is the type of the alignment in this position. Type can be 00034 * TYPE_MATCH in case of match or mismatch, TYPE_GAP_1 if there is a gap in 00035 * sequence S_0 and TYPE_GAP_2 if there is a gap in sequence S_1. 00036 */ 00037 typedef struct crosspoint_t { 00038 /** vertical coordinate */ 00039 int i; 00040 00041 /** horizontal coordinate */ 00042 int j; 00043 00044 /** type of the crosspoint. It can be TYPE_MATCH, TYPE_GAP_1 or TYPE_GAP_2. */ 00045 int type; 00046 00047 /** The score of this crosspoint considering since the start of the alignment. */ 00048 int score; 00049 00050 /** 00051 * Reverse the crosspoint considering the reversed sequences. The reverse 00052 * procedure changes the original (i,j) coordinates to new (i', j') coordinates 00053 * using the following equations: 00054 * \f{eqnarray*}{ 00055 * i' &=& |S_1|-j \\ 00056 * j' &=& |S_0|-i 00057 * \f} 00058 * The type of the crosspoint is changed between TYPE_GAP_1 and TYPE_GAP_2. 00059 * The score is not changed. 00060 * 00061 * @param seq0_len The length \f$|S_0|\f$ of the sequence 0 (related to the i coordinate). 00062 * @param seq1_len The length \f$|S_1|\f$ of the sequence 1 (related to the j coordinate). 00063 * @return the new crosspoint with the reversed sequences. 00064 */ 00065 crosspoint_t reverse(int seq0_len, int seq1_len) { 00066 crosspoint_t ret; 00067 ret.i = seq1_len-this->j; 00068 ret.j = seq0_len-this->i; 00069 ret.score = this->score; 00070 if (this->type == TYPE_GAP_1) { 00071 ret.type = TYPE_GAP_2; 00072 } else if (this->type == TYPE_GAP_2) { 00073 ret.type = TYPE_GAP_1; 00074 } else { 00075 ret.type = this->type; 00076 } 00077 return ret; 00078 } 00079 00080 bool operator==(const crosspoint_t &other) const { 00081 return (this->i==other.i) && (this->j==other.j) && (this->type==other.type) && (this->score==other.score); 00082 } 00083 00084 bool operator!=(const crosspoint_t &other) const { 00085 return !(*this == other); 00086 } 00087 } crosspoint_t; 00088 00089 00090 #endif /* CROSSPOINT_HPP_ */
1.7.6.1