| 1 |
package tracker; |
| 2 |
|
| 3 |
import java.util.ArrayList; |
| 4 |
import java.util.Arrays; |
| 5 |
import java.util.Collections; |
| 6 |
import java.util.HashMap; |
| 7 |
import java.util.Map.Entry; |
| 8 |
|
| 9 |
import align2.QualityTools; |
| 10 |
import barcode.Barcode; |
| 11 |
import dna.AminoAcid; |
| 12 |
import fileIO.ByteStreamWriter; |
| 13 |
import fileIO.TextStreamWriter; |
| 14 |
import shared.Shared; |
| 15 |
import shared.Tools; |
| 16 |
import shared.TrimRead; |
| 17 |
import stream.Read; |
| 18 |
import stream.SamLine; |
| 19 |
import structures.ByteBuilder; |
| 20 |
import structures.LongList; |
| 21 |
import structures.SuperLongList; |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
public class ReadStats { |
| 30 |
|
| 31 |
public ReadStats(){this(true);} |
| 32 |
|
| 33 |
public ReadStats(boolean addToList){ |
| 34 |
if(addToList){ |
| 35 |
synchronized(ReadStats.class){ |
| 36 |
objectList.add(this); |
| 37 |
} |
| 38 |
} |
| 39 |
|
| 40 |
if(COLLECT_QUALITY_STATS){ |
| 41 |
aqualArray=new long[2][QMAX2]; |
| 42 |
qualLength=new long[2][MAXLEN]; |
| 43 |
qualSum=new long[2][MAXLEN]; |
| 44 |
qualSumDouble=new double[2][MAXLEN]; |
| 45 |
bqualHistOverall=new long[QMAX2]; |
| 46 |
}else{ |
| 47 |
aqualArray=null; |
| 48 |
qualLength=null; |
| 49 |
qualSum=null; |
| 50 |
qualSumDouble=null; |
| 51 |
bqualHistOverall=null; |
| 52 |
} |
| 53 |
|
| 54 |
if(BQUAL_HIST_FILE!=null || COLLECT_QUALITY_STATS || COLLECT_QUALITY_ACCURACY){ |
| 55 |
bqualHist=new long[2][MAXLEN][QMAX2]; |
| 56 |
}else{ |
| 57 |
bqualHist=null; |
| 58 |
} |
| 59 |
|
| 60 |
if(QUAL_COUNT_HIST_FILE!=null){ |
| 61 |
qcountHist=new long[2][QMAX2]; |
| 62 |
}else{ |
| 63 |
qcountHist=null; |
| 64 |
} |
| 65 |
|
| 66 |
if(COLLECT_MATCH_STATS){ |
| 67 |
matchSum=new long[2][MAXLEN]; |
| 68 |
delSum=new long[2][MAXLEN]; |
| 69 |
insSum=new long[2][MAXLEN]; |
| 70 |
subSum=new long[2][MAXLEN]; |
| 71 |
nSum=new long[2][MAXLEN]; |
| 72 |
clipSum=new long[2][MAXLEN]; |
| 73 |
otherSum=new long[2][MAXLEN]; |
| 74 |
}else{ |
| 75 |
matchSum=null; |
| 76 |
delSum=null; |
| 77 |
insSum=null; |
| 78 |
subSum=null; |
| 79 |
nSum=null; |
| 80 |
clipSum=null; |
| 81 |
otherSum=null; |
| 82 |
} |
| 83 |
|
| 84 |
if(COLLECT_QUALITY_ACCURACY){ |
| 85 |
qualMatch=new long[QMAX2]; |
| 86 |
qualSub=new long[QMAX2]; |
| 87 |
qualIns=new long[QMAX2]; |
| 88 |
qualDel=new long[QMAX2]; |
| 89 |
}else{ |
| 90 |
qualMatch=null; |
| 91 |
qualSub=null; |
| 92 |
qualIns=null; |
| 93 |
qualDel=null; |
| 94 |
} |
| 95 |
|
| 96 |
if(COLLECT_INSERT_STATS){ |
| 97 |
insertHist=new LongList(MAXLEN); |
| 98 |
}else{ |
| 99 |
insertHist=null; |
| 100 |
} |
| 101 |
|
| 102 |
if(COLLECT_BASE_STATS){ |
| 103 |
baseHist=new LongList[2][5]; |
| 104 |
for(int i=0; i<baseHist.length; i++){ |
| 105 |
for(int j=0; j<baseHist[i].length; j++){ |
| 106 |
baseHist[i][j]=new LongList(400); |
| 107 |
} |
| 108 |
} |
| 109 |
}else{ |
| 110 |
baseHist=null; |
| 111 |
} |
| 112 |
|
| 113 |
|
| 114 |
if(COLLECT_INDEL_STATS){ |
| 115 |
insHist=new LongList(100); |
| 116 |
delHist=new LongList(100); |
| 117 |
delHist2=new LongList(100); |
| 118 |
}else{ |
| 119 |
insHist=null; |
| 120 |
delHist=null; |
| 121 |
delHist2=null; |
| 122 |
} |
| 123 |
|
| 124 |
if(COLLECT_GC_STATS){ |
| 125 |
gcHist=new long[GC_BINS+1]; |
| 126 |
}else{ |
| 127 |
gcHist=null; |
| 128 |
} |
| 129 |
|
| 130 |
if(COLLECT_ENTROPY_STATS){ |
| 131 |
entropyHist=new long[ENTROPY_BINS+1]; |
| 132 |
eTracker=new EntropyTracker(Shared.AMINO_IN, 0, true); |
| 133 |
}else{ |
| 134 |
entropyHist=null; |
| 135 |
eTracker=null; |
| 136 |
} |
| 137 |
|
| 138 |
if(COLLECT_ERROR_STATS){ |
| 139 |
errorHist=new LongList(100); |
| 140 |
}else{ |
| 141 |
errorHist=null; |
| 142 |
} |
| 143 |
|
| 144 |
if(COLLECT_LENGTH_STATS){ |
| 145 |
lengthHist=new SuperLongList(20000); |
| 146 |
}else{ |
| 147 |
lengthHist=null; |
| 148 |
} |
| 149 |
|
| 150 |
if(COLLECT_IDENTITY_STATS){ |
| 151 |
idHist=new long[ID_BINS+1]; |
| 152 |
idBaseHist=new long[ID_BINS+1]; |
| 153 |
}else{ |
| 154 |
idHist=null; |
| 155 |
idBaseHist=null; |
| 156 |
} |
| 157 |
|
| 158 |
if(COLLECT_TIME_STATS){ |
| 159 |
timeHist=new LongList(1001); |
| 160 |
}else{ |
| 161 |
timeHist=null; |
| 162 |
} |
| 163 |
|
| 164 |
if(COLLECT_BARCODE_STATS) { |
| 165 |
barcodeMap=new HashMap<String, Barcode>(); |
| 166 |
}else { |
| 167 |
barcodeMap=null; |
| 168 |
} |
| 169 |
} |
| 170 |
|
| 171 |
public static ReadStats mergeAll(){ |
| 172 |
if(objectList==null || objectList.isEmpty()){return merged=null;} |
| 173 |
if(objectList.size()==1){return merged=objectList.get(0);} |
| 174 |
|
| 175 |
ReadStats x=new ReadStats(false); |
| 176 |
for(ReadStats rs : objectList){ |
| 177 |
x.read2Count+=rs.read2Count; |
| 178 |
if(COLLECT_QUALITY_STATS){ |
| 179 |
for(int i=0; i<MAXLEN; i++){ |
| 180 |
x.qualLength[0][i]+=rs.qualLength[0][i]; |
| 181 |
x.qualLength[1][i]+=rs.qualLength[1][i]; |
| 182 |
x.qualSum[0][i]+=rs.qualSum[0][i]; |
| 183 |
x.qualSum[1][i]+=rs.qualSum[1][i]; |
| 184 |
x.qualSumDouble[0][i]+=rs.qualSumDouble[0][i]; |
| 185 |
x.qualSumDouble[1][i]+=rs.qualSumDouble[1][i]; |
| 186 |
} |
| 187 |
for(int i=0; i<x.aqualArray[0].length; i++){ |
| 188 |
x.aqualArray[0][i]+=rs.aqualArray[0][i]; |
| 189 |
x.aqualArray[1][i]+=rs.aqualArray[1][i]; |
| 190 |
} |
| 191 |
for(int i=0; i<x.bqualHistOverall.length; i++){ |
| 192 |
x.bqualHistOverall[i]+=rs.bqualHistOverall[i]; |
| 193 |
} |
| 194 |
if(x.bqualHist!=null){ |
| 195 |
for(int i=0; i<x.bqualHist.length; i++){ |
| 196 |
for(int j=0; j<x.bqualHist[i].length; j++){ |
| 197 |
for(int k=0; k<x.bqualHist[i][j].length; k++){ |
| 198 |
x.bqualHist[i][j][k]+=rs.bqualHist[i][j][k]; |
| 199 |
} |
| 200 |
} |
| 201 |
} |
| 202 |
} |
| 203 |
if(QUAL_COUNT_HIST_FILE!=null){ |
| 204 |
for(int i=0; i<x.qcountHist.length; i++){ |
| 205 |
for(int j=0; j<x.qcountHist[i].length; j++){ |
| 206 |
x.qcountHist[i][j]+=rs.qcountHist[i][j]; |
| 207 |
} |
| 208 |
} |
| 209 |
} |
| 210 |
} |
| 211 |
|
| 212 |
if(COLLECT_MATCH_STATS){ |
| 213 |
for(int i=0; i<MAXLEN; i++){ |
| 214 |
x.matchSum[0][i]+=rs.matchSum[0][i]; |
| 215 |
x.matchSum[1][i]+=rs.matchSum[1][i]; |
| 216 |
x.delSum[0][i]+=rs.delSum[0][i]; |
| 217 |
x.delSum[1][i]+=rs.delSum[1][i]; |
| 218 |
x.insSum[0][i]+=rs.insSum[0][i]; |
| 219 |
x.insSum[1][i]+=rs.insSum[1][i]; |
| 220 |
x.subSum[0][i]+=rs.subSum[0][i]; |
| 221 |
x.subSum[1][i]+=rs.subSum[1][i]; |
| 222 |
x.nSum[0][i]+=rs.nSum[0][i]; |
| 223 |
x.nSum[1][i]+=rs.nSum[1][i]; |
| 224 |
x.clipSum[0][i]+=rs.clipSum[0][i]; |
| 225 |
x.clipSum[1][i]+=rs.clipSum[1][i]; |
| 226 |
x.otherSum[0][i]+=rs.otherSum[0][i]; |
| 227 |
x.otherSum[1][i]+=rs.otherSum[1][i]; |
| 228 |
} |
| 229 |
} |
| 230 |
if(COLLECT_INSERT_STATS){ |
| 231 |
x.insertHist.incrementBy(rs.insertHist); |
| 232 |
x.pairedCount+=rs.pairedCount; |
| 233 |
x.unpairedCount+=rs.unpairedCount; |
| 234 |
} |
| 235 |
if(COLLECT_BASE_STATS){ |
| 236 |
for(int i=0; i<rs.baseHist.length; i++){ |
| 237 |
for(int j=0; j<rs.baseHist[i].length; j++){ |
| 238 |
x.baseHist[i][j].incrementBy(rs.baseHist[i][j]); |
| 239 |
} |
| 240 |
} |
| 241 |
} |
| 242 |
if(COLLECT_QUALITY_ACCURACY){ |
| 243 |
for(int i=0; i<x.qualMatch.length; i++){ |
| 244 |
x.qualMatch[i]+=rs.qualMatch[i]; |
| 245 |
x.qualSub[i]+=rs.qualSub[i]; |
| 246 |
x.qualIns[i]+=rs.qualIns[i]; |
| 247 |
x.qualDel[i]+=rs.qualDel[i]; |
| 248 |
} |
| 249 |
} |
| 250 |
|
| 251 |
|
| 252 |
if(COLLECT_INDEL_STATS){ |
| 253 |
x.delHist.incrementBy(rs.delHist); |
| 254 |
x.delHist2.incrementBy(rs.delHist2); |
| 255 |
x.insHist.incrementBy(rs.insHist); |
| 256 |
} |
| 257 |
|
| 258 |
if(COLLECT_LENGTH_STATS){ |
| 259 |
x.lengthHist.incrementBy(rs.lengthHist); |
| 260 |
} |
| 261 |
|
| 262 |
|
| 263 |
if(COLLECT_ERROR_STATS){ |
| 264 |
x.errorHist.incrementBy(rs.errorHist); |
| 265 |
} |
| 266 |
|
| 267 |
if(COLLECT_GC_STATS){ |
| 268 |
for(int i=0; i<rs.gcHist.length; i++){ |
| 269 |
x.gcHist[i]+=rs.gcHist[i]; |
| 270 |
} |
| 271 |
} |
| 272 |
|
| 273 |
if(COLLECT_ENTROPY_STATS){ |
| 274 |
for(int i=0; i<rs.entropyHist.length; i++){ |
| 275 |
x.entropyHist[i]+=rs.entropyHist[i]; |
| 276 |
} |
| 277 |
} |
| 278 |
|
| 279 |
if(COLLECT_IDENTITY_STATS){ |
| 280 |
for(int i=0; i<rs.idHist.length; i++){ |
| 281 |
x.idHist[i]+=rs.idHist[i]; |
| 282 |
x.idBaseHist[i]+=rs.idBaseHist[i]; |
| 283 |
} |
| 284 |
} |
| 285 |
|
| 286 |
if(COLLECT_TIME_STATS){ |
| 287 |
x.timeHist.incrementBy(rs.timeHist); |
| 288 |
} |
| 289 |
|
| 290 |
if(COLLECT_BARCODE_STATS){ |
| 291 |
for(Entry<String, Barcode> e : rs.barcodeMap.entrySet()) { |
| 292 |
final String key=e.getKey(); |
| 293 |
final Barcode brs=e.getValue(); |
| 294 |
Barcode bx=x.barcodeMap.get(key); |
| 295 |
if(bx==null) { |
| 296 |
x.barcodeMap.put(key, brs); |
| 297 |
}else{ |
| 298 |
bx.increment(brs); |
| 299 |
} |
| 300 |
} |
| 301 |
} |
| 302 |
|
| 303 |
x.gcMaxReadLen=Tools.max(x.gcMaxReadLen, rs.gcMaxReadLen); |
| 304 |
x.idMaxReadLen=Tools.max(x.idMaxReadLen, rs.idMaxReadLen); |
| 305 |
} |
| 306 |
|
| 307 |
merged=x; |
| 308 |
return x; |
| 309 |
} |
| 310 |
|
| 311 |
public void addToHistograms(Read r) { |
| 312 |
if(COLLECT_QUALITY_STATS){addToQualityHistogram(r);} |
| 313 |
if(COLLECT_BASE_STATS){addToBaseHistogram(r);} |
| 314 |
if(COLLECT_MATCH_STATS){addToMatchHistogram(r);} |
| 315 |
if(COLLECT_QUALITY_ACCURACY){addToQualityAccuracy(r);} |
| 316 |
|
| 317 |
if(COLLECT_ERROR_STATS){addToErrorHistogram(r);} |
| 318 |
if(COLLECT_INDEL_STATS){addToIndelHistogram(r);} |
| 319 |
if(COLLECT_LENGTH_STATS){addToLengthHistogram(r);} |
| 320 |
if(COLLECT_GC_STATS){addToGCHistogram(r);} |
| 321 |
if(COLLECT_ENTROPY_STATS){addToEntropyHistogram(r);} |
| 322 |
if(COLLECT_IDENTITY_STATS){addToIdentityHistogram(r);} |
| 323 |
if(COLLECT_BARCODE_STATS){addToBarcodeStats(r);} |
| 324 |
} |
| 325 |
|
| 326 |
public void addToQualityHistogram(final Read r){ |
| 327 |
if(r==null){return;} |
| 328 |
addToQualityHistogram2(r); |
| 329 |
if(r.mate!=null){addToQualityHistogram2(r.mate);} |
| 330 |
} |
| 331 |
|
| 332 |
private void addToQualityHistogram2(final Read r){ |
| 333 |
final int pairnum=r.samline==null ? r.pairnum() : r.samline.pairnum(); |
| 334 |
if(r==null || r.quality==null || r.quality.length<1){return;} |
| 335 |
byte[] quals=r.quality, bases=r.bases; |
| 336 |
final Object obj=r.obj; |
| 337 |
if(obj!=null && obj.getClass()==TrimRead.class){ |
| 338 |
quals=(pairnum==0 ? ((TrimRead)obj).qual1 : ((TrimRead)obj).qual2); |
| 339 |
bases=(pairnum==0 ? ((TrimRead)obj).bases1 : ((TrimRead)obj).bases2); |
| 340 |
} |
| 341 |
if(pairnum==1){read2Count++;} |
| 342 |
addToQualityHistogram(quals, pairnum); |
| 343 |
int x=Read.avgQualityByProbabilityInt(bases, quals, true, 0); |
| 344 |
aqualArray[pairnum][x]++; |
| 345 |
if(bqualHist!=null){ |
| 346 |
addToBQualityHistogram(quals, pairnum); |
| 347 |
} |
| 348 |
if(QUAL_COUNT_HIST_FILE!=null){ |
| 349 |
addToQCountHistogram(quals, pairnum); |
| 350 |
} |
| 351 |
} |
| 352 |
|
| 353 |
public void addToQualityHistogram(byte[] qual, int pairnum){ |
| 354 |
if(qual==null || qual.length<1){return;} |
| 355 |
final int limit=Tools.min(qual.length, MAXLEN); |
| 356 |
final long[] ql=qualLength[pairnum], qs=qualSum[pairnum]; |
| 357 |
final double[] qsd=qualSumDouble[pairnum]; |
| 358 |
ql[limit-1]++; |
| 359 |
for(int i=0; i<limit; i++){ |
| 360 |
qs[i]+=qual[i]; |
| 361 |
qsd[i]+=QualityTools.PROB_ERROR[qual[i]]; |
| 362 |
} |
| 363 |
for(byte q : qual){ |
| 364 |
bqualHistOverall[q]++; |
| 365 |
} |
| 366 |
} |
| 367 |
|
| 368 |
private void addToBQualityHistogram(byte[] qual, int pairnum){ |
| 369 |
if(qual==null || qual.length<1){return;} |
| 370 |
final int limit=Tools.min(qual.length, MAXLEN); |
| 371 |
final long[][] bqh=bqualHist[pairnum]; |
| 372 |
for(int i=0; i<limit; i++){ |
| 373 |
bqh[i][qual[i]]++; |
| 374 |
} |
| 375 |
} |
| 376 |
|
| 377 |
private void addToQCountHistogram(byte[] qual, int pairnum){ |
| 378 |
if(qual==null || qual.length<1){return;} |
| 379 |
final long[] qch=qcountHist[pairnum]; |
| 380 |
for(byte q : qual){ |
| 381 |
qch[q]++; |
| 382 |
} |
| 383 |
} |
| 384 |
|
| 385 |
public void addToQualityAccuracy(final Read r){ |
| 386 |
if(r==null){return;} |
| 387 |
addToQualityAccuracy(r, 0); |
| 388 |
if(r.mate!=null){addToQualityAccuracy(r.mate, 1);} |
| 389 |
} |
| 390 |
|
| 391 |
public void addToQualityAccuracy(final Read r, int pairnum){ |
| 392 |
if(r==null || r.quality==null || r.quality.length<1 || !r.mapped() || r.match==null){return;} |
| 393 |
final byte[] bases=r.bases; |
| 394 |
final byte[] qual=r.quality; |
| 395 |
byte[] match=r.match; |
| 396 |
|
| 397 |
if(r.shortmatch()){match=Read.toLongMatchString(match);} |
| 398 |
|
| 399 |
final boolean plus=(r.strand()==0); |
| 400 |
int bpos=0; |
| 401 |
byte lastm='A'; |
| 402 |
for(int mpos=0; mpos<match.length; mpos++){ |
| 403 |
byte b=bases[bpos]; |
| 404 |
byte q=qual[bpos]; |
| 405 |
byte m=match[plus ? mpos : match.length-mpos-1]; |
| 406 |
|
| 407 |
{ |
| 408 |
if(m=='m'){ |
| 409 |
qualMatch[q]++; |
| 410 |
}else if(m=='S'){ |
| 411 |
qualSub[q]++; |
| 412 |
}else if(m=='I'){ |
| 413 |
if(AminoAcid.isFullyDefined(b)){qualIns[q]++;} |
| 414 |
}else if(m=='N'){ |
| 415 |
|
| 416 |
}else if(m=='C'){ |
| 417 |
|
| 418 |
}else if(m=='V' || m=='i'){ |
| 419 |
|
| 420 |
}else if(m=='D'){ |
| 421 |
if(lastm!=m){ |
| 422 |
int x=bpos, y=bpos-1; |
| 423 |
if(x<qual.length){ |
| 424 |
if(AminoAcid.isFullyDefined(bases[x])){ |
| 425 |
qualDel[qual[x]]++; |
| 426 |
} |
| 427 |
} |
| 428 |
if(y>=0){ |
| 429 |
if(AminoAcid.isFullyDefined(bases[y])){ |
| 430 |
qualDel[qual[y]]++; |
| 431 |
} |
| 432 |
} |
| 433 |
} |
| 434 |
bpos--; |
| 435 |
}else if(m=='d'){ |
| 436 |
bpos--; |
| 437 |
}else{ |
| 438 |
assert(!Tools.isDigit(m)) : ((char)m); |
| 439 |
} |
| 440 |
} |
| 441 |
|
| 442 |
bpos++; |
| 443 |
lastm=m; |
| 444 |
} |
| 445 |
|
| 446 |
} |
| 447 |
|
| 448 |
public void addToErrorHistogram(final Read r){ |
| 449 |
if(r==null){return;} |
| 450 |
addToErrorHistogram(r, 0); |
| 451 |
if(r.mate!=null){addToErrorHistogram(r.mate, 1);} |
| 452 |
} |
| 453 |
|
| 454 |
private void addToErrorHistogram(final Read r, int pairnum){ |
| 455 |
if(r==null || r.bases==null || r.length()<1 || !r.mapped() || r.match==null){return;} |
| 456 |
r.toLongMatchString(false); |
| 457 |
int x=r.countSubs(); |
| 458 |
errorHist.increment(x, 1); |
| 459 |
} |
| 460 |
|
| 461 |
public void addToLengthHistogram(final Read r){ |
| 462 |
if(r==null){return;} |
| 463 |
addToLengthHistogram(r, 0); |
| 464 |
if(r.mate!=null){addToLengthHistogram(r.mate, 1);} |
| 465 |
} |
| 466 |
|
| 467 |
private void addToLengthHistogram(final Read r, int pairnum){ |
| 468 |
if(r==null || r.bases==null){return;} |
| 469 |
int x=r.length(); |
| 470 |
lengthHist.increment(x, 1); |
| 471 |
} |
| 472 |
|
| 473 |
public void addToGCHistogram(final Read r1){ |
| 474 |
if(r1==null){return;} |
| 475 |
final Read r2=r1.mate; |
| 476 |
final int len1=r1.length(), len2=r1.mateLength(); |
| 477 |
|
| 478 |
final float gc1=(len1>0 ? r1.gc() : -1); |
| 479 |
final float gc2=(len2>0 ? r2.gc() : -1); |
| 480 |
if(usePairGC){ |
| 481 |
final float gc; |
| 482 |
if(r2==null){ |
| 483 |
gc=gc1; |
| 484 |
}else{ |
| 485 |
gc=(gc1*len1+gc2*len2)/(len1+len2); |
| 486 |
} |
| 487 |
addToGCHistogram(gc, len1+len2); |
| 488 |
}else{ |
| 489 |
addToGCHistogram(gc1, len1); |
| 490 |
addToGCHistogram(gc2, len2); |
| 491 |
} |
| 492 |
} |
| 493 |
|
| 494 |
private void addToGCHistogram(final float gc, final int len){ |
| 495 |
if(gc<0 || len<1){return;} |
| 496 |
gcHist[Tools.min(GC_BINS, (int)(gc*(GC_BINS+1)))]++; |
| 497 |
gcMaxReadLen=Tools.max(len, gcMaxReadLen); |
| 498 |
} |
| 499 |
|
| 500 |
public void addToEntropyHistogram(final Read r1){ |
| 501 |
if(r1==null){return;} |
| 502 |
final Read r2=r1.mate; |
| 503 |
final int len1=r1.length(), len2=r1.mateLength(); |
| 504 |
|
| 505 |
final float entropy1=(len1>0 ? eTracker.averageEntropy(r1.bases, allowEntropyNs) : -1); |
| 506 |
final float entropy2=(len2>0 ? eTracker.averageEntropy(r2.bases, allowEntropyNs) : -1); |
| 507 |
if( false){ |
| 508 |
final float entropy; |
| 509 |
if(r2==null){ |
| 510 |
entropy=entropy1; |
| 511 |
}else{ |
| 512 |
entropy=(entropy1*len1+entropy2*len2)/(len1+len2); |
| 513 |
} |
| 514 |
addToEntropyHistogram(entropy, len1+len2); |
| 515 |
}else{ |
| 516 |
addToEntropyHistogram(entropy1, len1); |
| 517 |
addToEntropyHistogram(entropy2, len2); |
| 518 |
} |
| 519 |
} |
| 520 |
|
| 521 |
private void addToEntropyHistogram(final float entropy, final int len){ |
| 522 |
if(entropy<0 || len<1){return;} |
| 523 |
entropyHist[Tools.min(ENTROPY_BINS, (int)(entropy*(ENTROPY_BINS+1)))]++; |
| 524 |
} |
| 525 |
|
| 526 |
public void addToIdentityHistogram(final Read r){ |
| 527 |
if(r==null){return;} |
| 528 |
addToIdentityHistogram(r, 0); |
| 529 |
if(r.mate!=null){addToIdentityHistogram(r.mate, 1);} |
| 530 |
} |
| 531 |
|
| 532 |
private void addToIdentityHistogram(final Read r, int pairnum){ |
| 533 |
if(r==null || r.bases==null || r.length()<1 || !r.mapped() || r.match==null){return;} |
| 534 |
float id=r.identity(); |
| 535 |
idHist[(int)(id*ID_BINS)]++; |
| 536 |
idBaseHist[(int)(id*ID_BINS)]+=r.length(); |
| 537 |
idMaxReadLen=Tools.max(r.length(), idMaxReadLen); |
| 538 |
} |
| 539 |
|
| 540 |
public void addToTimeHistogram(final Read r){ |
| 541 |
if(r==null){return;} |
| 542 |
addToTimeHistogram(r, 0); |
| 543 |
} |
| 544 |
|
| 545 |
private void addToTimeHistogram(final Read r, int pairnum){ |
| 546 |
if(r==null){return;} |
| 547 |
assert(r.obj!=null && r.obj.getClass()==Long.class); |
| 548 |
int x=(int)Tools.min(((Long)r.obj).longValue(), MAXTIMELEN); |
| 549 |
timeHist.increment(x, 1); |
| 550 |
} |
| 551 |
|
| 552 |
public boolean addToIndelHistogram(final Read r){ |
| 553 |
if(r==null){return false;} |
| 554 |
boolean success=addToIndelHistogram(r, 0); |
| 555 |
if(r.mate!=null){success=addToIndelHistogram(r.mate, 1)|success;} |
| 556 |
return success; |
| 557 |
} |
| 558 |
|
| 559 |
|
| 560 |
private boolean addToIndelHistogram(final Read r, int pairnum){ |
| 561 |
if(r==null || !r.mapped()){return false;} |
| 562 |
if(r.samline!=null){ |
| 563 |
boolean success=addToIndelHistogram(r.samline); |
| 564 |
if(success){return true;} |
| 565 |
} |
| 566 |
if(r.match==null){return false;} |
| 567 |
final byte[] match=r.match; |
| 568 |
|
| 569 |
byte lastLetter='?'; |
| 570 |
boolean digit=false; |
| 571 |
int streak=0; |
| 572 |
for(int mpos=0; mpos<match.length; mpos++){ |
| 573 |
final byte m=match[mpos]; |
| 574 |
|
| 575 |
if(Tools.isDigit(m)){ |
| 576 |
streak=streak*10+m-'0'; |
| 577 |
digit=true; |
| 578 |
}else{ |
| 579 |
if(lastLetter==m){ |
| 580 |
streak++; |
| 581 |
}else{ |
| 582 |
|
| 583 |
if(!digit){streak++;} |
| 584 |
digit=false; |
| 585 |
if(lastLetter=='D'){ |
| 586 |
streak=Tools.min(streak, MAXDELLEN2); |
| 587 |
if(streak<MAXDELLEN){delHist.increment(streak, 1);} |
| 588 |
delHist2.increment(streak/100, 1); |
| 589 |
|
| 590 |
}else if(lastLetter=='I'){ |
| 591 |
streak=Tools.min(streak, MAXINSLEN); |
| 592 |
insHist.increment(streak, 1); |
| 593 |
|
| 594 |
} |
| 595 |
streak=0; |
| 596 |
} |
| 597 |
lastLetter=m; |
| 598 |
} |
| 599 |
} |
| 600 |
|
| 601 |
{ |
| 602 |
if(!digit){streak++;} |
| 603 |
digit=false; |
| 604 |
if(lastLetter=='D'){ |
| 605 |
streak=Tools.min(streak, MAXDELLEN2); |
| 606 |
if(streak<MAXDELLEN){delHist.increment(streak, 1);} |
| 607 |
delHist2.increment(streak/100, 1); |
| 608 |
|
| 609 |
}else if(lastLetter=='I'){ |
| 610 |
streak=Tools.min(streak, MAXINSLEN); |
| 611 |
insHist.increment(streak, 1); |
| 612 |
|
| 613 |
} |
| 614 |
streak=0; |
| 615 |
} |
| 616 |
return true; |
| 617 |
} |
| 618 |
|
| 619 |
private boolean addToIndelHistogram(SamLine sl){ |
| 620 |
if(sl==null || sl.cigar==null || !sl.mapped()){ |
| 621 |
return false; |
| 622 |
} |
| 623 |
final String cigar=sl.cigar; |
| 624 |
|
| 625 |
|
| 626 |
int count=0; |
| 627 |
for(int cpos=0; cpos<cigar.length(); cpos++){ |
| 628 |
final char c=cigar.charAt(cpos); |
| 629 |
|
| 630 |
if(Tools.isDigit(c)){ |
| 631 |
count=count*10+c-'0'; |
| 632 |
}else{ |
| 633 |
if(c=='I'){ |
| 634 |
int streak=Tools.min(count, MAXINSLEN); |
| 635 |
insHist.increment(streak, 1); |
| 636 |
|
| 637 |
}else if(c=='D'){ |
| 638 |
int streak=Tools.min(count, MAXDELLEN2); |
| 639 |
if(streak<MAXDELLEN){delHist.increment(streak, 1);} |
| 640 |
delHist2.increment(streak/100, 1); |
| 641 |
|
| 642 |
}else{ |
| 643 |
|
| 644 |
} |
| 645 |
count=0; |
| 646 |
} |
| 647 |
} |
| 648 |
assert(count==0) : count; |
| 649 |
return true; |
| 650 |
} |
| 651 |
|
| 652 |
public void addToMatchHistogram(final Read r){ |
| 653 |
if(r==null){return;} |
| 654 |
addToMatchHistogram2(r); |
| 655 |
if(r.mate!=null){addToMatchHistogram2(r.mate);} |
| 656 |
} |
| 657 |
|
| 658 |
private void addToMatchHistogram2(final Read r){ |
| 659 |
if(r==null || r.bases==null || r.length()<1 || !r.mapped() || r.match==null){return;} |
| 660 |
final int pairnum=r.samline==null ? r.pairnum() : r.samline.pairnum(); |
| 661 |
if(pairnum==1){read2Count++;} |
| 662 |
final byte[] bases=r.bases; |
| 663 |
final int limit=Tools.min(bases.length, MAXLEN); |
| 664 |
final long[] ms=matchSum[pairnum], ds=delSum[pairnum], is=insSum[pairnum], |
| 665 |
ss=subSum[pairnum], ns=nSum[pairnum], cs=clipSum[pairnum], os=otherSum[pairnum]; |
| 666 |
|
| 667 |
byte[] match=r.match; |
| 668 |
if(r.shortmatch() && match!=null){match=Read.toLongMatchString(match);} |
| 669 |
|
| 670 |
if(match==null){ |
| 671 |
for(int i=0; i<limit; i++){ |
| 672 |
byte b=bases[i]; |
| 673 |
if(b=='N'){ns[i]++;} |
| 674 |
else{os[i]++;} |
| 675 |
} |
| 676 |
}else{ |
| 677 |
final boolean plus=(r.strand()==0); |
| 678 |
int bpos=0; |
| 679 |
byte lastm='A'; |
| 680 |
for(int mpos=0; mpos<match.length && bpos<limit; mpos++){ |
| 681 |
byte b=bases[bpos]; |
| 682 |
byte m=match[plus ? mpos : match.length-mpos-1]; |
| 683 |
if(b=='N'){ |
| 684 |
if(m=='D'){ |
| 685 |
if(lastm!=m){ds[bpos]++;} |
| 686 |
bpos--; |
| 687 |
}else{ns[bpos]++;} |
| 688 |
}else{ |
| 689 |
if(m=='m'){ |
| 690 |
ms[bpos]++; |
| 691 |
}else if(m=='S'){ |
| 692 |
ss[bpos]++; |
| 693 |
}else if(m=='I'){ |
| 694 |
is[bpos]++; |
| 695 |
}else if(m=='N' || m=='V'){ |
| 696 |
|
| 697 |
os[bpos]++; |
| 698 |
}else if(m=='C'){ |
| 699 |
|
| 700 |
cs[bpos]++; |
| 701 |
}else if(m=='D'){ |
| 702 |
if(lastm!=m){ds[bpos]++;} |
| 703 |
bpos--; |
| 704 |
}else if(m=='i'){ |
| 705 |
os[bpos]++; |
| 706 |
}else if(m=='d'){ |
| 707 |
bpos--; |
| 708 |
}else{ |
| 709 |
os[bpos]++; |
| 710 |
assert(false) : "For read "+r.numericID+", unknown symbol in match string: ASCII "+m+" = "+(char)m; |
| 711 |
} |
| 712 |
} |
| 713 |
bpos++; |
| 714 |
lastm=m; |
| 715 |
} |
| 716 |
} |
| 717 |
} |
| 718 |
|
| 719 |
public void addToInsertHistogram(final Read r, boolean ignoreMappingStrand){ |
| 720 |
if(verbose){ |
| 721 |
System.err.print(r.numericID); |
| 722 |
if(r==null || r.mate==null || !r.mapped() || !r.mate.mapped() || !r.paired()){ |
| 723 |
System.err.println("\n"); |
| 724 |
}else{ |
| 725 |
System.err.println("\t"+r.strand()+"\t"+r.insertSizeMapped(ignoreMappingStrand)+"\t"+r.mate.insertSizeMapped(ignoreMappingStrand)); |
| 726 |
} |
| 727 |
} |
| 728 |
if(r==null || r.mate==null || !r.mapped() || !r.mate.mapped() || !r.paired()){ |
| 729 |
unpairedCount++; |
| 730 |
return; |
| 731 |
} |
| 732 |
int x=Tools.min(MAXINSERTLEN, r.insertSizeMapped(ignoreMappingStrand)); |
| 733 |
if(x>0){ |
| 734 |
insertHist.increment(x, 1); |
| 735 |
pairedCount++; |
| 736 |
}else{ |
| 737 |
unpairedCount++; |
| 738 |
} |
| 739 |
|
| 740 |
|
| 741 |
} |
| 742 |
|
| 743 |
public void addToInsertHistogram(final SamLine r1){ |
| 744 |
int x=r1.tlen; |
| 745 |
if(x<0) {x=-x;} |
| 746 |
x=Tools.min(MAXINSERTLEN, x); |
| 747 |
if(r1.pairedOnSameChrom() && x>0){ |
| 748 |
pairedCount++; |
| 749 |
insertHist.increment(x, 1); |
| 750 |
}else { |
| 751 |
unpairedCount++; |
| 752 |
} |
| 753 |
} |
| 754 |
|
| 755 |
public void addToInsertHistogram(final SamLine r1, final SamLine r2){ |
| 756 |
if(r1==null){return;} |
| 757 |
int x=insertSizeMapped(r1, r2, REQUIRE_PROPER_PAIR); |
| 758 |
if(verbose){ |
| 759 |
System.err.println(r1.qname+"\t"+x); |
| 760 |
} |
| 761 |
x=Tools.min(MAXINSERTLEN, x); |
| 762 |
if(x>0){ |
| 763 |
insertHist.increment(x, 1); |
| 764 |
pairedCount++; |
| 765 |
}else{ |
| 766 |
unpairedCount++; |
| 767 |
} |
| 768 |
} |
| 769 |
|
| 770 |
|
| 771 |
|
| 772 |
|
| 773 |
public static int insertSizeMapped(SamLine r1, SamLine r2, boolean requireProperPair){ |
| 774 |
if(r2==null){return r1.length();} |
| 775 |
if(!r1.mapped() || !r2.mapped() || !r1.pairedOnSameChrom() || (requireProperPair && !r1.properPair())){ |
| 776 |
return -1; |
| 777 |
} |
| 778 |
|
| 779 |
int a1=r1.start(true, false); |
| 780 |
int a2=r2.start(true, false); |
| 781 |
|
| 782 |
if(r1.strand()!=r2.strand()){ |
| 783 |
if(r1.strand()==1){return insertSizeMapped(r2, r1, requireProperPair);} |
| 784 |
}else if(a1>a2){ |
| 785 |
return insertSizeMapped(r2, r1, requireProperPair); |
| 786 |
} |
| 787 |
|
| 788 |
int b1=r1.stop(a1, true, false); |
| 789 |
int b2=r2.stop(a2, true, false); |
| 790 |
|
| 791 |
int clen1=r1.calcCigarLength(true, false); |
| 792 |
int clen2=r2.calcCigarLength(true, false); |
| 793 |
|
| 794 |
int mlen1=b1-a1+1; |
| 795 |
int mlen2=b2-a2+1; |
| 796 |
|
| 797 |
int dif1=mlen1-clen1; |
| 798 |
int dif2=mlen2-clen2; |
| 799 |
|
| 800 |
int mlen12=b2-a1+1; |
| 801 |
|
| 802 |
if(Tools.overlap(a1, b1, a2, b2)){ |
| 803 |
return mlen12-Tools.max(dif1, dif2); |
| 804 |
}else{ |
| 805 |
return mlen12-dif1-dif2; |
| 806 |
} |
| 807 |
} |
| 808 |
|
| 809 |
public void addToBaseHistogram(final Read r){ |
| 810 |
addToBaseHistogram2(r); |
| 811 |
if(r.mate!=null){addToBaseHistogram2(r.mate);} |
| 812 |
} |
| 813 |
|
| 814 |
public void addToBaseHistogram2(final Read r){ |
| 815 |
if(r==null || r.bases==null){return;} |
| 816 |
final int pairnum=r.samline==null ? r.pairnum() : r.samline.pairnum(); |
| 817 |
if(pairnum==1){read2Count++;} |
| 818 |
final byte[] bases=r.bases; |
| 819 |
final LongList[] lists=baseHist[pairnum]; |
| 820 |
for(int i=0; i<bases.length; i++){ |
| 821 |
byte b=bases[i]; |
| 822 |
int x=AminoAcid.baseToNumber[b]+1; |
| 823 |
lists[x].increment(i, 1); |
| 824 |
} |
| 825 |
} |
| 826 |
|
| 827 |
public void addToBarcodeStats(final Read r){ |
| 828 |
String key=r.barcode(false); |
| 829 |
if(key==null) {key="NONE";} |
| 830 |
Barcode b=barcodeMap.get(key); |
| 831 |
if(b==null) { |
| 832 |
b=new Barcode(key); |
| 833 |
barcodeMap.put(key, b); |
| 834 |
} |
| 835 |
b.increment(r.pairCount()); |
| 836 |
|
| 837 |
} |
| 838 |
|
| 839 |
public static boolean testFiles(boolean allowDuplicates){ |
| 840 |
return Tools.testOutputFiles(overwrite, append, allowDuplicates, |
| 841 |
AVG_QUAL_HIST_FILE, QUAL_HIST_FILE, BQUAL_HIST_FILE, BQUAL_HIST_OVERALL_FILE, QUAL_COUNT_HIST_FILE, |
| 842 |
MATCH_HIST_FILE, INSERT_HIST_FILE, BASE_HIST_FILE, QUAL_ACCURACY_FILE, INDEL_HIST_FILE, ERROR_HIST_FILE, LENGTH_HIST_FILE, |
| 843 |
GC_HIST_FILE, ENTROPY_HIST_FILE, IDENTITY_HIST_FILE, TIME_HIST_FILE, BARCODE_STATS_FILE); |
| 844 |
} |
| 845 |
|
| 846 |
public static boolean writeAll(){ |
| 847 |
if(collectingStats()){ |
| 848 |
ReadStats rs=mergeAll(); |
| 849 |
boolean paired=rs.read2Count>0; |
| 850 |
|
| 851 |
if(AVG_QUAL_HIST_FILE!=null){rs.writeAverageQualityToFile(AVG_QUAL_HIST_FILE, paired);} |
| 852 |
if(QUAL_HIST_FILE!=null){rs.writeQualityToFile(QUAL_HIST_FILE, paired);} |
| 853 |
if(BQUAL_HIST_FILE!=null){rs.writeBQualityToFile(BQUAL_HIST_FILE, paired);} |
| 854 |
if(BQUAL_HIST_OVERALL_FILE!=null){rs.writeBQualityOverallToFile(BQUAL_HIST_OVERALL_FILE);} |
| 855 |
if(QUAL_COUNT_HIST_FILE!=null){rs.writeQCountToFile(QUAL_COUNT_HIST_FILE, paired);} |
| 856 |
if(MATCH_HIST_FILE!=null){rs.writeMatchToFile(MATCH_HIST_FILE, paired);} |
| 857 |
if(INSERT_HIST_FILE!=null){rs.writeInsertToFile(INSERT_HIST_FILE);} |
| 858 |
if(BASE_HIST_FILE!=null){rs.writeBaseContentToFile(BASE_HIST_FILE, paired);} |
| 859 |
if(QUAL_ACCURACY_FILE!=null){rs.writeQualityAccuracyToFile(QUAL_ACCURACY_FILE);} |
| 860 |
|
| 861 |
if(INDEL_HIST_FILE!=null){rs.writeIndelToFile(INDEL_HIST_FILE);} |
| 862 |
if(ERROR_HIST_FILE!=null){rs.writeErrorToFile(ERROR_HIST_FILE);} |
| 863 |
if(LENGTH_HIST_FILE!=null){rs.writeLengthToFile(LENGTH_HIST_FILE);} |
| 864 |
if(GC_HIST_FILE!=null){rs.writeGCToFile(GC_HIST_FILE, true);} |
| 865 |
if(ENTROPY_HIST_FILE!=null){rs.writeEntropyToFile(ENTROPY_HIST_FILE, true);} |
| 866 |
if(IDENTITY_HIST_FILE!=null){rs.writeIdentityToFile(IDENTITY_HIST_FILE, true);} |
| 867 |
if(TIME_HIST_FILE!=null){rs.writeTimeToFile(TIME_HIST_FILE);} |
| 868 |
if(BARCODE_STATS_FILE!=null){rs.writeBarcodesToFile(BARCODE_STATS_FILE);} |
| 869 |
|
| 870 |
boolean b=rs.errorState; |
| 871 |
clear(); |
| 872 |
return b; |
| 873 |
} |
| 874 |
clear(); |
| 875 |
return false; |
| 876 |
} |
| 877 |
|
| 878 |
public void writeAverageQualityToFile(String fname, boolean writePaired){ |
| 879 |
TextStreamWriter tsw=new TextStreamWriter(fname, overwrite, append, false); |
| 880 |
tsw.start(); |
| 881 |
tsw.print("#Quality\tcount1\tfraction1"+(writePaired ? "\tcount2\tfraction2" : "")+"\n"); |
| 882 |
|
| 883 |
long sum1=shared.Vector.sum(aqualArray[0]); |
| 884 |
long sum2=shared.Vector.sum(aqualArray[1]); |
| 885 |
double mult1=1.0/Tools.max(1, sum1); |
| 886 |
double mult2=1.0/Tools.max(1, sum2); |
| 887 |
|
| 888 |
long y=sum1+sum2; |
| 889 |
for(int i=0; i<aqualArray[0].length; i++){ |
| 890 |
long x1=aqualArray[0][i]; |
| 891 |
long x2=aqualArray[1][i]; |
| 892 |
y-=x1; |
| 893 |
y-=x2; |
| 894 |
tsw.print(Tools.format("%d\t%d\t%.5f", i, x1, x1*mult1)); |
| 895 |
if(writePaired){ |
| 896 |
tsw.print(Tools.format("\t%d\t%.5f", x2, x2*mult2)); |
| 897 |
} |
| 898 |
tsw.print("\n"); |
| 899 |
if(y<=0){break;} |
| 900 |
} |
| 901 |
tsw.poisonAndWait(); |
| 902 |
errorState|=tsw.errorState; |
| 903 |
} |
| 904 |
|
| 905 |
public void writeQCountToFile(String fname, boolean writePaired){ |
| 906 |
TextStreamWriter tsw=new TextStreamWriter(fname, overwrite, append, false); |
| 907 |
tsw.start(); |
| 908 |
tsw.print("#Quality\tcount1\tfraction1"+(writePaired ? "\tcount2\tfraction2" : "")+"\n"); |
| 909 |
|
| 910 |
long sum1=shared.Vector.sum(qcountHist[0]); |
| 911 |
long sum2=shared.Vector.sum(qcountHist[1]); |
| 912 |
double mult1=1.0/Tools.max(1, sum1); |
| 913 |
double mult2=1.0/Tools.max(1, sum2); |
| 914 |
|
| 915 |
long y=sum1+sum2; |
| 916 |
for(int i=0; i<qcountHist[0].length; i++){ |
| 917 |
long x1=qcountHist[0][i]; |
| 918 |
long x2=qcountHist[1][i]; |
| 919 |
y-=x1; |
| 920 |
y-=x2; |
| 921 |
tsw.print(Tools.format("%d\t%d\t%.5f", i, x1, x1*mult1)); |
| 922 |
if(writePaired){ |
| 923 |
tsw.print(Tools.format("\t%d\t%.5f", x2, x2*mult2)); |
| 924 |
} |
| 925 |
tsw.print("\n"); |
| 926 |
if(y<=0){break;} |
| 927 |
} |
| 928 |
tsw.poisonAndWait(); |
| 929 |
errorState|=tsw.errorState; |
| 930 |
} |
| 931 |
|
| 932 |
public int q30(int pairnum) { |
| 933 |
return lengthAboveAverageQscore(30, pairnum); |
| 934 |
} |
| 935 |
|
| 936 |
public int lengthAboveAverageQscore(float limit, int pairnum) { |
| 937 |
final long[] qs=qualSum[pairnum]; |
| 938 |
long[] ql=qualLength[pairnum]; |
| 939 |
if(ql!=null) {ql=ql.clone();} |
| 940 |
|
| 941 |
for(int i=MAXLEN-2; i>=0; i--){ql[i]+=ql[i+1];} |
| 942 |
for(int i=0; i<MAXLEN; i++) { |
| 943 |
if(ql[i]<0) {return i;} |
| 944 |
float avg=qs[i]/(float)ql[i]; |
| 945 |
if(avg<limit) {return i;} |
| 946 |
} |
| 947 |
return MAXLEN; |
| 948 |
} |
| 949 |
|
| 950 |
public void writeQualityToFile(String fname, boolean writePaired){ |
| 951 |
StringBuilder sb=new StringBuilder(); |
| 952 |
final boolean measure=(matchSum!=null); |
| 953 |
if(measure){ |
| 954 |
if(writePaired){ |
| 955 |
sb.append("#BaseNum\tRead1_linear\tRead1_log\tRead1_measured\tRead2_linear\tRead2_log\tRead2_measured\n"); |
| 956 |
}else{ |
| 957 |
sb.append("#BaseNum\tRead1_linear\tRead1_log\tRead1_measured\n"); |
| 958 |
} |
| 959 |
}else{ |
| 960 |
sb.append("#BaseNum\tRead1_linear\tRead1_log"+(writePaired ? "\tRead2_linear\tRead2_log" : "")+"\n"); |
| 961 |
} |
| 962 |
|
| 963 |
final long[] qs1=qualSum[0], qs2=qualSum[1]; |
| 964 |
long[] ql1=qualLength[0], ql2=qualLength[1]; |
| 965 |
if(ql1!=null) {ql1=ql1.clone();} |
| 966 |
if(ql2!=null) {ql2=ql2.clone();} |
| 967 |
final double[] qsd1=qualSumDouble[0], qsd2=qualSumDouble[1]; |
| 968 |
|
| 969 |
for(int i=MAXLEN-2; i>=0; i--){ |
| 970 |
ql1[i]+=ql1[i+1]; |
| 971 |
ql2[i]+=ql2[i+1]; |
| 972 |
} |
| 973 |
|
| 974 |
double div1sum=0; |
| 975 |
double div2sum=0; |
| 976 |
double deviation1sum=0; |
| 977 |
double deviation2sum=0; |
| 978 |
|
| 979 |
if(writePaired){ |
| 980 |
for(int i=0; i<MAXLEN && (ql1[i]>0 || ql2[i]>0); i++){ |
| 981 |
final int a=i+1; |
| 982 |
double blin, clin, blog, clog; |
| 983 |
final double div1=(double)Tools.max(1, ql1[i]); |
| 984 |
final double div2=(double)Tools.max(1, ql2[i]); |
| 985 |
|
| 986 |
blin=qs1[i]/div1; |
| 987 |
clin=qs2[i]/div2; |
| 988 |
blog=qsd1[i]/div1; |
| 989 |
clog=qsd2[i]/div2; |
| 990 |
blog=QualityTools.probErrorToPhredDouble(blog); |
| 991 |
clog=QualityTools.probErrorToPhredDouble(clog); |
| 992 |
if(measure){ |
| 993 |
double bcalc=calcQualityAtPosition(i, 0); |
| 994 |
double ccalc=calcQualityAtPosition(i, 1); |
| 995 |
|
| 996 |
div1sum+=div1; |
| 997 |
div2sum+=div2; |
| 998 |
deviation1sum+=Math.abs(blog-bcalc)*div1; |
| 999 |
deviation2sum+=Math.abs(clog-ccalc)*div2; |
| 1000 |
|
| 1001 |
sb.append(Tools.format("%d\t%.3f\t%.3f\t%.3f\t%.3f\t%.3f\t%.3f\n", a, blin, blog, bcalc, clin, clog, ccalc)); |
| 1002 |
}else{ |
| 1003 |
sb.append(Tools.format("%d\t%.3f\t%.3f\t%.3f\t%.3f\n", a, blin, blog, clin, clog)); |
| 1004 |
} |
| 1005 |
} |
| 1006 |
}else{ |
| 1007 |
for(int i=0; i<MAXLEN && ql1[i]>0; i++){ |
| 1008 |
final int a=i+1; |
| 1009 |
double blin, blog; |
| 1010 |
final double div1=(double)Tools.max(1, ql1[i]); |
| 1011 |
|
| 1012 |
blin=qs1[i]/div1; |
| 1013 |
blog=qsd1[i]/div1; |
| 1014 |
blog=QualityTools.probErrorToPhredDouble(blog); |
| 1015 |
if(measure){ |
| 1016 |
double bcalc=calcQualityAtPosition(i, 0); |
| 1017 |
|
| 1018 |
div1sum+=div1; |
| 1019 |
deviation1sum+=Math.abs(blog-bcalc)*div1; |
| 1020 |
|
| 1021 |
sb.append(Tools.format("%d\t%.3f\t%.3f\t%.3f\n", a, blin, blog, bcalc)); |
| 1022 |
}else{ |
| 1023 |
sb.append(Tools.format("%d\t%.3f\t%.3f\n", a, blin, blog)); |
| 1024 |
} |
| 1025 |
} |
| 1026 |
} |
| 1027 |
|
| 1028 |
final double stdev; |
| 1029 |
final double variance; |
| 1030 |
final double entropy; |
| 1031 |
{ |
| 1032 |
double stdevSum=0; |
| 1033 |
double varianceSum=0; |
| 1034 |
double entropySum=0; |
| 1035 |
long values=0; |
| 1036 |
for(int pos=0; pos<MAXLEN; pos++) { |
| 1037 |
long count=0; |
| 1038 |
for(int rnum=0; rnum<2; rnum++) { |
| 1039 |
final long[] array=bqualHist[rnum][pos]; |
| 1040 |
final long sum=Tools.sum(array); |
| 1041 |
if(sum>0) { |
| 1042 |
values++;; |
| 1043 |
count+=sum; |
| 1044 |
final double avg=Tools.averageHistogram(array); |
| 1045 |
final double stdev0=Tools.standardDeviationHistogram(array); |
| 1046 |
final double entropy0=calcEntropySuperSlow(array); |
| 1047 |
entropySum+=entropy0; |
| 1048 |
double varSum=0; |
| 1049 |
for(int i=0; i<array.length; i++) { |
| 1050 |
double var=Tools.absdif(i, avg); |
| 1051 |
varSum+=(var*array[i]); |
| 1052 |
} |
| 1053 |
stdevSum+=stdev0; |
| 1054 |
varianceSum+=(varSum/sum); |
| 1055 |
} |
| 1056 |
} |
| 1057 |
if(count==0) {break;} |
| 1058 |
} |
| 1059 |
stdev=stdevSum/values; |
| 1060 |
variance=varianceSum/values; |
| 1061 |
entropy=entropySum/values; |
| 1062 |
} |
| 1063 |
|
| 1064 |
TextStreamWriter tsw=new TextStreamWriter(fname, overwrite, append, false); |
| 1065 |
tsw.start(); |
| 1066 |
if(measure){ |
| 1067 |
if(writePaired){ |
| 1068 |
tsw.print(Tools.format("#Deviation\t%.4f\t%.4f\n", deviation1sum/div1sum, deviation2sum/div2sum)); |
| 1069 |
}else{ |
| 1070 |
tsw.print(Tools.format("#Deviation\t%.4f\n", deviation1sum/div1sum)); |
| 1071 |
} |
| 1072 |
tsw.print(Tools.format("#Avg_STDev\t%.3f\n", stdev)); |
| 1073 |
tsw.print(Tools.format("#Diversity\t%.3f\n", variance)); |
| 1074 |
tsw.print(Tools.format("#Entropy\t%.3f\n", entropy)); |
| 1075 |
} |
| 1076 |
tsw.print(sb); |
| 1077 |
tsw.poisonAndWait(); |
| 1078 |
errorState|=tsw.errorState; |
| 1079 |
} |
| 1080 |
|
| 1081 |
private double calcQualityAtPosition(int pos, int pairnum){ |
| 1082 |
boolean includeNs=true; |
| 1083 |
long m=matchSum[pairnum][pos]; |
| 1084 |
long d=delSum[pairnum][pos]; |
| 1085 |
long d2=delSum[pairnum][Tools.min(pos, delSum[pairnum].length-1)]; |
| 1086 |
long i=insSum[pairnum][pos]; |
| 1087 |
long s=subSum[pairnum][pos]; |
| 1088 |
long n=(includeNs ? nSum[pairnum][pos] : 0); |
| 1089 |
long good=Tools.max(0, m*2-d-d2+n/2); |
| 1090 |
long total=Tools.max(0, m*2+i*2+s*2+n*2); |
| 1091 |
long bad=total-good; |
| 1092 |
if(total<1){return 0;} |
| 1093 |
double error=bad/(double)total; |
| 1094 |
return QualityTools.probErrorToPhredDouble(error); |
| 1095 |
} |
| 1096 |
|
| 1097 |
public void writeBQualityOverallToFile(String fname){ |
| 1098 |
final long[] cp30=Arrays.copyOf(bqualHistOverall, bqualHistOverall.length); |
| 1099 |
for(int i=0; i<30; i++){cp30[i]=0;} |
| 1100 |
|
| 1101 |
final long sum=shared.Vector.sum(bqualHistOverall); |
| 1102 |
final long median=Tools.percentileHistogram(bqualHistOverall, 0.5); |
| 1103 |
final double mean=Tools.averageHistogram(bqualHistOverall); |
| 1104 |
final double stdev=Tools.standardDeviationHistogram(bqualHistOverall); |
| 1105 |
final double mean30=Tools.averageHistogram(cp30); |
| 1106 |
final double stdev30=Tools.standardDeviationHistogram(cp30); |
| 1107 |
final double mult=1.0/Tools.max(1, sum); |
| 1108 |
long y=sum; |
| 1109 |
|
| 1110 |
TextStreamWriter tsw=new TextStreamWriter(fname, overwrite, append, false); |
| 1111 |
tsw.start(); |
| 1112 |
tsw.print("#Median\t"+median+"\n"); |
| 1113 |
tsw.print("#Mean\t"+Tools.format("%.3f", mean)+"\n"); |
| 1114 |
tsw.print("#STDev\t"+Tools.format("%.3f", stdev)+"\n"); |
| 1115 |
tsw.print("#Mean_30\t"+Tools.format("%.3f", mean30)+"\n"); |
| 1116 |
tsw.print("#STDev_30\t"+Tools.format("%.3f", stdev30)+"\n"); |
| 1117 |
tsw.print("#Quality\tbases\tfraction\n"); |
| 1118 |
|
| 1119 |
for(int i=0; i<bqualHistOverall.length; i++){ |
| 1120 |
long x=bqualHistOverall[i]; |
| 1121 |
y-=x; |
| 1122 |
tsw.print(Tools.format("%d\t%d\t%.5f", i, x, x*mult)); |
| 1123 |
tsw.print("\n"); |
| 1124 |
if(y<=0){break;} |
| 1125 |
} |
| 1126 |
tsw.poisonAndWait(); |
| 1127 |
errorState|=tsw.errorState; |
| 1128 |
} |
| 1129 |
|
| 1130 |
public void writeBQualityToFile(String fname, boolean writePaired){ |
| 1131 |
TextStreamWriter tsw=new TextStreamWriter(fname, overwrite, append, false); |
| 1132 |
tsw.start(); |
| 1133 |
tsw.print("#BaseNum\tcount_1\tmin_1\tmax_1\tmean_1\tQ1_1\tmed_1\tQ3_1\tLW_1\tRW_1"); |
| 1134 |
if(writePaired){tsw.print("\tcount_2\tmin_2\tmax_2\tmean_2\tQ1_2\tmed_2\tQ3_2\tLW_2\tRW_2");} |
| 1135 |
tsw.print("\n"); |
| 1136 |
|
| 1137 |
for(int i=0; i<MAXLEN; i++){ |
| 1138 |
final long[] a1=bqualHist[0][i], a2=bqualHist[1][i]; |
| 1139 |
final long sum1=shared.Vector.sum(a1), sum2=shared.Vector.sum(a2); |
| 1140 |
if(sum1<1 && sum2<1){break;} |
| 1141 |
|
| 1142 |
{ |
| 1143 |
final long a[]=a1, sum=sum1; |
| 1144 |
|
| 1145 |
final long weightedSum=Tools.sumHistogram(a); |
| 1146 |
final long med=Tools.medianHistogram(a), min=Tools.minHistogram(a), max=Tools.maxHistogram(a); |
| 1147 |
final long firstQuart=Tools.percentileHistogram(a, 0.25); |
| 1148 |
final long thirdQuart=Tools.percentileHistogram(a, 0.75); |
| 1149 |
final long leftWhisker=Tools.percentileHistogram(a, 0.02); |
| 1150 |
final long rightWhisker=Tools.percentileHistogram(a, 0.98); |
| 1151 |
final double mean=weightedSum*1.0/Tools.max(sum, 0); |
| 1152 |
tsw.print(Tools.format("%d\t%d\t%d\t%d\t%.2f\t%d\t%d\t%d\t%d\t%d", i, sum, min, max, mean, firstQuart, med, thirdQuart, leftWhisker, rightWhisker)); |
| 1153 |
} |
| 1154 |
|
| 1155 |
if(writePaired){ |
| 1156 |
final long a[]=a2, sum=sum2; |
| 1157 |
|
| 1158 |
final long weightedSum=Tools.sumHistogram(a); |
| 1159 |
final long med=Tools.medianHistogram(a), min=Tools.minHistogram(a), max=Tools.maxHistogram(a); |
| 1160 |
final long firstQuart=Tools.percentileHistogram(a, 0.25); |
| 1161 |
final long thirdQuart=Tools.percentileHistogram(a, 0.75); |
| 1162 |
final long leftWhisker=Tools.percentileHistogram(a, 0.02); |
| 1163 |
final long rightWhisker=Tools.percentileHistogram(a, 0.98); |
| 1164 |
final double mean=weightedSum*1.0/Tools.max(sum, 0); |
| 1165 |
tsw.print(Tools.format("\t%d\t%d\t%d\t%.2f\t%d\t%d\t%d\t%d\t%d", sum, min, max, mean, firstQuart, med, thirdQuart, leftWhisker, rightWhisker)); |
| 1166 |
} |
| 1167 |
tsw.print("\n"); |
| 1168 |
} |
| 1169 |
tsw.poisonAndWait(); |
| 1170 |
errorState|=tsw.errorState; |
| 1171 |
} |
| 1172 |
|
| 1173 |
public void writeQualityAccuracyToFile(String fname){ |
| 1174 |
|
| 1175 |
int max=qualMatch.length; |
| 1176 |
for(int i=max-1; i>=0; i--){ |
| 1177 |
if(qualMatch[i]+qualSub[i]+qualIns[i]+qualDel[i]>0){break;} |
| 1178 |
max=i; |
| 1179 |
} |
| 1180 |
|
| 1181 |
double devsum=0; |
| 1182 |
double devsumSub=0; |
| 1183 |
long observations=0; |
| 1184 |
for(int i=0; i<max; i++){ |
| 1185 |
long qm=qualMatch[i]*2; |
| 1186 |
long qs=qualSub[i]*2; |
| 1187 |
long qi=qualIns[i]*2; |
| 1188 |
long qd=qualDel[i]; |
| 1189 |
|
| 1190 |
double phred=-1; |
| 1191 |
double phredSub=-1; |
| 1192 |
|
| 1193 |
long sum=qm+qs+qi+qd; |
| 1194 |
if(sum>0){ |
| 1195 |
double mult=1.0/sum; |
| 1196 |
double subRate=(qs)*mult; |
| 1197 |
double errorRate=(qs+qi+qd)*mult; |
| 1198 |
|
| 1199 |
phredSub=QualityTools.probErrorToPhredDouble(subRate); |
| 1200 |
phred=QualityTools.probErrorToPhredDouble(errorRate); |
| 1201 |
double deviation=phred-i; |
| 1202 |
double deviationSub=phredSub-i; |
| 1203 |
if(i==QMIN && deviation<0){deviation=0;} |
| 1204 |
else if(i==QMAX && max==QMAX2 && deviation>0){deviation=0;} |
| 1205 |
if(i==QMIN && deviationSub<0){deviationSub=0;} |
| 1206 |
else if(i==QMAX && max==QMAX2 && deviationSub>0){deviationSub=0;} |
| 1207 |
devsum+=(Math.abs(deviation)*sum); |
| 1208 |
devsumSub+=(Math.abs(deviationSub)*sum); |
| 1209 |
observations+=sum; |
| 1210 |
} |
| 1211 |
} |
| 1212 |
|
| 1213 |
double stdevSum=0; |
| 1214 |
double varianceSum=0; |
| 1215 |
double entropySum=0; |
| 1216 |
long values=0; |
| 1217 |
for(int pos=0; pos<MAXLEN; pos++) { |
| 1218 |
long count=0; |
| 1219 |
for(int rnum=0; rnum<2; rnum++) { |
| 1220 |
final long[] array=bqualHist[rnum][pos]; |
| 1221 |
final long sum=Tools.sum(array); |
| 1222 |
if(sum>0) { |
| 1223 |
values++;; |
| 1224 |
count+=sum; |
| 1225 |
final double avg=Tools.averageHistogram(array); |
| 1226 |
final double stdev=Tools.standardDeviationHistogram(array); |
| 1227 |
final double entropy=calcEntropySuperSlow(array); |
| 1228 |
entropySum+=entropy; |
| 1229 |
double varSum=0; |
| 1230 |
for(int i=0; i<array.length; i++) { |
| 1231 |
double var=Tools.absdif(i, avg); |
| 1232 |
varSum+=(var*array[i]); |
| 1233 |
} |
| 1234 |
stdevSum+=stdev; |
| 1235 |
varianceSum+=(varSum/sum); |
| 1236 |
} |
| 1237 |
} |
| 1238 |
if(count==0) {break;} |
| 1239 |
} |
| 1240 |
final double stdev=stdevSum/values; |
| 1241 |
final double variance=varianceSum/values; |
| 1242 |
final double entropy=entropySum/values; |
| 1243 |
|
| 1244 |
TextStreamWriter tsw=new TextStreamWriter(fname, overwrite, append, false); |
| 1245 |
tsw.start(); |
| 1246 |
tsw.print(Tools.format("#Deviation\t%.3f\n", devsum/observations)); |
| 1247 |
tsw.print(Tools.format("#DeviationSub\t%.3f\n", devsumSub/observations)); |
| 1248 |
|
| 1249 |
tsw.print(Tools.format("#Avg_STDev\t%.3f\n", stdev)); |
| 1250 |
tsw.print(Tools.format("#Diversity\t%.3f\n", variance)); |
| 1251 |
tsw.print(Tools.format("#Entropy\t%.3f\n", entropy)); |
| 1252 |
|
| 1253 |
tsw.print("#Quality\tMatch\tSub\tIns\tDel\tTrueQuality\tTrueQualitySub\n"); |
| 1254 |
for(int i=0; i<max; i++){ |
| 1255 |
long qm=qualMatch[i]*2; |
| 1256 |
long qs=qualSub[i]*2; |
| 1257 |
long qi=qualIns[i]*2; |
| 1258 |
long qd=qualDel[i]; |
| 1259 |
|
| 1260 |
double phred=-1; |
| 1261 |
double phredSub=-1; |
| 1262 |
|
| 1263 |
long sum=qm+qs+qi+qd; |
| 1264 |
if(sum>0){ |
| 1265 |
double mult=1.0/sum; |
| 1266 |
double subRate=(qs)*mult; |
| 1267 |
double errorRate=(qs+qi+qd)*mult; |
| 1268 |
|
| 1269 |
phredSub=QualityTools.probErrorToPhredDouble(subRate); |
| 1270 |
phred=QualityTools.probErrorToPhredDouble(errorRate); |
| 1271 |
|
| 1272 |
|
| 1273 |
} |
| 1274 |
|
| 1275 |
tsw.print(i+"\t"+qm+"\t"+qs+"\t"+qi+"\t"+qd); |
| 1276 |
tsw.print(phred>=0 ? Tools.format("\t%.2f", phred) : "\t"); |
| 1277 |
tsw.print(phredSub>=0 ? Tools.format("\t%.2f\n", phredSub) : "\t\n"); |
| 1278 |
|
| 1279 |
|
| 1280 |
} |
| 1281 |
|
| 1282 |
tsw.poisonAndWait(); |
| 1283 |
errorState|=tsw.errorState; |
| 1284 |
} |
| 1285 |
|
| 1286 |
private float calcEntropySuperSlow(long[] counts){ |
| 1287 |
|
| 1288 |
double eSum=0; |
| 1289 |
|
| 1290 |
final double total=Tools.sum(counts); |
| 1291 |
|
| 1292 |
|
| 1293 |
for(long count : counts){ |
| 1294 |
|
| 1295 |
|
| 1296 |
if(count>0){ |
| 1297 |
|
| 1298 |
double pk=count/(double)total; |
| 1299 |
|
| 1300 |
|
| 1301 |
|
| 1302 |
double npklogpk=-pk*Math.log(pk); |
| 1303 |
|
| 1304 |
eSum+=npklogpk; |
| 1305 |
|
| 1306 |
} |
| 1307 |
} |
| 1308 |
|
| 1309 |
|
| 1310 |
|
| 1311 |
double multiplier=1/Math.log(total); |
| 1312 |
|
| 1313 |
|
| 1314 |
float e=(float)(eSum*multiplier); |
| 1315 |
|
| 1316 |
assert(e>=0 && e<=1) : e+", "+eSum+", "+total+"\n"+Arrays.toString(counts)+"\n"+this; |
| 1317 |
|
| 1318 |
|
| 1319 |
if(e<=0){e=0;} |
| 1320 |
|
| 1321 |
return e; |
| 1322 |
} |
| 1323 |
|
| 1324 |
public void writeMatchToFile(String fname, boolean writePaired){ |
| 1325 |
if(!writePaired){ |
| 1326 |
writeMatchToFileUnpaired(fname); |
| 1327 |
return; |
| 1328 |
} |
| 1329 |
TextStreamWriter tsw=new TextStreamWriter(fname, overwrite, false, false); |
| 1330 |
tsw.start(); |
| 1331 |
tsw.print("#BaseNum\tMatch1\tSub1\tDel1\tIns1\tN1\tOther1\tMatch2\tSub2\tDel2\tIns2\tN2\tOther2\n"); |
| 1332 |
|
| 1333 |
final long[] ms1=matchSum[0], ds1=delSum[0], is1=insSum[0], |
| 1334 |
ss1=subSum[0], ns1=nSum[0], cs1=clipSum[0], os1=otherSum[0]; |
| 1335 |
final long[] ms2=matchSum[1], ds2=delSum[1], is2=insSum[1], |
| 1336 |
ss2=subSum[1], ns2=nSum[1], cs2=clipSum[1], os2=otherSum[1]; |
| 1337 |
|
| 1338 |
for(int i=0; i<MAXLEN; i++){ |
| 1339 |
int a=i+1; |
| 1340 |
long sum1=ms1[i]+is1[i]+ss1[i]+ns1[i]+cs1[i]+os1[i]; |
| 1341 |
long sum2=ms2[i]+is2[i]+ss2[i]+ns2[i]+cs2[i]+os2[i]; |
| 1342 |
if(sum1==0 && sum2==0){break;} |
| 1343 |
double inv1=1.0/(double)Tools.max(1, sum1); |
| 1344 |
double inv2=1.0/(double)Tools.max(1, sum2); |
| 1345 |
|
| 1346 |
tsw.print(Tools.format("%d", a)); |
| 1347 |
tsw.print(Tools.format("\t%.5f\t%.5f\t%.5f\t%.5f\t%.5f\t%.5f", |
| 1348 |
ms1[i]*inv1, ss1[i]*inv1, ds1[i]*inv1, is1[i]*inv1, ns1[i]*inv1, (os1[i]+cs1[i])*inv1)); |
| 1349 |
tsw.print(Tools.format("\t%.5f\t%.5f\t%.5f\t%.5f\t%.5f\t%.5f", |
| 1350 |
ms2[i]*inv2, ss2[i]*inv2, ds2[i]*inv2, is2[i]*inv2, ns2[i]*inv2, (os2[i]+cs2[i])*inv2) |
| 1351 |
|
| 1352 |
); |
| 1353 |
tsw.print("\n"); |
| 1354 |
} |
| 1355 |
tsw.poisonAndWait(); |
| 1356 |
errorState|=tsw.errorState; |
| 1357 |
} |
| 1358 |
|
| 1359 |
public void writeMatchToFileUnpaired(String fname){ |
| 1360 |
TextStreamWriter tsw=new TextStreamWriter(fname, overwrite, false, false); |
| 1361 |
tsw.start(); |
| 1362 |
tsw.print("#BaseNum\tMatch1\tSub1\tDel1\tIns1\tN1\tOther1\n"); |
| 1363 |
|
| 1364 |
final long[] ms1=matchSum[0], ds1=delSum[0], is1=insSum[0], |
| 1365 |
ss1=subSum[0], ns1=nSum[0], cs1=clipSum[0], os1=otherSum[0]; |
| 1366 |
|
| 1367 |
for(int i=0; i<MAXLEN; i++){ |
| 1368 |
int a=i+1; |
| 1369 |
long sum1=ms1[i]+is1[i]+ss1[i]+ns1[i]+cs1[i]+os1[i]; |
| 1370 |
if(sum1==0){break;} |
| 1371 |
double inv1=1.0/(double)Tools.max(1, sum1); |
| 1372 |
|
| 1373 |
tsw.print(Tools.format("%d", a)); |
| 1374 |
tsw.print(Tools.format("\t%.5f\t%.5f\t%.5f\t%.5f\t%.5f\t%.5f", |
| 1375 |
ms1[i]*inv1, ss1[i]*inv1, ds1[i]*inv1, is1[i]*inv1, ns1[i]*inv1, (os1[i]+cs1[i])*inv1) |
| 1376 |
|
| 1377 |
); |
| 1378 |
tsw.print("\n"); |
| 1379 |
} |
| 1380 |
tsw.poisonAndWait(); |
| 1381 |
errorState|=tsw.errorState; |
| 1382 |
} |
| 1383 |
|
| 1384 |
public void writeInsertToFile(String fname){ |
| 1385 |
StringBuilder sb=new StringBuilder(); |
| 1386 |
sb.append("#Mean\t"+Tools.format("%.3f", Tools.averageHistogram(insertHist.array))+"\n"); |
| 1387 |
sb.append("#Median\t"+Tools.percentileHistogram(insertHist.array, 0.5)+"\n"); |
| 1388 |
sb.append("#Mode\t"+Tools.calcModeHistogram(insertHist.array)+"\n"); |
| 1389 |
sb.append("#STDev\t"+Tools.format("%.3f", Tools.standardDeviationHistogram(insertHist.array))+"\n"); |
| 1390 |
double percent=pairedCount*100.0/(pairedCount+unpairedCount); |
| 1391 |
sb.append("#PercentOfPairs\t"+Tools.format("%.3f", percent)+"\n"); |
| 1392 |
|
| 1393 |
sb.append("#InsertSize\tCount\n"); |
| 1394 |
writeHistogramToFile(fname, sb.toString(), insertHist, !skipZeroInsertCount); |
| 1395 |
} |
| 1396 |
|
| 1397 |
public void writeBaseContentToFile(String fname, boolean paired){ |
| 1398 |
ByteStreamWriter bsw=new ByteStreamWriter(fname, overwrite, false, false); |
| 1399 |
bsw.start(); |
| 1400 |
bsw.print("#Pos\tA\tC\tG\tT\tN\n"); |
| 1401 |
|
| 1402 |
int max=writeBaseContentToFile2(bsw, baseHist[0], 0); |
| 1403 |
if(paired){ |
| 1404 |
writeBaseContentToFile2(bsw, baseHist[1], max); |
| 1405 |
} |
| 1406 |
|
| 1407 |
bsw.poisonAndWait(); |
| 1408 |
errorState|=bsw.errorState; |
| 1409 |
} |
| 1410 |
|
| 1411 |
private static int writeBaseContentToFile2(ByteStreamWriter bsw, LongList[] lists, int offset){ |
| 1412 |
int max=0; |
| 1413 |
ByteBuilder sb=new ByteBuilder(100); |
| 1414 |
for(LongList ll : lists){max=Tools.max(max, ll.size);} |
| 1415 |
for(int i=0; i<max; i++){ |
| 1416 |
long a=lists[1].get(i); |
| 1417 |
long c=lists[2].get(i); |
| 1418 |
long g=lists[3].get(i); |
| 1419 |
long t=lists[4].get(i); |
| 1420 |
long n=lists[0].get(i); |
| 1421 |
double mult=1.0/(a+c+g+t+n); |
| 1422 |
|
| 1423 |
sb.setLength(0); |
| 1424 |
sb.append(i+offset).tab(); |
| 1425 |
sb.append(a*mult, 5).tab(); |
| 1426 |
sb.append(c*mult, 5).tab(); |
| 1427 |
sb.append(g*mult, 5).tab(); |
| 1428 |
sb.append(t*mult, 5).tab(); |
| 1429 |
sb.append(n*mult, 5); |
| 1430 |
sb.nl(); |
| 1431 |
|
| 1432 |
bsw.print(sb); |
| 1433 |
} |
| 1434 |
return max; |
| 1435 |
} |
| 1436 |
|
| 1437 |
public void writeIndelToFile(String fname){ |
| 1438 |
ByteStreamWriter bsw=new ByteStreamWriter(fname, overwrite, false, false); |
| 1439 |
bsw.start(); |
| 1440 |
bsw.print("#Length\tDeletions\tInsertions\n"); |
| 1441 |
|
| 1442 |
int max=Tools.max(insHist.size, delHist.size); |
| 1443 |
|
| 1444 |
ByteBuilder bb=new ByteBuilder(100); |
| 1445 |
for(int i=0; i<max; i++){ |
| 1446 |
long x=delHist.get(i); |
| 1447 |
long y=insHist.get(i); |
| 1448 |
if(x>0 || y>0 || !skipZeroIndel){ |
| 1449 |
bb.clear(); |
| 1450 |
bb.append(i).tab().append(x).tab().append(y).nl(); |
| 1451 |
bsw.print(bb); |
| 1452 |
} |
| 1453 |
} |
| 1454 |
|
| 1455 |
|
| 1456 |
|
| 1457 |
|
| 1458 |
|
| 1459 |
|
| 1460 |
|
| 1461 |
|
| 1462 |
|
| 1463 |
|
| 1464 |
|
| 1465 |
bsw.poisonAndWait(); |
| 1466 |
errorState|=bsw.errorState; |
| 1467 |
} |
| 1468 |
|
| 1469 |
public void writeErrorToFile(String fname){ |
| 1470 |
writeHistogramToFile(fname, "#Errors\tCount\n", errorHist, false); |
| 1471 |
} |
| 1472 |
|
| 1473 |
public void writeLengthToFile(String fname){ |
| 1474 |
writeHistogramToFile(fname, "#Length\tCount\n", lengthHist, false); |
| 1475 |
} |
| 1476 |
|
| 1477 |
public void writeTimeToFile(String fname){ |
| 1478 |
writeHistogramToFile(fname, "#Time\tCount\n", timeHist, false); |
| 1479 |
} |
| 1480 |
|
| 1481 |
public void writeBarcodesToFile(String fname) { |
| 1482 |
ArrayList<Barcode> barcodes=new ArrayList<Barcode>(); |
| 1483 |
for(Barcode b : barcodeMap.values()) { |
| 1484 |
barcodes.add(b); |
| 1485 |
} |
| 1486 |
Collections.sort(barcodes); |
| 1487 |
ByteStreamWriter bsw=new ByteStreamWriter(fname, overwrite, false, false); |
| 1488 |
bsw.start(); |
| 1489 |
long sum=0; |
| 1490 |
for(Barcode b : barcodes) { |
| 1491 |
sum+=b.count(); |
| 1492 |
} |
| 1493 |
bsw.print("#Reads\t").print(sum).nl(); |
| 1494 |
bsw.print("#Barcodes\t").print(barcodes.size()).nl(); |
| 1495 |
|
| 1496 |
ByteBuilder bb=new ByteBuilder(40); |
| 1497 |
for(Barcode b : barcodes) { |
| 1498 |
bb.clear().append(b.name).tab().append(b.count()).nl(); |
| 1499 |
bsw.print(bb); |
| 1500 |
} |
| 1501 |
bsw.poisonAndWait(); |
| 1502 |
errorState|=bsw.errorState; |
| 1503 |
} |
| 1504 |
|
| 1505 |
public void writeHistogramToFile(String fname, String header, LongList hist, boolean printZeros){ |
| 1506 |
ByteStreamWriter bsw=new ByteStreamWriter(fname, overwrite, false, false); |
| 1507 |
bsw.start(); |
| 1508 |
bsw.print(header); |
| 1509 |
|
| 1510 |
int max=hist.size; |
| 1511 |
|
| 1512 |
ByteBuilder bb=new ByteBuilder(40); |
| 1513 |
for(int i=0; i<max; i++){ |
| 1514 |
long x=hist.get(i); |
| 1515 |
if(x>0 || printZeros){ |
| 1516 |
bb.clear().append(i).tab().append(x).nl(); |
| 1517 |
bsw.print(bb); |
| 1518 |
} |
| 1519 |
} |
| 1520 |
bsw.poisonAndWait(); |
| 1521 |
errorState|=bsw.errorState; |
| 1522 |
} |
| 1523 |
|
| 1524 |
public void writeHistogramToFile(String fname, String header, SuperLongList hist, boolean printZeros){ |
| 1525 |
ByteStreamWriter bsw=new ByteStreamWriter(fname, overwrite, false, false); |
| 1526 |
bsw.start(); |
| 1527 |
bsw.print(header); |
| 1528 |
|
| 1529 |
hist.sort(); |
| 1530 |
long max=hist.max(); |
| 1531 |
long[] array=hist.array(); |
| 1532 |
LongList list=hist.list(); |
| 1533 |
|
| 1534 |
ByteBuilder bb=new ByteBuilder(40); |
| 1535 |
for(int i=0; i<array.length; i++){ |
| 1536 |
long x=array[i]; |
| 1537 |
if(x>0 || printZeros){ |
| 1538 |
bb.clear().append(i).tab().append(x).nl(); |
| 1539 |
bsw.print(bb); |
| 1540 |
} |
| 1541 |
} |
| 1542 |
{ |
| 1543 |
long prev=-1; |
| 1544 |
int streak=0; |
| 1545 |
for(int i=0; i<list.size(); i++){ |
| 1546 |
long x=list.get(i); |
| 1547 |
if(x==prev){streak++;} |
| 1548 |
else{ |
| 1549 |
if(streak>0){ |
| 1550 |
bb.clear().append(prev).tab().append(streak).nl(); |
| 1551 |
bsw.print(bb); |
| 1552 |
} |
| 1553 |
streak=1; |
| 1554 |
prev=x; |
| 1555 |
} |
| 1556 |
} |
| 1557 |
if(streak>0){ |
| 1558 |
bb.clear().append(prev).tab().append(streak).nl(); |
| 1559 |
bsw.print(bb); |
| 1560 |
} |
| 1561 |
} |
| 1562 |
bsw.poisonAndWait(); |
| 1563 |
errorState|=bsw.errorState; |
| 1564 |
} |
| 1565 |
|
| 1566 |
public void writeGCToFile(String fname, boolean printZeros){ |
| 1567 |
final long[] hist; |
| 1568 |
if(GC_BINS_AUTO && gcMaxReadLen+1<gcHist.length){ |
| 1569 |
hist=Tools.downsample(gcHist, gcMaxReadLen+1); |
| 1570 |
}else{ |
| 1571 |
hist=gcHist; |
| 1572 |
} |
| 1573 |
final int bins=hist.length; |
| 1574 |
final double gcMult=100.0/Tools.max(1, bins-1); |
| 1575 |
final long total=shared.Vector.sum(hist); |
| 1576 |
final long max=Tools.max(hist); |
| 1577 |
final double countsPerX=Tools.max(1, ((max*1000.0)/40)); |
| 1578 |
final double fractionMult=1.0/Tools.max(1, total); |
| 1579 |
long sum=0; |
| 1580 |
|
| 1581 |
GCMean=Tools.averageHistogram(hist)*gcMult; |
| 1582 |
GCMedian=Tools.percentileHistogram(hist, 0.5)*gcMult; |
| 1583 |
GCMode=Tools.calcModeHistogram(hist)*gcMult; |
| 1584 |
GCSTDev=Tools.standardDeviationHistogram(hist)*gcMult; |
| 1585 |
|
| 1586 |
ByteBuilder bb=new ByteBuilder(256); |
| 1587 |
bb.append("#Mean\t").append(GCMean, 3).nl(); |
| 1588 |
bb.append("#Median\t").append(GCMedian, 3).nl(); |
| 1589 |
bb.append("#Mode\t").append(GCMode, 3).nl(); |
| 1590 |
bb.append("#STDev\t").append(GCSTDev, 3).nl(); |
| 1591 |
if(GC_PLOT_X){ |
| 1592 |
bb.append("#GC\tCount\tCumulative\tPlot\n"); |
| 1593 |
}else{ |
| 1594 |
bb.append("#GC\tCount\n"); |
| 1595 |
} |
| 1596 |
|
| 1597 |
|
| 1598 |
|
| 1599 |
|
| 1600 |
|
| 1601 |
|
| 1602 |
|
| 1603 |
|
| 1604 |
|
| 1605 |
|
| 1606 |
|
| 1607 |
|
| 1608 |
ByteStreamWriter bsw=new ByteStreamWriter(fname, overwrite, false, false); |
| 1609 |
bsw.start(); |
| 1610 |
bsw.print(bb); |
| 1611 |
|
| 1612 |
for(int i=0; i<bins; i++){ |
| 1613 |
long x=hist[i]; |
| 1614 |
sum+=x; |
| 1615 |
if(x>0 || printZeros){ |
| 1616 |
|
| 1617 |
|
| 1618 |
if(GC_PLOT_X){ |
| 1619 |
bb.clear(); |
| 1620 |
bb.append(i*gcMult, 1).tab().append(x).tab(); |
| 1621 |
bb.append(sum*fractionMult, 3).tab(); |
| 1622 |
|
| 1623 |
int len=(int)((x*1000)/countsPerX); |
| 1624 |
for(int j=0; j<len; j++){bb.append('X');} |
| 1625 |
if(len<1 && x>0){ |
| 1626 |
if((x*1000f)/countsPerX>0.1f){bb.append('x');} |
| 1627 |
else{bb.append('.');} |
| 1628 |
} |
| 1629 |
|
| 1630 |
bb.append('\n'); |
| 1631 |
bsw.print(bb); |
| 1632 |
}else{ |
| 1633 |
bb.clear().append(i*gcMult, 1).tab().append(x).nl(); |
| 1634 |
bsw.print(bb); |
| 1635 |
} |
| 1636 |
} |
| 1637 |
} |
| 1638 |
bsw.poisonAndWait(); |
| 1639 |
errorState|=bsw.errorState; |
| 1640 |
} |
| 1641 |
|
| 1642 |
public void writeEntropyToFile(String fname, boolean printZeros){ |
| 1643 |
final long[] hist=entropyHist; |
| 1644 |
|
| 1645 |
final int bins=hist.length; |
| 1646 |
final double mult=1.0/Tools.max(1, bins-1); |
| 1647 |
final long total=shared.Vector.sum(hist); |
| 1648 |
final long max=Tools.max(hist); |
| 1649 |
final double countsPerX=Tools.max(1, ((max*1000.0)/40)); |
| 1650 |
final double fractionMult=1.0/Tools.max(1, total); |
| 1651 |
long sum=0; |
| 1652 |
|
| 1653 |
double mean=Tools.averageHistogram(hist)*mult; |
| 1654 |
double median=Tools.percentileHistogram(hist, 0.5)*mult; |
| 1655 |
double mode=Tools.calcModeHistogram(hist)*mult; |
| 1656 |
double stdev=Tools.standardDeviationHistogram(hist)*mult; |
| 1657 |
|
| 1658 |
ByteBuilder bb=new ByteBuilder(256); |
| 1659 |
bb.append("#Mean\t").append(mean, 6).nl(); |
| 1660 |
bb.append("#Median\t").append(median, 6).nl(); |
| 1661 |
bb.append("#Mode\t").append(mode, 6).nl(); |
| 1662 |
bb.append("#STDev\t").append(stdev, 6).nl(); |
| 1663 |
bb.append("#Value\tCount\n"); |
| 1664 |
|
| 1665 |
ByteStreamWriter bsw=new ByteStreamWriter(fname, overwrite, false, false); |
| 1666 |
bsw.start(); |
| 1667 |
bsw.print(bb); |
| 1668 |
|
| 1669 |
for(int i=0; i<bins; i++){ |
| 1670 |
long x=hist[i]; |
| 1671 |
sum+=x; |
| 1672 |
if(x>0 || printZeros){ |
| 1673 |
bb.clear().append(i*mult, 4).tab().append(x).nl(); |
| 1674 |
bsw.print(bb); |
| 1675 |
} |
| 1676 |
} |
| 1677 |
bsw.poisonAndWait(); |
| 1678 |
errorState|=bsw.errorState; |
| 1679 |
} |
| 1680 |
|
| 1681 |
public void writeIdentityToFile(String fname, boolean printZeros){ |
| 1682 |
final long[] hist, histb; |
| 1683 |
if(ID_BINS_AUTO && idMaxReadLen+1<idHist.length){ |
| 1684 |
hist=Tools.downsample(idHist, idMaxReadLen+1); |
| 1685 |
histb=Tools.downsample(idBaseHist, idMaxReadLen+1); |
| 1686 |
}else{ |
| 1687 |
hist=idHist; |
| 1688 |
histb=idBaseHist; |
| 1689 |
} |
| 1690 |
final int max=hist.length; |
| 1691 |
final double mult=100.0/(max-1); |
| 1692 |
|
| 1693 |
TextStreamWriter tsw=new TextStreamWriter(fname, overwrite, false, false); |
| 1694 |
tsw.start(); |
| 1695 |
|
| 1696 |
|
| 1697 |
tsw.print("#Mean_reads\t"+Tools.format("%.3f", (Tools.averageHistogram(hist)*mult))+"\n"); |
| 1698 |
tsw.print("#Mean_bases\t"+(Tools.format("%.3f", Tools.averageHistogram(histb)*mult))+"\n"); |
| 1699 |
tsw.print("#Median_reads\t"+(int)Math.round(Tools.percentileHistogram(hist, 0.5)*mult)+"\n"); |
| 1700 |
tsw.print("#Median_bases\t"+(int)Math.round(Tools.percentileHistogram(histb, 0.5)*mult)+"\n"); |
| 1701 |
tsw.print("#Mode_reads\t"+(int)Math.round(Tools.calcModeHistogram(hist)*mult)+"\n"); |
| 1702 |
tsw.print("#Mode_bases\t"+(int)Math.round(Tools.calcModeHistogram(histb)*mult)+"\n"); |
| 1703 |
tsw.print("#STDev_reads\t"+Tools.format("%.3f", (Tools.standardDeviationHistogram(hist)*mult))+"\n"); |
| 1704 |
tsw.print("#STDev_bases\t"+Tools.format("%.3f", (Tools.standardDeviationHistogram(histb)*mult))+"\n"); |
| 1705 |
tsw.print("#Identity\tReads\tBases\n"); |
| 1706 |
|
| 1707 |
for(int i=0; i<max; i++){ |
| 1708 |
long x=hist[i], x2=histb[i]; |
| 1709 |
if(x>0 || printZeros){ |
| 1710 |
tsw.print(Tools.format("%.1f", i*mult)+"\t"+x+"\t"+x2+"\n"); |
| 1711 |
} |
| 1712 |
} |
| 1713 |
tsw.poisonAndWait(); |
| 1714 |
errorState|=tsw.errorState; |
| 1715 |
} |
| 1716 |
|
| 1717 |
|
| 1718 |
private long read2Count=0; |
| 1719 |
|
| 1720 |
public long pairedCount=0; |
| 1721 |
public long unpairedCount=0; |
| 1722 |
|
| 1723 |
private final int QMIN=Read.MIN_CALLED_QUALITY(); |
| 1724 |
private final int QMAX=Read.MAX_CALLED_QUALITY(); |
| 1725 |
private final int QMAX2=QMAX+1; |
| 1726 |
|
| 1727 |
public final long[][] aqualArray; |
| 1728 |
public final long[][] qualLength; |
| 1729 |
public final long[][] qualSum; |
| 1730 |
|
| 1731 |
public final long[][][] bqualHist; |
| 1732 |
public final long[] bqualHistOverall; |
| 1733 |
|
| 1734 |
public final long[][] qcountHist; |
| 1735 |
|
| 1736 |
public final double[][] qualSumDouble; |
| 1737 |
|
| 1738 |
public final long[][] matchSum; |
| 1739 |
public final long[][] delSum; |
| 1740 |
public final long[][] insSum; |
| 1741 |
public final long[][] subSum; |
| 1742 |
public final long[][] nSum; |
| 1743 |
public final long[][] clipSum; |
| 1744 |
public final long[][] otherSum; |
| 1745 |
|
| 1746 |
public final long[] qualMatch; |
| 1747 |
public final long[] qualSub; |
| 1748 |
public final long[] qualIns; |
| 1749 |
public final long[] qualDel; |
| 1750 |
|
| 1751 |
public final long[] gcHist; |
| 1752 |
public final long[] entropyHist; |
| 1753 |
public final EntropyTracker eTracker; |
| 1754 |
public final long[] idHist; |
| 1755 |
public final long[] idBaseHist; |
| 1756 |
private int gcMaxReadLen=1; |
| 1757 |
private int idMaxReadLen=1; |
| 1758 |
|
| 1759 |
public final LongList[][] baseHist; |
| 1760 |
|
| 1761 |
public final HashMap<String, Barcode> barcodeMap; |
| 1762 |
|
| 1763 |
|
| 1764 |
public final LongList insertHist; |
| 1765 |
|
| 1766 |
public final SuperLongList lengthHist; |
| 1767 |
|
| 1768 |
public final LongList errorHist; |
| 1769 |
|
| 1770 |
public final LongList insHist; |
| 1771 |
|
| 1772 |
public final LongList delHist; |
| 1773 |
|
| 1774 |
public final LongList delHist2; |
| 1775 |
|
| 1776 |
public final LongList timeHist; |
| 1777 |
|
| 1778 |
public static boolean REQUIRE_PROPER_PAIR=true; |
| 1779 |
public static int MAXLEN=6000; |
| 1780 |
public static int MAXINSERTLEN=80000; |
| 1781 |
@Deprecated |
| 1782 |
public static int MAXLENGTHLEN=80000; |
| 1783 |
public static final int MAXTIMELEN=80000; |
| 1784 |
public static final int MAXINSLEN=1000; |
| 1785 |
public static final int MAXDELLEN=1000; |
| 1786 |
public static final int MAXDELLEN2=1000000; |
| 1787 |
public static final int DEL_BIN=100; |
| 1788 |
public static int ID_BINS=100; |
| 1789 |
public static boolean ID_BINS_AUTO=false; |
| 1790 |
public static int GC_BINS=100; |
| 1791 |
public static boolean GC_BINS_AUTO=false; |
| 1792 |
public static boolean GC_PLOT_X=false; |
| 1793 |
public static int ENTROPY_BINS=1000; |
| 1794 |
|
| 1795 |
public static double GCMean; |
| 1796 |
public static double GCMedian; |
| 1797 |
public static double GCMode; |
| 1798 |
public static double GCSTDev; |
| 1799 |
|
| 1800 |
|
| 1801 |
|
| 1802 |
|
| 1803 |
|
| 1804 |
|
| 1805 |
public boolean errorState=false; |
| 1806 |
|
| 1807 |
public static ReadStats merged=null; |
| 1808 |
|
| 1809 |
|
| 1810 |
|
| 1811 |
public static void clear(){ |
| 1812 |
COLLECT_QUALITY_STATS=false; |
| 1813 |
COLLECT_QUALITY_ACCURACY=false; |
| 1814 |
COLLECT_MATCH_STATS=false; |
| 1815 |
COLLECT_INSERT_STATS=false; |
| 1816 |
COLLECT_BASE_STATS=false; |
| 1817 |
COLLECT_INDEL_STATS=false; |
| 1818 |
COLLECT_GC_STATS=false; |
| 1819 |
COLLECT_ENTROPY_STATS=false; |
| 1820 |
COLLECT_ERROR_STATS=false; |
| 1821 |
COLLECT_LENGTH_STATS=false; |
| 1822 |
COLLECT_IDENTITY_STATS=false; |
| 1823 |
COLLECT_TIME_STATS=false; |
| 1824 |
COLLECT_BARCODE_STATS=false; |
| 1825 |
|
| 1826 |
AVG_QUAL_HIST_FILE=null; |
| 1827 |
QUAL_HIST_FILE=null; |
| 1828 |
BQUAL_HIST_FILE=null; |
| 1829 |
QUAL_COUNT_HIST_FILE=null; |
| 1830 |
BQUAL_HIST_OVERALL_FILE=null; |
| 1831 |
QUAL_ACCURACY_FILE=null; |
| 1832 |
MATCH_HIST_FILE=null; |
| 1833 |
INSERT_HIST_FILE=null; |
| 1834 |
BASE_HIST_FILE=null; |
| 1835 |
INDEL_HIST_FILE=null; |
| 1836 |
ERROR_HIST_FILE=null; |
| 1837 |
LENGTH_HIST_FILE=null; |
| 1838 |
GC_HIST_FILE=null; |
| 1839 |
ENTROPY_HIST_FILE=null; |
| 1840 |
IDENTITY_HIST_FILE=null; |
| 1841 |
TIME_HIST_FILE=null; |
| 1842 |
BARCODE_STATS_FILE=null; |
| 1843 |
if(objectList!=null) {objectList.clear();} |
| 1844 |
|
| 1845 |
} |
| 1846 |
|
| 1847 |
public static ArrayList<ReadStats> objectList=new ArrayList<ReadStats>(); |
| 1848 |
public static boolean COLLECT_QUALITY_STATS=false; |
| 1849 |
public static boolean COLLECT_QUALITY_ACCURACY=false; |
| 1850 |
public static boolean COLLECT_MATCH_STATS=false; |
| 1851 |
public static boolean COLLECT_INSERT_STATS=false; |
| 1852 |
public static boolean COLLECT_BASE_STATS=false; |
| 1853 |
public static boolean COLLECT_INDEL_STATS=false; |
| 1854 |
public static boolean COLLECT_GC_STATS=false; |
| 1855 |
public static boolean COLLECT_ENTROPY_STATS=false; |
| 1856 |
public static boolean COLLECT_ERROR_STATS=false; |
| 1857 |
public static boolean COLLECT_LENGTH_STATS=false; |
| 1858 |
public static boolean COLLECT_IDENTITY_STATS=false; |
| 1859 |
public static boolean COLLECT_TIME_STATS=false; |
| 1860 |
public static boolean COLLECT_BARCODE_STATS=false; |
| 1861 |
|
| 1862 |
public static boolean collectingStats(){ |
| 1863 |
return COLLECT_QUALITY_STATS || COLLECT_QUALITY_ACCURACY || COLLECT_MATCH_STATS || COLLECT_INSERT_STATS |
| 1864 |
|| COLLECT_BASE_STATS || COLLECT_INDEL_STATS || COLLECT_GC_STATS || COLLECT_ENTROPY_STATS |
| 1865 |
|| COLLECT_ERROR_STATS || COLLECT_LENGTH_STATS || COLLECT_IDENTITY_STATS || COLLECT_TIME_STATS |
| 1866 |
|| COLLECT_BARCODE_STATS; |
| 1867 |
} |
| 1868 |
|
| 1869 |
public static boolean usePairGC=true; |
| 1870 |
public static boolean allowEntropyNs=true; |
| 1871 |
|
| 1872 |
public static String AVG_QUAL_HIST_FILE=null; |
| 1873 |
public static String QUAL_HIST_FILE=null; |
| 1874 |
public static String BQUAL_HIST_FILE=null; |
| 1875 |
public static String QUAL_COUNT_HIST_FILE=null; |
| 1876 |
public static String BQUAL_HIST_OVERALL_FILE=null; |
| 1877 |
public static String QUAL_ACCURACY_FILE=null; |
| 1878 |
public static String MATCH_HIST_FILE=null; |
| 1879 |
public static String INSERT_HIST_FILE=null; |
| 1880 |
public static String BASE_HIST_FILE=null; |
| 1881 |
public static String INDEL_HIST_FILE=null; |
| 1882 |
public static String ERROR_HIST_FILE=null; |
| 1883 |
public static String LENGTH_HIST_FILE=null; |
| 1884 |
public static String GC_HIST_FILE=null; |
| 1885 |
public static String ENTROPY_HIST_FILE=null; |
| 1886 |
public static String IDENTITY_HIST_FILE=null; |
| 1887 |
public static String TIME_HIST_FILE=null; |
| 1888 |
public static String BARCODE_STATS_FILE=null; |
| 1889 |
|
| 1890 |
public static boolean overwrite=true; |
| 1891 |
public static boolean append=false; |
| 1892 |
public static final boolean verbose=false; |
| 1893 |
|
| 1894 |
public static boolean skipZeroInsertCount=true; |
| 1895 |
public static boolean skipZeroIndel=true; |
| 1896 |
|
| 1897 |
} |