File: SummarizeMSDIN.java

package info (click to toggle)
bbmap 39.20%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 26,024 kB
  • sloc: java: 312,743; sh: 18,099; python: 5,247; ansic: 2,074; perl: 96; makefile: 39; xml: 38
file content (122 lines) | stat: -rwxr-xr-x 3,141 bytes parent folder | download | duplicates (4)
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
package driver;

import fileIO.TextFile;

/**
 * Summarizes match/sub/ins/del/N rates for consecutive BBMap runs
 * @author Brian Bushnell
 * @date Jan 8, 2014
 *
 */
public class SummarizeMSDIN {
	
	public static void main(String[] args){
		String fname=args[0];
		boolean M=false;
		boolean E=false;
		boolean S=true;
		boolean D=false;
		boolean I=false;
		boolean N=false;
		boolean B=false;
		boolean MS=true;

		long mcount=0;
		long ecount=0;
		long scount=0;
		long dcount=0;
		long icount=0;
		long ncount=0;
		long bcount=0;
		
		TextFile tf=new TextFile(fname);
		StringBuilder sb=new StringBuilder();
		for(String s=tf.nextLine(); s!=null; s=tf.nextLine()){
			String[] split=s.split("\t");
			if(s.startsWith("Total time:")){
				if(B){
					if(sb.length()>0){sb.append('\t');}
					sb.append(bcount);
				}
				if(MS){
					if(sb.length()>0){sb.append('\t');}
					sb.append((mcount+scount));
				}
				if(M){
					if(sb.length()>0){sb.append('\t');}
					sb.append(mcount);
				}
				if(E){
					if(sb.length()>0){sb.append('\t');}
					sb.append(ecount);
				}
				if(S){
					if(sb.length()>0){sb.append('\t');}
					sb.append(scount);
				}
				if(D){
					if(sb.length()>0){sb.append('\t');}
					sb.append(dcount);
				}
				if(I){
					if(sb.length()>0){sb.append('\t');}
					sb.append(icount);
				}
				if(N){
					if(sb.length()>0){sb.append('\t');}
					sb.append(ncount);
				}
				System.out.println(sb);
				sb.setLength(0);
				mcount=ecount=scount=dcount=icount=ncount=bcount=0;
			}else if(s.startsWith("Match Rate:")){
				String x=split[split.length-1];
				try{mcount=(Long.parseLong(x));}catch(Exception e){}
			}else if(E && s.startsWith("Error Rate:")){
				String x=split[split.length-1];
//				if(E){
//					if(sb.length()>0){sb.append('\t');}
//					sb.append(x);
//				}
				try{ecount=(Long.parseLong(x));}catch(Exception e){}
			}else if(s.startsWith("Sub Rate:")){
				String x=split[split.length-1];
//				if(S){
//					if(sb.length()>0){sb.append('\t');}
//					sb.append(x);
//				}
				try{scount=(Long.parseLong(x));}catch(Exception e){}
			}else if(s.startsWith("Del Rate:")){
				String x=split[split.length-1];
//				if(D){
//					if(sb.length()>0){sb.append('\t');}
//					sb.append(x);
//				}
				try{dcount=(Long.parseLong(x));}catch(Exception e){}
			}else if(s.startsWith("Ins Rate:")){
				String x=split[split.length-1];
//				if(I){
//					if(sb.length()>0){sb.append('\t');}
//					sb.append(x);
//				}
				try{icount=(Long.parseLong(x));}catch(Exception e){}
			}else if(s.startsWith("N Rate:")){
				String x=split[split.length-1];
//				if(N){
//					if(sb.length()>0){sb.append('\t');}
//					sb.append(x);
//				}
				try{ncount=(Long.parseLong(x));}catch(Exception e){}
			}else if(s.startsWith("Reads Used:")){
				String x=split[split.length-1].replace("(", "").replace(" bases)", "");
//				if(B){
//					if(sb.length()>0){sb.append('\t');}
//					sb.append(x);
//				}
				try{bcount=(Long.parseLong(x));}catch(Exception e){}
			}
		}
		
	}
	
}