-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathelem.c
150 lines (125 loc) · 4.71 KB
/
elem.c
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
#include "stride.h"
/*************************************************************************
** **
** Calculate the number of individual secondary structure elements of **
** type SecStrType and length not less than ElemLength that are: **
** - Present in Asn1 and Asn2 and absent in Asn3 (YYN) **
** - Present in Asn2 and Asn3 and absent in Asn1 (NYY) **
** - Absent in Asn2 and Asn3 and present in Asn1 (YYN) **
** - Absent in Asn1 and Asn2 and present in Asn3 (YYN) **
** **
*************************************************************************/
int FullElement(char *Asn1, char *Asn2, char *Asn3, int Length, char SecStrType, int ElemLength,
char EditChar, int *YYN, int *NYY, int *YNN, int *NNY)
{
register int i, j, Count1, Count2, Count3;
int Beg, ElLength;
*YYN = 0;
*NYY = 0;
*YNN = 0;
*NNY = 0;
if( ElemLength >= Length )
return(0);
ElLength = ElemLength-1;
Count1 = 0;
Count2 = 0;
Count3 = 0;
Beg = -1;
for( i=1; i<Length; i++ ) {
if( ( i == 0 &&
( Asn1[i] == SecStrType && Asn2[i] == SecStrType && Asn3[i] == SecStrType) ||
( Asn1[i] != SecStrType && Asn2[i] != SecStrType && Asn3[i] != SecStrType) )
||
( i > 0 &&
( Asn1[i] != Asn1[i-1] || Asn2[i] != Asn2[i-1] || Asn3[i] != Asn3[i-1] ) )
||
i == Length-1 ) {
if( Count1 >= ElLength && Count2 >= ElLength && Count3 < ElLength )
(*YYN)++;
else
if( Count1 < ElLength && Count2 >= ElLength && Count3 >= ElLength )
(*NYY)++;
else
if( Count1 >= ElLength && Count2 < ElLength && Count3 < ElLength )
(*YNN)++;
else
if( Count1 < ElLength && Count2 < ElLength && Count3 >= ElLength )
(*NNY)++;
/* if( Count1 >= ElLength || Count2 >= ElLength || Count3 >= ElLength ) {
* for( j=Beg-1; j<i; j++ ) {
* Asn1[j] = 'X';
* Asn2[j] = 'X';
* Asn3[j] = 'X';
* }
* }
*
*/
if( Count1 >= ElLength && ( Count2 < ElLength || Count3 < ElLength ) )
for( j=Beg-1; j<i; j++ )
Asn1[j] = EditChar;
if( Count2 >= ElLength && ( Count1 < ElLength || Count3 < ElLength ) )
for( j=Beg-1; j<i; j++ )
Asn2[j] = EditChar;
if( Count3 >= ElLength && ( Count1 < ElLength || Count2 < ElLength ) )
for( j=Beg-1; j<i; j++ )
Asn3[j] = EditChar;
Count1 = 0;
Count2 = 0;
Count3 = 0;
Beg = -1;
}
else {
if( Asn1[i] == SecStrType ) Count1++;
if( Asn2[i] == SecStrType ) Count2++;
if( Asn3[i] == SecStrType ) Count3++;
if( Beg == -1 && (Count1 == 1 || Count2 == 1 || Count3 == 1) ) Beg = i;
}
}
CorrectAsn(Asn1,Length,SecStrType,EditChar,ElLength);
CorrectAsn(Asn2,Length,SecStrType,EditChar,ElLength);
CorrectAsn(Asn3,Length,SecStrType,EditChar,ElLength);
return( (*YYN) * (*NYY) * (*YNN) * (*NNY) );
}
/*************************************************************************
** **
** Calculate the number of individual secondary structure elements of **
** type SecStrType in the known assignment Asn2 that are: **
** - Reproduced in Asn1 better than in Asn3 (Better) **
** - Reproduced in Asn1 worse than in Asn3 (Worse) **
** **
*************************************************************************/
int CompareElements(char *Asn1, char *Asn2, char *Asn3, int Length,
char SecStrType, int *Better, int *Worse)
{
register int i, j, Count1, Count2;
int TotalNumber = 0, Beg;
*Better = 0;
*Worse = 0;
Beg = -1;
for( i=0; i<Length; i++ ) {
if( (Asn1[i] == SecStrType || Asn2[i] == SecStrType || Asn3[i] == SecStrType) &&
(i == 0 ||
( Asn1[i-1] != SecStrType && Asn2[i-1] != SecStrType && Asn3[i-1] != SecStrType) ) ) {
TotalNumber++;
Beg = i;
}
else
if( Beg != -1 && ( i == Length-1 ||
( Asn1[i] != SecStrType && Asn2[i] != SecStrType && Asn3[i] != SecStrType ) ) ) {
Count1 = Count2 = 0;
for( j=Beg; j<=i; j++ ) {
if( (Asn1[j] == SecStrType || Asn2[j] == SecStrType) && Asn1[j] != Asn2[j] )
Count1++;
if( (Asn3[j] == SecStrType || Asn2[j] == SecStrType) && Asn3[j] != Asn2[j] )
Count2++;
}
if( Count1 > Count2 )
(*Worse)++;
else
if( Count2 > Count1 )
(*Better)++;
Beg = -1;
}
}
return(TotalNumber);
}