source: branches/stable/CONVERTALN/embl.h

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