-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCountRep.cpp
More file actions
51 lines (47 loc) · 1.11 KB
/
CountRep.cpp
File metadata and controls
51 lines (47 loc) · 1.11 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
#include <iostream>
#include <string>
#include <vector>
using namespace std;
// purpose: Calculate percent assembly masked.
// method: Report number of lower and upper case chars in input.
// input: (assembly) fasta file
// output: <fasta entry header> <(num lowercase chars)/(num total chars)> <num lowercase chars in entry> <num uppercase chars in entry>
int main() {
long int nl=0, nh=0, other=0;
string prevTitle = "";
while (cin) {
string line;
cin >> line;
if (line.size() > 0) {
if (line[0] == '>') {
if (prevTitle != "") {
int s=nl+nh;
if (s > 0) {
cout << prevTitle << "\t"<< nl / ((float)s) << "\t" << nl << "\t" << nh << endl;
}
else {
cout << prevTitle << "\t0\t0\t0" << endl;
}
}
nl=0; nh=0;
prevTitle = line;
} else {
for (int i=0; i < line.size(); i++) {
if (line[i] >= 'a' && line[i] <= 'z') {
nl+=1;
}
else {
nh+=1;
}
}
}
}
}
int s=nl+nh;
if (s > 0) {
cout << prevTitle << "\t"<< nl / ((float)s) << "\t" << nl << "\t" << nh<< endl;
}
else {
cout << prevTitle << "\t0\t0\t0" << endl;
}
}