-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathprep_data.cpp
More file actions
executable file
·106 lines (93 loc) · 2.26 KB
/
prep_data.cpp
File metadata and controls
executable file
·106 lines (93 loc) · 2.26 KB
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
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
using namespace std;
int main(int argc, char* argv[])
{
if(argc<4)
{
printf("Usage: %s input_filename positive_output negative_output group_val\n", argv[0]);
printf("Here the file has to be one of the JAIST Nucleosome dataset file.\n");
return -1;
}
char str[600];
char value[10];
char ch;
int group_val = atoi(argv[4]);
FILE *fp1;
FILE *fp2;
FILE *fp3;
fp1 = fopen(argv[1],"r");\
if(fp1==NULL)
{
printf("Error Opening File: %s\n", argv[1]);
return -5;
}
fp2 = fopen(argv[2],"w");
if(fp2==NULL)
{
fclose(fp1);
printf("Error Opening File: %s\n", argv[2]);
return -6;
}
fp3 = fopen(argv[3],"w");
if(fp3==NULL)
{
fclose(fp1);
fclose(fp2);
printf("Error Opening File: %s\n", argv[3]);
return -7;
}
while((ch = fgetc(fp1)) != EOF)
{
if(fgets(str,600,fp1)==NULL)
{
printf("Error Reading File! - 1\n");
fclose(fp1);
fclose(fp2);
fclose(fp3);
return -2;
}
if(fgets(str,600,fp1)==NULL)
{
printf("Error Reading File! - 2\n");
fclose(fp1);
fclose(fp2);
fclose(fp3);
return -3;
}
if(fgets(value,10,fp1)==NULL)
{
printf("Error Reading File! - 3\n");
fclose(fp1);
fclose(fp2);
fclose(fp3);
return -4;
}
if(atoi(value)==1)
{
for(int i=0; str[i+group_val]!='\n'; i++)
{
for(int j=0; j<group_val; j++)
fputc(str[i+j],fp2);
fputc(' ',fp2);
}
fputc('\n',fp2);
}
else
{
for(int i=0; str[i+group_val]!='\n'; i++)
{
for(int j=0; j<group_val; j++)
fputc(str[i+j],fp3);
fputc(' ',fp3);
}
fputc('\n',fp3);
}
}
fclose(fp1);
fclose(fp2);
fclose(fp3);
return 0;
}