root/trunk/CONVERTALN/genbank.h

Revision 7623, 2.8 KB (checked in by westram, 12 months ago)
  • merge from dev [7450] [7452] [7456] [7457] [7458] [7459] [7460] [7461] [7464] [7465] [7466] [7467] [7468] [7469] [7482]
    • tweaked compiler options
      • activated -Weffc++
        • postfilter warnings where Scott Meyers' advices are too general.
          • base classes should not always have virtual destructors, since that renders tiny classes useless and
          • members should not always be initialized via initialization list, since that often violates the DRY principle
        • fix gcc's inability to detect that Noncopyable implements a private copy-ctor and op=
        • this slows down complete ARB recompilation by ~5%
    • added -Wold-style-cast (inactive)
    • removed -Wno-non-template-friend added in [7447]
  • postcompile.pl
    • added option --original to show unmodified compiler output
  • declared op= for classes which had a copy-ctor
  • moved op= macros to arbtools.h
  • derived classes containing pointers from Noncopyable (use Noncopyable virtually) or
  • made them copyable if needed (awt_mask_item, KnownDB, Code, AWT_registered_itemtype, GEN_gene, PosGene, PartialSequence, PlugIn, Range, Convaln_exception)
  • other related changes
    • user mask destruction working now
Line 
1#ifndef GENBANK_H
2#define GENBANK_H
3
4#ifndef REFS_H
5#include "refs.h"
6#endif
7#ifndef PARSER_H
8#include "parser.h"
9#endif
10
11
12struct GenbankRef {
13    char *ref;
14    char *author;
15    char *title;
16    char *journal;
17    char *standard;
18
19    GenbankRef() {
20        ref      = no_content();
21        author   = no_content();
22        title    = no_content();
23        journal  = no_content();
24        standard = no_content();
25    }
26    GenbankRef(const GenbankRef& other) {
27        freedup(ref, other.ref);
28        freedup(author, other.author);
29        freedup(title, other.title);
30        freedup(journal, other.journal);
31        freedup(standard, other.standard);
32    }
33    ~GenbankRef() {
34        freenull(ref);
35        freenull(author);
36        freenull(title);
37        freenull(journal);
38        freenull(standard);
39    }
40    DECLARE_ASSIGNMENT_OPERATOR(GenbankRef);
41};
42
43class GenBank : public InputFormat, public RefContainer<GenbankRef> { // derived from a Noncopyable
44    char *create_id() const {
45        char buf[TOKENSIZE];
46        genbank_key_word(locus, 0, buf);
47        return strdup(buf);
48    }
49public:
50    char *locus;
51    char *definition;
52    char *accession;
53    char *keywords;
54    char *source;
55    char *organism;
56
57    RDP_comments comments;
58
59    GenBank() {
60        locus      = no_content();
61        definition = no_content();
62        accession  = no_content();
63        keywords   = no_content();
64        source     = no_content();
65        organism   = no_content();
66    }
67    virtual ~GenBank() {
68        freenull(locus);
69        freenull(definition);
70        freenull(accession);
71        freenull(keywords);
72        freenull(source);
73        freenull(organism);
74    }
75
76    bool locus_contains_date() const { return str0len(locus) >= 60; }
77
78    char *get_date() const {
79        if (locus_contains_date()) return strndup(locus+50, 11);
80        return strdup(genbank_date(today_date()));
81    }
82
83    // InputFormat interface
84    void reinit() { INPLACE_RECONSTRUCT(GenBank, this); }
85    Format format() const { return GENBANK; }
86};
87
88class GenbankReader : public SimpleFormatReader {
89    GenBank data;
90public:
91    GenbankReader(const char *inf) : SimpleFormatReader(inf) {}
92
93    const char *get_key_word(int offset) {
94        char key[TOKENSIZE];
95        genbank_key_word(line() + offset, 0, key);
96        return shorttimecopy(key);
97    }
98    bool read_one_entry(Seq& seq) __ATTR__USERESULT;
99    InputFormat& get_data() { return data; }
100};
101
102// ----------------------
103//      GenbankParser
104
105class GenbankParser : public Parser {
106    GenBank& gbk;
107
108    void parse_keyed_section(const char *key);
109public:
110    GenbankParser(GenBank& gbk_, Seq& seq_, GenbankReader& reader_) : Parser(seq_, reader_), gbk(gbk_) {}
111    void parse_section();
112
113    const GenBank& get_data() const { return gbk; }
114};
115
116#else
117#error genbank.h included twice
118#endif // GENBANK_H
Note: See TracBrowser for help on using the browser.