1 /** 2 * UGENE - Integrated Bioinformatics Tools. 3 * Copyright (C) 2008-2021 UniPro <ugene@unipro.ru> 4 * http://ugene.net 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License 8 * as published by the Free Software Foundation; either version 2 9 * of the License, or (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 19 * MA 02110-1301, USA. 20 */ 21 22 #ifndef _U2_REPEAT_FINDER_SETTINGS_H_ 23 #define _U2_REPEAT_FINDER_SETTINGS_H_ 24 25 #include <QString> 26 27 #include <U2Core/Task.h> 28 29 namespace U2 { 30 31 class DNAAlphabet; 32 33 enum RFAlgorithm { 34 RFAlgorithm_Auto, 35 RFAlgorithm_Diagonal, 36 RFAlgorithm_Suffix 37 }; 38 39 enum RepeatsFilterAlgorithm { 40 DisjointRepeats, 41 NoFiltering, 42 UniqueRepeats 43 }; 44 45 class RFResult { 46 public: RFResult()47 RFResult() 48 : x(0), y(0), l(0), c(0) { 49 } 50 51 RFResult(int _x, int _y, int _len, int _c = 0) x(_x)52 : x(_x), y(_y), l(_len) { // if not specified, repeats have no mismatches 53 if (_c == 0) 54 c = l; 55 else 56 c = _c; 57 } 58 RFResult(int _x,int _y,int _len,int _c,QString _fragment)59 RFResult(int _x, int _y, int _len, int _c, QString _fragment) 60 : fragment(_fragment), x(_x), y(_y), l(_len), c(_c) { 61 if (_c == 0) 62 c = l; 63 else 64 c = _c; 65 } 66 67 bool operator==(const RFResult &r) const { 68 return x == r.x && y == r.y && l == r.l; 69 } 70 bool operator!=(const RFResult &r) const { 71 return !(*this == r); 72 } 73 bool operator<(const RFResult &r) const { 74 return (x != r.x) ? x < r.x : (y != r.y) ? y < r.y 75 : (l < r.l); 76 } 77 78 QString fragment; 79 int x; 80 int y; 81 int l; 82 int c; // matches 83 }; 84 85 class RFResultsListener { 86 public: 87 virtual void onResult(const RFResult &r) = 0; 88 virtual void onResults(const QVector<RFResult> &v) = 0; 89 }; 90 91 struct RepeatFinderSettings { RepeatFinderSettingsRepeatFinderSettings92 RepeatFinderSettings() 93 : l(nullptr), seqX(nullptr), sizeX(0), inverted(false), 94 seqY(nullptr), sizeY(0), 95 al(nullptr), w(0), mismatches(0), 96 alg(RFAlgorithm_Auto), nThreads(0) { 97 } 98 99 RepeatFinderSettings( 100 RFResultsListener *_l, 101 const char *_seqX, 102 int _sizeX, 103 bool _inverted, 104 const char *_seqY, 105 int _sizeY, 106 const DNAAlphabet *_al, 107 int _w, 108 int _mismatches, 109 RFAlgorithm _alg, 110 int _nThreads = MAX_PARALLEL_SUBTASKS_AUTO) lRepeatFinderSettings111 : l(_l), seqX(_seqX), sizeX(_sizeX), inverted(_inverted), 112 seqY(_seqY), sizeY(_sizeY), 113 al(_al), w(_w), mismatches(_mismatches), 114 alg(_alg), nThreads(_nThreads) { 115 } 116 117 RFResultsListener *l; 118 const char *seqX; 119 int sizeX; 120 bool inverted; 121 const char *seqY; 122 int sizeY; 123 const DNAAlphabet *al; 124 int w; 125 int mismatches; 126 RFAlgorithm alg; 127 int nThreads; 128 129 bool operator==(const RepeatFinderSettings &op) const { 130 return l == op.l && 131 seqX == op.seqX && 132 sizeX == op.sizeX && 133 inverted == op.inverted && 134 seqY == op.seqY && 135 sizeY == op.sizeY && 136 al == op.al && 137 w == op.w && 138 mismatches == op.mismatches && 139 alg == op.alg && 140 nThreads == op.nThreads; 141 } 142 }; 143 144 } // namespace U2 145 146 #endif 147