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_SW_WORKER_H_
23 #define _U2_SW_WORKER_H_
24 
25 #include <U2Algorithm/SmithWatermanReportCallback.h>
26 #include <U2Algorithm/SmithWatermanSettings.h>
27 #include <U2Algorithm/SmithWatermanTaskFactory.h>
28 
29 #include <U2Designer/DelegateEditors.h>
30 
31 #include <U2Lang/LocalDomain.h>
32 #include <U2Lang/WorkflowUtils.h>
33 
34 namespace U2 {
35 namespace LocalWorkflow {
36 
37 class SWPrompter : public PrompterBase<SWPrompter> {
38     Q_OBJECT
39 public:
40     SWPrompter(Actor *p = 0)
41         : PrompterBase<SWPrompter>(p) {
42     }
43 
44 protected:
45     QString composeRichDoc();
46 };
47 
48 class SWAlgoEditor : public ComboBoxDelegate {
49     Q_OBJECT
50 public:
SWAlgoEditor(ActorPrototype * proto)51     SWAlgoEditor(ActorPrototype *proto)
52         : ComboBoxDelegate(QVariantMap()), proto(proto) {
53     }
54 public slots:
55     void populate();
56 
57 private:
58     ActorPrototype *proto;
59 };
60 
61 class SWWorker : public BaseWorker {
62     Q_OBJECT
63 public:
64     SWWorker(Actor *a);
65 
66     virtual void init();
67     virtual bool isReady() const;
68     virtual Task *tick();
69     virtual void cleanup();
70 
71 private slots:
72     void sl_taskFinished(Task *);
73 
74 private:
75     IntegralBus *input, *patternPort, *output;
76     QMap<Task *, SmithWatermanReportCallbackAnnotImpl *> callbacks;
77     QList<QByteArray> patternList;
78     QMap<Task *, QByteArray> patterns;
79     QMap<QString, QString> patternNames;
80 };
81 
82 class SWWorkerFactory : public DomainFactory {
83 public:
84     static const QString ACTOR_ID;
85     static void init();
SWWorkerFactory()86     SWWorkerFactory()
87         : DomainFactory(ACTOR_ID) {
88     }
createWorker(Actor * a)89     virtual Worker *createWorker(Actor *a) {
90         return new SWWorker(a);
91     }
92 };
93 
94 }  // namespace LocalWorkflow
95 }  // namespace U2
96 
97 #endif
98