| 1 | #ifndef GDE_DEF_H |
|---|
| 2 | #define GDE_DEF_H |
|---|
| 3 | |
|---|
| 4 | #ifndef ARBDBT_H |
|---|
| 5 | #include <arbdbt.h> |
|---|
| 6 | #endif |
|---|
| 7 | |
|---|
| 8 | /* Copyright (c) 1990,1991,1992 Steven Smith at the Harvard Genome Laboratory. |
|---|
| 9 | * All rights reserved. |
|---|
| 10 | */ |
|---|
| 11 | |
|---|
| 12 | #define gde_assert(bed) arb_assert(bed) |
|---|
| 13 | |
|---|
| 14 | #define TRUTH 1 |
|---|
| 15 | #define JUSTICE 2 |
|---|
| 16 | #define BEAUTY 3 |
|---|
| 17 | |
|---|
| 18 | // Cursor directions |
|---|
| 19 | #define RIGHT 1 |
|---|
| 20 | #define LEFT 0 |
|---|
| 21 | #define UP 0 |
|---|
| 22 | #define DOWN 1 |
|---|
| 23 | |
|---|
| 24 | #ifndef TRUE |
|---|
| 25 | #define TRUE 1 |
|---|
| 26 | #define FALSE 0 |
|---|
| 27 | #endif |
|---|
| 28 | |
|---|
| 29 | #define GBUFSIZ 4096 |
|---|
| 30 | #define MAX_NA_DISPLAY_WIDTH 1024 |
|---|
| 31 | #define MAX_NA_DISPLAY_HEIGHT 1024 |
|---|
| 32 | #define MAX_STARTUP_CANVAS_HEIGHT 512 |
|---|
| 33 | #define grey_height 8 |
|---|
| 34 | #define grey_width 8 |
|---|
| 35 | |
|---|
| 36 | #define TEXTFIELDWIDTH 15 |
|---|
| 37 | |
|---|
| 38 | // Definable dialog types |
|---|
| 39 | #define TEXTFIELD 0x1 |
|---|
| 40 | #define SLIDER 0x2 |
|---|
| 41 | #define CHOOSER 0x3 |
|---|
| 42 | #define CHOICE_MENU 0x4 |
|---|
| 43 | #define CHOICE_LIST 0x5 |
|---|
| 44 | #define CHOICE_TREE 0x6 |
|---|
| 45 | #define CHOICE_SAI 0x7 |
|---|
| 46 | #define CHOICE_WEIGHTS 0x8 |
|---|
| 47 | #define FILE_SELECTOR 0x9 |
|---|
| 48 | |
|---|
| 49 | // File Formats |
|---|
| 50 | #define GDE 0x100 |
|---|
| 51 | #define GENBANK 0x101 |
|---|
| 52 | #define NA_FLAT 0x102 |
|---|
| 53 | #define COLORMASK 0x103 |
|---|
| 54 | #define STATUS_FILE 0x104 |
|---|
| 55 | #define ARBDB 0x105 |
|---|
| 56 | |
|---|
| 57 | // Protection bits |
|---|
| 58 | #define PROT_BASE_CHANGES 0x1 // Allow base changes |
|---|
| 59 | #define PROT_GREY_SPACE 0x2 // Allow greyspace modification |
|---|
| 60 | #define PROT_WHITE_SPACE 0x4 // Allow whitespace modification |
|---|
| 61 | #define PROT_TRANSLATION 0x8 // Allow translation |
|---|
| 62 | #define PROT_REORIENTATION 0x10 // Allow reorientation |
|---|
| 63 | |
|---|
| 64 | |
|---|
| 65 | // File loading methods (must be 'OR/AND' able) |
|---|
| 66 | #define NONE 0x0 |
|---|
| 67 | #define DESTROY 0x1 |
|---|
| 68 | #define LOAD 0x2 |
|---|
| 69 | #define SAVE 0x4 |
|---|
| 70 | #define SELECTED 0x8 |
|---|
| 71 | #define ALL 0x10 |
|---|
| 72 | #define SELECT_REGION 0x20 |
|---|
| 73 | #define SELECT_ONE 0x30 |
|---|
| 74 | |
|---|
| 75 | // Sequence DISPLAY Types |
|---|
| 76 | #define NASEQ_ALIGN 0x201 |
|---|
| 77 | #define NASEQ 0x202 |
|---|
| 78 | |
|---|
| 79 | // Sequence Data Types |
|---|
| 80 | #define DNA 0x300 |
|---|
| 81 | #define RNA 0x301 |
|---|
| 82 | #define TEXT 0x302 |
|---|
| 83 | #define MASK 0x303 |
|---|
| 84 | #define PROTEIN 0x304 |
|---|
| 85 | |
|---|
| 86 | // extended sequence attributes (true/false) |
|---|
| 87 | #define IS_5_TO_3 0x01 // 5prime to 3 prime |
|---|
| 88 | #define IS_3_TO_5 0x02 // 3 prime to 5 prime |
|---|
| 89 | #define IS_CIRCULAR 0x04 // circular dna |
|---|
| 90 | #define IS_PRIMARY 0x10 // on the primary strand |
|---|
| 91 | #define IS_SECONDARY 0x20 // on the secondary strand |
|---|
| 92 | #define IS_MODIFIED 0x40 // modification flag |
|---|
| 93 | #define IS_ORIG_PRIMARY 0x80 // Original sequence was primary |
|---|
| 94 | #define IS_ORIG_SECONDARY 0x100 // Original sequence was secondary |
|---|
| 95 | #define IS_ORIG_5_TO_3 0x200 // Original sequence was 5_to_3 |
|---|
| 96 | #define IS_ORIG_3_TO_5 0x400 // Original sequence was 3_to_5 |
|---|
| 97 | |
|---|
| 98 | #ifdef HGL |
|---|
| 99 | #define DEFAULT_X_ATTR 0 |
|---|
| 100 | #else |
|---|
| 101 | #define DEFAULT_X_ATTR IS_5_TO_3+IS_PRIMARY; |
|---|
| 102 | #endif |
|---|
| 103 | |
|---|
| 104 | // Other display attributed |
|---|
| 105 | #define INVERTED 1 |
|---|
| 106 | #define VSCROLL_LOCK 2 |
|---|
| 107 | #define KEYCLICKS 4 |
|---|
| 108 | #define GDE_MESSAGE_PANEL 8 |
|---|
| 109 | |
|---|
| 110 | // Coloring Methods |
|---|
| 111 | #define COLOR_MONO 0x40 // no color, simple black and white |
|---|
| 112 | #define COLOR_LOOKUP 0x41 // Use a simple value->color lookup |
|---|
| 113 | #define COLOR_ALN_MASK 0x42 /* The alignment has a column by column color |
|---|
| 114 | mask associated with it */ |
|---|
| 115 | #define COLOR_SEQ_MASK 0x43 // Each sequence has a color mask |
|---|
| 116 | #define COLOR_STRAND 0x44 // Color based on original strandedness |
|---|
| 117 | |
|---|
| 118 | |
|---|
| 119 | |
|---|
| 120 | // Data types |
|---|
| 121 | |
|---|
| 122 | struct NumList { |
|---|
| 123 | int *valu; |
|---|
| 124 | }; |
|---|
| 125 | |
|---|
| 126 | |
|---|
| 127 | struct TimeStamp { |
|---|
| 128 | struct { |
|---|
| 129 | int yy; |
|---|
| 130 | int mm; |
|---|
| 131 | int dd; |
|---|
| 132 | int hr; |
|---|
| 133 | int mn; |
|---|
| 134 | int sc; |
|---|
| 135 | } origin, modify; |
|---|
| 136 | }; |
|---|
| 137 | |
|---|
| 138 | typedef unsigned char NA_Base; |
|---|
| 139 | |
|---|
| 140 | struct GMask { |
|---|
| 141 | char *name; |
|---|
| 142 | int type; |
|---|
| 143 | NumList *list; |
|---|
| 144 | int listlen; |
|---|
| 145 | int maxlen; |
|---|
| 146 | }; |
|---|
| 147 | |
|---|
| 148 | |
|---|
| 149 | // sizes for fields (including terminating zero byte) |
|---|
| 150 | #define SIZE_FIELD_GENBANK 80 |
|---|
| 151 | #define SIZE_ID SIZE_FIELD_GENBANK |
|---|
| 152 | #define SIZE_SEQ_NAME SIZE_FIELD_GENBANK |
|---|
| 153 | #define SIZE_SHORT_NAME 32 |
|---|
| 154 | #define SIZE_DESCRIPTION SIZE_FIELD_GENBANK |
|---|
| 155 | #define SIZE_AUTHORITY SIZE_FIELD_GENBANK |
|---|
| 156 | |
|---|
| 157 | struct NA_Sequence { |
|---|
| 158 | char id[SIZE_ID]; // sequence id (ACCESSION) |
|---|
| 159 | char seq_name[SIZE_SEQ_NAME]; // Sequence name (ORGANISM) |
|---|
| 160 | char short_name[SIZE_SHORT_NAME]; // Name (LOCUS) |
|---|
| 161 | char barcode[80]; |
|---|
| 162 | char contig[80]; |
|---|
| 163 | char membrane[80]; |
|---|
| 164 | char description[SIZE_DESCRIPTION];// Description (DEFINITION) |
|---|
| 165 | char authority[SIZE_AUTHORITY]; // Author (or creator) |
|---|
| 166 | char *comments; // Stuff we can't parse |
|---|
| 167 | int comments_len, comments_maxlen; |
|---|
| 168 | |
|---|
| 169 | NA_Base *sequence; // List of bases |
|---|
| 170 | TimeStamp t_stamp; // Time stamp of origin/modification |
|---|
| 171 | GMask *mask; // List of masks(analysis/display) |
|---|
| 172 | int offset; // offset into alignment (left white) space |
|---|
| 173 | int seqlen; // Number of elements in sequence[] |
|---|
| 174 | int seqmaxlen; // Size sequence[] (for mem alloc) |
|---|
| 175 | unsigned int protect; // Protection mask |
|---|
| 176 | int attr; // Extended attributes |
|---|
| 177 | size_t groupid; // group id |
|---|
| 178 | int *col_lut; // character to color LUT |
|---|
| 179 | |
|---|
| 180 | NA_Sequence *groupb; // Group link backward |
|---|
| 181 | NA_Sequence *groupf; // Group link forward |
|---|
| 182 | |
|---|
| 183 | int *cmask; // color mask |
|---|
| 184 | int selected; // Selection flag |
|---|
| 185 | int subselected; // Sub selection flag |
|---|
| 186 | int format; // default file format |
|---|
| 187 | int elementtype; // what type of data are being aligned |
|---|
| 188 | char *baggage; // unformatted comments |
|---|
| 189 | int baggage_len, baggage_maxlen; |
|---|
| 190 | int *tmatrix; // translation matrix (code->char) |
|---|
| 191 | int *rmatrix; // reverse translation matrix (char->code) |
|---|
| 192 | |
|---|
| 193 | GBDATA *gb_species; |
|---|
| 194 | }; |
|---|
| 195 | |
|---|
| 196 | struct NA_Alignment { |
|---|
| 197 | char *id; // Alignment ID |
|---|
| 198 | char *description; // Description of the alignment |
|---|
| 199 | char *authority; // Who generated the alignment |
|---|
| 200 | int *cmask; // color mask |
|---|
| 201 | int cmask_offset; // color mask offset |
|---|
| 202 | int cmask_len; // color mask length |
|---|
| 203 | int ref; // reference sequence |
|---|
| 204 | size_t numelements; // number of data elements |
|---|
| 205 | int maxnumelements; // maximum number of data elements |
|---|
| 206 | int nummasks; // number of masks |
|---|
| 207 | int maxlen; // Maximum length of alignment |
|---|
| 208 | int rel_offset; // add this to every sequence offset |
|---|
| 209 | // to orient it back to 0 |
|---|
| 210 | GMask *mask; // masks |
|---|
| 211 | NA_Sequence *element; // alignment elements |
|---|
| 212 | size_t numgroups; // number of groups |
|---|
| 213 | NA_Sequence **group; /* link to array of pointers into |
|---|
| 214 | each group */ |
|---|
| 215 | char *na_ddata; // display data |
|---|
| 216 | int format; // default file format |
|---|
| 217 | char *selection_mask; // Sub sequence selection mask |
|---|
| 218 | int selection_mask_len; // Sub selection mask length |
|---|
| 219 | int min_subselect; // Leftmost coord of selection mask |
|---|
| 220 | |
|---|
| 221 | GBDATA *gb_main; |
|---|
| 222 | char *alignment_name; |
|---|
| 223 | |
|---|
| 224 | }; |
|---|
| 225 | |
|---|
| 226 | extern NA_Alignment *DataSet; |
|---|
| 227 | |
|---|
| 228 | #define getcmask(a, b) (b < ((a)->offset)) ? 0 : ((a)->cmask[(b-(a)->offset)]) |
|---|
| 229 | |
|---|
| 230 | inline void strncpy_terminate(char *dest, const char *source, size_t dest_size) { |
|---|
| 231 | // like strncpy, but also writes terminating zero byte |
|---|
| 232 | // 'dest_size' is overall 'dest'-buffersize (incl. zero terminator) |
|---|
| 233 | strncpy(dest, source, dest_size-1); |
|---|
| 234 | dest[dest_size-1] = 0; |
|---|
| 235 | } |
|---|
| 236 | |
|---|
| 237 | #else |
|---|
| 238 | #error GDE_def.h included twice |
|---|
| 239 | #endif // GDE_DEF_H |
|---|