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_BAM_DBI_PLUGIN_H_
23 #define _U2_BAM_DBI_PLUGIN_H_
24 
25 #include <time.h>
26 
27 #include <U2Core/DocumentImport.h>
28 #include <U2Core/DocumentProviderTask.h>
29 #include <U2Core/Log.h>
30 #include <U2Core/PluginModel.h>
31 #include <U2Core/U2Dbi.h>
32 
33 #include "PrepareToImportTask.h"
34 
35 namespace U2 {
36 
37 class CloneObjectTask;
38 class LoadDocumentTask;
39 
40 namespace BAM {
41 
42 class BAMDbiPlugin : public Plugin {
43     Q_OBJECT
44 public:
45     BAMDbiPlugin();
46 };
47 
48 class BAMImporter : public DocumentImporter {
49     Q_OBJECT
50 public:
51     BAMImporter();
52 
53     virtual FormatCheckResult checkRawData(const QByteArray &rawData, const GUrl &url);
54 
55     virtual DocumentProviderTask *createImportTask(const FormatDetectionResult &res, bool showGui, const QVariantMap &hints);
56 };
57 
58 class LoadInfoTask;
59 class ConvertToSQLiteTask;
60 
61 class BAMImporterTask : public DocumentProviderTask {
62     Q_OBJECT
63 public:
64     BAMImporterTask(const GUrl &url, bool useGui, const QVariantMap &hints);
65 
66     void prepare();
67     QList<Task *> onSubTaskFinished(Task *subTask);
68     ReportResult report();
69 
70 private:
71     void initPrepareToImportTask();
72     void initLoadBamInfoTask();
73     void initConvertToSqliteTask();
74     void initCloneObjectTasks();
75     void initLoadDocumentTask();
76 
77     LoadInfoTask *loadInfoTask;
78     LoadInfoTask *loadBamInfoTask;
79     PrepareToImportTask *prepareToImportTask;
80     ConvertToSQLiteTask *convertTask;
81     QList<Task *> cloneTasks;
82     LoadDocumentTask *loadDocTask;
83 
84     bool isSqliteDbTransit;
85     bool useGui;
86     bool sam;
87 
88     QVariantMap hints;
89     U2DbiRef hintedDbiRef;
90     U2DbiRef localDbiRef;
91     time_t startTime;
92 };
93 
94 }  // namespace BAM
95 }  // namespace U2
96 
97 #endif  // _U2_BAM_DBI_PLUGIN_H_
98