1 | // ================================================================ // |
---|
2 | // // |
---|
3 | // File : DBwriter.h // |
---|
4 | // Purpose : // |
---|
5 | // // |
---|
6 | // Coded by Ralf Westram (coder@reallysoft.de) in November 2006 // |
---|
7 | // Institute of Microbiology (Technical University Munich) // |
---|
8 | // http://www.arb-home.de/ // |
---|
9 | // // |
---|
10 | // ================================================================ // |
---|
11 | |
---|
12 | #ifndef DBWRITER_H |
---|
13 | #define DBWRITER_H |
---|
14 | |
---|
15 | #ifndef METAINFO_H |
---|
16 | #include "MetaInfo.h" |
---|
17 | #endif |
---|
18 | #ifndef FEATURE_H |
---|
19 | #include "Feature.h" |
---|
20 | #endif |
---|
21 | #ifndef SEQUENCEBUFFER_H |
---|
22 | #include "SequenceBuffer.h" |
---|
23 | #endif |
---|
24 | #ifndef IMPORTER_H |
---|
25 | #include "Importer.h" |
---|
26 | #endif |
---|
27 | #ifndef GENOMEIMPORT_H |
---|
28 | #include "GenomeImport.h" |
---|
29 | #endif |
---|
30 | |
---|
31 | class UniqueNameDetector; |
---|
32 | |
---|
33 | class DBerror { |
---|
34 | // error class used for DB errors |
---|
35 | |
---|
36 | string err; // error message |
---|
37 | |
---|
38 | void init(const string& msg, GB_ERROR gberror); |
---|
39 | |
---|
40 | public: |
---|
41 | DBerror(); |
---|
42 | DBerror(const char *msg); |
---|
43 | DBerror(const string& msg); |
---|
44 | DBerror(const char *msg, GB_ERROR gberror); |
---|
45 | DBerror(const string& msg, GB_ERROR gberror); |
---|
46 | |
---|
47 | const string& getMessage() const { return err; } |
---|
48 | }; |
---|
49 | |
---|
50 | typedef std::map<std::string, int> NameCounter; |
---|
51 | struct Translator; |
---|
52 | |
---|
53 | class DBwriter : virtual Noncopyable { |
---|
54 | const char *ali_name; |
---|
55 | ImportSession& session; |
---|
56 | |
---|
57 | // following data is valid for one organism write : |
---|
58 | GBDATA *gb_organism; // current organism |
---|
59 | GBDATA *gb_gene_data; // current gene data |
---|
60 | NameCounter generatedGenes; // helper to create unique gene names (key = name, value = count occurrences) |
---|
61 | |
---|
62 | void testAndRemoveTranslations(Importer& importer); // test and delete translations (if test was ok). warns via Importer |
---|
63 | void hideUnwantedGenes(); |
---|
64 | |
---|
65 | static Translator *unreserve; |
---|
66 | static const string& getUnreservedQualifier(const string& qualifier); |
---|
67 | |
---|
68 | public: |
---|
69 | DBwriter(ImportSession& session_, const char *Ali_name) |
---|
70 | // : gb_species_data(Gb_species_data) |
---|
71 | : ali_name(Ali_name) |
---|
72 | // , UND_species(Und_species) |
---|
73 | , session(session_) |
---|
74 | , gb_organism(0) |
---|
75 | , gb_gene_data(0) |
---|
76 | {} |
---|
77 | |
---|
78 | void createOrganism(const string& flatfile, const char *importerTag); |
---|
79 | |
---|
80 | void writeFeature(const Feature& feature, long seqLength); |
---|
81 | void writeSequence(const SequenceBuffer& seqData); |
---|
82 | |
---|
83 | void renumberDuplicateGenes(); |
---|
84 | void finalizeOrganism(const MetaInfo& meta, const References& refs, Importer& importer); |
---|
85 | |
---|
86 | static void deleteStaticData(); |
---|
87 | }; |
---|
88 | |
---|
89 | |
---|
90 | #else |
---|
91 | #error DBwriter.h included twice |
---|
92 | #endif // DBWRITER_H |
---|
93 | |
---|
94 | |
---|
95 | |
---|