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_MSA_UTIL_TASKS
23 #define _U2_MSA_UTIL_TASKS
24 
25 #include <U2Core/MultipleSequenceAlignmentObject.h>
26 #include <U2Core/Task.h>
27 #include <U2Core/global.h>
28 
29 namespace U2 {
30 
31 class DNATranslation;
32 
33 /**
34  Performs in-place translation of multiple sequence alignment object
35 */
36 
37 class U2ALGORITHM_EXPORT TranslateMsa2AminoTask : public Task {
38     Q_OBJECT
39 public:
40     TranslateMsa2AminoTask(MultipleSequenceAlignmentObject *obj);
41     TranslateMsa2AminoTask(MultipleSequenceAlignmentObject *obj, const QString &trId);
getTaskResult()42     const MultipleSequenceAlignment &getTaskResult() {
43         return resultMA;
44     }
45     void run();
46     ReportResult report();
47 
48 private:
49     MultipleSequenceAlignment resultMA;
50     MultipleSequenceAlignmentObject *maObj;
51     DNATranslation *translation;
52 };
53 
54 /**
55  Wrapper for multiple alignment task
56 */
57 
58 class U2ALGORITHM_EXPORT AlignGObjectTask : public Task {
59     Q_OBJECT
60 public:
AlignGObjectTask(const QString & taskName,TaskFlags f,MultipleSequenceAlignmentObject * maobj)61     AlignGObjectTask(const QString &taskName, TaskFlags f, MultipleSequenceAlignmentObject *maobj)
62         : Task(taskName, f), obj(maobj) {
63     }
setMAObject(MultipleSequenceAlignmentObject * maobj)64     virtual void setMAObject(MultipleSequenceAlignmentObject *maobj) {
65         obj = maobj;
66     }
getMAObject()67     MultipleSequenceAlignmentObject *getMAObject() {
68         return obj;
69     }
70 
71 protected:
72     QPointer<MultipleSequenceAlignmentObject> obj;
73 };
74 
75 /**
76  Multi task converts alignment object to amino representation if possible.
77  This allows to:
78  1) speed up alignment
79  2) avoid errors of inserting gaps within codon boundaries
80 */
81 
82 class U2ALGORITHM_EXPORT AlignInAminoFormTask : public Task {
83     Q_OBJECT
84     Q_DISABLE_COPY(AlignInAminoFormTask)
85 public:
86     AlignInAminoFormTask(MultipleSequenceAlignmentObject *obj, AlignGObjectTask *alignTask, const QString &traslId);
87     ~AlignInAminoFormTask();
88 
89     virtual void prepare();
90     virtual void run();
91     virtual ReportResult report();
92 
93 protected:
94     AlignGObjectTask *alignTask;
95     MultipleSequenceAlignmentObject *maObj, *clonedObj;
96     QString traslId;
97     Document *tmpDoc;
98     QMap<qint64, QList<U2MsaGap>> rowsGapModel;
99     QMap<qint64, QList<U2MsaGap>> emptyGapModel;
100 };
101 
102 }  // namespace U2
103 
104 #endif  // _U2_MSA_UTIL_TASKS
105