-
Notifications
You must be signed in to change notification settings - Fork 20
/
convertToFasta.cpp
82 lines (53 loc) · 1.32 KB
/
convertToFasta.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
#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 main(int argc, const char * argv[])
{
FILE *inFile=fopen("pvals_case_top_merged_sorted.txt","r");
FILE *outFile=fopen("case_kmers.fasta","w");
FILE *totalFile=fopen("total_kmers.txt","r");
char *line= new char[MAX_REC_LEN];
char *line2= new char[MAX_REC_LEN];
char *temp;
double pval;
long long int totalKmers;
fscanf(totalFile,"%lld",&totalKmers);
int MAX_FILE_READ=MAX_REC_LEN/sizeof(line[0]);
while(fgets(line, MAX_FILE_READ, inFile)!=NULL)
{
temp=strtok(line,"\t\n ");
pval=atof(temp);
temp=strtok(NULL,"\t\n ");
if(pval<0.05/totalKmers)
{
fprintf(outFile,">%e\n%s\n",pval,temp);
}
}
fclose(inFile);
fclose(outFile);
fclose(totalFile);
inFile=fopen("pvals_control_top_merged_sorted.txt","r");
outFile=fopen("control_kmers.fasta","w");
while(fgets(line, MAX_FILE_READ, inFile)!=NULL)
{
temp=strtok(line,"\t\n ");
pval=atof(temp);
temp=strtok(NULL,"\t\n ");
if(pval<0.05/totalKmers)
{
fprintf(outFile,">%e\n%s\n",pval,temp);
}
}
fclose(inFile);
fclose(outFile);
}