2 /* Program COILS version 2.1 */
3 /* written by J.Lupas, 22 JUN 1993 */
4 /* edited on 15 JAN 1994 */
5 /* revised and corrected 4 APR 1994 */
6 /* incorporates the option to use either the old MTK chart or
7 the new MTIDK chart AND the choice of weighting positions
8 a & d more (2.5 times) */
10 - probabilities for window sizes 14, 21 & 28 in columns,
11 - probabilities for window sizes 14, 21 & 28 in rows,
12 - scores only for a user-input window size, or
13 - the probabilities above a user-input cutoff.
14 Requests input and output files from user. */
15 /* transferred to c++ by Larry Harvie, harvie@owl.WPI.EDU */
16 /* adapted to C by Reinhard Schneider, SCHNEIDER@EMBL-Heidelberg.DE */
18 /* Adapted by Rob Russell (SB) to make it less user friendly
19 * (UNIX command line options replace command line-driven commands)
20 * Also a FASTA output option: */
29 typedef double chartstore[21][8];
30 typedef char residuestore[10001];
31 typedef double calcstore[4][10001];
32 typedef int heptadstore[4][10001];
36 char inputfile[80],outputfile[80];
38 chartstore chartvalue; /* probability values */
39 residuestore residue; /* stores amino acid sequence */
40 heptadstore heptnum; /* stores heptad position number */
41 calcstore calcnumb; /* stores best scores */
42 int res_total; /* total no. of residues in protein */
43 char junkline[9000]; /* reads opening protein info. */
45 int nomore; /* in case there's junk after last protein */
48 char option,chartchar,weightchar;
55 char fr14[10001],fr21[10001],fr28[10001];
56 int pr14[10001],pr21[10001],pr28[10001];
58 short mod(short x,short y)
60 double x1=(double) x,y1=(double) y;
62 return (short) floor(fmod(x,y));
65 /* store the probability values for each of the 20
66 amino acids to occur in each of the heptad positions */
68 chartvalue[1][1]=2.998; chartvalue[1][2]=0.269; chartvalue[1][3]=0.367;
69 chartvalue[1][4]=3.852; chartvalue[1][5]=0.510; chartvalue[1][6]=0.514;
70 chartvalue[1][7]=0.562;
71 chartvalue[2][1]=2.408; chartvalue[2][2]=0.261; chartvalue[2][3]=0.345;
72 chartvalue[2][4]=0.931; chartvalue[2][5]=0.402; chartvalue[2][6]=0.440;
73 chartvalue[2][7]=0.289;
74 chartvalue[3][1]=1.525; chartvalue[3][2]=0.479; chartvalue[3][3]=0.350;
75 chartvalue[3][4]=0.887; chartvalue[3][5]=0.286; chartvalue[3][6]=0.350;
76 chartvalue[3][7]=0.362;
77 chartvalue[4][1]=2.161; chartvalue[4][2]=0.605; chartvalue[4][3]=0.442;
78 chartvalue[4][4]=1.441; chartvalue[4][5]=0.607; chartvalue[4][6]=0.457;
79 chartvalue[4][7]=0.570;
80 chartvalue[5][1]=0.490; chartvalue[5][2]=0.075; chartvalue[5][3]=0.391;
81 chartvalue[5][4]=0.639; chartvalue[5][5]=0.125; chartvalue[5][6]=0.081;
82 chartvalue[5][7]=0.038;
83 chartvalue[6][1]=1.319; chartvalue[6][2]=0.064; chartvalue[6][3]=0.081;
84 chartvalue[6][4]=1.526; chartvalue[6][5]=0.204; chartvalue[6][6]=0.118;
85 chartvalue[6][7]=0.096;
86 chartvalue[7][1]=0.084; chartvalue[7][2]=0.215; chartvalue[7][3]=0.432;
87 chartvalue[7][4]=0.111; chartvalue[7][5]=0.153; chartvalue[7][6]=0.367;
88 chartvalue[7][7]=0.125;
89 chartvalue[8][1]=1.283; chartvalue[8][2]=1.364; chartvalue[8][3]=1.077;
90 chartvalue[8][4]=2.219; chartvalue[8][5]=0.490; chartvalue[8][6]=1.265;
91 chartvalue[8][7]=0.903;
92 chartvalue[9][1]=1.233; chartvalue[9][2]=2.194; chartvalue[9][3]=1.817;
93 chartvalue[9][4]=0.611; chartvalue[9][5]=2.095; chartvalue[9][6]=1.686;
94 chartvalue[9][7]=2.027;
95 chartvalue[10][1]=1.014; chartvalue[10][2]=1.476; chartvalue[10][3]=1.771;
96 chartvalue[10][4]=0.114; chartvalue[10][5]=1.667; chartvalue[10][6]=2.006;
97 chartvalue[10][7]=1.844;
98 chartvalue[11][1]=0.590; chartvalue[11][2]=0.646; chartvalue[11][3]=0.584;
99 chartvalue[11][4]=0.842; chartvalue[11][5]=0.307; chartvalue[11][6]=0.611;
100 chartvalue[11][7]=0.396;
101 chartvalue[12][1]=0.281; chartvalue[12][2]=3.351; chartvalue[12][3]=2.998;
102 chartvalue[12][4]=0.789; chartvalue[12][5]=4.868; chartvalue[12][6]=2.735;
103 chartvalue[12][7]=3.812;
104 chartvalue[13][1]=0.068; chartvalue[13][2]=2.103; chartvalue[13][3]=1.646;
105 chartvalue[13][4]=0.182; chartvalue[13][5]=0.664; chartvalue[13][6]=1.581;
106 chartvalue[13][7]=1.401;
107 chartvalue[14][1]=0.311; chartvalue[14][2]=2.290; chartvalue[14][3]=2.330;
108 chartvalue[14][4]=0.811; chartvalue[14][5]=2.596; chartvalue[14][6]=2.155;
109 chartvalue[14][7]=2.585;
110 chartvalue[15][1]=1.231; chartvalue[15][2]=1.683; chartvalue[15][3]=2.157;
111 chartvalue[15][4]=0.197; chartvalue[15][5]=1.653; chartvalue[15][6]=2.430;
112 chartvalue[15][7]=2.065;
113 chartvalue[16][1]=0.332; chartvalue[16][2]=0.753; chartvalue[16][3]=0.930;
114 chartvalue[16][4]=0.424; chartvalue[16][5]=0.734; chartvalue[16][6]=0.801;
115 chartvalue[16][7]=0.518;
116 chartvalue[17][1]=0.197; chartvalue[17][2]=0.543; chartvalue[17][3]=0.647;
117 chartvalue[17][4]=0.680; chartvalue[17][5]=0.905; chartvalue[17][6]=0.643;
118 chartvalue[17][7]=0.808;
119 chartvalue[18][1]=0.918; chartvalue[18][2]=0.002; chartvalue[18][3]=0.385;
120 chartvalue[18][4]=0.440; chartvalue[18][5]=0.138; chartvalue[18][6]=0.432;
121 chartvalue[18][7]=0.079;
122 chartvalue[19][1]=0.066; chartvalue[19][2]=0.064; chartvalue[19][3]=0.065;
123 chartvalue[19][4]=0.747; chartvalue[19][5]=0.006; chartvalue[19][6]=0.115;
124 chartvalue[19][7]=0.014;
125 chartvalue[20][1]=0.004; chartvalue[20][2]=0.108; chartvalue[20][3]=0.018;
126 chartvalue[20][4]=0.006; chartvalue[20][5]=0.010; chartvalue[20][6]=0.004;
127 chartvalue[20][7]=0.007;
131 chartvalue[1][1]=3.167; chartvalue[1][2]=0.297;
132 chartvalue[1][3]=0.398;
133 chartvalue[1][4]=3.902; chartvalue[1][5]=0.585;
134 chartvalue[1][6]=0.501;
135 chartvalue[1][7]=0.483;
136 chartvalue[2][1]=2.597; chartvalue[2][2]=0.098;
137 chartvalue[2][3]=0.345;
138 chartvalue[2][4]=0.894; chartvalue[2][5]=0.514;
139 chartvalue[2][6]=0.471;
140 chartvalue[2][7]=0.431;
141 chartvalue[3][1]=1.665; chartvalue[3][2]=0.403;
142 chartvalue[3][3]=0.386;
143 chartvalue[3][4]=0.949; chartvalue[3][5]=0.211;
144 chartvalue[3][6]=0.342;
145 chartvalue[3][7]=0.360;
146 chartvalue[4][1]=2.240; chartvalue[4][2]=0.37;
147 chartvalue[4][3]=0.480;
148 chartvalue[4][4]=1.409; chartvalue[4][5]=0.541;
149 chartvalue[4][6]=0.772;
150 chartvalue[4][7]=0.663;
151 chartvalue[5][1]=0.531; chartvalue[5][2]=0.076;
152 chartvalue[5][3]=0.403;
153 chartvalue[5][4]=0.662; chartvalue[5][5]=0.189;
154 chartvalue[5][6]=0.106;
155 chartvalue[5][7]=0.013;
156 chartvalue[6][1]=1.417; chartvalue[6][2]=0.090;
157 chartvalue[6][3]=0.122;
158 chartvalue[6][4]=1.659; chartvalue[6][5]=0.19; chartvalue[6][6]=0.13;
159 chartvalue[6][7]=0.1550;
160 chartvalue[7][1]=0.045; chartvalue[7][2]=0.275;
161 chartvalue[7][3]=0.578;
162 chartvalue[7][4]=0.216; chartvalue[7][5]=0.211;
163 chartvalue[7][6]=0.426;
164 chartvalue[7][7]=0.156;
165 chartvalue[8][1]=1.297; chartvalue[8][2]=1.551;
166 chartvalue[8][3]=1.084;
167 chartvalue[8][4]=2.612; chartvalue[8][5]=0.377;
168 chartvalue[8][6]=1.248;
169 chartvalue[8][7]=0.877;
170 chartvalue[9][1]=1.375; chartvalue[9][2]=2.639;
171 chartvalue[9][3]=1.763;
172 chartvalue[9][4]=0.191; chartvalue[9][5]=1.815;
173 chartvalue[9][6]=1.961;
174 chartvalue[9][7]=2.795;
175 chartvalue[10][1]=0.659; chartvalue[10][2]=1.163;
176 chartvalue[10][3]=1.210;
177 chartvalue[10][4]=0.031; chartvalue[10][5]=1.358;
178 chartvalue[10][6]=1.937;
179 chartvalue[10][7]=1.798;
180 chartvalue[11][1]=0.347; chartvalue[11][2]=0.275;
181 chartvalue[11][3]=0.679;
182 chartvalue[11][4]=0.395; chartvalue[11][5]=0.294;
183 chartvalue[11][6]=0.579;
184 chartvalue[11][7]=0.213;
185 chartvalue[12][1]=0.262; chartvalue[12][2]=3.496;
186 chartvalue[12][3]=3.108;
187 chartvalue[12][4]=0.998; chartvalue[12][5]=5.685;
188 chartvalue[12][6]=2.494;
189 chartvalue[12][7]=3.048;
190 chartvalue[13][1]=0.03; chartvalue[13][2]=2.352;
191 chartvalue[13][3]=2.268;
192 chartvalue[13][4]=0.237; chartvalue[13][5]=0.663;
193 chartvalue[13][6]=1.62;
194 chartvalue[13][7]=1.448;
195 chartvalue[14][1]=0.179; chartvalue[14][2]=2.114;
196 chartvalue[14][3]=1.778;
197 chartvalue[14][4]=0.631; chartvalue[14][5]=2.55;
198 chartvalue[14][6]=1.578;
199 chartvalue[14][7]=2.526;
200 chartvalue[15][1]=0.835; chartvalue[15][2]=1.475;
201 chartvalue[15][3]=1.534;
202 chartvalue[15][4]=0.039; chartvalue[15][5]=1.722;
203 chartvalue[15][6]=2.456;
204 chartvalue[15][7]=2.280;
205 chartvalue[16][1]=0.382; chartvalue[16][2]=0.583;
206 chartvalue[16][3]=1.052;
207 chartvalue[16][4]=0.419; chartvalue[16][5]=0.525;
208 chartvalue[16][6]=0.916;
209 chartvalue[16][7]=0.628;
210 chartvalue[17][1]=0.169; chartvalue[17][2]=0.702;
211 chartvalue[17][3]=0.955;
212 chartvalue[17][4]=0.654; chartvalue[17][5]=0.791;
213 chartvalue[17][6]=0.843;
214 chartvalue[17][7]=0.647;
215 chartvalue[18][1]=0.824; chartvalue[18][2]=0.022;
216 chartvalue[18][3]=0.308;
217 chartvalue[18][4]=0.152; chartvalue[18][5]=0.180;
218 chartvalue[18][6]=0.156;
219 chartvalue[18][7]=0.044;
220 chartvalue[19][1]=0.24; chartvalue[19][2]=0;
221 chartvalue[19][3]=0.00;
222 chartvalue[19][4]=0.456; chartvalue[19][5]=0.019;
223 chartvalue[19][6]=0.00;
224 chartvalue[19][7]=0.00;
225 chartvalue[20][1]=0.00; chartvalue[20][2]=0.008; chartvalue[20][3]=0;
226 chartvalue[20][4]=0.013; chartvalue[20][5]=0.0; chartvalue[20][6]=0;
235 printf("COILS version 2.1\n");
236 printf("ENTER INPUT FILE: ");
238 scanf("%s",&inputfile[0]);
239 printf("-->%s\n",inputfile);
240 protein=fopen(inputfile,"r"); /* modify for reading */
243 printf("'%s' can not be found. Try again after verifying the file name.\n",inputfile);
247 printf("ENTER OUTPUT FILE: ");
248 scanf("%s",&outputfile[0]);
249 pickup=fopen(outputfile,"w");
251 printf("The system could not open the output file\n");
252 printf(". Check the free space on disk\n");
255 printf("Two scoring matrices are available:\n");
256 printf(" 1 - MTK\n");
257 printf(" 2 - MTIDK\n");
258 printf("Which matix? (1|2) <enter>? ");
260 while ((chartchar!='1') && (chartchar!='2') && (chartchar!=(char) 13))
261 scanf("%c",&chartchar);
262 printf("Do you want a weight of 2.5 for positions a & d? (Y|N) <enter>? ");
264 while ((weightchar!='n') && (weightchar!='y') && (weightchar!='Y') &&
265 (weightchar!='N') && (weightchar!=(char) 13))
266 scanf("%c",&weightchar);
268 if(verbose) fprintf(pickup,"COILS version 2.1\n");
271 if(verbose) fprintf(pickup,"using MTIDK matrix.\n");
274 if(verbose) fprintf(pickup,"using MTK matrix.\n");
277 if ((weightchar=='y') || (weightchar=='Y'))
279 if(verbose) fprintf(pickup,"weights: a,d=2.5 and b,c,e,f,g=1.0\n");
283 if(verbose) fprintf(pickup,"no weights\n");
288 if(inputfile[0]!='-') fprintf(pickup,"Input file is %s\n",inputfile);
289 else fprintf(pickup,"Reading from standard input\n");
294 printf("OUTPUT OPTIONS:\n");
295 printf(" p - probabilities in columns\n");
296 printf(" a - probabilities in rows, abbreviated to the first digit\n");
297 printf(" b - scores (size of the scanning window defined by the user)\n");
298 printf(" c - only probabilities above a user-defined cutoff\n");
299 printf("ENTER OPTION: ");
300 while ((option!='a') && (option!='b') && (option!='c') &&
302 && (option!='B') && (option!='C') && (option!='p') && (option!='P')) {
306 if ((option=='b') || (option=='B'))
308 printf("ENTER WINDOW SIZE: ");
321 junkline[strlen(junkline)-1]='\0';
322 junklen=strlen(junkline);
325 if (junkline[0] == '>')
327 strcpy(nameprot,junkline);
331 last4=(char *) &(junkline[junklen-4]);
332 if (strcmp(last4," ..")==0)
335 strcpy(nameprot,junkline);
340 void Skip_opening_info()
341 /* Skip opening lines of protein to get to amino acid sequence */
345 endingfound=checkforend();
350 fgets(junkline,9999,protein);
351 endingfound=checkforend();
353 strcpy(nameprot," ");
355 protein=fopen(inputfile,"r");
360 void Store_residues()
361 /* stores only the amino acids of the sequence, skipping numbers,
363 and carriage returns and ending with '/' || '*' */
369 tempstore=fgetc(protein);
370 while ((tempstore != '/') && (tempstore != '*') && (!feof(protein)))
372 switch (tempstore & 95) {
402 res_total=res_total+1;
403 residue[res_total]=tempstore;
405 tempstore=fgetc(protein);
407 if (tempstore == '/') fgets(junkline,9999,protein); /* read other '/'
416 switch (res & (char) 95) {
462 void Calculate(int startwindow,int endindex)
463 /* calculates best scores for each window frame */
465 int X,x,y,extras,heptad_pos,window_pos,res_pos;
466 double root_inverse,scores,misc;
467 int hept,index,window;
471 if(verbose) printf("Calculating...\n");
474 while (index<=endindex)
476 if(verbose) printf(".");
479 root=(window / 7) * hept_weight;
482 tempcalc[index][res_pos]=0;
483 for (heptad_pos=0; heptad_pos<=6; heptad_pos++) /* go through each residue in each heptad pos */
487 for (window_pos=0;window_pos<=window-1;window_pos++) /* get values at all 21 positions */
489 switch (residue[window_pos + res_pos] & 95){
533 y=(int) fmod((double)(window_pos + res_pos + heptad_pos),7.0);
535 if (window_pos==0) hept=y;
537 if ((y==1) || (y==4)) weight=ad_weight;
539 root_inverse=1.0/(double) root;
540 misc=pow(chartvalue[x][y],weight);
541 scores=scores*(pow(misc,root_inverse));
542 } /* end of window_pos loop */
543 if (scores>tempcalc[index][res_pos])
545 tempcalc[index][res_pos]=scores;
546 temphept[index][res_pos]=(int) fmod((double) (hept-1),7.0);
548 } /* end of heptad_pos loop*/
549 } while (res_pos+window != res_total+1);
550 for (extras=1; extras<=window-1;extras++)
552 tempcalc[index][res_pos+extras]=tempcalc[index][res_pos];
553 temphept[index][res_pos+extras]=(int) fmod((double)
554 (temphept[index][res_pos]+extras),7.0);
558 } /* for window sizes 14, 21 & 28 */
562 while (index<=endindex)
567 calcnumb[index][res_pos]=tempcalc[index][res_pos];
568 heptnum[index][res_pos]=temphept[index][res_pos];
571 window_pos=window_pos+1;
572 if (res_pos-window_pos<1) window_pos=window-1;
574 if (tempcalc[index][res_pos-window_pos]>calcnumb[index][res_pos])
576 calcnumb[index][res_pos]=tempcalc[index][res_pos-window_pos];
577 heptnum[index][res_pos]=(int)fmod((temphept[index][res_pos-window_pos]+window_pos),7.0);
579 } while (window_pos!=window-1); /* enddo */
580 } while (res_pos!=res_total); /* enddo */
584 if(verbose) printf("\n");
586 double Calcprob(double x,double meancc,double stddevcc,double
587 meangl,double stddevgl,double ratio_gl_cc)
589 double prob1,prob2,prob3,prob4;
591 prob1=(0.5) * pow(((x-meancc) / stddevcc),2.0);
592 prob2=(0.5) * pow(((x-meangl) / stddevgl),2.0);
593 prob3=stddevgl * exp(-prob1);
594 prob4=ratio_gl_cc * stddevcc * exp(-prob2);
595 return (prob3) / (prob3+prob4);
597 char frame(int heptnum)
617 int i_trunc(double n)
619 return (int) floor(n);
625 double prob14,prob21,prob28,old14,old21,old28,xx=1,lastxx=1;
626 int prevres,color=8,c14=9,c21=15,c28=12;
627 char t1[]="14",t2[]="21",t3[]="28";
629 fprintf(pickup,"%s\n",nameprot);
630 fprintf(pickup," Residue Window=14 Window=21 Window=28\n");
631 fprintf(pickup," Score Probability Score Probability Score Probability\n");
633 for (res_pos=1;res_pos<=res_total;res_pos++)
635 fr14=frame(heptnum[1][res_pos]);
636 fr21=frame(heptnum[2][res_pos]);
637 fr28=frame(heptnum[3][res_pos]);
640 if ((weightchar=='y') || (weightchar=='Y'))
642 prob28=Calcprob(calcnumb[3][res_pos],1.74,0.20,0.86,0.18,30);
643 prob21=Calcprob(calcnumb[2][res_pos],1.79,0.24,0.92,0.22,25);
644 prob14=Calcprob(calcnumb[1][res_pos],1.89,0.30,1.04,0.27,20);
646 prob28=Calcprob(calcnumb[3][res_pos],1.69,0.18,0.80,0.18,30);
647 prob21=Calcprob(calcnumb[2][res_pos],1.74,0.23,0.86,0.21,25);
648 prob14=Calcprob(calcnumb[1][res_pos],1.82,0.28,0.95,0.26,20);
653 if ((weightchar=='y') || (weightchar=='Y'))
655 if (calcnumb[3][res_pos] > 0.0)
656 prob28=Calcprob(calcnumb[3][res_pos],1.70,0.24,0.79,0.23,30);
661 if (calcnumb[2][res_pos] > 0.0)
662 prob21=Calcprob(calcnumb[2][res_pos],1.76,0.28,0.86,0.26,25);
663 else { prob21=0.0; fr21='x'; }
664 if (calcnumb[1][res_pos] > 0.0)
665 prob14=Calcprob(calcnumb[1][res_pos],1.88,0.34,1.00,0.33,20);
666 else { prob14=0.0; fr14='x'; }
670 if (calcnumb[3][res_pos] > 0.0)
672 prob28=Calcprob(calcnumb[3][res_pos],1.628,0.243,0.770,0.202,30);
673 else { prob28=0.0; fr28='x'; }
674 if (calcnumb[2][res_pos] > 0.0)
676 prob21=Calcprob(calcnumb[2][res_pos],1.683,0.285,0.828,0.236,25);
677 else { prob21=0.0; fr21='x'; }
678 if (calcnumb[1][res_pos] > 0.0)
680 prob14=Calcprob(calcnumb[1][res_pos],1.782,0.328,0.936,0.289,20);
681 else { prob14=0.0; fr14='x'; }
684 if ((prob14>=peakmin) || (prob21>=peakmin) || (prob28>=peakmin))
686 if (res_pos-1!=prevres) fprintf(pickup,"...\n");
688 fprintf(pickup,"%5d %c",res_pos,residue[res_pos]);
689 fprintf(pickup," %c %5.3lf %5.3lf",fr14,calcnumb[1][res_pos],prob14);
690 fprintf(pickup," %c %5.3lf %5.3lf",fr21,calcnumb[2][res_pos],prob21);
691 fprintf(pickup," %c %5.3lf %5.3lf",fr28,calcnumb[3][res_pos],prob28);
692 fprintf(pickup,"\n");
698 int res_pos,maxline,startpos;
700 fprintf(pickup,"%s\n",nameprot);
701 for (res_pos=1;res_pos<=res_total;res_pos++)
703 fr14[res_pos]=frame(heptnum[1][res_pos]);
704 fr21[res_pos]=frame(heptnum[2][res_pos]);
705 fr28[res_pos]=frame(heptnum[3][res_pos]);
708 if ((weightchar=='y') || (weightchar=='Y'))
710 pr14[res_pos]=i_trunc(Calcprob(calcnumb[1][res_pos],1.89,0.30,1.04,0.27,20)*10.0);
711 pr21[res_pos]=i_trunc(Calcprob(calcnumb[2][res_pos],1.79,0.24,0.92,0.22,25)*10.0);
712 pr28[res_pos]=i_trunc(Calcprob(calcnumb[3][res_pos],1.74,0.20,0.86,0.18,30)*10.0);
716 pr14[res_pos]=i_trunc(Calcprob(calcnumb[1][res_pos],1.82,0.28,0.95,0.26,20)*10.0);
717 pr21[res_pos]=i_trunc(Calcprob(calcnumb[2][res_pos],1.74,0.23,0.86,0.21,25)*10.0);
718 pr28[res_pos]=i_trunc(Calcprob(calcnumb[3][res_pos],1.69,0.18,0.80,0.18,30)*10.0);
723 if ((weightchar=='y') || (weightchar=='Y'))
725 if (calcnumb[3][res_pos] > 0)
726 pr28[res_pos]=i_trunc(Calcprob(calcnumb[3][res_pos],1.70,0.24,0.79,0.23,30)*10.0);
727 else { pr28[res_pos]=0; fr28[res_pos]='x'; }
728 if (calcnumb[2][res_pos] > 0)
729 pr21[res_pos]=i_trunc(Calcprob(calcnumb[2][res_pos],1.76,0.28,0.86,0.26,25)*10.0);
730 else { pr21[res_pos]=0; fr21[res_pos]='x'; }
731 if (calcnumb[1][res_pos] > 0)
732 pr14[res_pos]=i_trunc(Calcprob(calcnumb[1][res_pos],1.88,0.34,1.00,0.33,20)*10.0);
733 else { pr14[res_pos]=0; fr14[res_pos]='x'; }
737 if (calcnumb[3][res_pos] > 0)
738 pr28[res_pos]=i_trunc(Calcprob(calcnumb[3][res_pos],1.628,0.243,0.770,0.202,30)*10.0);
739 else { pr28[res_pos]=0; fr28[res_pos]='x'; }
740 if (calcnumb[2][res_pos] > 0)
741 pr21[res_pos]=i_trunc(Calcprob(calcnumb[2][res_pos],1.683,0.285,0.828,0.236,25)*10.0);
742 else { pr21[res_pos]=0; fr21[res_pos]='x'; }
743 if (calcnumb[1][res_pos] > 0)
744 pr14[res_pos]=i_trunc(Calcprob(calcnumb[1][res_pos],1.782,0.328,0.936,0.289,20)*10.0);
745 else { pr14[res_pos]=0; fr14[res_pos]='x'; }
748 if (pr14[res_pos]>9) pr14[res_pos]=9;
749 if (pr21[res_pos]>9) pr21[res_pos]=9;
750 if (pr28[res_pos]>9) pr28[res_pos]=9;
754 while (startpos+maxline-1 <= res_total)
756 fprintf(pickup,"%d\n",startpos);
757 fprintf(pickup," . | . | . | . | . | . |\n");
758 for (res_pos=startpos;res_pos<=startpos+maxline-1;res_pos++)
759 fprintf(pickup,"%c",residue[res_pos]);
760 fprintf(pickup,"\n\n");
761 for (res_pos=startpos;res_pos<=startpos+maxline-1;res_pos++)
762 fprintf(pickup,"%d",pr14[res_pos]);
763 fprintf(pickup,"\n");
764 for (res_pos=startpos;res_pos<=startpos+maxline-1;res_pos++)
765 fprintf(pickup,"%d",pr21[res_pos]);
766 fprintf(pickup,"\n");
767 for (res_pos=startpos;res_pos<=startpos+maxline-1;res_pos++)
768 fprintf(pickup,"%d",pr28[res_pos]);
769 fprintf(pickup,"\n");
770 for (res_pos=startpos;res_pos<=startpos+maxline-1;res_pos++)
771 fprintf(pickup,"%c",fr14[res_pos]);
772 fprintf(pickup,"\n");
773 for (res_pos=startpos;res_pos<=startpos+maxline-1;res_pos++)
774 fprintf(pickup,"%c",fr21[res_pos]);
775 fprintf(pickup,"\n");
776 for (res_pos=startpos;res_pos<=startpos+maxline-1;res_pos++)
777 fprintf(pickup,"%c",fr28[res_pos]);
778 fprintf(pickup,"\n");
779 fprintf(pickup,"\n");
780 startpos=startpos+60;
783 if (startpos<=res_total)
785 fprintf(pickup,"%d\n",startpos);
786 fprintf(pickup," . | . | . | . | . | . |\n");
787 for (res_pos=startpos;res_pos<=res_total;res_pos++)
788 fprintf(pickup,"%c",residue[res_pos]);
789 fprintf(pickup,"\n");
790 fprintf(pickup,"\n");
791 for (res_pos=startpos;res_pos<=res_total;res_pos++)
792 fprintf(pickup,"%d",pr14[res_pos]);
793 fprintf(pickup,"\n");
794 for (res_pos=startpos;res_pos<=res_total;res_pos++)
795 fprintf(pickup,"%d",pr21[res_pos]);
796 fprintf(pickup,"\n");
797 for (res_pos=startpos;res_pos<=res_total;res_pos++)
798 fprintf(pickup,"%d",pr28[res_pos]);
799 fprintf(pickup,"\n");
800 for (res_pos=startpos;res_pos<=res_total;res_pos++)
801 fprintf(pickup,"%c",fr14[res_pos]);
802 fprintf(pickup,"\n");
803 for (res_pos=startpos;res_pos<=res_total;res_pos++)
804 fprintf(pickup,"%c",fr21[res_pos]);
805 fprintf(pickup,"\n");
806 for (res_pos=startpos;res_pos<=res_total;res_pos++)
807 fprintf(pickup,"%c",fr28[res_pos]);
808 fprintf(pickup,"\n");
809 fprintf(pickup,"\n");
819 fprintf(pickup,"%s\n",nameprot);
820 fprintf(pickup," Residue Frame Score\n");
821 for (res_pos=1;res_pos<=res_total;res_pos++)
823 if (calcnumb[1][res_pos] > 0.0)
825 fr=frame(heptnum[1][res_pos]);
826 fprintf(pickup," %6d %c %c %2.6lf\n",res_pos,residue[res_pos],fr, calcnumb[1][res_pos]);
828 fprintf(pickup," %6d %c x %2.6lf\n",res_pos,residue[res_pos], calcnumb[1][res_pos]);
836 if (res_total >= window)
839 if ((option=='a') || (option=='A'))
841 Calculate(window,num_wind);
844 if ((option=='b') || (option=='B'))
847 Calculate(window,num_wind);
852 Calculate(window,num_wind);
856 fprintf(pickup,"Protein too short. Length=%d\n",res_total);
860 fprintf(stderr,"format: coils [options] < [fasta file] > [output file]\n");
861 fprintf(stderr," -mtk (use MTK matrix) \n");
862 fprintf(stderr," -mtidk (use MTIDK matrix) \n");
863 fprintf(stderr," -ad2.5 (a weight of 2.5 for positions a & d)\n");
864 fprintf(stderr," -w <window size> [default is 21]\n");
865 fprintf(stderr," -pm <minimum probabilty> [default is 0.0]\n");
866 fprintf(stderr," -v (verbose mode)\n");
867 fprintf(stderr," -out <char>\n");
868 fprintf(stderr," p = propabilities in columns \n");
869 fprintf(stderr," a = probabilities in rows\n");
870 fprintf(stderr," b = scores (size of the scanning window defined by the user)\n");
874 void Get_info(int argc, char *argv[])
877 /* Modified version of Get_info()
878 * Rob Russell, March 1999 makes commands command line driven */
891 strcpy(&inputfile[0],"-");
892 for(i=1; i<argc; ++i) {
893 if(argv[i][0]!='-') {
894 strcpy(&inputfile[0],argv[i]);
895 } else if(strcmp(&argv[i][1],"v")==0) {
897 } else if(strcmp(&argv[i][1],"mtk")==0) {
900 } else if(strcmp(&argv[i][1],"mtidk")==0) {
903 } else if(strcmp(&argv[i][1],"ad2.5")==0) {
907 } else if(strcmp(&argv[i][1],"pm")==0) {
908 if((i+1)>=argc) { exit_error(); }
909 sscanf(argv[i+1],"%f",&peakmin);
911 } else if(strcmp(&argv[i][1],"w")==0) {
912 if((i+1)>=argc) { exit_error(); }
913 sscanf(argv[i+1],"%d",&window);
915 } else if(strcmp(&argv[i][1],"out")==0) {
916 if((i+1)>=argc) { exit_error(); }
917 option = argv[i+1][0];
918 if((option!='p') && (option!='a') && (option!='b') && (option!='c')) {
927 if(inputfile[0]!='-') {
928 protein=fopen(inputfile,"r"); /* modify for reading */
931 fprintf(stderr,"Error: file %s does not exist\n",inputfile);
934 if(verbose) printf("Input file is: %s\n",inputfile);
937 if(verbose) printf("Reading from standard input\n");
940 if(verbose) fprintf(pickup,"COILS version 2.1\n");
943 if(verbose) fprintf(pickup,"using MTIDK matrix.\n");
946 if(verbose) fprintf(pickup,"using MTK matrix.\n");
949 if ((weightchar=='y') || (weightchar=='Y'))
951 if(verbose) fprintf(pickup,"weights: a,d=2.5 and b,c,e,f,g=1.0\n");
955 if(verbose) fprintf(pickup,"no weights\n");
962 main(int argc, char *argv[], char *envp[])
964 Get_info(argc, argv);
969 fgets(junkline,9999,protein);
977 if (!feof(protein)) fgets(junkline,9999,protein);
979 } while (!feof(protein)); /* enddo */