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 /** Set of wrappers for typical workflow tasks */ 23 24 #ifndef _SIMPLE_WORKFLOW_TASK_H_ 25 #define _SIMPLE_WORKFLOW_TASK_H_ 26 27 #include <QTemporaryFile> 28 29 #include <U2Core/DocumentModel.h> 30 #include <U2Core/DocumentProviderTask.h> 31 #include <U2Core/MultipleSequenceAlignment.h> 32 #include <U2Core/SaveDocumentTask.h> 33 #include <U2Core/Task.h> 34 35 #include <U2Lang/Schema.h> 36 #include <U2Lang/WorkflowIOTasks.h> 37 38 namespace U2 { 39 40 using namespace Workflow; 41 42 class CmdlineTaskRunner; 43 class LoadDocumentTask; 44 class MultipleSequenceAlignmentObject; 45 46 class U2LANG_EXPORT SimpleInOutWorkflowTaskConfig { 47 public: 48 SimpleInOutWorkflowTaskConfig(); 49 QList<GObject *> objects; 50 DocumentFormatId inFormat; 51 QVariantMap inDocHints; 52 DocumentFormatId outFormat; 53 QVariantMap outDocHints; 54 QStringList extraArgs; 55 QString schemaName; 56 bool emptyResultPossible; 57 }; 58 59 /** 60 Runs workflow in a separate process and handles in-out parameters. 61 The result is output document. 62 If problems occur during the workflow execution, only the first error is detected and warnings are skipped. 63 */ 64 class U2LANG_EXPORT SimpleInOutWorkflowTask : public DocumentProviderTask { 65 Q_OBJECT 66 public: 67 SimpleInOutWorkflowTask(const SimpleInOutWorkflowTaskConfig &conf); 68 void prepare(); 69 virtual QList<Task *> onSubTaskFinished(Task *subTask); 70 71 private: 72 void prepareTmpFile(QTemporaryFile &tmpFile, const QString &tmpl); 73 74 SimpleInOutWorkflowTaskConfig conf; 75 76 Document *inDoc; 77 78 SaveDocumentTask *saveInputTask; 79 QTemporaryFile inputTmpFile; 80 81 CmdlineTaskRunner *runWorkflowTask; 82 83 QTemporaryFile resultTmpFile; 84 LoadDocumentTask *loadResultTask; 85 86 QString schemaPath; 87 }; 88 89 class SimpleMSAWorkflowTaskConfig { 90 public: 91 QString schemaName; 92 QStringList schemaArgs; 93 QVariantMap resultDocHints; 94 }; 95 96 class U2LANG_EXPORT SimpleMSAWorkflow4GObjectTask : public Task { 97 Q_OBJECT 98 99 public: 100 SimpleMSAWorkflow4GObjectTask(const QString &taskName, MultipleSequenceAlignmentObject *maObj, const SimpleMSAWorkflowTaskConfig &conf); 101 102 void prepare(); 103 ReportResult report(); 104 MultipleSequenceAlignment getResult(); 105 106 private: 107 QPointer<MultipleSequenceAlignmentObject> msaObjectPointer; 108 QString docName; 109 SimpleMSAWorkflowTaskConfig conf; 110 SimpleInOutWorkflowTask *runWorkflowTask; 111 QPointer<StateLock> msaObjectLock; 112 }; 113 114 } // namespace U2 115 116 #endif // #ifndef _RUN_SCHEMA_FOR_TASK_H_ 117