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_DNASTAT_MSA_PROFILE_DIALOG_H_ 23 #define _U2_DNASTAT_MSA_PROFILE_DIALOG_H_ 24 25 #include <QHash> 26 #include <QSet> 27 28 #include <U2Core/MultipleSequenceAlignment.h> 29 #include <U2Core/Task.h> 30 #include <U2Core/global.h> 31 32 #include "ui_DNAStatMSAProfileDialog.h" 33 34 namespace U2 { 35 36 class MSAEditor; 37 class SaveDocumentController; 38 39 class DNAStatMSAProfileDialog : public QDialog, public Ui_DNAStatMSAProfileDialog { 40 Q_OBJECT 41 42 public: 43 DNAStatMSAProfileDialog(QWidget *p, MSAEditor *ctx); 44 45 void accept(); 46 /*Notify user about problems with big report, and disable opening report in UGENE*/ 47 void showAlignmentIsTooBigWarning(); 48 private slots: 49 void sl_formatSelected(); 50 void sl_formatChanged(const QString &newFormat); 51 52 private: 53 void initSaveController(); 54 55 MSAEditor *ctx; 56 SaveDocumentController *saveController; 57 58 static const QString HTML; 59 static const QString CSV; 60 }; 61 62 enum DNAStatMSAProfileOutputFormat { 63 DNAStatMSAProfileOutputFormat_Show, 64 DNAStatMSAProfileOutputFormat_CSV, 65 DNAStatMSAProfileOutputFormat_HTML 66 }; 67 68 class DNAStatMSAProfileTaskSettings { 69 public: DNAStatMSAProfileTaskSettings()70 DNAStatMSAProfileTaskSettings() { 71 outFormat = DNAStatMSAProfileOutputFormat_Show; 72 usePercents = false; 73 reportGaps = false; 74 stripUnused = false; 75 countGapsInConsensusNumbering = true; 76 } 77 78 QString profileName; // usually object name 79 QString profileURL; // document url 80 MultipleSequenceAlignment ma; 81 bool usePercents; // report percents but not counts 82 DNAStatMSAProfileOutputFormat outFormat; 83 QString outURL; 84 bool reportGaps; // report GAPS statistics 85 bool stripUnused; // do not include into report chars unused in alignment 86 bool countGapsInConsensusNumbering; // affects html output only 87 }; 88 89 class DNAStatMSAProfileTask : public Task { 90 Q_OBJECT 91 public: 92 DNAStatMSAProfileTask(const DNAStatMSAProfileTaskSettings &s); 93 94 void run(); 95 QString generateReport() const; 96 virtual bool isReportingEnabled() const; 97 98 ReportResult report(); 99 100 private: 101 void computeStats(); 102 103 DNAStatMSAProfileTaskSettings s; 104 105 // fields to keep statistics 106 struct ColumnStat { 107 char consChar; 108 QVector<int> charFreqs; 109 }; 110 111 QStringList verticalColumnNames; 112 QVector<ColumnStat> columns; 113 QVector<char> consenusChars; 114 QHash<char, int> char2index; // char 2 index in 'ColumnStat' 115 QSet<char> unusedChars; 116 QString resultText; 117 }; 118 119 } // namespace U2 120 121 #endif 122