1 | // =============================================================== // |
---|
2 | // // |
---|
3 | // File : GEN_gene.hxx // |
---|
4 | // Purpose : // |
---|
5 | // // |
---|
6 | // Coded by Ralf Westram (coder@reallysoft.de) in 2001 // |
---|
7 | // Institute of Microbiology (Technical University Munich) // |
---|
8 | // http://www.arb-home.de/ // |
---|
9 | // // |
---|
10 | // =============================================================== // |
---|
11 | |
---|
12 | #ifndef GEN_GENE_HXX |
---|
13 | #define GEN_GENE_HXX |
---|
14 | |
---|
15 | #ifndef ARBDB_BASE_H |
---|
16 | #include <arbdb_base.h> |
---|
17 | #endif |
---|
18 | #ifndef AW_BASE_HXX |
---|
19 | #include <aw_base.hxx> |
---|
20 | #endif |
---|
21 | #ifndef ARBTOOLS_H |
---|
22 | #include <arbtools.h> |
---|
23 | #endif |
---|
24 | #ifndef AW_POSITION_HXX |
---|
25 | #include <aw_position.hxx> |
---|
26 | #endif |
---|
27 | |
---|
28 | #ifndef _GLIBCXX_SET |
---|
29 | #include <set> |
---|
30 | #endif |
---|
31 | #ifndef _GLIBCXX_STRING |
---|
32 | #include <string> |
---|
33 | #endif |
---|
34 | |
---|
35 | |
---|
36 | // ------------------------------------------ |
---|
37 | // display classes for ARB_GENE_MAP: |
---|
38 | |
---|
39 | class GEN_root; |
---|
40 | class GEN_graphic; |
---|
41 | struct GEN_position; |
---|
42 | |
---|
43 | class GEN_gene { |
---|
44 | RefPtr<GBDATA> gb_gene; |
---|
45 | RefPtr<GEN_root> root; |
---|
46 | std::string name; |
---|
47 | mutable std::string nodeInfo; |
---|
48 | long pos1; |
---|
49 | long pos2; |
---|
50 | bool complement; |
---|
51 | |
---|
52 | // Note: if a gene is joined from several parts it is represented in several GEN_gene's! |
---|
53 | |
---|
54 | void init(); |
---|
55 | void load_location(int part, const GEN_position *location); |
---|
56 | |
---|
57 | public: |
---|
58 | GEN_gene(GBDATA *gb_gene_, GEN_root *root_, const GEN_position *location); |
---|
59 | GEN_gene(GBDATA *gb_gene_, GEN_root *root_, const GEN_position *location, int partNumber); |
---|
60 | |
---|
61 | inline bool operator<(const GEN_gene& other) const { |
---|
62 | long cmp = pos1-other.pos1; |
---|
63 | if (cmp) cmp = pos2-other.pos2; |
---|
64 | return cmp<0; |
---|
65 | } |
---|
66 | |
---|
67 | long StartPos() const { return pos1; } // first position of gene (1..n) |
---|
68 | long EndPos() const { return pos2; } // last position of gene (1..n) |
---|
69 | long Length() const { return pos2-pos1+1; } |
---|
70 | bool Complement() const { return complement; } |
---|
71 | const std::string& NodeInfo() const { return nodeInfo; } |
---|
72 | const std::string& Name() const { return name; } // returns the short name of the gene |
---|
73 | const GBDATA *GbGene() const { return gb_gene; } |
---|
74 | GEN_root *Root() { return root; } |
---|
75 | |
---|
76 | void reinit_NDS() const; |
---|
77 | }; |
---|
78 | |
---|
79 | typedef std::multiset<GEN_gene> GEN_gene_set; |
---|
80 | typedef GEN_gene_set::iterator GEN_iterator; |
---|
81 | |
---|
82 | class AW_device; |
---|
83 | |
---|
84 | class GEN_root : virtual Noncopyable { |
---|
85 | GBDATA *gb_main; |
---|
86 | GEN_graphic *gen_graphic; |
---|
87 | std::string organism_name; // name1 of current species |
---|
88 | // (in case of a pseudo gene-species this is the name of the species it originated from) |
---|
89 | |
---|
90 | std::string gene_name; // name of current gene |
---|
91 | GEN_gene_set gene_set; |
---|
92 | std::string error_reason; // reason why we can't display gene_map |
---|
93 | long length; // length of organism sequence |
---|
94 | |
---|
95 | GBDATA *gb_gene_data; // i am build upon this |
---|
96 | |
---|
97 | AW::Rectangle gene_range; |
---|
98 | |
---|
99 | |
---|
100 | void clear_selected_range() { gene_range = AW::Rectangle(); } |
---|
101 | void increase_selected_range(AW::Position pos) { |
---|
102 | gene_range = gene_range.valid() ? bounding_box(gene_range, pos) : AW::Rectangle(pos, pos); |
---|
103 | } |
---|
104 | void increase_selected_range(AW::Rectangle rect) { |
---|
105 | gene_range = gene_range.valid() ? bounding_box(gene_range, rect) : rect; |
---|
106 | } |
---|
107 | |
---|
108 | int smart_text(AW_device *device, int gc, const char *str, AW_pos x, AW_pos y); |
---|
109 | int smart_line(AW_device *device, int gc, AW_pos x0, AW_pos y0, AW_pos x1, AW_pos y1); |
---|
110 | |
---|
111 | public: |
---|
112 | GEN_root(const char *organism_name_, const char *gene_name_, GBDATA *gb_main_, AW_root *aw_root, GEN_graphic *gen_graphic_); |
---|
113 | ~GEN_root() {} |
---|
114 | |
---|
115 | const std::string& GeneName() const { return gene_name; } |
---|
116 | const std::string& OrganismName() const { return organism_name; } |
---|
117 | |
---|
118 | GBDATA *GbMain() const { return gb_main; } |
---|
119 | |
---|
120 | void set_GeneName(const std::string& gene_name_) { gene_name = gene_name_; } |
---|
121 | |
---|
122 | void paint(AW_device *device); |
---|
123 | |
---|
124 | void reinit_NDS() const; |
---|
125 | |
---|
126 | const AW::Rectangle& get_selected_range() const { return gene_range; } |
---|
127 | }; |
---|
128 | |
---|
129 | #else |
---|
130 | #error GEN_gene.hxx included twice |
---|
131 | #endif // GEN_GENE_HXX |
---|