#include "affinityScore.h" // Computes the global affinity score for the proteins in msa // using the subsitution Matrix subMat AffinityScore::AffinityScore(Alignment msa, Matrix subMat) { int i, j, k, A, B=0; // int n, totNumRes=0; length = msa.maximumSequenceLength; val = new float[msa.maximumSequenceLength]; for(i=0;i-1 && B>-1) { val[i]+=subMat.cell[A][B]; } else { #if ADD_GAP_PENALTY if(A>-1 || B>-1) val[i]+=.5*subMat.minimumCellValue; #endif } } // Normalize Scores for(j=0; j-1 && B>-1) { val[i]+=subMat.cell[A][B]; } else { if(A>-1 || B>-1) if(ADD_GAP_PENALTY) val[i]+=.5*subMat.minimumCellValue; } } } } // Normalize Scores for(j=0; j-1) { // printf("%c %d %f \n", msa.sequences[n].residues[i],k+1, val[i]); // printf("%d %f \n", k+1, val[i]); k++; } } if(DB) printf("leaving AffinityScore::getSubN\n"); } // Copies the pdb file corresponding to AffinityScore::name and modifies its occupancy field // so that it is floor(100*AffinityScore) for each residue void AffinityScore::modifyPDB() { FILE * oPdbFile, *nPdbFile; char *temp = new char[MSL]; char *temp1 = new char[MSL]; char *temp2 = new char[MSL]; int n, old; strcpy(temp, "cp "); strcat(temp, PDB_PATH); strcat(temp, lower(subName)); strcat(temp, "* "); strcat(temp, lower(subName)); strcat(temp, ".pdb"); system(temp); strcat(temp, "2"); system(temp); strcpy(temp1, lower(subName)); strcat(temp1, ".pdb2"); strcpy(temp2, lower(subName)); strcat(temp2, ".pdb"); oPdbFile = fopen(temp1, "r"); nPdbFile = fopen(temp2, "w"); old = -99; int count = 0; while(fgets(temp, 500, oPdbFile)!=NULL) { if(strncmp(temp, "ATOM", 4)!=0) { fputs(temp, nPdbFile); } else { strcpy(temp1,temp+23); temp1[4] = '\0'; n = charToInt(temp1); if(n!=old) { old=n; count++; } // strcpy(temp1, intToString((int)floor(100*subVal[count-1]),5)); // strcpy(temp1, intToString(normVal(subVal[count-1]),5)); strcpy(temp1, intToString(normVal(val[count-1]),5)); for(int i=0; i<5; i++) temp[55+i] = temp1[i]; fputs(temp, nPdbFile); } } strcpy(temp2, "rm -f "); strcat(temp2, lower(subName)); strcat(temp2, ".pdb2"); system(temp2); delete[] temp; delete[] temp1; delete[] temp2; } // Computes the some stats for the affinity score int AffinityScore::normVal(float f) { if(f<-3*stdDev) return (int)floor(100*(-3*stdDev + avg)); if(f>3*stdDev) return (int)floor(100*(3*stdDev + avg)); return (int)floor(100*f); } // Prints the global affinity score calculated in the constructor void AffinityScore::print() { for(int i=0; i