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_QD_GC_CONTENT_ACTOR_H_ 23 #define _U2_QD_GC_CONTENT_ACTOR_H_ 24 25 #include <U2Core/DNASequence.h> 26 #include <U2Core/U2Region.h> 27 28 #include <U2Lang/QDScheme.h> 29 #include <U2Lang/QueryDesignerRegistry.h> 30 31 namespace U2 { 32 33 class DNATranslation; 34 35 class FindGcRegionsSettings { 36 public: 37 U2Region gcRangeInPercents; 38 qint64 minLen; 39 qint64 offset; 40 DNATranslation *complTT; 41 QDStrandOption strand; FindGcRegionsSettings()42 FindGcRegionsSettings() 43 : gcRangeInPercents(20, 40), minLen(0), offset(0), complTT(nullptr) { 44 } 45 }; 46 47 class FindGcRegionsTask : public Task { 48 Q_OBJECT 49 public: FindGcRegionsTask(const FindGcRegionsSettings & settings,const DNASequence & sequence)50 FindGcRegionsTask(const FindGcRegionsSettings &settings, const DNASequence &sequence) 51 : Task(tr("Find base content task"), TaskFlag_None), settings_(settings), sequence_(sequence) { 52 } 53 void run(); 54 QList<SharedAnnotationData> getResultAsAnnotations() const; 55 56 private: 57 void find(const char *seq, 58 qint64 seqLen, 59 U2Region gcRangeInPercents, 60 qint64 len, 61 QVector<U2Region> &result); 62 static QList<SharedAnnotationData> createAnnotations(const QVector<U2Region> ®ions, qint64 offset, U2Strand::Direction strand); 63 64 private: 65 FindGcRegionsSettings settings_; 66 DNASequence sequence_; 67 QVector<U2Region> directResults; 68 QVector<U2Region> compResults; 69 }; 70 71 class QDFindGcRegionsActor : public QDActor { 72 Q_OBJECT 73 public: 74 QDFindGcRegionsActor(QDActorPrototype const *proto); 75 int getMinResultLen() const; 76 int getMaxResultLen() const; 77 QString getText() const; 78 Task *getAlgorithmTask(const QVector<U2Region> &location); defaultColor()79 QColor defaultColor() const { 80 return QColor(0xc6, 0xc6, 0x55); 81 } 82 private slots: 83 void sl_onTaskFinished(Task *); 84 }; 85 86 class QDFindGcActorPrototype : public QDActorPrototype { 87 public: 88 QDFindGcActorPrototype(); createInstance()89 virtual QDActor *createInstance() const { 90 return new QDFindGcRegionsActor(this); 91 } 92 }; 93 94 } // namespace U2 95 96 #endif 97