| 474 | } |
| 475 | |
| 476 | float SNPinGenome::addInfoFromAPileUp (int totalLetterCount, int minimalTotalLetterCountPerPosition,char whatToLook, int index,int &positionCount, int &sNPpositionToProceed, const char * pileup,int minimalQualityPerPosition, const char * quality){ |
| 477 | float value=NA; |
| 478 | float status = NA; |
| 479 | string pileupShort = ""; |
| 480 | if (totalLetterCount>=minimalTotalLetterCountPerPosition) { |
| 481 | //check that there is not deletions/insertions at this position: |
| 482 | if (strccnt(pileup, int('+'))+strccnt(pileup, int('-'))==0) { |
| 483 | |
| 484 | |
| 485 | if (minimalQualityPerPosition>0) { |
| 486 | |
| 487 | pileupShort=pileup; |
| 488 | // cout << quality << "\t"<< pileupShort <<"\t"; |
| 489 | string qualityS = quality; |
| 490 | chomp(qualityS); |
| 491 | deleteChar(pileupShort, '^', 1); |
| 492 | strkeepOnly(pileupShort, ".,ACGTNacgtn*"); |
| 493 | // cout << pileupShort <<"\n"; |
| 494 | if (pileupShort.length()==qualityS.length()) { |
| 495 | filterWithQualities(pileupShort,qualityS,minimalQualityPerPosition); |
| 496 | deleteChar(pileupShort, '*'); |
| 497 | pileup = pileupShort.c_str(); |
| 498 | totalLetterCount = pileupShort.length(); |
| 499 | } else { |
| 500 | cout << "position to skip: " << pileupShort << " " << qualityS << "\n"; |
| 501 | //skip this position.. |
| 502 | totalLetterCount = -1; |
| 503 | } |
| 504 | } |
| 505 | |
| 506 | if (totalLetterCount>=minimalTotalLetterCountPerPosition) { |
| 507 | |
| 508 | //we will recalculate totalLetterCount = refCount+countForOverLetter |
| 509 | int refCount =strccnt(pileup, '.')+strccnt(pileup, ','); |
| 510 | int countForOverLetter=strccnt(pileup, whatToLook)+strccnt(pileup, tolower(whatToLook)); |
| 511 | |
| 512 | //value = countForOverLetter*1./totalLetterCount; |
| 513 | |
| 514 | |
| 515 | if (refCount+countForOverLetter>=minimalTotalLetterCountPerPosition) { |
| 516 | if (countForOverLetter+refCount>totalLetterCount) { |
| 517 | countForOverLetter=totalLetterCount-refCount; |
| 518 | if (countForOverLetter<0) |
| 519 | countForOverLetter=0; |
| 520 | } |
| 521 | value = countForOverLetter*1./(refCount+countForOverLetter); |
| 522 | |
| 523 | //value = fabs(countForOverLetter*1./totalLetterCount-0.5); |
| 524 | // cout << "pileup: "<< pileup << " ; whatToLook: "<< whatToLook<< "\n"; |
| 525 | // cout << "countForOverLetter-1: "<< countForOverLetter-1 << "; totalLetterCount: "<< totalLetterCount << "; ERROR_PER_POS: "<< ERROR_PER_POS << "\n"; |
| 526 | double prob = binomialcdistribution(countForOverLetter-1, totalLetterCount, ERROR_PER_POS); //probability that there > k Beta Allel bases if the SNP is HomoZ. |
| 527 | status = 0; |
| 528 | if (prob<0.05) { //0.01 |
| 529 | |
| 530 | if (binomialcdistribution(totalLetterCount-countForOverLetter-1, totalLetterCount, ERROR_PER_POS)<0.01) |
| 531 | //decide that SNP is not homoZ. |
| 532 | status = 0.5; //at this point, to indicate possible AB |
| 533 | } |
nothing calls this directly
no test coverage detected