-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgccontent.h
77 lines (61 loc) · 1.19 KB
/
gccontent.h
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
static inline double gccontent_simple(const char *seq, size_t length)
{
size_t gc = 0;
const char *ptr = seq;
for (; *ptr; ptr++) {
if (*ptr == 'C' || *ptr == 'G') {
gc++;
}
}
return (double)gc / length;
}
static inline double gccontent_length(const char *seq, size_t length)
{
size_t gc = 0;
size_t i = 0;
for (; i < length; i++) {
if (seq[i] == 'C' || seq[i] == 'G') {
gc++;
}
}
return (double)gc / length;
}
static inline double gccontent_twiddle(const char *seq, size_t length)
{
size_t gc = 0;
for (; *seq; seq++) {
char masked = *seq & 'G' & 'C';
if (masked == ('G' & 'C')) {
gc++;
}
}
return (double)gc / length;
}
static inline double gccontent_length_twiddle(const char *seq, size_t length)
{
size_t gc = 0;
size_t i = 0;
for (; i < length; i++) {
char masked = seq[i] & 'G' & 'C';
if (masked == ('G' & 'C')) {
gc++;
}
}
return (double)gc / length;
}
static inline double gccontent_table(const char *seq, size_t length)
{
static char table[127];
table['A'] = 0;
table['C'] = 1;
table['G'] = 1;
table['T'] = 0;
size_t gc = 0;
size_t i = 0;
for (; i < length; i++) {
if (table[seq[i]]) {
gc++;
}
}
return (double)gc / length;
}