Debian Codegraph @

current/jgi/RemapQuality.java

raw symbols SCIP
1 package jgi;
2
3 import shared.Timer;
4 import stream.Read;
5 import stream.SamLine;
6 import template.BBTool_ST;
7
8 /**
9 * Changes quality scores to other quality scores.
10 * @author Brian Bushnell
11 * @date Apr 27, 2015
12 *
13 */
14 public class RemapQuality extends BBTool_ST {
15
16 /**
17 * Code entrance from the command line.
18 * Must be overridden; the commented body is an example.
19 * @param args Command line arguments
20 */
21 public static void main(String[] args){
22 //Example:
23 Timer t=new Timer();
24 RemapQuality bbt=new RemapQuality(args);
25 bbt.process(t);
26 }
27
28 @Override
29 protected void setDefaults(){}
30
31 /**
32 * @param args
33 */
34 public RemapQuality(String[] args) {
35 super(args);
36 SamLine.SET_FROM_OK=true;
37 map=new byte[256];
38 for(int i=0; i<map.length; i++){
39 map[i]=(byte)i;
40 }
41
42 if(mapString==null){//reverse quality
43 for(int i=2; i<=41; i++){
44 map[i]=(byte)(43-i);
45 }
46 }else{
47 String[] pairs=mapString.split(";");
48 for(String pair : pairs){
49 String[] split=pair.split(",");
50 int a=Integer.parseInt(split[0]);
51 int b=Integer.parseInt(split[1]);
52 map[a]=(byte)b;
53 }
54 }
55 }
56
57 /* (non-Javadoc)
58 * @see jgi.BBTool_ST#parseArgument(java.lang.String, java.lang.String, java.lang.String)
59 */
60 @Override
61 public boolean parseArgument(String arg, String a, String b){
62 if(a.equals("map")){
63 mapString=b;
64 return true;
65 }else if(false){
66 return true;
67 }
68 return false;
69 }
70
71 /* (non-Javadoc)
72 * @see jgi.BBTool_ST#startupSubclass()
73 */
74 @Override
75 protected void startupSubclass() {
76 // TODO Auto-generated method stub
77
78 }
79
80 /* (non-Javadoc)
81 * @see jgi.BBTool_ST#shutdownSubclass()
82 */
83 @Override
84 protected void shutdownSubclass() {
85 // TODO Auto-generated method stub
86
87 }
88
89 /* (non-Javadoc)
90 * @see jgi.BBTool_ST#showStatsSubclass(dna.Timer, long, long)
91 */
92 @Override
93 protected void showStatsSubclass(Timer t, long readsIn, long basesIn) {
94 // TODO Auto-generated method stub
95
96 }
97
98 @Override
99 protected final boolean useSharedHeader(){return true;}
100
101 /* (non-Javadoc)
102 * @see jgi.BBTool_ST#processReadPair(stream.Read, stream.Read)
103 */
104 @Override
105 protected boolean processReadPair(Read r1, Read r2) {
106 if(r1!=null && r1.quality!=null){
107 final byte[] qual=r1.quality;
108 for(int i=0; i<qual.length; i++){qual[i]=map[qual[i]];}
109 }
110 if(r2!=null && r2.quality!=null){
111 final byte[] qual=r2.quality;
112 for(int i=0; i<qual.length; i++){qual[i]=map[qual[i]];}
113 }
114 return true;
115 }
116
117 public String mapString;
118 public final byte[] map;
119
120 }