root/trunk/CONVERTALN/embl.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 EMBL_H
2#define EMBL_H
3
4#ifndef REFS_H
5#include "refs.h"
6#endif
7#ifndef PARSER_H
8#include "parser.h"
9#endif
10
11struct Emblref {
12    char *author;
13    char *title;
14    char *journal;
15    char *processing;
16
17    Emblref() {
18        author     = strdup("");
19        journal    = strdup("");
20        title      = strdup("");
21        processing = strdup("");
22    }
23    ~Emblref() {
24        freenull(author);
25        freenull(journal);
26        freenull(title);
27        freenull(processing);
28    }
29    Emblref(const Emblref& other) {
30        freedup(author, other.author);
31        freedup(journal, other.journal);
32        freedup(title, other.title);
33        freedup(processing, other.processing);
34    }
35    DECLARE_ASSIGNMENT_OPERATOR(Emblref);
36};
37
38class Embl : public InputFormat, public RefContainer<Emblref> { // derived from a Noncopyable
39    char *create_id() const {
40        char buf[TOKENSIZE];
41        embl_key_word(ID, 0, buf);
42        return strdup(buf);
43    }
44
45public:
46    char *ID;                    // entry name
47    char *dateu;                 // date of last updated
48    char *datec;                 // date of created
49    char *description;           // description line (DE)
50    char *os;                    // Organism species
51    char *accession;             // accession number(s)
52    char *keywords;              // keyword
53    char *dr;                    // database cross-reference
54
55    RDP_comments  comments;          // comments
56
57    Embl() {
58        ID          = no_content();
59        dateu       = no_content();
60        datec       = no_content();
61        description = no_content();
62        os          = no_content();
63        accession   = no_content();
64        keywords    = no_content();
65        dr          = no_content();
66    }
67    virtual ~Embl() {
68        freenull(ID);
69        freenull(dateu);
70        freenull(datec);
71        freenull(description);
72        freenull(os);
73        freenull(accession);
74        freenull(keywords);
75        freenull(dr);
76    }
77
78    // InputFormat interface
79    void reinit() { INPLACE_RECONSTRUCT(Embl, this); }
80    Format format() const { return EMBL; }
81};
82
83class EmblSwissprotReader : public SimpleFormatReader {
84    Embl data;
85public:
86    EmblSwissprotReader(const char *inf) : SimpleFormatReader(inf) {}
87
88    const char *get_key_word(int offset) {
89        char key[TOKENSIZE];
90        embl_key_word(line() + offset, 0, key);
91        return shorttimecopy(key);
92    }
93    bool read_one_entry(Seq& seq) __ATTR__USERESULT;
94    InputFormat& get_data() { return data; }
95};
96
97class EmblParser: public Parser {
98    Embl& embl;
99
100    void parse_keyed_section(const char *key);
101public:
102    EmblParser(Embl& embl_, Seq& seq_, Reader& reader_) : Parser(seq_, reader_), embl(embl_) {}
103    void parse_section();
104
105    const Embl& get_data() const { return embl; }
106};
107
108#else
109#error embl.h included twice
110#endif // EMBL_H
Note: See TracBrowser for help on using the browser.