| 1 |
package hiseq; |
| 2 |
|
| 3 |
import java.util.Arrays; |
| 4 |
|
| 5 |
import align2.QualityTools; |
| 6 |
import dna.AminoAcid; |
| 7 |
import shared.Tools; |
| 8 |
import stream.Read; |
| 9 |
import stream.SamLine; |
| 10 |
import structures.ByteBuilder; |
| 11 |
|
| 12 |
public class MicroTile implements Comparable<MicroTile>{ |
| 13 |
|
| 14 |
public MicroTile(){this(0,0,0,0,0,0);} |
| 15 |
|
| 16 |
public MicroTile(int lane_, int tile_, int x1_, int x2_, int y1_, int y2_){ |
| 17 |
lane=lane_; |
| 18 |
tile=tile_; |
| 19 |
x1=x1_; |
| 20 |
x2=x2_; |
| 21 |
y1=y1_; |
| 22 |
y2=y2_; |
| 23 |
} |
| 24 |
|
| 25 |
void process(){ |
| 26 |
if(tracker!=null){tracker.process();} |
| 27 |
} |
| 28 |
|
| 29 |
public boolean contains(int x, int y){ |
| 30 |
return x>=x1 && x<=x2 && y>=y1 && y<=y2; |
| 31 |
} |
| 32 |
|
| 33 |
@Override |
| 34 |
public String toString(){ |
| 35 |
return lane+", "+tile+", "+x1+", "+x2+", "+y1+", "+y2; |
| 36 |
} |
| 37 |
|
| 38 |
public double averageReadQualityByProb(){ |
| 39 |
return readCount==0 ? 0 : readQualityByProbSum/readCount; |
| 40 |
} |
| 41 |
|
| 42 |
public double averageExpectedBaseErrorRate(){ |
| 43 |
return baseCount==0 ? 0 : baseErrorProbSum/baseCount; |
| 44 |
} |
| 45 |
|
| 46 |
public double averageExpectedBaseErrorRatePhred(){ |
| 47 |
return QualityTools.probErrorToPhredDouble(averageExpectedBaseErrorRate()); |
| 48 |
} |
| 49 |
|
| 50 |
public double percentErrorFree(){ |
| 51 |
return readCount==0 ? 0 : probErrorFreeSum/readCount; |
| 52 |
} |
| 53 |
|
| 54 |
public double goodKmerFraction(){ |
| 55 |
double kmers=goodKmerSum+validKmerSum; |
| 56 |
return goodKmerSum/Tools.max(kmers, 1); |
| 57 |
} |
| 58 |
|
| 59 |
public double alignmentRate(){ |
| 60 |
return readCount==0 ? 0 : alignedReadCount/(double)readCount; |
| 61 |
} |
| 62 |
|
| 63 |
|
| 64 |
public double trueQuality(){ |
| 65 |
double e=baseErrorCount+1; |
| 66 |
double b=alignedBaseCount+200; |
| 67 |
double prob=e/b; |
| 68 |
double phred=QualityTools.probErrorToPhredDouble(prob); |
| 69 |
|
| 70 |
return phred; |
| 71 |
} |
| 72 |
|
| 73 |
|
| 74 |
public double readErrorRate(){ |
| 75 |
double e=readErrorCount+0.2; |
| 76 |
double b=alignedReadCount+1; |
| 77 |
double rate=e/b; |
| 78 |
return rate; |
| 79 |
} |
| 80 |
|
| 81 |
|
| 82 |
public double baseErrorRate(){ |
| 83 |
double e=baseErrorCount+0.002; |
| 84 |
double b=alignedBaseCount+1; |
| 85 |
double rate=e/b; |
| 86 |
return rate; |
| 87 |
} |
| 88 |
|
| 89 |
public double readInsRate(){ |
| 90 |
|
| 91 |
|
| 92 |
if(alignedReadCount==0) {return 0;} |
| 93 |
|
| 94 |
|
| 95 |
double e=readInsCount; |
| 96 |
double b=alignedReadCount; |
| 97 |
double rate=e/b; |
| 98 |
return rate; |
| 99 |
} |
| 100 |
|
| 101 |
public double readDelRate(){ |
| 102 |
if(alignedReadCount==0) {return 0;} |
| 103 |
|
| 104 |
|
| 105 |
double e=readDelCount; |
| 106 |
double b=alignedReadCount; |
| 107 |
double rate=e/b; |
| 108 |
return rate; |
| 109 |
} |
| 110 |
|
| 111 |
public double kmerErrorRateR(){ |
| 112 |
if(readCount==0) {return 0;} |
| 113 |
double e=kmerReadErrorCount; |
| 114 |
double b=readCount; |
| 115 |
double rate=e/b; |
| 116 |
return rate; |
| 117 |
} |
| 118 |
|
| 119 |
public double kmerErrorRateB(){ |
| 120 |
if(readCount==0) {return 0;} |
| 121 |
double e=kmerBaseErrorCount; |
| 122 |
double b=readCount; |
| 123 |
double rate=e/b; |
| 124 |
return rate; |
| 125 |
} |
| 126 |
|
| 127 |
public double hitPercent(){ |
| 128 |
long count=kmerCount(); |
| 129 |
return count==0 ? 0 : hits*100.0/count; |
| 130 |
} |
| 131 |
|
| 132 |
public double uniquePercent(){ |
| 133 |
long count=kmerCount(); |
| 134 |
return count==0 ? 0 : misses*100.0/count; |
| 135 |
} |
| 136 |
|
| 137 |
public double polyGPercent(){ |
| 138 |
long count=readCount; |
| 139 |
return count==0 ? 0 : homoPolyGCount*100.0/count; |
| 140 |
} |
| 141 |
|
| 142 |
public double depth(){ |
| 143 |
long count=kmerCount(); |
| 144 |
return depthSum*1.0/count; |
| 145 |
} |
| 146 |
|
| 147 |
public double avgG(){ |
| 148 |
return tracker==null ? 0 : tracker.avg('G'); |
| 149 |
} |
| 150 |
|
| 151 |
public double maxG(){ |
| 152 |
return tracker==null ? 0 : tracker.max('G'); |
| 153 |
} |
| 154 |
|
| 155 |
public double impliedErrorRate(double[] berf) { |
| 156 |
if(berf==null) {return 0;} |
| 157 |
double rootBer=Tools.mid(0.000001, 0.75, berf[0]+berf[1]*uniquePercent()); |
| 158 |
return rootBer*rootBer; |
| 159 |
} |
| 160 |
|
| 161 |
public long kmerCount(){return hits+misses;} |
| 162 |
|
| 163 |
public void clear() { |
| 164 |
hits=0; |
| 165 |
misses=0; |
| 166 |
depthSum=0; |
| 167 |
readCount=0; |
| 168 |
baseCount=0; |
| 169 |
alignedReadCount=0; |
| 170 |
alignedBaseCount=0; |
| 171 |
readErrorCount=0; |
| 172 |
baseErrorCount=0; |
| 173 |
kmerReadErrorCount=0; |
| 174 |
kmerBaseErrorCount=0; |
| 175 |
readInsCount=0; |
| 176 |
readDelCount=0; |
| 177 |
readQualityByProbSum=0; |
| 178 |
probErrorFreeSum=0; |
| 179 |
baseErrorProbSum=0; |
| 180 |
goodKmerSum=0; |
| 181 |
validKmerSum=0; |
| 182 |
Arrays.fill(acgtn, 0); |
| 183 |
|
| 184 |
homoPolyGCount=0; |
| 185 |
homoPolyGSum=0; |
| 186 |
if(TRACK_CYCLES){ |
| 187 |
tracker.clear(); |
| 188 |
} |
| 189 |
barcodes=0; |
| 190 |
barcodeHDistSum=0; |
| 191 |
barcodePolymers=0; |
| 192 |
|
| 193 |
mergedReads=0; |
| 194 |
insertSum=0; |
| 195 |
overlapSum=0; |
| 196 |
mergeErrorSum=0; |
| 197 |
} |
| 198 |
|
| 199 |
public void add(MicroTile mt) { |
| 200 |
hits+=mt.hits; |
| 201 |
misses+=mt.misses; |
| 202 |
depthSum+=mt.depthSum; |
| 203 |
readCount+=mt.readCount; |
| 204 |
baseCount+=mt.baseCount; |
| 205 |
alignedReadCount+=mt.alignedReadCount; |
| 206 |
alignedBaseCount+=mt.alignedBaseCount; |
| 207 |
readErrorCount+=mt.readErrorCount; |
| 208 |
baseErrorCount+=mt.baseErrorCount; |
| 209 |
kmerReadErrorCount+=mt.kmerReadErrorCount; |
| 210 |
kmerBaseErrorCount+=mt.kmerBaseErrorCount; |
| 211 |
readInsCount+=mt.readInsCount; |
| 212 |
readDelCount+=mt.readDelCount; |
| 213 |
readQualityByProbSum+=mt.readQualityByProbSum; |
| 214 |
probErrorFreeSum+=mt.probErrorFreeSum; |
| 215 |
baseErrorProbSum+=mt.baseErrorProbSum; |
| 216 |
goodKmerSum+=mt.goodKmerSum; |
| 217 |
validKmerSum+=mt.validKmerSum; |
| 218 |
|
| 219 |
for(int i=0; i<acgtn.length; i++){ |
| 220 |
acgtn[i]+=mt.acgtn[i]; |
| 221 |
} |
| 222 |
homoPolyGCount+=mt.homoPolyGCount; |
| 223 |
homoPolyGSum+=mt.homoPolyGSum; |
| 224 |
if(TRACK_CYCLES){ |
| 225 |
tracker.add(mt.tracker); |
| 226 |
} |
| 227 |
barcodes+=mt.barcodes; |
| 228 |
barcodeHDistSum+=mt.barcodeHDistSum; |
| 229 |
barcodePolymers+=mt.barcodePolymers; |
| 230 |
|
| 231 |
mergedReads+=mt.mergedReads; |
| 232 |
insertSum+=mt.insertSum; |
| 233 |
overlapSum+=mt.overlapSum; |
| 234 |
mergeErrorSum+=mt.mergeErrorSum; |
| 235 |
} |
| 236 |
|
| 237 |
public void multiplyBy(double mult) { |
| 238 |
hits=(long)(mult*hits); |
| 239 |
misses=(long)(mult*misses); |
| 240 |
depthSum=(long)(mult*depthSum); |
| 241 |
readCount=(long)(mult*readCount); |
| 242 |
baseCount=(long)(mult*baseCount); |
| 243 |
alignedReadCount=(long)(mult*alignedReadCount); |
| 244 |
alignedBaseCount=(long)(mult*alignedBaseCount); |
| 245 |
readErrorCount=(long)(mult*readErrorCount); |
| 246 |
baseErrorCount=(long)(mult*baseErrorCount); |
| 247 |
kmerReadErrorCount=(long)(mult*kmerReadErrorCount); |
| 248 |
kmerBaseErrorCount=(long)(mult*kmerBaseErrorCount); |
| 249 |
readInsCount=(long)(mult*readInsCount); |
| 250 |
readDelCount=(long)(mult*readDelCount); |
| 251 |
readQualityByProbSum=(double)(mult*readQualityByProbSum); |
| 252 |
probErrorFreeSum=(double)(mult*probErrorFreeSum); |
| 253 |
baseErrorProbSum=(double)(mult*baseErrorProbSum); |
| 254 |
goodKmerSum=(double)(mult*goodKmerSum); |
| 255 |
validKmerSum=(long)(mult*validKmerSum); |
| 256 |
|
| 257 |
for(int i=0; i<acgtn.length; i++){ |
| 258 |
acgtn[i]=(long)(mult*acgtn[i]); |
| 259 |
} |
| 260 |
homoPolyGCount=(long)(mult*homoPolyGCount); |
| 261 |
homoPolyGSum=(long)(mult*homoPolyGSum); |
| 262 |
if(TRACK_CYCLES){ |
| 263 |
|
| 264 |
assert(false) : "TRACK_CYCLES: Not handled with multiplyBy."; |
| 265 |
} |
| 266 |
barcodes=(long)(mult*barcodes); |
| 267 |
barcodeHDistSum=(long)(mult*barcodeHDistSum); |
| 268 |
barcodePolymers=(long)(mult*barcodePolymers); |
| 269 |
|
| 270 |
mergedReads=(long)(mult*mergedReads); |
| 271 |
insertSum=(long)(mult*insertSum); |
| 272 |
overlapSum=(long)(mult*overlapSum); |
| 273 |
mergeErrorSum=(long)(mult*mergeErrorSum); |
| 274 |
} |
| 275 |
|
| 276 |
private float countGoodKmers(byte[] quals, int k) { |
| 277 |
int valid=0; |
| 278 |
float good=0; |
| 279 |
float product=1; |
| 280 |
for(int i=0, len=0; i<quals.length; i++) { |
| 281 |
byte q=quals[i]; |
| 282 |
if(q>0) { |
| 283 |
len++; |
| 284 |
float pc=QualityTools.PROB_CORRECT[q]; |
| 285 |
product=product*pc; |
| 286 |
if(len>=k) { |
| 287 |
if(len>k) { |
| 288 |
product=product*QualityTools.PROB_CORRECT_INVERSE[quals[i-k]]; |
| 289 |
} |
| 290 |
valid++; |
| 291 |
good+=product; |
| 292 |
} |
| 293 |
}else { |
| 294 |
len=0; |
| 295 |
product=1; |
| 296 |
} |
| 297 |
} |
| 298 |
goodKmerSum+=good; |
| 299 |
validKmerSum+=valid; |
| 300 |
return good; |
| 301 |
} |
| 302 |
|
| 303 |
public void add(Read r){ |
| 304 |
if(r==null){return;} |
| 305 |
final int len=r.length(); |
| 306 |
if(len<1){return;} |
| 307 |
final SamLine sl=r.samline; |
| 308 |
final byte[] match=r.match; |
| 309 |
|
| 310 |
readCount++; |
| 311 |
baseCount+=r.length(); |
| 312 |
readQualityByProbSum+=r.avgQualityByProbabilityDouble(true, len); |
| 313 |
probErrorFreeSum+=100*r.probabilityErrorFree(true, len); |
| 314 |
baseErrorProbSum+=r.expectedErrors(true, len); |
| 315 |
|
| 316 |
countGoodKmers(r.quality, 62); |
| 317 |
|
| 318 |
|
| 319 |
|
| 320 |
if(match!=null) { |
| 321 |
int bc=r.countAlignedBases(); |
| 322 |
if(bc>0) { |
| 323 |
alignedReadCount++; |
| 324 |
alignedBaseCount+=bc; |
| 325 |
int errors=r.countErrors(); |
| 326 |
readErrorCount+=(errors>0 ? 1 : 0); |
| 327 |
baseErrorCount+=errors; |
| 328 |
int[] mSCNID=Read.countMatchEvents(match); |
| 329 |
readInsCount+=(mSCNID[4]>0 ? 1 : 0); |
| 330 |
readDelCount+=(mSCNID[5]>0 ? 1 : 0); |
| 331 |
} |
| 332 |
}else if(sl!=null && sl.mapped()) { |
| 333 |
alignedReadCount++; |
| 334 |
} |
| 335 |
|
| 336 |
final byte[] bases=r.bases; |
| 337 |
int maxPolyG=0, currentPolyG=0; |
| 338 |
for(int i=0; i<len; i++){ |
| 339 |
byte b=bases[i]; |
| 340 |
byte x=AminoAcid.baseToNumberACGTN[b]; |
| 341 |
acgtn[x]++; |
| 342 |
if(b=='G'){ |
| 343 |
currentPolyG++; |
| 344 |
maxPolyG=Tools.max(currentPolyG, maxPolyG); |
| 345 |
}else{ |
| 346 |
currentPolyG=0; |
| 347 |
} |
| 348 |
} |
| 349 |
final boolean polyg=(maxPolyG>=MIN_POLY_G); |
| 350 |
homoPolyGCount+=(polyg ? 1 : 0); |
| 351 |
homoPolyGSum+=(polyg ? maxPolyG : 0); |
| 352 |
r.setDiscarded(polyg); |
| 353 |
if(TRACK_CYCLES){ |
| 354 |
tracker.add(r); |
| 355 |
} |
| 356 |
} |
| 357 |
|
| 358 |
|
| 359 |
|
| 360 |
|
| 361 |
|
| 362 |
public void addQuick(Read r){ |
| 363 |
if(r==null){return;} |
| 364 |
final int len=r.length(); |
| 365 |
if(len<1){return;} |
| 366 |
|
| 367 |
readCount++; |
| 368 |
baseCount+=r.length(); |
| 369 |
|
| 370 |
countGoodKmers(r.quality, 62); |
| 371 |
|
| 372 |
final byte[] bases=r.bases; |
| 373 |
int maxPolyG=0, currentPolyG=0; |
| 374 |
for(int i=0; i<len; i++){ |
| 375 |
byte b=bases[i]; |
| 376 |
byte x=AminoAcid.baseToNumberACGTN[b]; |
| 377 |
acgtn[x]++; |
| 378 |
if(b=='G'){ |
| 379 |
currentPolyG++; |
| 380 |
maxPolyG=Tools.max(currentPolyG, maxPolyG); |
| 381 |
}else{ |
| 382 |
currentPolyG=0; |
| 383 |
} |
| 384 |
} |
| 385 |
final boolean polyg=(maxPolyG>=MIN_POLY_G); |
| 386 |
homoPolyGCount+=(polyg ? 1 : 0); |
| 387 |
homoPolyGSum+=(polyg ? maxPolyG : 0); |
| 388 |
r.setDiscarded(polyg); |
| 389 |
if(TRACK_CYCLES){ |
| 390 |
tracker.add(r); |
| 391 |
} |
| 392 |
} |
| 393 |
|
| 394 |
public static String header() { |
| 395 |
if(shortHeader) { |
| 396 |
return "lane\ttile\tx1\tx2\ty1\ty2" |
| 397 |
+ "\treads\tbases\talnRead\talnBase\terrAlnR\terrAlnB" |
| 398 |
+ "\terrKR\terrKB" |
| 399 |
+ "\tinsCnt\tdelCnt\tARERate\tABERate" |
| 400 |
+ "\tunique\tavQScor\tprobEF\tavBEPrb\tdepth" |
| 401 |
+ "\tIERate1\tIERate2\tIERate3\tIQScore" |
| 402 |
+ "\talnRate\ttruQual" |
| 403 |
+ "\teKRRate\teKBRate\tinsRate\tdelRate" |
| 404 |
+ "\tdiscard" |
| 405 |
+ "\tA\tC\tG\tT\tN\tpolyG\tplGLen\tplGRate" |
| 406 |
+ "\tBCCount\tBCHDist\tBCPoly\tBCHDAv\tBCPlyAv" |
| 407 |
+ "\tValKmrs\tGdKmrs\tGdKRate" |
| 408 |
+ "\tMerged\tInsert\tOverlap\tMrgErr" |
| 409 |
+ "\tAvInsrt\tMrgRate\tMrgBER"; |
| 410 |
} |
| 411 |
|
| 412 |
return "lane\ttile\tx1\tx2\ty1\ty2" |
| 413 |
+ "\treads\tbases\talignedRead\talignedBase\treadsAlignedWithErrors\talignedErrorCount" |
| 414 |
+ "\treadsWithKmerErrors\tkmerErrorCount" |
| 415 |
+ "\tinsertionCount\tdeletionCount\tAligedReadErrorRate\tAlignedBaseErrorRate" |
| 416 |
+ "\tuniqueKmerRate\tavgQScoreByProb\tprobErrorFree\taverageBaseErrorProb\tdepth" |
| 417 |
+ "\tinferredErrorRate1\tinferredErrorRate2\tinferredErrorRate3\timpliedQualityScore" |
| 418 |
+ "\talignmentRate\ttrueQuality" |
| 419 |
+ "\treadsWithKmerErrorsRate\tkmerErrorsPerRead\tinsertionRate\tdeletionRate" |
| 420 |
+ "\tdiscard" |
| 421 |
+ "\tA\tC\tG\tT\tN\tpolyG_Count\tpolyG_Length\tpolyG_Rate" |
| 422 |
+ "\tBarcodeCount\tBarcodeHDistSum\tBarcodePolymers\tBarcodeHDistAvg\tBarcodePolymerRate" |
| 423 |
+ "\tValidKmers\tGoodKmers\tGoodKmerRate" |
| 424 |
+ "\tMergedReads\tInsertSum\tOverlapSum\tMergeErrors" |
| 425 |
+ "\tAvgInsertSize\tMergeRate\tMergeBaseErrorRate"; |
| 426 |
} |
| 427 |
|
| 428 |
public ByteBuilder toText(ByteBuilder bb, int k, double HG, double[] rerf, double[] berf){ |
| 429 |
bb.append(lane).tab(); |
| 430 |
bb.append(tile).tab(); |
| 431 |
bb.append(x1).tab(); |
| 432 |
bb.append(x2).tab(); |
| 433 |
bb.append(y1).tab(); |
| 434 |
bb.append(y2).tab(); |
| 435 |
|
| 436 |
bb.append(readCount).tab(); |
| 437 |
bb.append(baseCount).tab(); |
| 438 |
bb.append(alignedReadCount).tab(); |
| 439 |
bb.append(alignedBaseCount).tab(); |
| 440 |
bb.append(readErrorCount).tab(); |
| 441 |
bb.append(baseErrorCount).tab(); |
| 442 |
bb.append(kmerReadErrorCount).tab(); |
| 443 |
bb.append(kmerBaseErrorCount).tab(); |
| 444 |
bb.append(readInsCount).tab(); |
| 445 |
bb.append(readDelCount).tab(); |
| 446 |
bb.append(readErrorRate(), 5).tab(); |
| 447 |
bb.append(baseErrorRate(), 5).tab(); |
| 448 |
|
| 449 |
final double uniquePercent=uniquePercent(); |
| 450 |
bb.append(uniquePercent, 4).tab(); |
| 451 |
bb.append(averageReadQualityByProb(), 4).tab(); |
| 452 |
bb.append(percentErrorFree(), 4).tab(); |
| 453 |
bb.append(averageExpectedBaseErrorRate(), 5).tab(); |
| 454 |
final double depth=depth(); |
| 455 |
if(depth>10000) { |
| 456 |
bb.append((long)Math.round(depth)).tab(); |
| 457 |
}else { |
| 458 |
bb.append(depth, depth>=100 ? 2 : 4).tab(); |
| 459 |
} |
| 460 |
final double E1=(HG>0 && hits+misses>0 ? calcErrorRateFromUniqueness(HG, k) : 0); |
| 461 |
bb.append(E1, 5).tab(); |
| 462 |
final double avgBases=baseCount/(Tools.max(1.0, readCount)); |
| 463 |
assert(rerf!=null || alignedReadCount<1 || depthSum<1) : readCount+", "+alignedReadCount; |
| 464 |
final double rer=(rerf==null ? 0 : Tools.mid(0.000001, 0.999999, rerf[0]+rerf[1]*uniquePercent)); |
| 465 |
|
| 466 |
final double E2=1-Math.pow(1-rer, 1/avgBases); |
| 467 |
bb.append(E2, 5).tab(); |
| 468 |
final double rootber=(berf==null ? 0 : Tools.mid(0.000001, 0.75, berf[0]+berf[1]*uniquePercent)); |
| 469 |
final double ber=rootber*rootber; |
| 470 |
bb.append(ber, 5).tab(); |
| 471 |
bb.append(QualityTools.probErrorToPhredDouble(ber), 4).tab(); |
| 472 |
|
| 473 |
bb.append(alignmentRate(), 5).tab(); |
| 474 |
bb.append(trueQuality(), 4).tab(); |
| 475 |
bb.append(kmerErrorRateR(), 5).tab(); |
| 476 |
bb.append(kmerErrorRateB(), 5).tab(); |
| 477 |
bb.append(readInsRate(), 5).tab(); |
| 478 |
bb.append(readDelRate(), 5).tab(); |
| 479 |
bb.append(discard); |
| 480 |
|
| 481 |
for(int i=0; i<5; i++){ |
| 482 |
bb.tab().append(acgtn[i]); |
| 483 |
} |
| 484 |
bb.tab().append(homoPolyGCount); |
| 485 |
bb.tab().append(homoPolyGSum); |
| 486 |
bb.tab().append(homoPolyGCount/(double)readCount, 5); |
| 487 |
|
| 488 |
|
| 489 |
bb.tab().append(barcodes); |
| 490 |
bb.tab().append(barcodeHDistSum); |
| 491 |
bb.tab().append(barcodePolymers); |
| 492 |
double invBarcodes=1.0/(Tools.max(1.0, barcodes)); |
| 493 |
bb.tab().append(barcodeHDistSum*invBarcodes, 5); |
| 494 |
bb.tab().append(barcodePolymers*invBarcodes, 5); |
| 495 |
|
| 496 |
bb.tab().append(validKmerSum); |
| 497 |
bb.tab().append(goodKmerSum, (goodKmerSum>=999 ? 0 : 2), true); |
| 498 |
bb.tab().append(goodKmerSum/(Tools.max(1.0, validKmerSum)), 5); |
| 499 |
|
| 500 |
if(mergedReads>0) { |
| 501 |
bb.tab().append(mergedReads); |
| 502 |
bb.tab().append(insertSum); |
| 503 |
bb.tab().append(overlapSum); |
| 504 |
bb.tab().append(mergeErrorSum); |
| 505 |
bb.tab().append(insertSum*2/Tools.max(1.0, mergedReads), 3); |
| 506 |
bb.tab().append(mergedReads/Tools.max(1.0, readCount), 5); |
| 507 |
bb.tab().append(mergeErrorSum/Tools.max(1.0, 2*overlapSum), 5); |
| 508 |
} |
| 509 |
|
| 510 |
return bb.nl(); |
| 511 |
} |
| 512 |
|
| 513 |
|
| 514 |
|
| 515 |
|
| 516 |
|
| 517 |
|
| 518 |
|
| 519 |
public float calcErrorRateFromUniqueness(double HG_lane, int k) { |
| 520 |
|
| 521 |
double U_tile=uniquePercent()*0.01; |
| 522 |
|
| 523 |
|
| 524 |
double NU_tile=1-U_tile; |
| 525 |
|
| 526 |
|
| 527 |
double P_tile=NU_tile/HG_lane; |
| 528 |
|
| 529 |
P_tile=Tools.mid(0.000001, P_tile, 0.99999); |
| 530 |
|
| 531 |
|
| 532 |
double NE_tile=Math.pow(P_tile, 1.0/k); |
| 533 |
|
| 534 |
double E_tile=1-NE_tile; |
| 535 |
|
| 536 |
return (float)E_tile; |
| 537 |
} |
| 538 |
|
| 539 |
|
| 540 |
@Override |
| 541 |
public int compareTo(MicroTile mt) { |
| 542 |
double ua=uniquePercent(); |
| 543 |
double ub=mt.uniquePercent(); |
| 544 |
if(ua!=ub) {return ua>ub ? 1 : -1;} |
| 545 |
double qa=averageReadQualityByProb(); |
| 546 |
double qb=mt.averageReadQualityByProb(); |
| 547 |
if(ua!=ub) {return qa<qb ? 1 : -1;} |
| 548 |
if(readCount!=mt.readCount) {return readCount>mt.readCount ? -1 : 1;} |
| 549 |
return 0; |
| 550 |
} |
| 551 |
|
| 552 |
public long hits; |
| 553 |
public long misses; |
| 554 |
public long depthSum; |
| 555 |
public long readCount; |
| 556 |
public long baseCount; |
| 557 |
public long alignedReadCount; |
| 558 |
public long alignedBaseCount; |
| 559 |
public long readErrorCount; |
| 560 |
public long baseErrorCount; |
| 561 |
public long kmerReadErrorCount; |
| 562 |
public long kmerBaseErrorCount; |
| 563 |
public long readInsCount; |
| 564 |
public long readDelCount; |
| 565 |
public double readQualityByProbSum; |
| 566 |
public double probErrorFreeSum; |
| 567 |
public double baseErrorProbSum; |
| 568 |
|
| 569 |
public double goodKmerSum; |
| 570 |
public long validKmerSum; |
| 571 |
|
| 572 |
public long[] acgtn=new long[5]; |
| 573 |
public long homoPolyGCount; |
| 574 |
public long homoPolyGSum; |
| 575 |
|
| 576 |
public int discard=0; |
| 577 |
|
| 578 |
public final int lane; |
| 579 |
public final int tile; |
| 580 |
public final int x1, x2; |
| 581 |
public final int y1, y2; |
| 582 |
|
| 583 |
|
| 584 |
long barcodes; |
| 585 |
long barcodeHDistSum=0; |
| 586 |
long barcodePolymers=0; |
| 587 |
|
| 588 |
long mergedReads=0; |
| 589 |
long insertSum=0; |
| 590 |
long overlapSum=0; |
| 591 |
long mergeErrorSum=0; |
| 592 |
|
| 593 |
public final CycleTracker tracker=TRACK_CYCLES ? new CycleTracker() : null; |
| 594 |
|
| 595 |
public static int MIN_POLY_G=15; |
| 596 |
public static boolean TRACK_CYCLES=false; |
| 597 |
public static boolean shortHeader=true; |
| 598 |
|
| 599 |
} |