-
Notifications
You must be signed in to change notification settings - Fork 0
/
K-merCounting.cpp
68 lines (50 loc) · 1.25 KB
/
K-merCounting.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
// Pranav
// Kadam
#include<iostream>
#include<fstream>
#include<string>
using namespace std;
int main(int argc, char* argv[]) {
string dna_seq = "";
string fil_name = argv[1];
//because 2 command line arguments?
ifstream f(fil_name);
getline(f,dna_seq);
int k=atoi(argv[2]);
f.close();
//input completed and values stored in k and dna_seq
int l=dna_seq.length();
//l is the length of the string
cout<<0<<" "<<k<<" "<<l<<endl;
int* lettercount=new int[5];
lettercount[0]=0;
lettercount[1]=0;
lettercount[2]=0;
lettercount[3]=0;
lettercount[4]=0;
//try fill here
for(int x=0;x<l;x++){
if(dna_seq.at(x)=='A'){
lettercount[0]++;
}
if(dna_seq.at(x)=='C'){
lettercount[1]++;
}
if(dna_seq.at(x)=='G'){
lettercount[2]++;
}
if(dna_seq.at(x)=='T'){
lettercount[3]++;
}
if(dna_seq.at(x)=='N'){
lettercount[4]++;
}
}
cout<<1<<" "<<lettercount[0]<<" "<<lettercount[1]<<" "<<lettercount[2]<<" "<<lettercount[3]<<" "<<lettercount[4]<<endl;
delete[] lettercount;
//deallocation
if (k>l){
cout<<"error"<<endl;
return 0;
}
}