-
Notifications
You must be signed in to change notification settings - Fork 20
/
kmersummary.cpp
127 lines (88 loc) · 2.08 KB
/
kmersummary.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
118
119
120
121
122
123
124
125
126
127
//
// 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 main(int argc, const char * argv[])
{
noCases=atoi(argv[1]);
noControls=atoi(argv[2]);
char *temp;
char kmerString[100];
unsigned short count;
int MAX_FILE_READ=10240;
char *line=new char[MAX_FILE_READ+1];
FILE * kmerFile=fopen("test.txt","r");
double SIG_LEVEL=0.05;
FILE *kmerFileOut=fopen("kmerSummary.txt","w");
long long int count1, count2;
double meanCount1=0, meanCount2=0;
double pVal;
double meanpVal=0;
int positive1=0, positive2=0;
double meanPositive1=0, meanPositive2=0;
long long int k=0;
int val;
while(fgets(line, MAX_FILE_READ, kmerFile)!=NULL)
{
k++;
temp=strtok(line,"\t\n ");
strcpy(kmerString,temp);
temp=strtok(NULL,"\t\n ");
// count1=atoll(temp);
count1=0;
temp=strtok(NULL,"\t\n ");
// count2=atoll(temp);
count2=0;
temp=strtok(NULL,"\t\n ");
pVal=atof(temp);
positive1=0;
positive2=0;
for(int i=0;i<noCases;i++)
{
temp=strtok(NULL,"\t\n ");
val=atoi(temp);
count1+=val;
if(val>0)
positive1++;
}
for(int i=0;i<noControls;i++)
{
temp=strtok(NULL,"\t\n ");
val=atoi(temp);
count2+=val;
if(val>0)
positive2++;
}
meanCount1+=count1;
meanCount2+=count2;
meanPositive1+=positive1;
meanPositive2+=positive2;
meanpVal+=pVal;
}
meanCount1/=k;
meanCount2/=k;
meanPositive1/=k;
meanPositive2/=k;
meanpVal/=k;
cout<<meanpVal<<",";
cout<<meanCount1<<",";
cout<<meanCount2<<",";
cout<<meanPositive1<<",";
cout<<meanPositive2<<endl;
return 0;
}