source: tags/ms_r16q2/CONVERTALN/embl.h

Last change on this file was 13018, checked in by westram, 10 years ago
File size: 2.9 KB
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          title(strdup("")),
20          journal(strdup("")),
21          processing(strdup(""))
22    {}
23    Emblref(const Emblref& other)
24        : author(strdup(other.author)),
25          title(strdup(other.title)),
26          journal(strdup(other.journal)),
27          processing(strdup(other.processing))
28    {}
29    ~Emblref() {
30        free(processing);
31        free(journal);
32        free(title);
33        free(author);
34    }
35    DECLARE_ASSIGNMENT_OPERATOR(Emblref);
36};
37
38class Embl : public InputFormat, public RefContainer<Emblref> { // derived from a Noncopyable
39    char *create_id() const OVERRIDE {
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() OVERRIDE {
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() OVERRIDE { INPLACE_RECONSTRUCT(Embl, this); }
80    Format format() const OVERRIDE { 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) OVERRIDE __ATTR__USERESULT;
94    InputFormat& get_data() OVERRIDE { 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() OVERRIDE;
104
105    const Embl& get_data() const OVERRIDE { return embl; }
106};
107
108#else
109#error embl.h included twice
110#endif // EMBL_H
Note: See TracBrowser for help on using the repository browser.