-
Notifications
You must be signed in to change notification settings - Fork 1
/
trimmer.cpp
168 lines (125 loc) · 3.37 KB
/
trimmer.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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#include <stdlib.h>
#include <iostream>
#include <string>
#include <string.h>
#include <fstream>
#include <vector>
#include <cmath>
#include <sstream>
#include <algorithm>
#include <functional>
using namespace std;
int main(){
ifstream file1;
ifstream file2;
ofstream file3;
ofstream file4;
ofstream file5;
ofstream file6;
ofstream file7;
ofstream file8;
file1.open("300_R2.fastq");
file2.open("300_R2.fastq");
file3.open("300_R2_trimmed_Liseq.fastq");
file4.open("300_R2_trimmed_polyA.fastq");
file5.open("300_R2_trimmed_gDNA.fastq");
file6.open("300_R2_Liseq.txt");
file7.open("300_R2_polyA.txt");
file8.open("300_R2_gDNA.txt");
string input;
string seq;
string quan;
string title;
string title2;
int N_L1=21;
for(int i=0;!file1.eof();i++){
file1>>title;
file2>>title;
file1>>title2;
file2>>title2;
int seq_l=0;
int quan_l=0;
file1>>seq;
seq_l=seq.length();
char *seq_char;
seq_char= new char[seq_l];
for(int j=0;j!=seq_l;j++){
file2>>seq_char[j];
}
file1>>input;
file2>>input;
file1>>quan;
quan_l=quan.length();
char *quan_char;
quan_char= new char[quan_l];
for(int j=0;j!=quan_l;j++){
file2>>quan_char[j];
}
if(quan_l!=seq_l){
cout<<"f**king wrong"<<endl;
break;
}
file3<<title<<'\t'<<title2<<endl;
file4<<title<<'\t'<<title2<<endl;
file5<<title<<'\t'<<title2<<endl;
for(int j=0;j!=N_L1;j++){
file3<<seq_char[j];
file6<<seq_char[j];
}
file3<<endl;
file6<<endl;
int polyA_site=N_L1;
int end=0;
for(int j=N_L1;j!=seq_l-5;j++){
int flag=0;
if(seq_char[j]!='A') flag=flag+1;
if(seq_char[j+1]!='A') flag=flag+1;
if(seq_char[j+2]!='A') flag=flag+1;
if(seq_char[j+3]!='A') flag=flag+1;
if(seq_char[j+4]!='A') flag=flag+1;
if (flag>=4){
if(seq_char[j]!='A'){
polyA_site=j;
}
else {
polyA_site=j+1;
}
end=1;
break;
}
}
if(end==0){
polyA_site=seq_l;
}
for(int j=N_L1;j!=polyA_site;j++){
file4<<seq_char[j];
file7<<seq_char[j];
}
file4<<endl;
file7<<endl;
for(int j=polyA_site;j!=seq_l;j++){
file5<<seq_char[j];
file8<<seq_char[j];
}
file5<<endl;
file8<<endl;
file3<<input<<endl;
file4<<input<<endl;
file5<<input<<endl;
for(int j=0;j!=N_L1;j++){
file3<<quan_char[j];
}
file3<<endl;
for(int j=N_L1;j!=polyA_site;j++){
file4<<quan_char[j];
}
file4<<endl;
for(int j=polyA_site;j!=seq_l;j++){
file5<<quan_char[j];
}
file5<<endl;
}
file1.close();
file2.close();
file3.close();
}