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 | |
---|
11 | struct 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 | |
---|
38 | class 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 | |
---|
45 | public: |
---|
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 | |
---|
83 | class EmblSwissprotReader : public SimpleFormatReader { |
---|
84 | Embl data; |
---|
85 | public: |
---|
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 | |
---|
97 | class EmblParser: public Parser { |
---|
98 | Embl& embl; |
---|
99 | |
---|
100 | void parse_keyed_section(const char *key); |
---|
101 | public: |
---|
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 |
---|