-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChou Fasman Algorithm(BioInformatics_DS).cpp
More file actions
181 lines (169 loc) · 3.91 KB
/
Chou Fasman Algorithm(BioInformatics_DS).cpp
File metadata and controls
181 lines (169 loc) · 3.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
#include<stdio.h>
#include<iostream>
#include<fstream>
#include<string.h>
#include<ctype.h>
#include"protein orig.h"
#define MAXLENGTH 1000
#define TURN_PRODUCT 0.75e-4
#define ALPHA_CUT 100
#define BETA_CUT 100
#define TURN_CUT 0.75e-4
using namespace std;
struct protien_data
{
int code;
int p_alpha;
int p_beta;
int p_turn;
float bend[4];
int alpha_class;
int beta_class;
int p4_alpha;
int p4_beta;
int p4_turn;
float turn_prod;
}sequence[MAXLENGTH];
char infile[128], outfile[128], prot_name[64];
void get_probability(int);
void tetra_ave(int);
void print(int);
main()
{
int c,length = 0;
char seq[]= "ATSTKKLHKEPATLIKAIDGDTVKLMYKGQPMTFRLLLVDTPETKHPKKGVEK";
char ans[6];
cout<<"ENTER PROTIEN NAME:\n";
cin>>prot_name;
cout<<"enter sequence:\n";
// seq = "ATSTKKLHKEPATLIKAIDGDTVKLMYKGQPMTFRLLLVDTPETKHPKKGVEK";
cin>>seq;
length = strlen(seq);
for(int i=0; i<length; i++)
sequence[i].code = toupper(seq[i]);
get_probability(length);
tetra_ave(length);
print( length);
}
char d_base[5];
void get_probability(int length)
{
int dbase = 2,j;
do
{
cout<<"Use database or 29 proteins(Chou & Fasman '78)--> enter 0\n";
cout<<"Use database or 64 proteins(Chou '79)--> enter 1\n";
cin>>dbase;
}while(dbase>1);
for( int i =0,j=0; i< length; i++)
{
while((sequence[i].code != data[j].c) && j < 20)
j++;
if(j == 20)
{
cout<<"Illegal data point # "<<i<<" is "<<sequence[i].code;
exit(1);
}
sequence[i].p_alpha = data[j].p_a[dbase];
sequence[i].p_beta = data[j].p_b[dbase];
sequence[i].p_turn = data[j].p_t;
for(int k=0; k<=3; k++)
sequence[i].bend[k] = data[j].b[k];
sequence[i].alpha_class = data[j].a_class[dbase];
sequence[i].beta_class = data[j].b_class[dbase];
j = 0;
}
}
void tetra_ave(int length)
{
int aSum, bSum, tSum;
float tprod;
for(int i=1; i<length-3; i++)
{
aSum = bSum = tSum = 0;
tprod = 1;
for(int j=0; j<=3; j++)
{
aSum += sequence[i+j].p_alpha;
bSum += sequence[i+j].p_beta;
tSum += sequence[i+j].p_turn;
tprod*= sequence[i+j].bend[j];
}
sequence[i].p4_alpha = aSum/4;
sequence[i].p4_beta = bSum/4;
sequence[i].p4_turn = tSum/4;
sequence[i].turn_prod = tprod;
}
}
void print(int length){
int alpha_count = 0;
int beta_count = 0;
int aliph =0;
int bet=0;
ofstream pro;
pro.open("Protein.txt");
pro<<"\t\t***Chau Fasman Algorithm***\n\n";
cout<<"\t\tChau Fasman Algorithm\n\n";
cout<<"protien name: "<<prot_name<<endl;
pro<<"protien name: "<<prot_name<<endl;
pro<<"\n\t\tPa\tPb\tPt\t<Pa><Pb><Pt>\t\n";
cout<<"\t\tPa\tPb\tPt\t<Pa>\t<Pb>\t<Pt>\t\n\n\n";
for(int i=0; i<length ; i++)
{
cout<<i+1 <<"\t";
pro<<i+1 <<"\t";
printf("%c",toupper(sequence[i].code));
char x;
x=toupper(sequence[i].code);
pro<<x;
cout<<"\t"<<sequence[i].p_alpha<<"\t"<<sequence[i].p_beta<<"\t"<<sequence[i].p_turn<<"\t";
cout<<"\t"<<sequence[i].p4_alpha<<"\t";
pro<<"\t"<<sequence[i].p_alpha<<"\t"<<sequence[i].p_beta<<"\t"<<sequence[i].p_turn<<"\t";
pro<<"\t"<<sequence[i].p4_alpha<<"\t";
if(sequence[i].p4_alpha >= ALPHA_CUT){
cout<<'*';
pro<<"*";
aliph ++;
}
else{
cout<<'_';
pro<<'_';
if(aliph > alpha_count)
alpha_count = aliph;
aliph = 0;
}
if(sequence[i].p4_beta >= BETA_CUT)
{
cout<<'*';
pro<<'*';
bet ++;
}
else
{
cout<<'_';
pro<<'_';
if(bet > beta_count)
beta_count = bet;
bet = 0;
}
if(sequence[i].turn_prod >= TURN_CUT){
cout<<'*';
pro<<'*';
}
else{
cout<<'_';
pro<<'_';
}
pro<<endl;
cout<<endl;
}
if(alpha_count>beta_count)
{
cout<<"\nDominent Structure : AlphaHelix";
pro<<"\n\nDominent Structure : AlphaHelix";
}
else{
cout<<"\nDominant Structure : BetaSheets";
pro<<"\n\nDominant Structure : BetaSheets";
}
}