forked from atifrahman/HAWK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bonf_fasta.cpp
117 lines (75 loc) · 2.11 KB
/
bonf_fasta.cpp
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
//
// main.cpp
// kmer
//
#include <iostream>
#include <string>
#include <limits>
#include <vector>
#include <algorithm>
using namespace std;
#include <pthread.h>
#include <time.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#define MAX_REC_LEN 10240
int noCases, noControls;
int kmerLength=31;
int NUM_THREADS=16;
int main(int argc, const char * argv[])
{
char *temp;
char kmerString[100];
unsigned short count;
int MAX_FILE_READ=10240;
char *line=new char[MAX_FILE_READ+1];
long long int TOTAL_KMER;
double SIG_LEVEL=0.05;
FILE * kmerFile=fopen("total_kmers.txt","r");
fscanf(kmerFile,"%lld",&TOTAL_KMER);
FILE * caseFile=fopen("case_out_wo_bonf.kmerDiff","r");
FILE * controlFile=fopen("control_out_wo_bonf.kmerDiff","r");
FILE *caseFileOut=fopen("case_out_sig.fasta","w");
FILE *controlFileOut=fopen("control_out_sig.fasta","w");
int count1, count2;
double pVal;
long long int i=0;
while(fgets(line, MAX_FILE_READ, caseFile)!=NULL)
{
temp=strtok(line,"\t\n ");
strcpy(kmerString,temp);
temp=strtok(NULL,"\t\n ");
count1=atoi(temp);
temp=strtok(NULL,"\t\n ");
count2=atoi(temp);
temp=strtok(NULL,"\t\n ");
pVal=atof(temp);
if(pVal<SIG_LEVEL/TOTAL_KMER)
{
fprintf(caseFileOut,">%lld\n",i);
fprintf(caseFileOut,"%s\n",kmerString);
i++;
}
}
i=0;
while(fgets(line, MAX_FILE_READ, controlFile)!=NULL)
{
temp=strtok(line,"\t\n ");
strcpy(kmerString,temp);
temp=strtok(NULL,"\t\n ");
count1=atoi(temp);
temp=strtok(NULL,"\t\n ");
count2=atoi(temp);
temp=strtok(NULL,"\t\n ");
pVal=atof(temp);
if(pVal<SIG_LEVEL/TOTAL_KMER)
{
fprintf(controlFileOut,">%lld\n",i);
fprintf(controlFileOut,"%s\n",kmerString);
i++;
}
}
return 0;
}