source: branches/stable/GENOM_IMPORT/DBwriter.h

Last change on this file was 16763, checked in by westram, 6 years ago
File size: 2.7 KB
Line 
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
31class UniqueNameDetector;
32
33class 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
40public:
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
50typedef std::map<std::string, int> NameCounter;
51struct Translator;
52
53class 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
68public:
69    DBwriter(ImportSession& session_, const char *Ali_name) :
70        ali_name(Ali_name),
71        session(session_),
72        gb_organism(NULp),
73        gb_gene_data(NULp)
74    {}
75
76    void createOrganism(const string& flatfile, const char *importerTag);
77
78    void writeFeature(const Feature& feature, long seqLength);
79    void writeSequence(const SequenceBuffer& seqData);
80
81    void renumberDuplicateGenes();
82    void finalizeOrganism(const MetaInfo& meta, const References& refs, Importer& importer);
83
84    static void deleteStaticData();
85};
86
87
88#else
89#error DBwriter.h included twice
90#endif // DBWRITER_H
91
92
93
Note: See TracBrowser for help on using the repository browser.