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 #include "AbstractAlignmentTask.h"
23
24 namespace U2 {
25
26 const QString AbstractAlignmentTaskSettings::RESULT_FILE_NAME("resultFileName");
27 const QString AbstractAlignmentTaskSettings::ALGORITHM_NAME("algorithmName");
28 const QString AbstractAlignmentTaskSettings::REALIZATION_NAME("realizationName");
29 const QString AbstractAlignmentTaskSettings::IN_NEW_WINDOW("inNewWindow");
30 const QString AbstractAlignmentTaskSettings::ALPHABET("alphabet");
31
AbstractAlignmentTaskSettings()32 AbstractAlignmentTaskSettings::AbstractAlignmentTaskSettings()
33 : inNewWindow(true) {
34 }
35
AbstractAlignmentTaskSettings(const QVariantMap & someSettings)36 AbstractAlignmentTaskSettings::AbstractAlignmentTaskSettings(const QVariantMap &someSettings)
37 : inNewWindow(true), customSettings(someSettings) {
38 }
39
AbstractAlignmentTaskSettings(const AbstractAlignmentTaskSettings & s)40 AbstractAlignmentTaskSettings::AbstractAlignmentTaskSettings(const AbstractAlignmentTaskSettings &s)
41 : algorithmId(s.algorithmId),
42 realizationName(s.realizationName),
43 inNewWindow(s.inNewWindow),
44 msaRef(s.msaRef),
45 alphabet(s.alphabet),
46 resultFileName(s.resultFileName),
47 customSettings(s.customSettings) {
48 }
49
~AbstractAlignmentTaskSettings()50 AbstractAlignmentTaskSettings::~AbstractAlignmentTaskSettings() {
51 }
52
getCustomValue(const QString & optionName,const QVariant & defaultVal) const53 QVariant AbstractAlignmentTaskSettings::getCustomValue(const QString &optionName, const QVariant &defaultVal) const {
54 return customSettings.value(optionName, defaultVal);
55 }
56
setCustomValue(const QString & optionName,const QVariant & val)57 void AbstractAlignmentTaskSettings::setCustomValue(const QString &optionName, const QVariant &val) {
58 customSettings.insert(optionName, val);
59 }
60
convertCustomSettings()61 bool AbstractAlignmentTaskSettings::convertCustomSettings() {
62 if (customSettings.contains(ALGORITHM_NAME)) {
63 algorithmId = customSettings.value(ALGORITHM_NAME).toString();
64 customSettings.remove(ALGORITHM_NAME);
65 }
66 if (customSettings.contains(REALIZATION_NAME)) {
67 realizationName = customSettings.value(REALIZATION_NAME).toString();
68 customSettings.remove(REALIZATION_NAME);
69 }
70 if (customSettings.contains(RESULT_FILE_NAME) && customSettings.value(RESULT_FILE_NAME).type() == QVariant::String) {
71 resultFileName = GUrl(customSettings.value(RESULT_FILE_NAME).toString());
72 customSettings.remove(RESULT_FILE_NAME);
73 }
74 if (customSettings.contains(IN_NEW_WINDOW)) {
75 inNewWindow = customSettings.value(IN_NEW_WINDOW).toBool();
76 customSettings.remove(IN_NEW_WINDOW);
77 }
78 return true;
79 }
80
appendCustomSettings(const QVariantMap & settings)81 void AbstractAlignmentTaskSettings::appendCustomSettings(const QVariantMap &settings) {
82 foreach (const QString &key, settings.keys()) {
83 customSettings.insert(key, settings.value(key));
84 }
85 }
86
isValid() const87 bool AbstractAlignmentTaskSettings::isValid() const {
88 return msaRef.isValid() && alphabet.isValid() && (!resultFileName.isEmpty() || !inNewWindow);
89 }
90
AbstractAlignmentTask(const QString & taskName,TaskFlags flags)91 AbstractAlignmentTask::AbstractAlignmentTask(const QString &taskName, TaskFlags flags)
92 : Task(taskName, flags) {
93 }
94
~AbstractAlignmentTaskFactory()95 AbstractAlignmentTaskFactory::~AbstractAlignmentTaskFactory() {
96 }
97
98 } // namespace U2
99