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)),
119 if (!gbTemplateSeqData) {
120 aw_message(
"Could not find species in the database!");
124 int iSeqLen = strlen(pTemplateSeqData);
126 for (
int i = 0; i<iSeqLen; i++) {
127 if (!
is_Gap(pTemplateSeqData[i])) {
132 if (iBaseCount > 2000) rnaType =
LSU_23S;
133 else if (iBaseCount > 300) rnaType =
SSU_16S;
149 for (data = start2D; data; data = tmp) {
159 for (data = start2D3D; data; data = tmp) {
169 for (data = start3D; data; data = tmp) {
179 for (data = start; data; data = tmp) {
198 static char *DataFile =
NULp;
208 sprintf(globalComment,
"The 3D molecule rendered from PDB entry : 1PNU at 8.7 Angstrom.");
212 sprintf(globalComment,
"The 3D molecule is rendered from PDB entry [1VOR] with 11.5 Angstrom resolution.");
216 sprintf(globalComment,
"The 3D molecule is rendered from PDB entry [1C2W] with 7.5 Angstrom resolution.");
222 sprintf(globalComment,
"The 3D molecule is rendered from PDB entry [1C2X] with 7.5 Angstrom resolution.");
226 sprintf(globalComment,
"The 3D molecule is rendered from PDB entry [1M5G] with 11.5 Angstrom resolution.");
231 readData.open(DataFile, ios::in);
232 if (!readData.is_open()) {
237 unsigned int last3Dpos = 0;
238 static bool bEColiStartPosStored =
false;
240 while (!readData.eof()) {
242 readData.getline(buf, 100);
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());
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());
264 if (!bEColiStartPosStored) {
266 bEColiStartPosStored =
true;
273 cout<<
"--------------------------------------------------"<<endl
274 <<globalComment<<endl
277 <<
"---------------------------------------------------"<<endl;
291 data->
base = info[0];
292 data->
mask = info[1];
293 data->
code = info[2];
315 static char *DataFile =
NULp;
320 DataFile =
find_data_file(
"SecondaryStructureModel_23SrRNA.data");
326 DataFile =
find_data_file(
"SecondaryStructureModel_16SrRNA.data");
337 bool insideHelix =
false;
341 readData.open(DataFile, ios::in);
342 if (!readData.is_open()) {
346 while (!readData.eof()) {
347 readData.getline(buf, 100);
349 tmp = strtok(buf,
" ");
350 for (
int i = 0; tmp; tmp = strtok(
NULp,
" "), 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;
360 bool is_SE = (info[2] ==
'S') || (info[2] ==
'E');
362 if (helixNr>0) lastHelixNr = helixNr;
364 if (!insideHelix) insideHelix =
true;
371 if (insideHelix)
Store2Dinfo(info, pos, lastHelixNr);
373 if (skip) skip =
false;
412 cout<<
"Missing Base Positions : "<<endl;
416 while (temp3D && temp2D) {
417 if (temp2D->
pos == temp3D->
pos) {
421 while (temp2D->
pos != temp3D->
pos) {
422 cout<<temp2D->
pos<<
", ";
424 temp2D = temp2D->
next;
429 temp3D = temp3D->
next;
430 temp2D = temp2D->
next;
432 cout<<endl<<
"Total No. of bases missing = "<<cntr<<endl;
438 sprintf(buf,
"Total No. of bases missing = %d. See the console messages for the actual missing base positions.", cntr);
439 strcat(globalComment, buf);
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);
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);
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);
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);
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);
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);
494 glNewList(listID, GL_COMPILE);
499 for (
int i = 0; i < len; i++) {
503 if (t->
pos == tmpPos) {
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;
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;
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;
554 if ((t->
mask ==
'[') || (t->
mask ==
']') || (t->
mask ==
'<') || (t->
mask ==
'>')) {
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;
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;
583 if (t->
mask ==
'.') {
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;
612 static char *DataFile =
NULp;
620 cout<<
"There are no tertiary interactions observed in 5S rRNA model!"<<endl;
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;
633 readData.open(DataFile, ios::in);
634 if (!readData.is_open()) {
642 while (!readData.eof()) {
643 readData.getline(buf, 100);
645 tmp = strtok(buf,
" ");
647 if (strcmp(tmp,
"KNOT") == 0) {
648 tmp = strtok(
NULp,
":");
651 tmp = strtok(
NULp,
":");
654 else if (strcmp(tmp,
"TRIPLE") == 0) {
655 tmp = strtok(
NULp,
":");
658 tmp = strtok(
NULp,
":");
667 for (
int i = 0; i < k;) {
669 for (
int j = 0; j < 2; j++) {
672 if (t->
pos == K[i]) {
673 glVertex3f(t->
x, t->
y, t->
z);
687 for (
int i = 0; i < r;) {
688 glBegin(GL_LINE_STRIP);
689 for (
int j = 0; j < 3; j++) {
692 if (t->
pos == R[i]) {
693 glVertex3f(t->
x, t->
y, t->
z);
735 int thisStrandPos[MAX], otherStrandPos[MAX];
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;
746 temp2D = temp2D->
next;
751 float x1, x2, y1, y2, z1, z2; x1=x2=y1=y2=z1=z2=0.0;
753 bool bThisStrand, bOtherStrand;
754 bThisStrand = bOtherStrand =
false;
756 bool bMissingBasePair =
false;
758 glNewList(HELIX_NR_ID, GL_COMPILE);
760 for (
int k = 0, l = j-1; k < i && l >= 0; k++, l--) {
761 tempPos = thisStrandPos[k];
765 if (temp2D3D->
pos == tempPos) {
767 x1=temp2D3D->
x; y1=temp2D3D->
y; z1=temp2D3D->
z;
770 temp2D3D = temp2D3D->
next;
773 tempPos = otherStrandPos[l];
777 if (temp2D3D->
pos == tempPos) {
779 x2=temp2D3D->
x; y2=temp2D3D->
y; z2=temp2D3D->
z;
782 temp2D3D = temp2D3D->
next;
787 if (bThisStrand && bOtherStrand) {
788 glVertex3f(x1, y1, z1);
789 glVertex3f(x2, y2, z2);
791 x1 = (x1+x2)/2; y1 = (y1+y2)/2; z1 = (z1+z2)/2;
794 bThisStrand = bOtherStrand =
false;
797 bMissingBasePair =
true;
798 cout<<thisStrandPos[k]<<
"-"<<tempPos<<
"("<<HELIX_NR_ID<<
"), ";
801 if (bMissingBasePair) cout<<endl;
812 for (
int i = startHx; i <= endHx; i++) {
816 sprintf(POS,
"%d", t->
helixNr);
830 for (
int i = startHx; i <= endHx; i++) {
855 for (
int i = 1; i <= 50; i++) {
861 cout<<
"=========================================================="<<endl
862 <<
"Missing base pairs (bracket number indicates helix number) "<<endl;
864 for (
int i = 1; i <= 101; i++) {
868 cout<<
"=========================================================="<<endl;
872 for (
int i = 1; i <= 5; i++) {
891 glBegin(GL_LINE_STRIP);
894 glVertex3f(t->
x, t->
y, t->
z);
903 glBegin(GL_LINE_STRIP);
907 if ((t->
mask ==
'[') || (t->
mask ==
']') || (t->
mask ==
'<') || (t->
mask ==
'>')) {
909 glVertex3f(t->
x, t->
y, t->
z);
911 if (t->
mask ==
'.') {
913 glVertex3f(t->
x, t->
y, t->
z);
918 glVertex3f(t->
x, t->
y, t->
z);
935 if (temp->
pos == pos) {
937 cout<<
"Cursor Position : "<<pos<<endl;
939 glVertex3f(temp->
x, temp->
y, temp->
z);
955 if (posSkip <= 0) posSkip = 25;
961 if (temp->
pos%posSkip == 0) {
962 sprintf(POS,
"%d", temp->
pos);
976 if (temp->
pos%posSkip == 0) {
977 glVertex3f(temp->
x, temp->
y, temp->
z);
978 glVertex3f(temp->
x-spacer, temp->
y, temp->
z-spacer);
998 if (st->
pos == pos) {
1014 while (temp->
next) {
1028 for (data = startSp; data; data = tmp) {
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);
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);
1079 glNewList(listID, GL_COMPILE);
1084 for (
int i = 0; i < len; i++) {
1088 if (t->
pos == tmpPos) {
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;
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;
1169 while (temp->
next) {
1179 for (data = startIns; data; data = tmp) {
1198 for (str = start3D;
str; str = str->
next) {
1200 for (ins = startIns; ins; ins = ins->
next) {
1201 if (str->
pos == ins->
pos) {
1202 inserts[i++] = ins->
base;
1208 char buffer[strlen(inserts) + 10];
1209 sprintf(buffer,
"%d:%s", cntr, inserts);
1211 buffer, GLUT_BITMAP_8_BY_13);
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);
1245 for (str = start3D;
str; str = str->
next) {
1246 for (ins = startIns; ins; ins = ins->
next) {
1247 if (str->
pos == ins->
pos) {
1279 if (!gbTemplateSeqData) {
1293 sprintf(buf,
"%s : %s", pSpeciesName, pSpFullName);
1299 if (pSeqData && pTemplateSeqData) {
1300 int iSeqLen = strlen(pTemplateSeqData);
1306 for (
int i = 0, iSeqCount = 0; i<iSeqLen; i++) {
1307 if (!
is_Gap(pTemplateSeqData[i])) {
1312 if (pTemplateSeqData[i] != pSeqData[i]) {
1319 for (
int i = iSeqLen; i>0; i--) {
1320 if (!
is_Gap(pTemplateSeqData[i])) {
1334 if (!
is_Gap(pTemplateSeqData[i])) {
1339 if ((pTemplateSeqData[i] ==
'-') && !
is_Gap(pSeqData[i])) {
1357 bool isValid =
false;
1367 const char *pSearchColResults =
NULp;
1371 if (pSearchColResults) {
1379 long absPos = (
long) i;
1383 if ((t->pos == EColiPos) && (pSearchColResults[i] >= 0)) {
1384 iColor = pSearchColResults[i] -
COLORLINK;
1401 int iLastClr = 0;
int iLastPos = 0;
Vector3 vLastPt;
1405 long absPos = (
long) i;
1409 if ((t->pos == EColiPos) && (pSearchColResults[i] >= 0)) {
1410 iColor = pSearchColResults[i] -
COLORLINK;
1413 if ((iLastClr == iColor) && (iLastPos == EColiPos-1)) {
1415 glVertex3f(vLastPt.
x, vLastPt.
y, vLastPt.
z);
1416 glVertex3f(t->x, t->y, t->z);
1418 iLastPos = EColiPos;
1420 vLastPt.
x = t->x; vLastPt.
y = t->y; vLastPt.
z = t->z;
1433 else cout<<
"BuildColorString did not get the colors : SAI cannot be Visualized!"<<endl;
1437 const char *pSearchColResults =
NULp;
1443 if (pSearchColResults) {
1452 long absPos = (
long) i;
1456 if ((t->pos == EColiPos) && (pSearchColResults[i] >= 0)) {
1457 iColor = pSearchColResults[i-1] -
SAICOLORS;
1475 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)
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)
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)
GB_ERROR GB_pop_transaction(GBDATA *gbd)
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 aw_message(const char *msg)
void PrintString(float x, float y, float z, char *s, void *font)
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)
static bool bEndPosStored
static Struct2Dplus3D * start2D3D