ARB
DBwriter.h
Go to the documentation of this file.
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  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 
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 
void writeSequence(const SequenceBuffer &seqData)
Definition: DBwriter.cxx:198
static void deleteStaticData()
Definition: DBwriter.cxx:419
void writeFeature(const Feature &feature, long seqLength)
Definition: DBwriter.cxx:149
std::map< std::string, int > NameCounter
Definition: DBwriter.h:50
static ArbImporter * importer
void finalizeOrganism(const MetaInfo &meta, const References &refs, Importer &importer)
Definition: DBwriter.cxx:380
DBwriter(ImportSession &session_, const char *Ali_name)
Definition: DBwriter.h:69
DBerror()
Definition: DBwriter.cxx:38
void createOrganism(const string &flatfile, const char *importerTag)
Definition: DBwriter.cxx:87
void renumberDuplicateGenes()
Definition: DBwriter.cxx:207
#define NULp
Definition: cxxforward.h:97
const string & getMessage() const
Definition: DBwriter.h:47