-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathAdditional algorithm 47.html
109 lines (85 loc) · 4.1 KB
/
Additional algorithm 47.html
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
<!-- ############################################################################################################################## -->
<!-- # John Wiley & Sons, Inc. # -->
<!-- # # -->
<!-- # Book: Algorithms in Bioinformatics: Theory and Implementation # -->
<!-- # Author: Dr. Paul A. Gagniuc # -->
<!-- # # -->
<!-- # Institution: # -->
<!-- # University Politehnica of Bucharest # -->
<!-- # Faculty of Engineering in Foreign Languages # -->
<!-- # Department of Engineering in Foreign Languages # -->
<!-- # # -->
<!-- # Area: European Union # -->
<!-- # Date: 04/01/2021 # -->
<!-- # # -->
<!-- # Cite this work as: # -->
<!-- # Paul A. Gagniuc. Algorithms in Bioinformatics: Theory and Implementation. John Wiley & Sons, 2021, ISBN: 9781119697961. # -->
<!-- # # -->
<!-- ############################################################################################################################## -->
<script>
var c = "GAAGTGAGT,TTCGTAAGT,AAGGTACTT,CTGGTGAGC,AGAGTGAGT," +
"CAGGTAGAG,ACTGTACGT,CTGGTGAGT,TATGTAAGT,CGGGTGAGC";
var s = [];
var m = [];
m = c.split(',');
var n = m.length;
//THE ALIGNMENT MATRIX
for(var i=0; i<n; i++){
s[i] = [];
s[i]=m[i].split('');
}
// DETECT ALL SYMBOLS USING ARRAYS
var a = [];
var t = c.replace(/,/g, '').split('');
var k = t.length;
for(var i=0; i<=k; i++){
var q = 1;
for(var j=0; j<=a.length; j++){
if (t[i] === a[j]) {q = 0;}
}
if (q === 1) {a.push(t[i]);}
}
// PROFILE MATRIX INITIALIZATION
var p = [];
for(var h=0; h<a.length; h++){
p[h]=[];
for(var i=0; i<=s[0].length; i++) {
p[h][i]=0.00000000000000001;
p[h][0]=a[h];
}
}
// THE POSITION FREQUENCY MATRIX
for(var i=0; i<s.length; i++) {
for(var j=0; j<s[i].length; j++){
for(var h=0; h<a.length; h++){
if (s[i][j] === a[h]) {p[h][j+1]++;}
}
}
}
// THE POSITION PROBABILITY MATRIX
for(var i=0; i<p.length; i++) {
for(var j=0; j<p[i].length-1; j++){
p[i][j+1]=p[i][j+1]/s.length;
}
}
// THE POSITION WEIGHT MATRIX
for(var i=0; i<p.length; i++) {
for(var j=0; j<p[i].length-1; j++){
p[i][j+1]=Math.log(p[i][j+1]/0.25).toFixed(2);
}
}
document.write(SMC(p));
// SHOW MATRIX CONTENT
function SMC(m) {
var r = "<table border=1>";
for(var i=0; i<m.length; i++) {
r += "<tr>";
for(var j=0; j<m[i].length; j++){
r += "<td>"+m[i][j]+"</td>";
}
r += "</tr>";
}
r += "</table>";
return r;
}
</script>