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_CONVERT_SNPEFF_VARIATIONS_TO_ANNOTATIONS_TASK_H_
23 #define _U2_CONVERT_SNPEFF_VARIATIONS_TO_ANNOTATIONS_TASK_H_
24 
25 #include <QMap>
26 
27 #include <U2Core/AnnotationData.h>
28 #include <U2Core/Task.h>
29 
30 namespace U2 {
31 
32 class AnnotationTableObject;
33 class CreateAnnotationsTask;
34 class Document;
35 class LoadDocumentTask;
36 class SaveDocumentTask;
37 class VariantTrackObject;
38 
39 class ConvertSnpeffVariationsToAnnotationsTask : public Task {
40     Q_OBJECT
41 public:
42     ConvertSnpeffVariationsToAnnotationsTask(const QList<VariantTrackObject *> &variantTrackObjects);
43 
44     const QMap<QString, QList<SharedAnnotationData>> &getAnnotationsData() const;
45 
46 private:
47     void run();
48 
49     const QList<VariantTrackObject *> variantTrackObjects;
50     QMap<QString, QList<SharedAnnotationData>> annotationTablesData;
51 
52     static const QString CHROM_QUALIFIER_NAME;
53     static const QString LOCATION_QUALIFIER_NAME;
54     static const QString REFERENCE_QUALIFIER_NAME;
55     static const QString ALTERNATE_QUALIFIER_NAME;
56     static const QString ALLELE_QUALIFIER_NAME;
57     static const QString ID_QUALIFIER_NAME;
58 };
59 
60 class U2FORMATS_EXPORT LoadConvertAndSaveSnpeffVariationsToAnnotationsTask : public Task {
61     Q_OBJECT
62 public:
63     LoadConvertAndSaveSnpeffVariationsToAnnotationsTask(const QString &variationsUrl, const U2DbiRef &dstDbiRef, const QString &dstUrl, const QString &formatId);
64     ~LoadConvertAndSaveSnpeffVariationsToAnnotationsTask();
65 
66     const QString &getResultUrl() const;
67 
68 private:
69     void prepare();
70     QList<Task *> onSubTaskFinished(Task *subTask);
71 
72     Document *prepareDocument();
73     void prepareSaveTask();
74 
75     const QString variationsUrl;
76     const U2DbiRef dstDbiRef;
77     const QString dstUrl;
78     const QString formatId;
79 
80     LoadDocumentTask *loadTask;
81     ConvertSnpeffVariationsToAnnotationsTask *convertTask;
82     QList<Task *> createAnnotationsTasks;
83     SaveDocumentTask *saveTask;
84 
85     Document *loadedVariationsDocument;
86     Document *annotationsDocument;
87     QList<AnnotationTableObject *> annotationTableObjects;
88 };
89 
90 }  // namespace U2
91 
92 #endif  // _U2_CONVERT_SNPEFF_VARIATIONS_TO_ANNOTATIONS_TASK_H_
93