| 1 | #include "RNA3D_GlobalHeader.hxx" |
|---|
| 2 | #include "RNA3D_Global.hxx" |
|---|
| 3 | #include "RNA3D_OpenGLGraphics.hxx" |
|---|
| 4 | #include "RNA3D_Graphics.hxx" |
|---|
| 5 | #include "RNA3D_StructureData.hxx" |
|---|
| 6 | |
|---|
| 7 | #include <cerrno> |
|---|
| 8 | #include <string> |
|---|
| 9 | #include <iostream> |
|---|
| 10 | #include <fstream> |
|---|
| 11 | |
|---|
| 12 | #include <arbdbt.h> |
|---|
| 13 | #include <aw_msg.hxx> |
|---|
| 14 | #include <aw_awars.hxx> |
|---|
| 15 | #include <aw_root.hxx> |
|---|
| 16 | #include <ed4_extern.hxx> |
|---|
| 17 | #include <ed4_plugins.hxx> |
|---|
| 18 | #include <BI_basepos.hxx> |
|---|
| 19 | #include <arb_global_defs.h> |
|---|
| 20 | |
|---|
| 21 | |
|---|
| 22 | #define COLORLINK (ED4_G_SBACK_0 - RNA3D_GC_SBACK_0) // to link to the colors defined in primary editor ed4_defs.hxx |
|---|
| 23 | #define SAICOLORS (ED4_G_CBACK_0 - RNA3D_GC_CBACK_0) |
|---|
| 24 | |
|---|
| 25 | using namespace std; |
|---|
| 26 | |
|---|
| 27 | static Struct3Dinfo *start3D = NULp; |
|---|
| 28 | static Struct2Dinfo *start2D = NULp; |
|---|
| 29 | static Struct2Dplus3D *start2D3D = NULp; |
|---|
| 30 | static HelixNrInfo *start = NULp; |
|---|
| 31 | static CurrSpecies *startSp = NULp; |
|---|
| 32 | static bool bOldSpeciesDataExists = false; |
|---|
| 33 | static Insertions *startIns = NULp; |
|---|
| 34 | static bool bOldInsertionDataExists = false; |
|---|
| 35 | static bool bStartPosStored = false; |
|---|
| 36 | static bool bEndPosStored = false; |
|---|
| 37 | |
|---|
| 38 | inline bool is_Gap(char c) { |
|---|
| 39 | return GAP::is_std_gap(c); // @@@ use AWAR defined gaps? |
|---|
| 40 | } |
|---|
| 41 | |
|---|
| 42 | static char *find_data_file(const char *name) { |
|---|
| 43 | char *fname = GB_lib_file(false, "rna3d/", name); |
|---|
| 44 | if (!fname) throw string("file not found: ")+name; |
|---|
| 45 | return fname; |
|---|
| 46 | } |
|---|
| 47 | |
|---|
| 48 | static void throw_IO_error(const char *filename) __ATTR__NORETURN; |
|---|
| 49 | static void throw_IO_error(const char *filename) { |
|---|
| 50 | string error = string("IO-Error: ")+strerror(errno)+" ('"+filename+"')"; |
|---|
| 51 | throw error; |
|---|
| 52 | } |
|---|
| 53 | |
|---|
| 54 | GBDATA *Structure3D::gb_main = NULp; |
|---|
| 55 | |
|---|
| 56 | Structure3D::Structure3D(ED4_plugin_host& host_) |
|---|
| 57 | : strCen(new Vector3(0.0, 0.0, 0.0)), |
|---|
| 58 | iInterval(25), |
|---|
| 59 | iMapSAI(0), |
|---|
| 60 | iMapSearch(0), |
|---|
| 61 | iMapEnable(0), |
|---|
| 62 | iStartPos(0), |
|---|
| 63 | iEndPos(0), |
|---|
| 64 | iEColiStartPos(0), |
|---|
| 65 | iEColiEndPos(0), |
|---|
| 66 | iTotalSubs(0), |
|---|
| 67 | iTotalDels(0), |
|---|
| 68 | iTotalIns(0), |
|---|
| 69 | LSU_molID(3), // default molecule to load in case of 23S rRNA : 1C2W |
|---|
| 70 | HelixBase(500), |
|---|
| 71 | EColiRef(NULp), |
|---|
| 72 | Host(host_), |
|---|
| 73 | GRAPHICS(new OpenGLGraphics) |
|---|
| 74 | {} |
|---|
| 75 | |
|---|
| 76 | Structure3D::~Structure3D() { |
|---|
| 77 | delete GRAPHICS; |
|---|
| 78 | delete strCen; |
|---|
| 79 | } |
|---|
| 80 | |
|---|
| 81 | |
|---|
| 82 | void Structure3D::StoreCoordinates(float x, float y, float z, char base, unsigned int pos) { |
|---|
| 83 | Struct3Dinfo *data, *temp; |
|---|
| 84 | data = new Struct3Dinfo; |
|---|
| 85 | data->x = x; |
|---|
| 86 | data->y = y; |
|---|
| 87 | data->z = z; |
|---|
| 88 | data->base = base; |
|---|
| 89 | data->pos = pos; |
|---|
| 90 | data->next = NULp; |
|---|
| 91 | |
|---|
| 92 | if (!start3D) |
|---|
| 93 | start3D = data; |
|---|
| 94 | else { |
|---|
| 95 | temp = start3D; |
|---|
| 96 | // We know this is not NULp - list not empty! |
|---|
| 97 | while (temp->next) { |
|---|
| 98 | temp = temp->next; // Move to next link in chain |
|---|
| 99 | } |
|---|
| 100 | temp->next = data; |
|---|
| 101 | } |
|---|
| 102 | } |
|---|
| 103 | |
|---|
| 104 | // ------------------Selecting rRNA type--------------------------// |
|---|
| 105 | |
|---|
| 106 | int Structure3D::FindTypeOfRNA() { // @@@ should better return an enum type |
|---|
| 107 | int rnaType = 0; |
|---|
| 108 | GB_push_transaction(gb_main); // opening a transaction |
|---|
| 109 | |
|---|
| 110 | GBDATA *gbTemplate = GBT_find_SAI(gb_main, "ECOLI"); |
|---|
| 111 | if (!gbTemplate) { |
|---|
| 112 | aw_message("SAI:ECOLI not found"); |
|---|
| 113 | } |
|---|
| 114 | else { |
|---|
| 115 | char *ali_name = GBT_get_default_alignment(gb_main); |
|---|
| 116 | GBDATA *gbAlignment = GB_entry(gbTemplate, ali_name); |
|---|
| 117 | GBDATA *gbTemplateSeqData = gbAlignment ? GB_entry(gbAlignment, "data") : NULp; |
|---|
| 118 | |
|---|
| 119 | if (!gbTemplateSeqData) { |
|---|
| 120 | aw_message("Could not find species in the database!"); |
|---|
| 121 | } |
|---|
| 122 | else { |
|---|
| 123 | const char *pTemplateSeqData = GB_read_char_pntr(gbTemplateSeqData); |
|---|
| 124 | int iSeqLen = strlen(pTemplateSeqData); |
|---|
| 125 | int iBaseCount = 0; |
|---|
| 126 | for (int i = 0; i<iSeqLen; i++) { |
|---|
| 127 | if (!is_Gap(pTemplateSeqData[i])) { |
|---|
| 128 | iBaseCount++; |
|---|
| 129 | } |
|---|
| 130 | } |
|---|
| 131 | |
|---|
| 132 | if (iBaseCount > 2000) rnaType = LSU_23S; |
|---|
| 133 | else if (iBaseCount > 300) rnaType = SSU_16S; |
|---|
| 134 | else rnaType = LSU_5S; |
|---|
| 135 | } |
|---|
| 136 | } |
|---|
| 137 | GB_pop_transaction(gb_main); |
|---|
| 138 | |
|---|
| 139 | return rnaType; |
|---|
| 140 | } |
|---|
| 141 | |
|---|
| 142 | // ----------Delete old molecule data-------------------------------// |
|---|
| 143 | // Struct2Dinfo, Struct2Dplus3D, Struct3Dinfo, HelixNrInfo, Insertions |
|---|
| 144 | |
|---|
| 145 | void Structure3D::DeleteOldMoleculeData() { |
|---|
| 146 | // Struct2Dinfo -> start2D |
|---|
| 147 | { |
|---|
| 148 | Struct2Dinfo *tmp, *data; |
|---|
| 149 | for (data = start2D; data; data = tmp) { |
|---|
| 150 | tmp = data->next; |
|---|
| 151 | delete data; |
|---|
| 152 | } |
|---|
| 153 | start2D = NULp; |
|---|
| 154 | } |
|---|
| 155 | |
|---|
| 156 | // Struct2Dplus3D ->start2D3D |
|---|
| 157 | { |
|---|
| 158 | Struct2Dplus3D *tmp, *data; |
|---|
| 159 | for (data = start2D3D; data; data = tmp) { |
|---|
| 160 | tmp = data->next; |
|---|
| 161 | delete data; |
|---|
| 162 | } |
|---|
| 163 | start2D3D = NULp; |
|---|
| 164 | } |
|---|
| 165 | |
|---|
| 166 | // Struct3Dinfo ->start3D |
|---|
| 167 | { |
|---|
| 168 | Struct3Dinfo *tmp, *data; |
|---|
| 169 | for (data = start3D; data; data = tmp) { |
|---|
| 170 | tmp = data->next; |
|---|
| 171 | delete data; |
|---|
| 172 | } |
|---|
| 173 | start3D = NULp; |
|---|
| 174 | } |
|---|
| 175 | |
|---|
| 176 | // HelixNrInfo -> start |
|---|
| 177 | { |
|---|
| 178 | HelixNrInfo *tmp, *data; |
|---|
| 179 | for (data = start; data; data = tmp) { |
|---|
| 180 | tmp = data->next; |
|---|
| 181 | delete data; |
|---|
| 182 | } |
|---|
| 183 | start = NULp; |
|---|
| 184 | } |
|---|
| 185 | |
|---|
| 186 | // Delete insertions data |
|---|
| 187 | DeleteOldInsertionData(); |
|---|
| 188 | |
|---|
| 189 | // Delete mapped species data |
|---|
| 190 | DeleteOldSpeciesData (); |
|---|
| 191 | } |
|---|
| 192 | |
|---|
| 193 | // =========== Reading 3D Coordinates from PDB file ====================// |
|---|
| 194 | |
|---|
| 195 | static char globalComment[1000]; |
|---|
| 196 | |
|---|
| 197 | void Structure3D::ReadCoOrdinateFile() { |
|---|
| 198 | static char *DataFile = NULp; |
|---|
| 199 | int rnaType = FindTypeOfRNA(); |
|---|
| 200 | |
|---|
| 201 | RNA3D->bDisplayComments = true; // displaying comments in main window |
|---|
| 202 | |
|---|
| 203 | switch (rnaType) { |
|---|
| 204 | case LSU_23S: |
|---|
| 205 | switch (LSU_molID) { |
|---|
| 206 | case _1PNU: |
|---|
| 207 | DataFile = find_data_file("Ecoli_1PNU_23S_rRNA.pdb"); |
|---|
| 208 | sprintf(globalComment, "The 3D molecule rendered from PDB entry : 1PNU at 8.7 Angstrom."); |
|---|
| 209 | break; |
|---|
| 210 | case _1VOR: |
|---|
| 211 | DataFile = find_data_file("Ecoli_1VOR_23S_rRNA.pdb"); |
|---|
| 212 | sprintf(globalComment, "The 3D molecule is rendered from PDB entry [1VOR] with 11.5 Angstrom resolution."); |
|---|
| 213 | break; |
|---|
| 214 | case _1C2W: |
|---|
| 215 | DataFile = find_data_file("Ecoli_1C2W_23S_rRNA.pdb"); |
|---|
| 216 | sprintf(globalComment, "The 3D molecule is rendered from PDB entry [1C2W] with 7.5 Angstrom resolution."); |
|---|
| 217 | break; |
|---|
| 218 | } |
|---|
| 219 | break; |
|---|
| 220 | case LSU_5S: |
|---|
| 221 | DataFile = find_data_file("Ecoli_1C2X_5S_rRNA.pdb"); |
|---|
| 222 | sprintf(globalComment, "The 3D molecule is rendered from PDB entry [1C2X] with 7.5 Angstrom resolution."); |
|---|
| 223 | break; |
|---|
| 224 | case SSU_16S: |
|---|
| 225 | DataFile = find_data_file("Ecoli_1M5G_16S_rRNA.pdb"); |
|---|
| 226 | sprintf(globalComment, "The 3D molecule is rendered from PDB entry [1M5G] with 11.5 Angstrom resolution."); |
|---|
| 227 | break; |
|---|
| 228 | } |
|---|
| 229 | |
|---|
| 230 | ifstream readData; |
|---|
| 231 | readData.open(DataFile, ios::in); |
|---|
| 232 | if (!readData.is_open()) { |
|---|
| 233 | throw_IO_error(DataFile); |
|---|
| 234 | } |
|---|
| 235 | |
|---|
| 236 | int cntr = 0; |
|---|
| 237 | unsigned int last3Dpos = 0; |
|---|
| 238 | static bool bEColiStartPosStored = false; |
|---|
| 239 | |
|---|
| 240 | while (!readData.eof()) { |
|---|
| 241 | char buf[256]; |
|---|
| 242 | readData.getline(buf, 100); |
|---|
| 243 | |
|---|
| 244 | string line(buf); |
|---|
| 245 | if ((line.find("ATOM") != string::npos) || (line.find("HETATM") != string::npos)) { |
|---|
| 246 | string atom = line.substr(77, 2); |
|---|
| 247 | if (atom.find("P") != string::npos) { |
|---|
| 248 | char base = line[19]; |
|---|
| 249 | unsigned pos = atoi(line.substr(22, 4).c_str()); |
|---|
| 250 | |
|---|
| 251 | // special filter for 23S rRNA structure (IVOR/IPNU) |
|---|
| 252 | // IVOR/IPNU contains artifacts and are not mentioned in any of the |
|---|
| 253 | // remarks of PDB file |
|---|
| 254 | if (last3Dpos != pos && !(pos >= 3093)) { |
|---|
| 255 | float X = atof(line.substr(31, 8).c_str()); |
|---|
| 256 | float Y = atof(line.substr(39, 8).c_str()); |
|---|
| 257 | float Z = atof(line.substr(47, 8).c_str()); |
|---|
| 258 | |
|---|
| 259 | StoreCoordinates(X, Y, Z, base, pos); |
|---|
| 260 | last3Dpos = pos; |
|---|
| 261 | strCen->x += X; strCen->y += Y; strCen->z += Z; |
|---|
| 262 | cntr++; |
|---|
| 263 | } |
|---|
| 264 | if (!bEColiStartPosStored) { |
|---|
| 265 | iEColiStartPos = pos; |
|---|
| 266 | bEColiStartPosStored = true; |
|---|
| 267 | } |
|---|
| 268 | iEColiEndPos = pos; |
|---|
| 269 | } |
|---|
| 270 | } |
|---|
| 271 | } |
|---|
| 272 | |
|---|
| 273 | cout<<"--------------------------------------------------"<<endl |
|---|
| 274 | <<globalComment<<endl |
|---|
| 275 | <<"Structure contains "<<iEColiEndPos-iEColiStartPos<<"( "<<iEColiStartPos<<" - " |
|---|
| 276 | <<iEColiEndPos<<" ) positions."<<endl |
|---|
| 277 | <<"---------------------------------------------------"<<endl; |
|---|
| 278 | |
|---|
| 279 | strCen->x = strCen->x/cntr; |
|---|
| 280 | strCen->y = strCen->y/cntr; |
|---|
| 281 | strCen->z = strCen->z/cntr; |
|---|
| 282 | |
|---|
| 283 | readData.close(); |
|---|
| 284 | free(DataFile); |
|---|
| 285 | } |
|---|
| 286 | |
|---|
| 287 | |
|---|
| 288 | void Structure3D::Store2Dinfo(char *info, int pos, int helixNr) { |
|---|
| 289 | Struct2Dinfo *data = new Struct2Dinfo; |
|---|
| 290 | |
|---|
| 291 | data->base = info[0]; |
|---|
| 292 | data->mask = info[1]; |
|---|
| 293 | data->code = info[2]; |
|---|
| 294 | data->pos = pos; |
|---|
| 295 | data->helixNr = helixNr; |
|---|
| 296 | |
|---|
| 297 | data->next = NULp; |
|---|
| 298 | |
|---|
| 299 | if (!start2D) { |
|---|
| 300 | start2D = data; |
|---|
| 301 | } |
|---|
| 302 | else { |
|---|
| 303 | Struct2Dinfo *temp = start2D; |
|---|
| 304 | // We know this is not NULp - list not empty! |
|---|
| 305 | while (temp->next) { |
|---|
| 306 | temp = temp->next; // Move to next link in chain |
|---|
| 307 | } |
|---|
| 308 | temp->next = data; |
|---|
| 309 | } |
|---|
| 310 | } |
|---|
| 311 | |
|---|
| 312 | // =========== Reading Secondary Structure Data from Ecoli Secondary Structure Mask file ====================// |
|---|
| 313 | |
|---|
| 314 | void Structure3D::GetSecondaryStructureInfo() { |
|---|
| 315 | static char *DataFile = NULp; |
|---|
| 316 | int rnaType = FindTypeOfRNA(); |
|---|
| 317 | |
|---|
| 318 | switch (rnaType) { |
|---|
| 319 | case LSU_23S: |
|---|
| 320 | DataFile = find_data_file("SecondaryStructureModel_23SrRNA.data"); |
|---|
| 321 | break; |
|---|
| 322 | case LSU_5S: |
|---|
| 323 | DataFile = find_data_file("SecondaryStructureModel_5SrRNA.data"); |
|---|
| 324 | break; |
|---|
| 325 | case SSU_16S: |
|---|
| 326 | DataFile = find_data_file("SecondaryStructureModel_16SrRNA.data"); |
|---|
| 327 | break; |
|---|
| 328 | } |
|---|
| 329 | |
|---|
| 330 | char buf[256]; |
|---|
| 331 | |
|---|
| 332 | int pos = 0; |
|---|
| 333 | int helixNr = 0; |
|---|
| 334 | int lastHelixNr = 0; |
|---|
| 335 | char info[4]; |
|---|
| 336 | info[3] = '\0'; |
|---|
| 337 | bool insideHelix = false; |
|---|
| 338 | bool skip = false; |
|---|
| 339 | |
|---|
| 340 | ifstream readData; |
|---|
| 341 | readData.open(DataFile, ios::in); |
|---|
| 342 | if (!readData.is_open()) { |
|---|
| 343 | throw_IO_error(DataFile); |
|---|
| 344 | } |
|---|
| 345 | |
|---|
| 346 | while (!readData.eof()) { |
|---|
| 347 | readData.getline(buf, 100); |
|---|
| 348 | char *tmp; |
|---|
| 349 | tmp = strtok(buf, " "); |
|---|
| 350 | for (int i = 0; tmp; tmp = strtok(NULp, " "), i++) { |
|---|
| 351 | switch (i) { |
|---|
| 352 | case 0: pos = atoi(tmp); break; |
|---|
| 353 | case 1: info[0] = tmp[0]; break; |
|---|
| 354 | case 2: info[1] = tmp[0]; break; |
|---|
| 355 | case 3: info[2] = tmp[0]; break; |
|---|
| 356 | case 4: helixNr = atoi(tmp); break; |
|---|
| 357 | } |
|---|
| 358 | } |
|---|
| 359 | |
|---|
| 360 | bool is_SE = (info[2] == 'S') || (info[2] == 'E'); // 'S' = helix start 'E' = helix end |
|---|
| 361 | if (is_SE) { |
|---|
| 362 | if (helixNr>0) lastHelixNr = helixNr; |
|---|
| 363 | |
|---|
| 364 | if (!insideHelix) insideHelix = true; |
|---|
| 365 | else { |
|---|
| 366 | Store2Dinfo(info, pos, lastHelixNr); |
|---|
| 367 | skip = true; |
|---|
| 368 | insideHelix = false; |
|---|
| 369 | } |
|---|
| 370 | } |
|---|
| 371 | if (insideHelix) Store2Dinfo(info, pos, lastHelixNr); |
|---|
| 372 | else { |
|---|
| 373 | if (skip) skip = false; |
|---|
| 374 | else Store2Dinfo(info, pos, 0); |
|---|
| 375 | } |
|---|
| 376 | } |
|---|
| 377 | readData.close(); |
|---|
| 378 | free(DataFile); |
|---|
| 379 | } |
|---|
| 380 | |
|---|
| 381 | void Structure3D::Store2D3Dinfo(Struct2Dinfo *s2D, Struct3Dinfo *s3D) { |
|---|
| 382 | Struct2Dplus3D *data, *temp; |
|---|
| 383 | data = new Struct2Dplus3D; |
|---|
| 384 | data->base = s2D->base; |
|---|
| 385 | data->mask = s2D->mask; |
|---|
| 386 | data->code = s2D->code; |
|---|
| 387 | data->pos = s2D->pos; |
|---|
| 388 | data->helixNr = s2D->helixNr; |
|---|
| 389 | data->x = s3D->x; |
|---|
| 390 | data->y = s3D->y; |
|---|
| 391 | data->z = s3D->z; |
|---|
| 392 | data->next = NULp; |
|---|
| 393 | |
|---|
| 394 | if (!start2D3D) |
|---|
| 395 | start2D3D = data; |
|---|
| 396 | else { |
|---|
| 397 | temp = start2D3D; |
|---|
| 398 | while (temp->next) { |
|---|
| 399 | temp = temp->next; |
|---|
| 400 | } |
|---|
| 401 | temp->next = data; |
|---|
| 402 | } |
|---|
| 403 | } |
|---|
| 404 | |
|---|
| 405 | // =========== Combining Secondary Structure Data with 3D Coordinates =======================// |
|---|
| 406 | |
|---|
| 407 | void Structure3D::Combine2Dand3DstructureInfo() { |
|---|
| 408 | Struct3Dinfo *temp3D; |
|---|
| 409 | Struct2Dinfo *temp2D; |
|---|
| 410 | int cntr = 0; |
|---|
| 411 | |
|---|
| 412 | cout<<"Missing Base Positions : "<<endl; |
|---|
| 413 | |
|---|
| 414 | temp3D = start3D; |
|---|
| 415 | temp2D = start2D; |
|---|
| 416 | while (temp3D && temp2D) { |
|---|
| 417 | if (temp2D->pos == temp3D->pos) { |
|---|
| 418 | Store2D3Dinfo(temp2D, temp3D); |
|---|
| 419 | } |
|---|
| 420 | else { |
|---|
| 421 | while (temp2D->pos != temp3D->pos) { |
|---|
| 422 | cout<<temp2D->pos<<", "; // missing base positions |
|---|
| 423 | cntr++; |
|---|
| 424 | temp2D = temp2D->next; |
|---|
| 425 | } |
|---|
| 426 | Store2D3Dinfo(temp2D, temp3D); |
|---|
| 427 | } |
|---|
| 428 | |
|---|
| 429 | temp3D = temp3D->next; |
|---|
| 430 | temp2D = temp2D->next; |
|---|
| 431 | } |
|---|
| 432 | cout<<endl<<"Total No. of bases missing = "<<cntr<<endl; |
|---|
| 433 | |
|---|
| 434 | // printing comments in the main window |
|---|
| 435 | { |
|---|
| 436 | RNA3D->bDisplayComments = true; |
|---|
| 437 | char buf[256]; |
|---|
| 438 | sprintf(buf, "Total No. of bases missing = %d. See the console messages for the actual missing base positions.", cntr); |
|---|
| 439 | strcat(globalComment, buf); |
|---|
| 440 | } |
|---|
| 441 | } |
|---|
| 442 | |
|---|
| 443 | void Structure3D::PointsToQuads(float x, float y, float z) { |
|---|
| 444 | |
|---|
| 445 | if (RNA3D->bPointSpritesSupported) { |
|---|
| 446 | glVertex3f(x, y, z); |
|---|
| 447 | } |
|---|
| 448 | else { |
|---|
| 449 | glBegin(GL_QUADS); |
|---|
| 450 | // Front Face |
|---|
| 451 | glTexCoord2f(0, 0); glVertex3f(x - 1, y + 1, z + 1); |
|---|
| 452 | glTexCoord2f(1, 0); glVertex3f(x + 1, y + 1, z + 1); |
|---|
| 453 | glTexCoord2f(1, 1); glVertex3f(x + 1, y - 1, z + 1); |
|---|
| 454 | glTexCoord2f(0, 1); glVertex3f(x - 1, y - 1, z + 1); |
|---|
| 455 | |
|---|
| 456 | // Back Face |
|---|
| 457 | glTexCoord2f(0, 0); glVertex3f(x + 1, y + 1, z - 1); |
|---|
| 458 | glTexCoord2f(1, 0); glVertex3f(x - 1, y + 1, z - 1); |
|---|
| 459 | glTexCoord2f(1, 1); glVertex3f(x - 1, y - 1, z - 1); |
|---|
| 460 | glTexCoord2f(0, 1); glVertex3f(x + 1, y - 1, z - 1); |
|---|
| 461 | |
|---|
| 462 | // Top Face |
|---|
| 463 | glTexCoord2f(0, 0); glVertex3f(x + 1, y + 1, z + 1); |
|---|
| 464 | glTexCoord2f(1, 0); glVertex3f(x - 1, y + 1, z + 1); |
|---|
| 465 | glTexCoord2f(1, 1); glVertex3f(x - 1, y + 1, z - 1); |
|---|
| 466 | glTexCoord2f(0, 1); glVertex3f(x + 1, y + 1, z - 1); |
|---|
| 467 | |
|---|
| 468 | // Bottom Face |
|---|
| 469 | glTexCoord2f(0, 0); glVertex3f(x + 1, y - 1, z - 1); |
|---|
| 470 | glTexCoord2f(1, 0); glVertex3f(x - 1, y - 1, z - 1); |
|---|
| 471 | glTexCoord2f(1, 1); glVertex3f(x - 1, y - 1, z + 1); |
|---|
| 472 | glTexCoord2f(0, 1); glVertex3f(x + 1, y - 1, z + 1); |
|---|
| 473 | |
|---|
| 474 | // Left Face |
|---|
| 475 | glTexCoord2f(0, 0); glVertex3f(x + 1, y + 1, z + 1); |
|---|
| 476 | glTexCoord2f(1, 0); glVertex3f(x + 1, y + 1, z - 1); |
|---|
| 477 | glTexCoord2f(1, 1); glVertex3f(x + 1, y - 1, z - 1); |
|---|
| 478 | glTexCoord2f(0, 1); glVertex3f(x + 1, y - 1, z + 1); |
|---|
| 479 | |
|---|
| 480 | // Right Face |
|---|
| 481 | glTexCoord2f(0, 0); glVertex3f(x - 1, y + 1, z - 1); |
|---|
| 482 | glTexCoord2f(1, 0); glVertex3f(x - 1, y + 1, z + 1); |
|---|
| 483 | glTexCoord2f(1, 1); glVertex3f(x - 1, y - 1, z + 1); |
|---|
| 484 | glTexCoord2f(0, 1); glVertex3f(x - 1, y - 1, z - 1); |
|---|
| 485 | |
|---|
| 486 | glEnd(); |
|---|
| 487 | } |
|---|
| 488 | } |
|---|
| 489 | |
|---|
| 490 | void Structure3D::PositionsToCoordinatesDispList(int listID, int *pos, int len) { |
|---|
| 491 | Struct2Dplus3D *t; |
|---|
| 492 | int tmpPos = 0; |
|---|
| 493 | |
|---|
| 494 | glNewList(listID, GL_COMPILE); |
|---|
| 495 | { |
|---|
| 496 | if (RNA3D->bPointSpritesSupported) { |
|---|
| 497 | glBegin(GL_POINTS); |
|---|
| 498 | } |
|---|
| 499 | for (int i = 0; i < len; i++) { |
|---|
| 500 | tmpPos = pos[i]; |
|---|
| 501 | t = start2D3D; |
|---|
| 502 | while (t) { |
|---|
| 503 | if (t->pos == tmpPos) { |
|---|
| 504 | PointsToQuads(t->x, t->y, t->z); |
|---|
| 505 | break; |
|---|
| 506 | } |
|---|
| 507 | t = t->next; |
|---|
| 508 | } |
|---|
| 509 | } |
|---|
| 510 | if (RNA3D->bPointSpritesSupported) { |
|---|
| 511 | glEnd(); |
|---|
| 512 | } |
|---|
| 513 | } |
|---|
| 514 | glEndList(); |
|---|
| 515 | } |
|---|
| 516 | |
|---|
| 517 | void Structure3D::GenerateSecStructureNonHelixRegions() { |
|---|
| 518 | Struct2Dplus3D *t; |
|---|
| 519 | const int MAX_BASE = 1000; |
|---|
| 520 | int baseA[MAX_BASE], baseG[MAX_BASE], baseC[MAX_BASE], baseU[MAX_BASE]; |
|---|
| 521 | int a, g, c, u; a=g=c=u=0; |
|---|
| 522 | |
|---|
| 523 | { |
|---|
| 524 | t = start2D3D; |
|---|
| 525 | while (t) { |
|---|
| 526 | if (t->helixNr == 0) { |
|---|
| 527 | switch (t->base) { |
|---|
| 528 | case 'A': baseA[a++] = t->pos; break; |
|---|
| 529 | case 'G': baseG[g++] = t->pos; break; |
|---|
| 530 | case 'C': baseC[c++] = t->pos; break; |
|---|
| 531 | case 'U': baseU[u++] = t->pos; break; |
|---|
| 532 | } |
|---|
| 533 | } |
|---|
| 534 | t = t->next; |
|---|
| 535 | } |
|---|
| 536 | } |
|---|
| 537 | |
|---|
| 538 | PositionsToCoordinatesDispList(NON_HELIX_A, baseA, a); |
|---|
| 539 | PositionsToCoordinatesDispList(NON_HELIX_G, baseG, g); |
|---|
| 540 | PositionsToCoordinatesDispList(NON_HELIX_C, baseC, c); |
|---|
| 541 | PositionsToCoordinatesDispList(NON_HELIX_U, baseU, u); |
|---|
| 542 | } |
|---|
| 543 | |
|---|
| 544 | void Structure3D::GenerateSecStructureHelixRegions() { |
|---|
| 545 | Struct2Dplus3D *t; |
|---|
| 546 | const int MAX_BASE = 1000; |
|---|
| 547 | int baseA[MAX_BASE], baseG[MAX_BASE], baseC[MAX_BASE], baseU[MAX_BASE]; |
|---|
| 548 | int a, g, c, u; a=g=c=u=0; |
|---|
| 549 | |
|---|
| 550 | { |
|---|
| 551 | t = start2D3D; |
|---|
| 552 | while (t) { |
|---|
| 553 | if (t->helixNr > 0) { |
|---|
| 554 | if ((t->mask == '[') || (t->mask == ']') || (t->mask == '<') || (t->mask == '>')) { |
|---|
| 555 | switch (t->base) { |
|---|
| 556 | case 'A': baseA[a++] = t->pos; break; |
|---|
| 557 | case 'G': baseG[g++] = t->pos; break; |
|---|
| 558 | case 'C': baseC[c++] = t->pos; break; |
|---|
| 559 | case 'U': baseU[u++] = t->pos; break; |
|---|
| 560 | } |
|---|
| 561 | } |
|---|
| 562 | } |
|---|
| 563 | t = t->next; |
|---|
| 564 | } |
|---|
| 565 | } |
|---|
| 566 | |
|---|
| 567 | PositionsToCoordinatesDispList(HELIX_A, baseA, a); |
|---|
| 568 | PositionsToCoordinatesDispList(HELIX_G, baseG, g); |
|---|
| 569 | PositionsToCoordinatesDispList(HELIX_C, baseC, c); |
|---|
| 570 | PositionsToCoordinatesDispList(HELIX_U, baseU, u); |
|---|
| 571 | } |
|---|
| 572 | |
|---|
| 573 | void Structure3D::GenerateSecStructureUnpairedHelixRegions() { |
|---|
| 574 | Struct2Dplus3D *t; |
|---|
| 575 | const int MAX_BASE = 500; |
|---|
| 576 | int baseA[MAX_BASE], baseG[MAX_BASE], baseC[MAX_BASE], baseU[MAX_BASE]; |
|---|
| 577 | int a, g, c, u; a=g=c=u=0; |
|---|
| 578 | |
|---|
| 579 | { |
|---|
| 580 | t = start2D3D; |
|---|
| 581 | while (t) { |
|---|
| 582 | if (t->helixNr > 0) { |
|---|
| 583 | if (t->mask == '.') { |
|---|
| 584 | switch (t->base) { |
|---|
| 585 | case 'A': baseA[a++] = t->pos; break; |
|---|
| 586 | case 'G': baseG[g++] = t->pos; break; |
|---|
| 587 | case 'C': baseC[c++] = t->pos; break; |
|---|
| 588 | case 'U': baseU[u++] = t->pos; break; |
|---|
| 589 | } |
|---|
| 590 | } |
|---|
| 591 | } |
|---|
| 592 | t = t->next; |
|---|
| 593 | } |
|---|
| 594 | } |
|---|
| 595 | |
|---|
| 596 | PositionsToCoordinatesDispList(UNPAIRED_HELIX_A, baseA, a); |
|---|
| 597 | PositionsToCoordinatesDispList(UNPAIRED_HELIX_G, baseG, g); |
|---|
| 598 | PositionsToCoordinatesDispList(UNPAIRED_HELIX_C, baseC, c); |
|---|
| 599 | PositionsToCoordinatesDispList(UNPAIRED_HELIX_U, baseU, u); |
|---|
| 600 | } |
|---|
| 601 | |
|---|
| 602 | // ============================================================================== |
|---|
| 603 | // Tertiary Interactions of 16S ribosomal RNA model of E.coli. |
|---|
| 604 | // Reference : http://www.rna.icmb.utexas.edu/ |
|---|
| 605 | // Year of Last Update : 2001. |
|---|
| 606 | // Pseudoknots and Triple Base pairs are extracted and displayed in |
|---|
| 607 | // the 3D model. |
|---|
| 608 | // ============================================================================== |
|---|
| 609 | |
|---|
| 610 | void Structure3D::GenerateTertiaryInteractionsDispLists() { |
|---|
| 611 | Struct2Dplus3D *t; |
|---|
| 612 | static char *DataFile = NULp; |
|---|
| 613 | int rnaType = FindTypeOfRNA(); |
|---|
| 614 | |
|---|
| 615 | switch (rnaType) { |
|---|
| 616 | case LSU_23S: |
|---|
| 617 | DataFile = find_data_file("TertiaryInteractions_23SrRNA.data"); |
|---|
| 618 | break; |
|---|
| 619 | case LSU_5S: |
|---|
| 620 | cout<<"There are no tertiary interactions observed in 5S rRNA model!"<<endl; |
|---|
| 621 | return; |
|---|
| 622 | case SSU_16S: |
|---|
| 623 | DataFile = find_data_file("TertiaryInteractions_16SrRNA.data"); |
|---|
| 624 | break; |
|---|
| 625 | } |
|---|
| 626 | |
|---|
| 627 | cout<<"Tertiary Interactions are fetched from comparative RNA website [http://www.rna.icmb.utexas.edu]."<<endl |
|---|
| 628 | <<"The same are located in the file \""<<DataFile<<"\"."<<endl; |
|---|
| 629 | |
|---|
| 630 | char buf[256]; |
|---|
| 631 | |
|---|
| 632 | ifstream readData; |
|---|
| 633 | readData.open(DataFile, ios::in); |
|---|
| 634 | if (!readData.is_open()) { |
|---|
| 635 | throw_IO_error(DataFile); |
|---|
| 636 | } |
|---|
| 637 | |
|---|
| 638 | int K[100]; |
|---|
| 639 | int R[100]; |
|---|
| 640 | int k, r; k = r = 0; |
|---|
| 641 | |
|---|
| 642 | while (!readData.eof()) { |
|---|
| 643 | readData.getline(buf, 100); |
|---|
| 644 | char *tmp; |
|---|
| 645 | tmp = strtok(buf, " "); |
|---|
| 646 | if (tmp) { |
|---|
| 647 | if (strcmp(tmp, "KNOT") == 0) { |
|---|
| 648 | tmp = strtok(NULp, ":"); |
|---|
| 649 | while (tmp) { |
|---|
| 650 | K[k++] = atoi(tmp); |
|---|
| 651 | tmp = strtok(NULp, ":"); |
|---|
| 652 | } |
|---|
| 653 | } |
|---|
| 654 | else if (strcmp(tmp, "TRIPLE") == 0) { |
|---|
| 655 | tmp = strtok(NULp, ":"); |
|---|
| 656 | while (tmp) { |
|---|
| 657 | R[r++] = atoi(tmp); |
|---|
| 658 | tmp = strtok(NULp, ":"); |
|---|
| 659 | } |
|---|
| 660 | } |
|---|
| 661 | } |
|---|
| 662 | } |
|---|
| 663 | readData.close(); |
|---|
| 664 | |
|---|
| 665 | glNewList(ECOLI_TERTIARY_INTRACTION_PSEUDOKNOTS, GL_COMPILE); |
|---|
| 666 | { |
|---|
| 667 | for (int i = 0; i < k;) { |
|---|
| 668 | glBegin(GL_LINES); |
|---|
| 669 | for (int j = 0; j < 2; j++) { |
|---|
| 670 | t = start2D3D; |
|---|
| 671 | while (t) { |
|---|
| 672 | if (t->pos == K[i]) { |
|---|
| 673 | glVertex3f(t->x, t->y, t->z); |
|---|
| 674 | i++; |
|---|
| 675 | break; |
|---|
| 676 | } |
|---|
| 677 | t = t->next; |
|---|
| 678 | } |
|---|
| 679 | } |
|---|
| 680 | glEnd(); |
|---|
| 681 | } |
|---|
| 682 | } |
|---|
| 683 | glEndList(); |
|---|
| 684 | |
|---|
| 685 | glNewList(ECOLI_TERTIARY_INTRACTION_TRIPLE_BASES, GL_COMPILE); |
|---|
| 686 | { |
|---|
| 687 | for (int i = 0; i < r;) { |
|---|
| 688 | glBegin(GL_LINE_STRIP); |
|---|
| 689 | for (int j = 0; j < 3; j++) { |
|---|
| 690 | t = start2D3D; |
|---|
| 691 | while (t) { |
|---|
| 692 | if (t->pos == R[i]) { |
|---|
| 693 | glVertex3f(t->x, t->y, t->z); |
|---|
| 694 | i++; |
|---|
| 695 | break; |
|---|
| 696 | } |
|---|
| 697 | t = t->next; |
|---|
| 698 | } |
|---|
| 699 | } |
|---|
| 700 | glEnd(); |
|---|
| 701 | } |
|---|
| 702 | } |
|---|
| 703 | glEndList(); |
|---|
| 704 | free(DataFile); |
|---|
| 705 | } |
|---|
| 706 | |
|---|
| 707 | // ============================================================================== |
|---|
| 708 | |
|---|
| 709 | void Structure3D::StoreHelixNrInfo(float x, float y, float z, int helixNr) { |
|---|
| 710 | HelixNrInfo *data, *temp; |
|---|
| 711 | data = new HelixNrInfo; |
|---|
| 712 | data->helixNr = helixNr; |
|---|
| 713 | data->x = x; |
|---|
| 714 | data->y = y; |
|---|
| 715 | data->z = z; |
|---|
| 716 | data->next = NULp; |
|---|
| 717 | |
|---|
| 718 | if (!start) |
|---|
| 719 | start = data; |
|---|
| 720 | else { |
|---|
| 721 | temp = start; |
|---|
| 722 | while (temp->next) { |
|---|
| 723 | temp = temp->next; |
|---|
| 724 | } |
|---|
| 725 | temp->next = data; |
|---|
| 726 | } |
|---|
| 727 | } |
|---|
| 728 | |
|---|
| 729 | void Structure3D::GenerateHelixDispLists(int HELIX_NR_ID, int HELIX_NR) { |
|---|
| 730 | Struct2Dinfo *temp2D; |
|---|
| 731 | Struct2Dplus3D *temp2D3D; |
|---|
| 732 | |
|---|
| 733 | const int MAX = 500; |
|---|
| 734 | |
|---|
| 735 | int thisStrandPos[MAX], otherStrandPos[MAX]; |
|---|
| 736 | int i, j; i = j = 0; |
|---|
| 737 | { |
|---|
| 738 | temp2D = start2D; |
|---|
| 739 | while (temp2D) { |
|---|
| 740 | if (temp2D->helixNr == HELIX_NR) { |
|---|
| 741 | if ((temp2D->mask == '[') || (temp2D->mask == '<')) |
|---|
| 742 | thisStrandPos[i++] = temp2D->pos; |
|---|
| 743 | if ((temp2D->mask == ']') || (temp2D->mask == '>')) |
|---|
| 744 | otherStrandPos[j++] = temp2D->pos; |
|---|
| 745 | } |
|---|
| 746 | temp2D = temp2D->next; |
|---|
| 747 | } |
|---|
| 748 | } |
|---|
| 749 | |
|---|
| 750 | int tempPos = 0; |
|---|
| 751 | float x1, x2, y1, y2, z1, z2; x1=x2=y1=y2=z1=z2=0.0; |
|---|
| 752 | |
|---|
| 753 | bool bThisStrand, bOtherStrand; |
|---|
| 754 | bThisStrand = bOtherStrand = false; |
|---|
| 755 | |
|---|
| 756 | bool bMissingBasePair = false; |
|---|
| 757 | |
|---|
| 758 | glNewList(HELIX_NR_ID, GL_COMPILE); |
|---|
| 759 | { |
|---|
| 760 | for (int k = 0, l = j-1; k < i && l >= 0; k++, l--) { |
|---|
| 761 | tempPos = thisStrandPos[k]; |
|---|
| 762 | { |
|---|
| 763 | temp2D3D = start2D3D; |
|---|
| 764 | while (temp2D3D) { |
|---|
| 765 | if (temp2D3D->pos == tempPos) { |
|---|
| 766 | bThisStrand = true; |
|---|
| 767 | x1=temp2D3D->x; y1=temp2D3D->y; z1=temp2D3D->z; |
|---|
| 768 | break; |
|---|
| 769 | } |
|---|
| 770 | temp2D3D = temp2D3D->next; |
|---|
| 771 | } |
|---|
| 772 | } |
|---|
| 773 | tempPos = otherStrandPos[l]; |
|---|
| 774 | { |
|---|
| 775 | temp2D3D = start2D3D; |
|---|
| 776 | while (temp2D3D) { |
|---|
| 777 | if (temp2D3D->pos == tempPos) { |
|---|
| 778 | bOtherStrand = true; |
|---|
| 779 | x2=temp2D3D->x; y2=temp2D3D->y; z2=temp2D3D->z; |
|---|
| 780 | break; |
|---|
| 781 | } |
|---|
| 782 | temp2D3D = temp2D3D->next; |
|---|
| 783 | } |
|---|
| 784 | } |
|---|
| 785 | // if bases present in both the strands then draw a bond |
|---|
| 786 | // and store the helix number information |
|---|
| 787 | if (bThisStrand && bOtherStrand) { |
|---|
| 788 | glVertex3f(x1, y1, z1); |
|---|
| 789 | glVertex3f(x2, y2, z2); |
|---|
| 790 | |
|---|
| 791 | x1 = (x1+x2)/2; y1 = (y1+y2)/2; z1 = (z1+z2)/2; |
|---|
| 792 | StoreHelixNrInfo(x1, y1, z1, HELIX_NR); |
|---|
| 793 | |
|---|
| 794 | bThisStrand = bOtherStrand = false; |
|---|
| 795 | } |
|---|
| 796 | else { |
|---|
| 797 | bMissingBasePair = true; |
|---|
| 798 | cout<<thisStrandPos[k]<<"-"<<tempPos<<"("<<HELIX_NR_ID<<"), "; |
|---|
| 799 | } |
|---|
| 800 | } |
|---|
| 801 | if (bMissingBasePair) cout<<endl; |
|---|
| 802 | } |
|---|
| 803 | glEndList(); |
|---|
| 804 | } |
|---|
| 805 | |
|---|
| 806 | void Structure3D::GenerateHelixNrDispList(int startHx, int endHx) { |
|---|
| 807 | HelixNrInfo *t; |
|---|
| 808 | |
|---|
| 809 | glNewList(HELIX_NUMBERS, GL_COMPILE); |
|---|
| 810 | { |
|---|
| 811 | char POS[50]; |
|---|
| 812 | for (int i = startHx; i <= endHx; i++) { |
|---|
| 813 | t = start; |
|---|
| 814 | while (t) { |
|---|
| 815 | if (t->helixNr == i) { |
|---|
| 816 | sprintf(POS, "%d", t->helixNr); |
|---|
| 817 | GRAPHICS->PrintString(t->x, t->y, t->z, POS, GLUT_BITMAP_8_BY_13); |
|---|
| 818 | } |
|---|
| 819 | t = t->next; |
|---|
| 820 | } |
|---|
| 821 | } |
|---|
| 822 | } |
|---|
| 823 | glEndList(); |
|---|
| 824 | |
|---|
| 825 | glNewList(HELIX_NUMBERS_POINTS, GL_COMPILE); |
|---|
| 826 | { |
|---|
| 827 | if (RNA3D->bPointSpritesSupported) { |
|---|
| 828 | glBegin(GL_POINTS); |
|---|
| 829 | } |
|---|
| 830 | for (int i = startHx; i <= endHx; i++) { |
|---|
| 831 | t = start; |
|---|
| 832 | while (t) { |
|---|
| 833 | if (t->helixNr == i) { |
|---|
| 834 | PointsToQuads(t->x, t->y, t->z); |
|---|
| 835 | } |
|---|
| 836 | t = t->next; |
|---|
| 837 | } |
|---|
| 838 | } |
|---|
| 839 | if (RNA3D->bPointSpritesSupported) { |
|---|
| 840 | glEnd(); |
|---|
| 841 | } |
|---|
| 842 | } |
|---|
| 843 | glEndList(); |
|---|
| 844 | } |
|---|
| 845 | |
|---|
| 846 | void Structure3D::GenerateDisplayLists() { |
|---|
| 847 | |
|---|
| 848 | GenerateMoleculeSkeleton(); |
|---|
| 849 | ComputeBasePositions(); |
|---|
| 850 | |
|---|
| 851 | int rnaType = FindTypeOfRNA(); |
|---|
| 852 | switch (rnaType) { |
|---|
| 853 | case SSU_16S: |
|---|
| 854 | if (glIsList(HelixBase) != GL_TRUE) { |
|---|
| 855 | for (int i = 1; i <= 50; i++) { |
|---|
| 856 | GenerateHelixDispLists(HelixBase+i, i); |
|---|
| 857 | } |
|---|
| 858 | } |
|---|
| 859 | break; |
|---|
| 860 | case LSU_23S: |
|---|
| 861 | cout<<"=========================================================="<<endl |
|---|
| 862 | <<"Missing base pairs (bracket number indicates helix number) "<<endl; |
|---|
| 863 | if (glIsList(HelixBase) != GL_TRUE) { |
|---|
| 864 | for (int i = 1; i <= 101; i++) { |
|---|
| 865 | GenerateHelixDispLists(HelixBase+i, i); |
|---|
| 866 | } |
|---|
| 867 | } |
|---|
| 868 | cout<<"=========================================================="<<endl; |
|---|
| 869 | break; |
|---|
| 870 | case LSU_5S: |
|---|
| 871 | if (glIsList(HelixBase) != GL_TRUE) { |
|---|
| 872 | for (int i = 1; i <= 5; i++) { |
|---|
| 873 | GenerateHelixDispLists(HelixBase+i, i); |
|---|
| 874 | } |
|---|
| 875 | } |
|---|
| 876 | break; |
|---|
| 877 | } |
|---|
| 878 | |
|---|
| 879 | GenerateSecStructureHelixRegions(); |
|---|
| 880 | GenerateSecStructureNonHelixRegions(); |
|---|
| 881 | GenerateSecStructureUnpairedHelixRegions(); |
|---|
| 882 | |
|---|
| 883 | GenerateTertiaryInteractionsDispLists(); |
|---|
| 884 | } |
|---|
| 885 | |
|---|
| 886 | void Structure3D::GenerateMoleculeSkeleton() { |
|---|
| 887 | Struct2Dplus3D *t; |
|---|
| 888 | |
|---|
| 889 | glNewList(STRUCTURE_BACKBONE, GL_COMPILE); |
|---|
| 890 | { |
|---|
| 891 | glBegin(GL_LINE_STRIP); |
|---|
| 892 | t = start2D3D; |
|---|
| 893 | while (t) { |
|---|
| 894 | glVertex3f(t->x, t->y, t->z); |
|---|
| 895 | t = t->next; |
|---|
| 896 | } |
|---|
| 897 | glEnd(); |
|---|
| 898 | } |
|---|
| 899 | glEndList(); |
|---|
| 900 | |
|---|
| 901 | glNewList(STRUCTURE_BACKBONE_CLR, GL_COMPILE); |
|---|
| 902 | { |
|---|
| 903 | glBegin(GL_LINE_STRIP); |
|---|
| 904 | t = start2D3D; |
|---|
| 905 | while (t) { |
|---|
| 906 | if (t->helixNr > 0) { |
|---|
| 907 | if ((t->mask == '[') || (t->mask == ']') || (t->mask == '<') || (t->mask == '>')) { |
|---|
| 908 | GRAPHICS->SetColor(RNA3D_GC_BASES_HELIX); |
|---|
| 909 | glVertex3f(t->x, t->y, t->z); |
|---|
| 910 | } |
|---|
| 911 | if (t->mask == '.') { |
|---|
| 912 | GRAPHICS->SetColor(RNA3D_GC_BASES_UNPAIRED_HELIX); |
|---|
| 913 | glVertex3f(t->x, t->y, t->z); |
|---|
| 914 | } |
|---|
| 915 | } |
|---|
| 916 | if (t->helixNr == 0) { |
|---|
| 917 | GRAPHICS->SetColor(RNA3D_GC_BASES_NON_HELIX); |
|---|
| 918 | glVertex3f(t->x, t->y, t->z); |
|---|
| 919 | } |
|---|
| 920 | t = t->next; |
|---|
| 921 | } |
|---|
| 922 | glEnd(); |
|---|
| 923 | } |
|---|
| 924 | glEndList(); |
|---|
| 925 | } |
|---|
| 926 | |
|---|
| 927 | void Structure3D::GenerateCursorPositionDispList(long pos) { |
|---|
| 928 | Struct3Dinfo *temp; |
|---|
| 929 | |
|---|
| 930 | glNewList(ECOLI_CURSOR_POSITION, GL_COMPILE); |
|---|
| 931 | { |
|---|
| 932 | glBegin(GL_POINTS); |
|---|
| 933 | temp = start3D; |
|---|
| 934 | while (temp) { |
|---|
| 935 | if (temp->pos == pos) { |
|---|
| 936 | #ifdef DEBUG |
|---|
| 937 | cout<<"Cursor Position : "<<pos<<endl; |
|---|
| 938 | #endif |
|---|
| 939 | glVertex3f(temp->x, temp->y, temp->z); |
|---|
| 940 | break; |
|---|
| 941 | } |
|---|
| 942 | temp = temp->next; |
|---|
| 943 | } |
|---|
| 944 | glEnd(); |
|---|
| 945 | } |
|---|
| 946 | glEndList(); |
|---|
| 947 | } |
|---|
| 948 | |
|---|
| 949 | void Structure3D::ComputeBasePositions() { |
|---|
| 950 | Struct3Dinfo *temp; |
|---|
| 951 | |
|---|
| 952 | char POS[50]; |
|---|
| 953 | float spacer = 1.5; |
|---|
| 954 | int posSkip = iInterval; |
|---|
| 955 | if (posSkip <= 0) posSkip = 25; // default interval value |
|---|
| 956 | |
|---|
| 957 | glNewList(STRUCTURE_POS, GL_COMPILE); |
|---|
| 958 | { |
|---|
| 959 | temp = start3D; |
|---|
| 960 | while (temp) { |
|---|
| 961 | if (temp->pos%posSkip == 0) { |
|---|
| 962 | sprintf(POS, "%d", temp->pos); |
|---|
| 963 | GRAPHICS->PrintString(temp->x-spacer, temp->y, temp->z-spacer, POS, GLUT_BITMAP_HELVETICA_10); |
|---|
| 964 | } |
|---|
| 965 | temp = temp->next; |
|---|
| 966 | } |
|---|
| 967 | } |
|---|
| 968 | glEndList(); |
|---|
| 969 | |
|---|
| 970 | glNewList(STRUCTURE_POS_ANCHOR, GL_COMPILE); |
|---|
| 971 | { |
|---|
| 972 | glLineWidth(0.5); |
|---|
| 973 | glBegin(GL_LINES); |
|---|
| 974 | temp = start3D; |
|---|
| 975 | while (temp) { |
|---|
| 976 | if (temp->pos%posSkip == 0) { |
|---|
| 977 | glVertex3f(temp->x, temp->y, temp->z); |
|---|
| 978 | glVertex3f(temp->x-spacer, temp->y, temp->z-spacer); |
|---|
| 979 | } |
|---|
| 980 | temp = temp->next; |
|---|
| 981 | } |
|---|
| 982 | glEnd(); |
|---|
| 983 | } |
|---|
| 984 | glEndList(); |
|---|
| 985 | } |
|---|
| 986 | |
|---|
| 987 | // [ |
|---|
| 988 | // removed function Structure3D::PrepareSecondaryStructureData() |
|---|
| 989 | // - did read data from files in Yadhus account |
|---|
| 990 | // - was unused |
|---|
| 991 | // (stored in VC.. :) |
|---|
| 992 | // ] |
|---|
| 993 | |
|---|
| 994 | void Structure3D::StoreCurrSpeciesDifference(char base, int pos) { |
|---|
| 995 | Struct2Dplus3D *st; |
|---|
| 996 | st = start2D3D; |
|---|
| 997 | while (st) { |
|---|
| 998 | if (st->pos == pos) { |
|---|
| 999 | CurrSpecies *data, *temp; |
|---|
| 1000 | data = new CurrSpecies; |
|---|
| 1001 | data->base = base; |
|---|
| 1002 | data->pos = pos; |
|---|
| 1003 | data->x = st->x; |
|---|
| 1004 | data->y = st->y; |
|---|
| 1005 | data->z = st->z; |
|---|
| 1006 | data->next = NULp; |
|---|
| 1007 | |
|---|
| 1008 | if (!startSp) { |
|---|
| 1009 | startSp = data; |
|---|
| 1010 | bOldSpeciesDataExists = true; |
|---|
| 1011 | } |
|---|
| 1012 | else { |
|---|
| 1013 | temp = startSp; |
|---|
| 1014 | while (temp->next) { |
|---|
| 1015 | temp = temp->next; |
|---|
| 1016 | } |
|---|
| 1017 | temp->next = data; |
|---|
| 1018 | } |
|---|
| 1019 | break; |
|---|
| 1020 | } |
|---|
| 1021 | st = st->next; |
|---|
| 1022 | } |
|---|
| 1023 | } |
|---|
| 1024 | |
|---|
| 1025 | void Structure3D::DeleteOldSpeciesData() { |
|---|
| 1026 | CurrSpecies *tmp, *data; |
|---|
| 1027 | |
|---|
| 1028 | for (data = startSp; data; data = tmp) { |
|---|
| 1029 | tmp = data->next; |
|---|
| 1030 | delete data; |
|---|
| 1031 | } |
|---|
| 1032 | startSp = NULp; |
|---|
| 1033 | |
|---|
| 1034 | bOldSpeciesDataExists = false; |
|---|
| 1035 | } |
|---|
| 1036 | |
|---|
| 1037 | void Structure3D::GenerateBaseDifferencePositionDisplayList() { |
|---|
| 1038 | CurrSpecies *t; |
|---|
| 1039 | Struct3Dinfo *temp; |
|---|
| 1040 | |
|---|
| 1041 | char POS[50]; |
|---|
| 1042 | float spacer = 1.5; |
|---|
| 1043 | |
|---|
| 1044 | glNewList(MAP_SPECIES_BASE_DIFFERENCE_POS, GL_COMPILE); |
|---|
| 1045 | { |
|---|
| 1046 | for (t = startSp; t; t = t->next) { |
|---|
| 1047 | for (temp = start3D; temp; temp = temp->next) { |
|---|
| 1048 | if (temp->pos == t->pos) { |
|---|
| 1049 | sprintf(POS, "%d", temp->pos); |
|---|
| 1050 | GRAPHICS->PrintString(temp->x-spacer, temp->y, temp->z-spacer, POS, GLUT_BITMAP_8_BY_13); |
|---|
| 1051 | } |
|---|
| 1052 | } |
|---|
| 1053 | } |
|---|
| 1054 | } |
|---|
| 1055 | glEndList(); |
|---|
| 1056 | |
|---|
| 1057 | glNewList(MAP_SPECIES_BASE_DIFFERENCE_POS_ANCHOR, GL_COMPILE); |
|---|
| 1058 | { |
|---|
| 1059 | glLineWidth(1.0); |
|---|
| 1060 | glBegin(GL_LINES); |
|---|
| 1061 | |
|---|
| 1062 | for (t = startSp; t; t = t->next) { |
|---|
| 1063 | for (temp = start3D; temp; temp = temp->next) { |
|---|
| 1064 | if (temp->pos == t->pos) { |
|---|
| 1065 | glVertex3f(temp->x, temp->y, temp->z); |
|---|
| 1066 | glVertex3f(temp->x-spacer, temp->y, temp->z-spacer); |
|---|
| 1067 | } |
|---|
| 1068 | } |
|---|
| 1069 | } |
|---|
| 1070 | glEnd(); |
|---|
| 1071 | } |
|---|
| 1072 | glEndList(); |
|---|
| 1073 | } |
|---|
| 1074 | |
|---|
| 1075 | void Structure3D::BuildDisplayList(int listID, int *pos, int len) { |
|---|
| 1076 | CurrSpecies *t; |
|---|
| 1077 | int tmpPos = 0; |
|---|
| 1078 | |
|---|
| 1079 | glNewList(listID, GL_COMPILE); |
|---|
| 1080 | { |
|---|
| 1081 | if (RNA3D->bPointSpritesSupported) { |
|---|
| 1082 | glBegin(GL_POINTS); |
|---|
| 1083 | } |
|---|
| 1084 | for (int i = 0; i < len; i++) { |
|---|
| 1085 | tmpPos = pos[i]; |
|---|
| 1086 | t = startSp; |
|---|
| 1087 | while (t) { |
|---|
| 1088 | if (t->pos == tmpPos) { |
|---|
| 1089 | PointsToQuads(t->x, t->y, t->z); |
|---|
| 1090 | break; |
|---|
| 1091 | } |
|---|
| 1092 | t = t->next; |
|---|
| 1093 | } |
|---|
| 1094 | } |
|---|
| 1095 | if (RNA3D->bPointSpritesSupported) { |
|---|
| 1096 | glEnd(); |
|---|
| 1097 | } |
|---|
| 1098 | } |
|---|
| 1099 | glEndList(); |
|---|
| 1100 | } |
|---|
| 1101 | |
|---|
| 1102 | void Structure3D::GenerateBaseDifferenceDisplayList() { |
|---|
| 1103 | CurrSpecies *t; |
|---|
| 1104 | |
|---|
| 1105 | glNewList(MAP_SPECIES_BASE_DIFFERENCE, GL_COMPILE); |
|---|
| 1106 | { |
|---|
| 1107 | if (RNA3D->bPointSpritesSupported) { |
|---|
| 1108 | glBegin(GL_POINTS); |
|---|
| 1109 | } |
|---|
| 1110 | t = startSp; |
|---|
| 1111 | while (t) { |
|---|
| 1112 | PointsToQuads(t->x, t->y, t->z); |
|---|
| 1113 | t = t->next; |
|---|
| 1114 | } |
|---|
| 1115 | if (RNA3D->bPointSpritesSupported) { |
|---|
| 1116 | glEnd(); |
|---|
| 1117 | } |
|---|
| 1118 | } |
|---|
| 1119 | glEndList(); |
|---|
| 1120 | |
|---|
| 1121 | const int MAX_BASE = 400; |
|---|
| 1122 | int baseA[MAX_BASE], baseG[MAX_BASE], baseC[MAX_BASE], |
|---|
| 1123 | baseU[MAX_BASE], deletion[MAX_BASE], miss[MAX_BASE]; |
|---|
| 1124 | int a, g, c, u, d, m; a=g=c=u=d=m=0; |
|---|
| 1125 | |
|---|
| 1126 | { |
|---|
| 1127 | t = startSp; |
|---|
| 1128 | while (t) { |
|---|
| 1129 | switch (t->base) { |
|---|
| 1130 | case 'A': baseA[a++] = t->pos; break; |
|---|
| 1131 | case 'G': baseG[g++] = t->pos; break; |
|---|
| 1132 | case 'C': baseC[c++] = t->pos; break; |
|---|
| 1133 | case 'U': baseU[u++] = t->pos; break; |
|---|
| 1134 | case '-': deletion[d++] = t->pos; break; |
|---|
| 1135 | case '.': miss[m++] = t->pos; break; |
|---|
| 1136 | } |
|---|
| 1137 | t = t->next; |
|---|
| 1138 | } |
|---|
| 1139 | BuildDisplayList(MAP_SPECIES_BASE_A, baseA, a); |
|---|
| 1140 | BuildDisplayList(MAP_SPECIES_BASE_U, baseU, u); |
|---|
| 1141 | BuildDisplayList(MAP_SPECIES_BASE_G, baseG, g); |
|---|
| 1142 | BuildDisplayList(MAP_SPECIES_BASE_C, baseC, c); |
|---|
| 1143 | BuildDisplayList(MAP_SPECIES_DELETION, deletion, d); |
|---|
| 1144 | BuildDisplayList(MAP_SPECIES_MISSING, miss, m); |
|---|
| 1145 | GenerateBaseDifferencePositionDisplayList(); |
|---|
| 1146 | |
|---|
| 1147 | iTotalSubs = a+g+c+u; // Summing up the substitutions/mutations |
|---|
| 1148 | iTotalDels = d; // Storing total number of deletions |
|---|
| 1149 | #ifdef DEBUG |
|---|
| 1150 | cout<<"Substitutions = "<<iTotalSubs<<endl; |
|---|
| 1151 | cout<<"Deletions = "<<iTotalDels<<endl; |
|---|
| 1152 | #endif |
|---|
| 1153 | } |
|---|
| 1154 | } |
|---|
| 1155 | |
|---|
| 1156 | void Structure3D::StoreInsertions(char base, int pos) { |
|---|
| 1157 | Insertions *data, *temp; |
|---|
| 1158 | data = new Insertions; |
|---|
| 1159 | data->base = base; |
|---|
| 1160 | data->pos = pos; |
|---|
| 1161 | data->next = NULp; |
|---|
| 1162 | |
|---|
| 1163 | if (!startIns) { |
|---|
| 1164 | startIns = data; |
|---|
| 1165 | bOldInsertionDataExists = true; |
|---|
| 1166 | } |
|---|
| 1167 | else { |
|---|
| 1168 | temp = startIns; |
|---|
| 1169 | while (temp->next) { |
|---|
| 1170 | temp = temp->next; |
|---|
| 1171 | } |
|---|
| 1172 | temp->next = data; |
|---|
| 1173 | } |
|---|
| 1174 | } |
|---|
| 1175 | |
|---|
| 1176 | void Structure3D::DeleteOldInsertionData() { |
|---|
| 1177 | Insertions *tmp, *data; |
|---|
| 1178 | |
|---|
| 1179 | for (data = startIns; data; data = tmp) { |
|---|
| 1180 | tmp = data->next; |
|---|
| 1181 | delete data; |
|---|
| 1182 | } |
|---|
| 1183 | startIns = NULp; |
|---|
| 1184 | |
|---|
| 1185 | bOldInsertionDataExists = false; |
|---|
| 1186 | } |
|---|
| 1187 | |
|---|
| 1188 | void Structure3D::GenerateInsertionDisplayList() { |
|---|
| 1189 | Insertions *ins; |
|---|
| 1190 | Struct3Dinfo *str; |
|---|
| 1191 | char inserts[500]; |
|---|
| 1192 | int i, cntr; |
|---|
| 1193 | float spacer = 2.0; |
|---|
| 1194 | iTotalIns = 0; |
|---|
| 1195 | |
|---|
| 1196 | glNewList(MAP_SPECIES_INSERTION_BASES, GL_COMPILE); |
|---|
| 1197 | { |
|---|
| 1198 | for (str = start3D; str; str = str->next) { |
|---|
| 1199 | i = cntr = 0; |
|---|
| 1200 | for (ins = startIns; ins; ins = ins->next) { |
|---|
| 1201 | if (str->pos == ins->pos) { |
|---|
| 1202 | inserts[i++] = ins->base; |
|---|
| 1203 | cntr++; |
|---|
| 1204 | } |
|---|
| 1205 | } |
|---|
| 1206 | if (cntr>0) { |
|---|
| 1207 | inserts[i] = '\0'; |
|---|
| 1208 | char buffer[strlen(inserts) + 10]; |
|---|
| 1209 | sprintf(buffer, "%d:%s", cntr, inserts); |
|---|
| 1210 | GRAPHICS->PrintString(str->x, str->y+spacer, str->z, |
|---|
| 1211 | buffer, GLUT_BITMAP_8_BY_13); |
|---|
| 1212 | |
|---|
| 1213 | iTotalIns += cntr; // Summing up the insertions |
|---|
| 1214 | } |
|---|
| 1215 | } |
|---|
| 1216 | } |
|---|
| 1217 | glEndList(); |
|---|
| 1218 | |
|---|
| 1219 | #ifdef DEBUG |
|---|
| 1220 | cout<<"Insertions = "<<iTotalIns<<endl; |
|---|
| 1221 | #endif |
|---|
| 1222 | |
|---|
| 1223 | glNewList(MAP_SPECIES_INSERTION_BASES_ANCHOR, GL_COMPILE); |
|---|
| 1224 | { |
|---|
| 1225 | glLineWidth(1.0); |
|---|
| 1226 | glBegin(GL_LINES); |
|---|
| 1227 | |
|---|
| 1228 | for (str = start3D; str; str = str->next) { |
|---|
| 1229 | for (ins = startIns; ins; ins = ins->next) { |
|---|
| 1230 | if (str->pos == ins->pos) { |
|---|
| 1231 | glVertex3f(str->x, str->y, str->z); |
|---|
| 1232 | glVertex3f(str->x, str->y+spacer, str->z); |
|---|
| 1233 | } |
|---|
| 1234 | } |
|---|
| 1235 | } |
|---|
| 1236 | glEnd(); |
|---|
| 1237 | } |
|---|
| 1238 | glEndList(); |
|---|
| 1239 | |
|---|
| 1240 | glNewList(MAP_SPECIES_INSERTION_POINTS, GL_COMPILE); |
|---|
| 1241 | { |
|---|
| 1242 | if (RNA3D->bPointSpritesSupported) { |
|---|
| 1243 | glBegin(GL_POINTS); |
|---|
| 1244 | } |
|---|
| 1245 | for (str = start3D; str; str = str->next) { |
|---|
| 1246 | for (ins = startIns; ins; ins = ins->next) { |
|---|
| 1247 | if (str->pos == ins->pos) { |
|---|
| 1248 | PointsToQuads(str->x, str->y, str->z); |
|---|
| 1249 | break; |
|---|
| 1250 | } |
|---|
| 1251 | } |
|---|
| 1252 | } |
|---|
| 1253 | if (RNA3D->bPointSpritesSupported) { |
|---|
| 1254 | glEnd(); |
|---|
| 1255 | } |
|---|
| 1256 | } |
|---|
| 1257 | glEndList(); |
|---|
| 1258 | } |
|---|
| 1259 | |
|---|
| 1260 | void Structure3D::MapCurrentSpeciesToEcoliTemplate(AW_root *awr) { |
|---|
| 1261 | |
|---|
| 1262 | GB_push_transaction(gb_main); |
|---|
| 1263 | |
|---|
| 1264 | GBDATA *gbTemplate = GBT_find_SAI(gb_main, "ECOLI"); |
|---|
| 1265 | |
|---|
| 1266 | if (!gbTemplate) { |
|---|
| 1267 | aw_message("SAI:ECOLI not found"); |
|---|
| 1268 | } |
|---|
| 1269 | else { |
|---|
| 1270 | char *pSpeciesName = awr->awar(AWAR_SPECIES_NAME)->read_string(); |
|---|
| 1271 | if (pSpeciesName) { |
|---|
| 1272 | Host.announce_current_species(pSpeciesName); |
|---|
| 1273 | GBDATA *gbSpecies = GBT_find_species(gb_main, pSpeciesName); |
|---|
| 1274 | if (gbSpecies) { |
|---|
| 1275 | char *ali_name = GBT_get_default_alignment(gb_main); |
|---|
| 1276 | GBDATA *gbAlignment = GB_entry(gbTemplate, ali_name); |
|---|
| 1277 | GBDATA *gbTemplateSeqData = gbAlignment ? GB_entry(gbAlignment, "data") : NULp; |
|---|
| 1278 | |
|---|
| 1279 | if (!gbTemplateSeqData) { |
|---|
| 1280 | aw_message(GBS_global_string("Mapping impossible, since SAI:ECOLI has no data in alignment '%s'", ali_name)); |
|---|
| 1281 | } |
|---|
| 1282 | else { |
|---|
| 1283 | const char *pTemplateSeqData = GB_read_char_pntr(gbTemplateSeqData); |
|---|
| 1284 | |
|---|
| 1285 | if (!RNA3D->bEColiRefInitialized) { |
|---|
| 1286 | EColiRef = new BI_ecoli_ref; |
|---|
| 1287 | EColiRef->init(gb_main); |
|---|
| 1288 | RNA3D->bEColiRefInitialized = true; |
|---|
| 1289 | } |
|---|
| 1290 | |
|---|
| 1291 | char buf[100]; |
|---|
| 1292 | char *pSpFullName = GB_read_string(GB_entry(gbSpecies, "full_name")); |
|---|
| 1293 | sprintf(buf, "%s : %s", pSpeciesName, pSpFullName); |
|---|
| 1294 | awr->awar(AWAR_3D_SELECTED_SPECIES)->write_string(buf); |
|---|
| 1295 | |
|---|
| 1296 | GBDATA *gbSeqData = GBT_find_sequence(gbSpecies, ali_name); |
|---|
| 1297 | const char *pSeqData = GB_read_char_pntr(gbSeqData); |
|---|
| 1298 | |
|---|
| 1299 | if (pSeqData && pTemplateSeqData) { |
|---|
| 1300 | int iSeqLen = strlen(pTemplateSeqData); |
|---|
| 1301 | |
|---|
| 1302 | if (bOldSpeciesDataExists) { |
|---|
| 1303 | DeleteOldSpeciesData(); |
|---|
| 1304 | } |
|---|
| 1305 | |
|---|
| 1306 | for (int i = 0, iSeqCount = 0; i<iSeqLen; i++) { |
|---|
| 1307 | if (!is_Gap(pTemplateSeqData[i])) { |
|---|
| 1308 | if (!bStartPosStored) { |
|---|
| 1309 | iStartPos = i; |
|---|
| 1310 | bStartPosStored = true; |
|---|
| 1311 | } |
|---|
| 1312 | if (pTemplateSeqData[i] != pSeqData[i]) { |
|---|
| 1313 | StoreCurrSpeciesDifference(pSeqData[i], iSeqCount); |
|---|
| 1314 | } |
|---|
| 1315 | iSeqCount++; |
|---|
| 1316 | } |
|---|
| 1317 | } |
|---|
| 1318 | |
|---|
| 1319 | for (int i = iSeqLen; i>0; i--) { |
|---|
| 1320 | if (!is_Gap(pTemplateSeqData[i])) { |
|---|
| 1321 | if (!bEndPosStored) { |
|---|
| 1322 | iEndPos = i; |
|---|
| 1323 | bEndPosStored = true; |
|---|
| 1324 | break; |
|---|
| 1325 | } |
|---|
| 1326 | } |
|---|
| 1327 | } |
|---|
| 1328 | |
|---|
| 1329 | if (bOldInsertionDataExists) { |
|---|
| 1330 | DeleteOldInsertionData(); |
|---|
| 1331 | } |
|---|
| 1332 | |
|---|
| 1333 | for (int i = iStartPos, iSeqCount = 0; i < iEndPos; i++) { |
|---|
| 1334 | if (!is_Gap(pTemplateSeqData[i])) { |
|---|
| 1335 | // Store EColi base positions : Insertion point! |
|---|
| 1336 | iSeqCount++; |
|---|
| 1337 | } |
|---|
| 1338 | |
|---|
| 1339 | if ((pTemplateSeqData[i] == '-') && !is_Gap(pSeqData[i])) { |
|---|
| 1340 | StoreInsertions(pSeqData[i], iSeqCount); |
|---|
| 1341 | } |
|---|
| 1342 | } |
|---|
| 1343 | } |
|---|
| 1344 | free(pSpFullName); |
|---|
| 1345 | } |
|---|
| 1346 | free(ali_name); |
|---|
| 1347 | } |
|---|
| 1348 | GenerateBaseDifferenceDisplayList(); |
|---|
| 1349 | GenerateInsertionDisplayList(); |
|---|
| 1350 | } |
|---|
| 1351 | free(pSpeciesName); |
|---|
| 1352 | } |
|---|
| 1353 | GB_pop_transaction(gb_main); |
|---|
| 1354 | } |
|---|
| 1355 | |
|---|
| 1356 | static bool ValidSearchColor(int iColor, int mode) { |
|---|
| 1357 | bool isValid = false; |
|---|
| 1358 | |
|---|
| 1359 | switch (mode) { |
|---|
| 1360 | case SAI: isValid = (iColor >= RNA3D_GC_CBACK_0) && (iColor < RNA3D_GC_MAX); break; |
|---|
| 1361 | case SEARCH: isValid = (iColor >= RNA3D_GC_SBACK_0) && (iColor < RNA3D_GC_MAX); break; |
|---|
| 1362 | } |
|---|
| 1363 | return isValid; |
|---|
| 1364 | } |
|---|
| 1365 | |
|---|
| 1366 | void Structure3D::MapSearchStringsToEcoliTemplate(AW_root * /* awr */) { |
|---|
| 1367 | const char *pSearchColResults = NULp; |
|---|
| 1368 | |
|---|
| 1369 | if (iMapSearch) pSearchColResults = Host.get_search_background(iStartPos, iEndPos); |
|---|
| 1370 | |
|---|
| 1371 | if (pSearchColResults) { |
|---|
| 1372 | int iColor = 0; |
|---|
| 1373 | |
|---|
| 1374 | glNewList(MAP_SEARCH_STRINGS_TO_STRUCTURE, GL_COMPILE); |
|---|
| 1375 | { |
|---|
| 1376 | if (RNA3D->bPointSpritesSupported) glBegin(GL_POINTS); |
|---|
| 1377 | for (int i = iStartPos; i < iEndPos; i++) { |
|---|
| 1378 | if (RNA3D->bEColiRefInitialized) { |
|---|
| 1379 | long absPos = (long) i; |
|---|
| 1380 | long EColiPos = EColiRef->abs_2_rel(absPos); |
|---|
| 1381 | |
|---|
| 1382 | for (Struct3Dinfo *t = start3D; t; t = t->next) { |
|---|
| 1383 | if ((t->pos == EColiPos) && (pSearchColResults[i] >= 0)) { |
|---|
| 1384 | iColor = pSearchColResults[i] - COLORLINK; |
|---|
| 1385 | |
|---|
| 1386 | if (ValidSearchColor(iColor, SEARCH)) { |
|---|
| 1387 | RNA3D->cGraphics->SetColor(iColor); |
|---|
| 1388 | PointsToQuads(t->x, t->y, t->z); |
|---|
| 1389 | } |
|---|
| 1390 | break; |
|---|
| 1391 | } |
|---|
| 1392 | } |
|---|
| 1393 | } |
|---|
| 1394 | } |
|---|
| 1395 | if (RNA3D->bPointSpritesSupported) glEnd(); |
|---|
| 1396 | } |
|---|
| 1397 | glEndList(); |
|---|
| 1398 | |
|---|
| 1399 | glNewList(MAP_SEARCH_STRINGS_BACKBONE, GL_COMPILE); |
|---|
| 1400 | { |
|---|
| 1401 | int iLastClr = 0; int iLastPos = 0; Vector3 vLastPt; |
|---|
| 1402 | glBegin(GL_LINES); |
|---|
| 1403 | for (int i = iStartPos; i < iEndPos; i++) { |
|---|
| 1404 | if (RNA3D->bEColiRefInitialized) { |
|---|
| 1405 | long absPos = (long) i; |
|---|
| 1406 | long EColiPos = EColiRef->abs_2_rel(absPos); |
|---|
| 1407 | |
|---|
| 1408 | for (Struct3Dinfo *t = start3D; t; t = t->next) { |
|---|
| 1409 | if ((t->pos == EColiPos) && (pSearchColResults[i] >= 0)) { |
|---|
| 1410 | iColor = pSearchColResults[i] - COLORLINK; |
|---|
| 1411 | |
|---|
| 1412 | if (ValidSearchColor(iColor, SEARCH)) { |
|---|
| 1413 | if ((iLastClr == iColor) && (iLastPos == EColiPos-1)) { |
|---|
| 1414 | RNA3D->cGraphics->SetColor(iColor); |
|---|
| 1415 | glVertex3f(vLastPt.x, vLastPt.y, vLastPt.z); |
|---|
| 1416 | glVertex3f(t->x, t->y, t->z); |
|---|
| 1417 | } |
|---|
| 1418 | iLastPos = EColiPos; |
|---|
| 1419 | iLastClr = iColor; |
|---|
| 1420 | vLastPt.x = t->x; vLastPt.y = t->y; vLastPt.z = t->z; |
|---|
| 1421 | } |
|---|
| 1422 | break; |
|---|
| 1423 | } |
|---|
| 1424 | } |
|---|
| 1425 | } |
|---|
| 1426 | } |
|---|
| 1427 | glEnd(); |
|---|
| 1428 | } |
|---|
| 1429 | glEndList(); |
|---|
| 1430 | |
|---|
| 1431 | RNA3D->bMapSearchStringsDispListCreated = true; |
|---|
| 1432 | } |
|---|
| 1433 | else cout<<"BuildColorString did not get the colors : SAI cannot be Visualized!"<<endl; |
|---|
| 1434 | } |
|---|
| 1435 | |
|---|
| 1436 | void Structure3D::MapSaiToEcoliTemplate() { |
|---|
| 1437 | const char *pSearchColResults = NULp; |
|---|
| 1438 | |
|---|
| 1439 | if (iMapSAI && Host.SAIs_visualized()) { |
|---|
| 1440 | pSearchColResults = Host.get_SAI_background(iStartPos, iEndPos); // returns 0 if sth went wrong |
|---|
| 1441 | } |
|---|
| 1442 | |
|---|
| 1443 | if (pSearchColResults) { |
|---|
| 1444 | int iColor = 0; |
|---|
| 1445 | |
|---|
| 1446 | glNewList(MAP_SAI_TO_STRUCTURE, GL_COMPILE); |
|---|
| 1447 | { |
|---|
| 1448 | if (RNA3D->bPointSpritesSupported) glBegin(GL_POINTS); |
|---|
| 1449 | |
|---|
| 1450 | for (int i = iStartPos; i < iEndPos; i++) { |
|---|
| 1451 | if (RNA3D->bEColiRefInitialized) { |
|---|
| 1452 | long absPos = (long) i; |
|---|
| 1453 | long EColiPos = EColiRef->abs_2_rel(absPos); |
|---|
| 1454 | |
|---|
| 1455 | for (Struct3Dinfo *t = start3D; t; t = t->next) { |
|---|
| 1456 | if ((t->pos == EColiPos) && (pSearchColResults[i] >= 0)) { |
|---|
| 1457 | iColor = pSearchColResults[i-1] - SAICOLORS; |
|---|
| 1458 | |
|---|
| 1459 | if (ValidSearchColor(iColor, SAI)) { |
|---|
| 1460 | RNA3D->cGraphics->SetColor(iColor); |
|---|
| 1461 | PointsToQuads(t->x, t->y, t->z); |
|---|
| 1462 | } |
|---|
| 1463 | break; |
|---|
| 1464 | } |
|---|
| 1465 | } |
|---|
| 1466 | } |
|---|
| 1467 | } |
|---|
| 1468 | |
|---|
| 1469 | if (RNA3D->bPointSpritesSupported) glEnd(); |
|---|
| 1470 | } |
|---|
| 1471 | glEndList(); |
|---|
| 1472 | |
|---|
| 1473 | RNA3D->bMapSaiDispListCreated = true; |
|---|
| 1474 | } |
|---|
| 1475 | else cout<<"ED4_getSaiColorString did not get the colors : SAI cannot be Visualized!"<<endl; |
|---|
| 1476 | } |
|---|