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_KALIGN_TASK_H_ 23 #define _U2_KALIGN_TASK_H_ 24 25 #include <U2Algorithm/MsaUtilTasks.h> 26 27 #include <U2Core/MultipleSequenceAlignmentObject.h> 28 #include <U2Core/SaveDocumentTask.h> 29 #include <U2Core/TLSTask.h> 30 #include <U2Core/Task.h> 31 #include <U2Core/U2Mod.h> 32 33 #define KALIGN_CONTEXT_ID "kalign" 34 35 struct kalign_context; 36 37 namespace U2 { 38 39 class StateLock; 40 class MultipleSequenceAlignmentObject; 41 class LoadDocumentTask; 42 43 class KalignContext : public TLSContext { 44 public: KalignContext(kalign_context * _d)45 KalignContext(kalign_context *_d) 46 : TLSContext(KALIGN_CONTEXT_ID), d(_d) { 47 } 48 kalign_context *d; 49 }; 50 51 class KalignTaskSettings { 52 public: KalignTaskSettings()53 KalignTaskSettings() { 54 reset(); 55 } 56 void reset(); 57 58 float gapOpenPenalty; 59 float gapExtenstionPenalty; 60 float termGapPenalty; 61 float secret; 62 QString inputFilePath; 63 QString outputFilePath; 64 }; 65 66 class KalignTask : public TLSTask { 67 Q_OBJECT 68 public: 69 KalignTask(const MultipleSequenceAlignment &ma, const KalignTaskSettings &config); 70 71 void _run(); 72 void doAlign(); 73 ReportResult report(); 74 75 static bool isAlphabetSupported(const QString &alphabetId); 76 77 KalignTaskSettings config; 78 MultipleSequenceAlignment inputMA; 79 MultipleSequenceAlignment resultMA; 80 81 MultipleSequenceAlignment inputSubMA; 82 MultipleSequenceAlignment resultSubMA; 83 84 protected: 85 TLSContext *createContextInstance(); 86 }; 87 88 // locks MultipleSequenceAlignment object and propagate KalignTask results to it 89 class KalignGObjectTask : public AlignGObjectTask { 90 Q_OBJECT 91 public: 92 KalignGObjectTask(MultipleSequenceAlignmentObject *obj, const KalignTaskSettings &config); 93 ~KalignGObjectTask(); 94 95 virtual void prepare(); 96 ReportResult report(); 97 98 QPointer<StateLock> lock; 99 KalignTask *kalignTask; 100 KalignTaskSettings config; 101 LoadDocumentTask *loadDocumentTask; 102 }; 103 104 /** 105 * runs kalign from cmdline schema in separate process 106 * using data/cmdline/align-kalign.uwl schema 107 * schema has following aliases: 108 * in - input file with alignment (will be set in WorkflowRunSchemaForTask) 109 * out - output file with result (will be set in WorkflowRunSchemaForTask) 110 * format - output file format (will be set in WorkflowRunSchemaForTask) 111 * bonus-score - bonus score of kalign task 112 * gap-ext-penalty - kalign parameter 113 * gap-open-penalty - kalign parameter 114 * gap-terminal-penalty - kalign parameter 115 */ 116 class KalignGObjectRunFromSchemaTask : public AlignGObjectTask { 117 Q_OBJECT 118 public: 119 KalignGObjectRunFromSchemaTask(MultipleSequenceAlignmentObject *obj, const KalignTaskSettings &config); 120 121 void prepare(); 122 void setMAObject(MultipleSequenceAlignmentObject *maobj); 123 124 private: 125 KalignTaskSettings config; 126 }; 127 128 class KalignWithExtFileSpecifySupportTask : public Task { 129 public: 130 KalignWithExtFileSpecifySupportTask(const KalignTaskSettings &config); 131 ~KalignWithExtFileSpecifySupportTask(); 132 133 void prepare(); 134 QList<Task *> onSubTaskFinished(Task *subTask); 135 136 private: 137 MultipleSequenceAlignmentObject *mAObject; 138 Document *currentDocument; 139 bool cleanDoc; 140 SaveDocumentTask *saveDocumentTask; 141 Task *kalignGObjectTask; 142 KalignTaskSettings config; 143 LoadDocumentTask *loadDocumentTask; 144 }; 145 146 } // namespace U2 147 148 #endif 149