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)
44 if (!fname)
throw string(
"file not found: ")+name;
50 string error =
string(
"IO-Error: ")+strerror(errno)+
" ('"+filename+
"')";
57 : strCen(new
Vector3(0.0, 0.0, 0.0)),
73 GRAPHICS(new OpenGLGraphics)
112 error =
"SAI:ECOLI not found";
123 if (!gbTemplateSeqData) {
124 error =
"Could not find ECOLI sequence data in the database!";
128 int iSeqLen = strlen(pTemplateSeqData);
130 for (
int i = 0; i<iSeqLen; i++) {
131 if (!
is_Gap(pTemplateSeqData[i])) {
136 if (iBaseCount > 2000) rnaType =
LSU_23S;
137 else if (iBaseCount > 300) rnaType =
SSU_16S;
157 for (data = start2D; data; data = tmp) {
167 for (data = start2D3D; data; data = tmp) {
177 for (data = start3D; data; data = tmp) {
187 for (data = start; data; data = tmp) {
206 static char *DataFile =
NULp;
216 sprintf(globalComment,
"The 3D molecule rendered from PDB entry : 1PNU at 8.7 Angstrom.");
220 sprintf(globalComment,
"The 3D molecule is rendered from PDB entry [1VOR] with 11.5 Angstrom resolution.");
224 sprintf(globalComment,
"The 3D molecule is rendered from PDB entry [1C2W] with 7.5 Angstrom resolution.");
230 sprintf(globalComment,
"The 3D molecule is rendered from PDB entry [1C2X] with 7.5 Angstrom resolution.");
234 sprintf(globalComment,
"The 3D molecule is rendered from PDB entry [1M5G] with 11.5 Angstrom resolution.");
239 readData.open(DataFile, ios::in);
240 if (!readData.is_open()) {
245 unsigned int last3Dpos = 0;
246 static bool bEColiStartPosStored =
false;
248 while (!readData.eof()) {
250 readData.getline(buf, 100);
253 if ((line.find(
"ATOM") != string::npos) || (line.find(
"HETATM") != string::npos)) {
254 string atom = line.substr(77, 2);
255 if (atom.find(
"P") != string::npos) {
256 char base = line[19];
257 unsigned pos = atoi(line.substr(22, 4).c_str());
262 if (last3Dpos != pos && !(pos >= 3093)) {
263 float X = atof(line.substr(31, 8).c_str());
264 float Y = atof(line.substr(39, 8).c_str());
265 float Z = atof(line.substr(47, 8).c_str());
272 if (!bEColiStartPosStored) {
274 bEColiStartPosStored =
true;
281 cout<<
"--------------------------------------------------"<<endl
282 <<globalComment<<endl
285 <<
"---------------------------------------------------"<<endl;
299 data->
base = info[0];
300 data->
mask = info[1];
301 data->
code = info[2];
323 static char *DataFile =
NULp;
328 DataFile =
find_data_file(
"SecondaryStructureModel_23SrRNA.data");
334 DataFile =
find_data_file(
"SecondaryStructureModel_16SrRNA.data");
345 bool insideHelix =
false;
349 readData.open(DataFile, ios::in);
350 if (!readData.is_open()) {
354 while (!readData.eof()) {
355 readData.getline(buf, 100);
357 tmp = strtok(buf,
" ");
358 for (
int i = 0; tmp; tmp = strtok(
NULp,
" "), i++) {
360 case 0: pos = atoi(tmp);
break;
361 case 1: info[0] = tmp[0];
break;
362 case 2: info[1] = tmp[0];
break;
363 case 3: info[2] = tmp[0];
break;
364 case 4: helixNr = atoi(tmp);
break;
368 bool is_SE = (info[2] ==
'S') || (info[2] ==
'E');
370 if (helixNr>0) lastHelixNr = helixNr;
372 if (!insideHelix) insideHelix =
true;
379 if (insideHelix)
Store2Dinfo(info, pos, lastHelixNr);
381 if (skip) skip =
false;
420 cout<<
"Missing Base Positions : "<<endl;
424 while (temp3D && temp2D) {
425 if (temp2D->
pos == temp3D->
pos) {
429 while (temp2D->
pos != temp3D->
pos) {
430 cout<<temp2D->
pos<<
", ";
432 temp2D = temp2D->
next;
437 temp3D = temp3D->
next;
438 temp2D = temp2D->
next;
440 cout<<endl<<
"Total No. of bases missing = "<<cntr<<endl;
446 sprintf(buf,
"Total No. of bases missing = %d. See the console messages for the actual missing base positions.", cntr);
447 strcat(globalComment, buf);
459 glTexCoord2f(0, 0); glVertex3f(x - 1, y + 1, z + 1);
460 glTexCoord2f(1, 0); glVertex3f(x + 1, y + 1, z + 1);
461 glTexCoord2f(1, 1); glVertex3f(x + 1, y - 1, z + 1);
462 glTexCoord2f(0, 1); glVertex3f(x - 1, y - 1, z + 1);
465 glTexCoord2f(0, 0); glVertex3f(x + 1, y + 1, z - 1);
466 glTexCoord2f(1, 0); glVertex3f(x - 1, y + 1, z - 1);
467 glTexCoord2f(1, 1); glVertex3f(x - 1, y - 1, z - 1);
468 glTexCoord2f(0, 1); glVertex3f(x + 1, y - 1, z - 1);
471 glTexCoord2f(0, 0); glVertex3f(x + 1, y + 1, z + 1);
472 glTexCoord2f(1, 0); glVertex3f(x - 1, y + 1, z + 1);
473 glTexCoord2f(1, 1); glVertex3f(x - 1, y + 1, z - 1);
474 glTexCoord2f(0, 1); glVertex3f(x + 1, y + 1, z - 1);
477 glTexCoord2f(0, 0); glVertex3f(x + 1, y - 1, z - 1);
478 glTexCoord2f(1, 0); glVertex3f(x - 1, y - 1, z - 1);
479 glTexCoord2f(1, 1); glVertex3f(x - 1, y - 1, z + 1);
480 glTexCoord2f(0, 1); glVertex3f(x + 1, y - 1, z + 1);
483 glTexCoord2f(0, 0); glVertex3f(x + 1, y + 1, z + 1);
484 glTexCoord2f(1, 0); glVertex3f(x + 1, y + 1, z - 1);
485 glTexCoord2f(1, 1); glVertex3f(x + 1, y - 1, z - 1);
486 glTexCoord2f(0, 1); glVertex3f(x + 1, y - 1, z + 1);
489 glTexCoord2f(0, 0); glVertex3f(x - 1, y + 1, z - 1);
490 glTexCoord2f(1, 0); glVertex3f(x - 1, y + 1, z + 1);
491 glTexCoord2f(1, 1); glVertex3f(x - 1, y - 1, z + 1);
492 glTexCoord2f(0, 1); glVertex3f(x - 1, y - 1, z - 1);
502 glNewList(listID, GL_COMPILE);
507 for (
int i = 0; i < len; i++) {
511 if (t->
pos == tmpPos) {
527 const int MAX_BASE = 1000;
528 int baseA[MAX_BASE], baseG[MAX_BASE], baseC[MAX_BASE], baseU[MAX_BASE];
529 int a, g, c, u; a=g=c=u=0;
536 case 'A': baseA[a++] = t->
pos;
break;
537 case 'G': baseG[g++] = t->
pos;
break;
538 case 'C': baseC[c++] = t->
pos;
break;
539 case 'U': baseU[u++] = t->
pos;
break;
554 const int MAX_BASE = 1000;
555 int baseA[MAX_BASE], baseG[MAX_BASE], baseC[MAX_BASE], baseU[MAX_BASE];
556 int a, g, c, u; a=g=c=u=0;
562 if ((t->
mask ==
'[') || (t->
mask ==
']') || (t->
mask ==
'<') || (t->
mask ==
'>')) {
564 case 'A': baseA[a++] = t->
pos;
break;
565 case 'G': baseG[g++] = t->
pos;
break;
566 case 'C': baseC[c++] = t->
pos;
break;
567 case 'U': baseU[u++] = t->
pos;
break;
583 const int MAX_BASE = 500;
584 int baseA[MAX_BASE], baseG[MAX_BASE], baseC[MAX_BASE], baseU[MAX_BASE];
585 int a, g, c, u; a=g=c=u=0;
591 if (t->
mask ==
'.') {
593 case 'A': baseA[a++] = t->
pos;
break;
594 case 'G': baseG[g++] = t->
pos;
break;
595 case 'C': baseC[c++] = t->
pos;
break;
596 case 'U': baseU[u++] = t->
pos;
break;
620 static char *DataFile =
NULp;
628 cout<<
"There are no tertiary interactions observed in 5S rRNA model!"<<endl;
635 cout<<
"Tertiary Interactions are fetched from comparative RNA website [http://www.rna.icmb.utexas.edu]."<<endl
636 <<
"The same are located in the file \""<<DataFile<<
"\"."<<endl;
641 readData.open(DataFile, ios::in);
642 if (!readData.is_open()) {
650 while (!readData.eof()) {
651 readData.getline(buf, 100);
653 tmp = strtok(buf,
" ");
655 if (strcmp(tmp,
"KNOT") == 0) {
656 tmp = strtok(
NULp,
":");
659 tmp = strtok(
NULp,
":");
662 else if (strcmp(tmp,
"TRIPLE") == 0) {
663 tmp = strtok(
NULp,
":");
666 tmp = strtok(
NULp,
":");
675 for (
int i = 0; i < k;) {
677 for (
int j = 0; j < 2; j++) {
680 if (t->
pos == K[i]) {
681 glVertex3f(t->
x, t->
y, t->
z);
695 for (
int i = 0; i < r;) {
696 glBegin(GL_LINE_STRIP);
697 for (
int j = 0; j < 3; j++) {
700 if (t->
pos == R[i]) {
701 glVertex3f(t->
x, t->
y, t->
z);
743 int thisStrandPos[MAX], otherStrandPos[MAX];
748 if (temp2D->
helixNr == HELIX_NR) {
749 if ((temp2D->
mask ==
'[') || (temp2D->
mask ==
'<'))
750 thisStrandPos[i++] = temp2D->
pos;
751 if ((temp2D->
mask ==
']') || (temp2D->
mask ==
'>'))
752 otherStrandPos[j++] = temp2D->
pos;
754 temp2D = temp2D->
next;
759 float x1, x2, y1, y2, z1, z2; x1=x2=y1=y2=z1=z2=0.0;
761 bool bThisStrand, bOtherStrand;
762 bThisStrand = bOtherStrand =
false;
764 bool bMissingBasePair =
false;
766 glNewList(HELIX_NR_ID, GL_COMPILE);
768 for (
int k = 0, l = j-1; k < i && l >= 0; k++, l--) {
769 tempPos = thisStrandPos[k];
773 if (temp2D3D->
pos == tempPos) {
775 x1=temp2D3D->
x; y1=temp2D3D->
y; z1=temp2D3D->
z;
778 temp2D3D = temp2D3D->
next;
781 tempPos = otherStrandPos[l];
785 if (temp2D3D->
pos == tempPos) {
787 x2=temp2D3D->
x; y2=temp2D3D->
y; z2=temp2D3D->
z;
790 temp2D3D = temp2D3D->
next;
795 if (bThisStrand && bOtherStrand) {
796 glVertex3f(x1, y1, z1);
797 glVertex3f(x2, y2, z2);
799 x1 = (x1+x2)/2; y1 = (y1+y2)/2; z1 = (z1+z2)/2;
802 bThisStrand = bOtherStrand =
false;
805 bMissingBasePair =
true;
806 cout<<thisStrandPos[k]<<
"-"<<tempPos<<
"("<<HELIX_NR_ID<<
"), ";
809 if (bMissingBasePair) cout<<endl;
820 for (
int i = startHx; i <= endHx; i++) {
824 sprintf(POS,
"%d", t->
helixNr);
825 GRAPHICS->PrintString(t->
x, t->
y, t->
z, POS, GLUT_BITMAP_8_BY_13);
838 for (
int i = startHx; i <= endHx; i++) {
863 for (
int i = 1; i <= 50; i++) {
869 cout<<
"=========================================================="<<endl
870 <<
"Missing base pairs (bracket number indicates helix number) "<<endl;
872 for (
int i = 1; i <= 101; i++) {
876 cout<<
"=========================================================="<<endl;
880 for (
int i = 1; i <= 5; i++) {
899 glBegin(GL_LINE_STRIP);
902 glVertex3f(t->
x, t->
y, t->
z);
911 glBegin(GL_LINE_STRIP);
915 if ((t->
mask ==
'[') || (t->
mask ==
']') || (t->
mask ==
'<') || (t->
mask ==
'>')) {
917 glVertex3f(t->
x, t->
y, t->
z);
919 if (t->
mask ==
'.') {
921 glVertex3f(t->
x, t->
y, t->
z);
926 glVertex3f(t->
x, t->
y, t->
z);
943 if (temp->
pos == pos) {
945 cout<<
"Cursor Position : "<<pos<<endl;
947 glVertex3f(temp->
x, temp->
y, temp->
z);
963 if (posSkip <= 0) posSkip = 25;
969 if (temp->
pos%posSkip == 0) {
970 sprintf(POS,
"%d", temp->
pos);
971 GRAPHICS->PrintString(temp->
x-spacer, temp->
y, temp->
z-spacer, POS, GLUT_BITMAP_HELVETICA_10);
984 if (temp->
pos%posSkip == 0) {
985 glVertex3f(temp->
x, temp->
y, temp->
z);
986 glVertex3f(temp->
x-spacer, temp->
y, temp->
z-spacer);
1006 if (st->
pos == pos) {
1022 while (temp->
next) {
1036 for (data = startSp; data; data = tmp) {
1054 for (t = startSp; t; t = t->
next) {
1055 for (temp = start3D; temp; temp = temp->
next) {
1056 if (temp->
pos == t->
pos) {
1057 sprintf(POS,
"%d", temp->
pos);
1058 GRAPHICS->PrintString(temp->
x-spacer, temp->
y, temp->
z-spacer, POS, GLUT_BITMAP_8_BY_13);
1070 for (t = startSp; t; t = t->
next) {
1071 for (temp = start3D; temp; temp = temp->
next) {
1072 if (temp->
pos == t->
pos) {
1073 glVertex3f(temp->
x, temp->
y, temp->
z);
1074 glVertex3f(temp->
x-spacer, temp->
y, temp->
z-spacer);
1087 glNewList(listID, GL_COMPILE);
1092 for (
int i = 0; i < len; i++) {
1096 if (t->
pos == tmpPos) {
1129 const int MAX_BASE = 400;
1130 int baseA[MAX_BASE], baseG[MAX_BASE], baseC[MAX_BASE],
1131 baseU[MAX_BASE], deletion[MAX_BASE], miss[MAX_BASE];
1132 int a, g, c, u, d, m; a=g=c=u=d=m=0;
1138 case 'A': baseA[a++] = t->
pos;
break;
1139 case 'G': baseG[g++] = t->
pos;
break;
1140 case 'C': baseC[c++] = t->
pos;
break;
1141 case 'U': baseU[u++] = t->
pos;
break;
1142 case '-': deletion[d++] = t->
pos;
break;
1143 case '.': miss[m++] = t->
pos;
break;
1177 while (temp->
next) {
1187 for (data = startIns; data; data = tmp) {
1206 for (str = start3D;
str; str = str->
next) {
1208 for (ins = startIns; ins; ins = ins->
next) {
1209 if (str->
pos == ins->
pos) {
1210 inserts[i++] = ins->
base;
1216 char buffer[strlen(inserts) + 10];
1217 sprintf(buffer,
"%d:%s", cntr, inserts);
1218 GRAPHICS->PrintString(str->
x, str->
y+spacer, str->
z,
1219 buffer, GLUT_BITMAP_8_BY_13);
1236 for (str = start3D;
str; str = str->
next) {
1237 for (ins = startIns; ins; ins = ins->
next) {
1238 if (str->
pos == ins->
pos) {
1239 glVertex3f(str->
x, str->
y, str->
z);
1240 glVertex3f(str->
x, str->
y+spacer, str->
z);
1253 for (str = start3D;
str; str = str->
next) {
1254 for (ins = startIns; ins; ins = ins->
next) {
1255 if (str->
pos == ins->
pos) {
1275 error =
"SAI:ECOLI not found";
1291 if (!gbTemplateSeqData) {
1292 error =
GBS_global_string(
"Mapping impossible, since SAI:ECOLI has no data in alignment '%s'", ali_name);
1305 sprintf(buf,
"%s : %s", pSpeciesName, pSpFullName);
1311 if (pSeqData && pTemplateSeqData) {
1312 int iSeqLen = strlen(pTemplateSeqData);
1318 for (
int i = 0, iSeqCount = 0; i<iSeqLen; i++) {
1319 if (!
is_Gap(pTemplateSeqData[i])) {
1324 if (pTemplateSeqData[i] != pSeqData[i]) {
1331 for (
int i = iSeqLen; i>0; i--) {
1332 if (!
is_Gap(pTemplateSeqData[i])) {
1346 if (!
is_Gap(pTemplateSeqData[i])) {
1351 if ((pTemplateSeqData[i] ==
'-') && !
is_Gap(pSeqData[i])) {
1373 bool isValid =
false;
1383 const char *pSearchColResults =
NULp;
1387 if (pSearchColResults) {
1395 long absPos = (
long) i;
1399 if ((t->pos == EColiPos) && (pSearchColResults[i] >= 0)) {
1400 iColor = pSearchColResults[i] -
COLORLINK;
1417 int iLastClr = 0;
int iLastPos = 0;
Vector3 vLastPt;
1421 long absPos = (
long) i;
1425 if ((t->pos == EColiPos) && (pSearchColResults[i] >= 0)) {
1426 iColor = pSearchColResults[i] -
COLORLINK;
1429 if ((iLastClr == iColor) && (iLastPos == EColiPos-1)) {
1431 glVertex3f(vLastPt.
x, vLastPt.
y, vLastPt.
z);
1432 glVertex3f(t->x, t->y, t->z);
1434 iLastPos = EColiPos;
1436 vLastPt.
x = t->x; vLastPt.
y = t->y; vLastPt.
z = t->z;
1449 else cout<<
"BuildColorString did not get the colors : SAI cannot be Visualized!"<<endl;
1453 const char *pSearchColResults =
NULp;
1459 if (pSearchColResults) {
1468 long absPos = (
long) i;
1472 if ((t->pos == EColiPos) && (pSearchColResults[i] >= 0)) {
1473 iColor = pSearchColResults[i-1] -
SAICOLORS;
1491 else cout<<
"ED4_getSaiColorString did not get the colors : SAI cannot be Visualized!"<<endl;
static char * find_data_file(const char *name)
struct CurrSpecies * next
static void throw_IO_error(const char *filename) __ATTR__NORETURN
static bool bOldSpeciesDataExists
return string(buffer, length)
static Insertions * startIns
void GenerateDisplayLists()
void MapSearchStringsToEcoliTemplate(AW_root *awr)
GB_ERROR GB_end_transaction(GBDATA *gbd, GB_ERROR error)
static bool ValidSearchColor(int iColor, int mode)
void GenerateHelixDispLists(int HELIX_NR_ID, int HELIX_NR)
void DeleteOldInsertionData()
virtual bool SAIs_visualized() const =0
void GenerateBaseDifferenceDisplayList()
void DeleteOldMoleculeData()
const char * GBS_global_string(const char *templat,...)
static bool bStartPosStored
#define AWAR_3D_SELECTED_SPECIES
struct HelixNrInfo * next
void GenerateSecStructureUnpairedHelixRegions()
void GenerateHelixNrDispList(int startHx, int endHx)
void StoreCurrSpeciesDifference(char base, int pos)
struct Struct2Dinfo * next
void MapCurrentSpeciesToEcoliTemplate(AW_root *awr)
char buffer[MESSAGE_BUFFERSIZE]
GB_ERROR GB_push_transaction(GBDATA *gbd)
void GenerateMoleculeSkeleton()
void Store2D3Dinfo(Struct2Dinfo *s2D, Struct3Dinfo *s3D)
void DeleteOldSpeciesData()
static Struct2Dinfo * start2D
bool bEColiRefInitialized
virtual void announce_current_species(const char *species_name)=0
void ReadCoOrdinateFile()
static HelixNrInfo * start
GBDATA * GBT_find_SAI(GBDATA *gb_main, const char *name)
GB_ERROR GB_await_error()
static CurrSpecies * startSp
int abs_2_rel(int abs) const
void GenerateSecStructureNonHelixRegions()
static void error(const char *msg)
void BuildDisplayList(int listID, int *pos, int len)
bool bMapSearchStringsDispListCreated
void StoreHelixNrInfo(float x, float y, float z, int helixNr)
#define AWAR_SPECIES_NAME
void init(const char *seq, int size)
bool bMapSaiDispListCreated
void GenerateCursorPositionDispList(long pos)
char * read_string() const
AW_awar * awar(const char *awar)
struct Struct2Dplus3D * next
GBDATA * GBT_find_sequence(GBDATA *gb_species, const char *aliname)
virtual const char * get_search_background(int start, int end) const =0
static Struct3Dinfo * start3D
void GenerateInsertionDisplayList()
char * GB_lib_file(bool warn_when_not_found, const char *libprefix, const char *filename)
static int FindTypeOfRNA()
OpenGLGraphics * GRAPHICS
void MapSaiToEcoliTemplate()
static bool bOldInsertionDataExists
void PositionsToCoordinatesDispList(int listID, int *pos, int len)
virtual const char * get_SAI_background(int start, int end) const =0
void GenerateBaseDifferencePositionDisplayList()
struct Struct3Dinfo * next
char * GB_read_string(GBDATA *gbd)
static char globalComment[1000]
void Store2Dinfo(char *info, int pos, int helixNr)
void StoreCoordinates(float x, float y, float z, char base, unsigned int pos)
bool bPointSpritesSupported
void ComputeBasePositions()
bool is_std_gap(const char c)
GBDATA * GBT_find_species(GBDATA *gb_main, const char *name)
void PointsToQuads(float x, float y, float z)
void StoreInsertions(char base, int pos)
GB_ERROR write_string(const char *aw_string)
char * GBT_get_default_alignment(GBDATA *gb_main)
Structure3D(ED4_plugin_host &host_)
void GetSecondaryStructureInfo()
GB_CSTR GB_read_char_pntr(GBDATA *gbd)
static int info[maxsites+1]
void GenerateTertiaryInteractionsDispLists()
void GenerateSecStructureHelixRegions()
OpenGLGraphics * cGraphics
void Combine2Dand3DstructureInfo()
GBDATA * GB_entry(GBDATA *father, const char *key)
void aw_message_if(GB_ERROR error)
static bool bEndPosStored
static Struct2Dplus3D * start2D3D