-
Notifications
You must be signed in to change notification settings - Fork 4
/
fatofq.cpp
70 lines (63 loc) · 1.36 KB
/
fatofq.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
#include <fstream>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include "zstr.hpp"
#include <cstdint>
using namespace std;
void clean(string& str){
for(uint i(0); i< str.size(); ++i){
switch(str[i]){
case 'a':break;
case 'A':break;
case 'c':break;
case 'C':break;
case 'g':break;
case 'G':break;
case 't':break;
case 'T':break;
case 'N':break;
case 'n':break;
default: str.clear();return;
}
}
transform(str.begin(), str.end(), str.begin(), ::toupper);
}
int main(int argc, char ** argv){
if(argc<2){
cout<<"[Fasta file] (clean)"<<endl;
exit(0);
}
bool cleaning(false),headercleaning(false);
if(argc>2){
if(string(argv[2])=="1" or string(argv[2])=="3"){
cleaning=true;
}
if(string(argv[2])=="2" or string(argv[2])=="3"){
headercleaning=true;
}
}
string input(argv[1]);
srand (time(NULL));
string ref, useless,toprint;
zstr::ifstream in(input);
vector<uint> lengths;
while(not in.eof()){
getline(in,useless);
getline(in,ref);
if( not useless.empty()){
if(not ref.empty()){
toprint+="@"+useless.substr(1)+"\n"+ref+'\n'+'+'+'\n'+string(ref.size(),'I')+'\n';
}else{
toprint+="@"+useless.substr(1)+"\n"+ref+'\n'+'+'+'\n'+string(ref.size(),'I')+'\n';
}
if(toprint.size()>10000){
cout<<toprint;
toprint="";
}
}
}
cout<<toprint;
}