#include #include #include /******************************************************************************/ #define TRUE 1 #define FALSE 0 #define FILE_NAME_SZ 81 #define HYDRO_CHARGE_TB "cnnrchrg.hyd" #define HYDRO_CHARGE_TB_SZ 21 #define RADIAN (3.14159265/180) #define LINE_SZ 101 #define MARGIN 6 #define MAX_PROTEIN_CNT 1000 #define AVE_SZ 2 /******************************************************************************/ typedef struct { float hydrophobicity, charge; char residue; } HydroCharge; typedef struct { char *pProt; float *pAveAlpha, *pAveBeta; } ResPos; /******************************************************************************/ static HydroCharge hydroChargeTb[HYDRO_CHARGE_TB_SZ]; static ResPos protArray[MAX_PROTEIN_CNT]; static int protCnt, longestProt; /******************************************************************************/ CleanUp() { int i; if (protCnt > 0) { for (i=0; i 0) break; } return winSz; } int GetProtCnt(fp) FILE *fp; { int cnt; char line[LINE_SZ]; cnt = 0; for (;;) { GetLine(fp, line); if (strlen(line) < 5 || strstr(line, "-- Results --") != NULL) break; else cnt++; } return cnt; } int GetLongestProteinLength(fp) FILE *fp; { char line[LINE_SZ]; int cnt; cnt = 0; for (;;) { GetLine(fp, line); if (strstr(line, "-- Results --") != NULL) break; cnt = cnt + ((strlen(line) - MARGIN) / 2); for (;;) { GetLine(fp, line); if (strstr(line, "-- Results --") != NULL) return cnt; if (strlen(line) < 5 || feof(fp)) break; } } return cnt; } int GetProtArray(fp) FILE *fp; { char line[LINE_SZ]; long curPos; int i,j, cnt1, cnt2; if (!FindLine(fp, "gap penalty")) { printf("The input file is not the correct output of ree program.\n"); return FALSE; } GetLine(fp, line); /* Skip a blank line */ curPos = ftell(fp); protCnt = GetProtCnt(fp); fseek(fp, curPos, 0); longestProt = GetLongestProteinLength(fp); fseek(fp, curPos, 0); for (i=0; i winSz/2) fprintf(fp, "%1.2f ", (aveBeta + prevAveBeta) / 2); else fprintf(fp, "0.0 "); fprintf(fp, "%2.f\n", (float) nonGapCnt*100.0/protCnt); prevAveBeta = aveBeta; } } main() { FILE *fpProtein, *fpOutput; float alphaAngle, betaAngle; int winSz, i; protCnt = 0; for (i=0; i