| 1 |
package jgi; |
| 2 |
|
| 3 |
import shared.Timer; |
| 4 |
import stream.Read; |
| 5 |
import stream.SamLine; |
| 6 |
import template.BBTool_ST; |
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
public class RemapQuality extends BBTool_ST { |
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
public static void main(String[] args){ |
| 22 |
|
| 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 |
|
| 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){ |
| 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 |
|
| 58 |
|
| 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 |
|
| 72 |
|
| 73 |
|
| 74 |
@Override |
| 75 |
protected void startupSubclass() { |
| 76 |
|
| 77 |
|
| 78 |
} |
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
@Override |
| 84 |
protected void shutdownSubclass() { |
| 85 |
|
| 86 |
|
| 87 |
} |
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
@Override |
| 93 |
protected void showStatsSubclass(Timer t, long readsIn, long basesIn) { |
| 94 |
|
| 95 |
|
| 96 |
} |
| 97 |
|
| 98 |
@Override |
| 99 |
protected final boolean useSharedHeader(){return true;} |
| 100 |
|
| 101 |
|
| 102 |
|
| 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 |
} |