File tree Expand file tree Collapse file tree 1 file changed +26
-17
lines changed Expand file tree Collapse file tree 1 file changed +26
-17
lines changed Original file line number Diff line number Diff line change 22#include < string>
33#include < vector>
44using namespace std ;
5+
6+ // purpose: Calculate percent assembly masked.
7+ // method: Report number of lower and upper case chars in input.
8+ // input: (assembly) fasta file
9+ // output: <fasta entry header> <(num lowercase chars)/(num total chars)> <num lowercase chars in entry> <num uppercase chars in entry>
10+
511int main () {
612 long int nl=0 , nh=0 , other=0 ;
713
814 string prevTitle = " " ;
915 while (cin) {
1016 string line;
1117 cin >> line;
12- if (line.size () > 0 and line[0 ] == ' >' ) {
13- if (prevTitle != " " ) {
14- int s=nl+nh;
15- if (s > 0 ) {
16- cout << prevTitle << " \t " << nl / ((float )s) << " \t " << nl << " \t " << nh << endl;
18+ if (line.size () > 0 ) {
19+ if (line[0 ] == ' >' ) {
20+ if (prevTitle != " " ) {
21+ int s=nl+nh;
22+ if (s > 0 ) {
23+ cout << prevTitle << " \t " << nl / ((float )s) << " \t " << nl << " \t " << nh << endl;
24+ }
25+ else {
26+ cout << prevTitle << " \t 0\t 0\t 0" << endl;
27+ }
1728 }
18- else {
19- cout << prevTitle << " \t 0\t 0\t 0" << endl;
29+ nl=0 ; nh=0 ;
30+ prevTitle = line;
31+ } else {
32+ for (int i=0 ; i < line.size (); i++) {
33+ if (line[i] >= ' a' && line[i] <= ' z' ) {
34+ nl+=1 ;
35+ }
36+ else {
37+ nh+=1 ;
38+ }
2039 }
2140 }
22- nl=0 ; nh=0 ;
23- prevTitle = line;
24- }
25- for (int i=0 ; i < line.size (); i++) {
26- if (line[i] >= ' a' && line[i] <= ' z' ) {
27- nl+=1 ;
28- }
29- else {
30- nh+=1 ;
31- }
3241 }
3342 }
3443 int s=nl+nh;
You can’t perform that action at this time.
0 commit comments