-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathfindZDNA.c
81 lines (75 loc) · 1.47 KB
/
findZDNA.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
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#include <math.h>
#include "gfa.h"
/*******************************************
* Start looking for RY/YR runs ************
* (excluding TA/AT dinucleotides.**********
*******************************************
*/
int pupy(int pos) {
//int GCscore = 25;
//int nonGCscore = 3;
int isPPY = 0;
if (dna[pos] == 'a') {
if (dna[pos + 1] == 'c') {
isPPY = 3;
}
}
else if (dna[pos] == 't') {
if (dna[pos + 1] == 'g') {
isPPY = 3;
}
}
else if (dna[pos] == 'c') {
if (dna[pos + 1] == 'g') {
isPPY = 25;
}
else if (dna[pos + 1] == 'a') {
isPPY = 3;
}
}
else if (dna[pos] == 'g') {
if (dna[pos + 1] == 'c') {
isPPY = 25;
}
if (dna[pos + 1] == 't') {
isPPY = 3;
}
}
return (isPPY);
}
int findZDNA(int minZ, int total_bases) {
register int i, j;
j = 0;
i = 0;
int ndx = 0;
int tmpPPY = 0;
int npy = 1;
int kvsum = 0;
while (i < (total_bases - minZ)) {
tmpPPY = pupy(i);
if (tmpPPY > 0) {
npy++;
kvsum = kvsum + tmpPPY;
}
else {
if (npy >= minZ) {
zrep[ndx].start = i - npy +2;
zrep[ndx].len = npy;
zrep[ndx].loop = kvsum / 2;//KV score
zrep[ndx].num = 0;// G/C C/G count (25 pts)
zrep[ndx].end = i+1;
zrep[ndx].sub = 0;//non G/C C/G count (3 pts)
zrep[ndx].strand = 0;
ndx++;
}
npy = 1;
kvsum = 0;
tmpPPY = 0;
}
i++;
}
return (ndx);
}