| 2498 | } |
| 2499 | |
| 2500 | void GenomeCopyNumber::readGemMappabilityFile(std::string const& inFile) { |
| 2501 | ifstream file (inFile.c_str()); |
| 2502 | string line; |
| 2503 | string::size_type pos = 0; |
| 2504 | string currentChr = ""; |
| 2505 | int index = NA; |
| 2506 | int count = 0; |
| 2507 | int uniqueCount = 0; |
| 2508 | int localWindowSize = windowSize_; |
| 2509 | float ratio; |
| 2510 | int positionInd = 0; |
| 2511 | int startPos = 0; |
| 2512 | int endPos = 0; |
| 2513 | int lastEnd = -1; |
| 2514 | string text = ""; |
| 2515 | if (file.is_open()) { |
| 2516 | cout << "..Reading "<< inFile << "\n"; |
| 2517 | int countChromosomes = 0; |
| 2518 | int countChromosomesOutOfIndex = 0; |
| 2519 | isMappUsed_=true; |
| 2520 | while (! file.eof() ) { |
| 2521 | getline (file,line); |
| 2522 | if (! line.length()) continue; |
| 2523 | pos = 0; |
| 2524 | if ( (line.substr(0,1) == "~") && (line.substr(0,2) != "~~")){ |
| 2525 | //if ( ( pos = line.find("~chr", pos)) != string::npos ){ |
| 2526 | //save the last info: |
| 2527 | if (count > endPos && index != NA) { // endPos ? |
| 2528 | int howMuchToDelete = startPos-lastEnd-1; |
| 2529 | text = text.substr(howMuchToDelete); |
| 2530 | uniqueCount =0; |
| 2531 | for(int i = 0; i < (int)text.length(); ++i) |
| 2532 | if (text[i] == '!') |
| 2533 | uniqueCount++; |
| 2534 | |
| 2535 | ratio = float(uniqueCount)/localWindowSize; |
| 2536 | chrCopyNumber_[index].setMappabilityProfileAt(positionInd, ratio); |
| 2537 | } |
| 2538 | //restore all variables for a new chromosome |
| 2539 | if ( ( pos = line.find("~chr", pos)) != string::npos ){ |
| 2540 | currentChr = line.substr(4); |
| 2541 | } else { |
| 2542 | currentChr = line.substr(1); |
| 2543 | } |
| 2544 | cout << "..Reading mappability for chromosome " << currentChr << "\n"; |
| 2545 | index = findIndex(currentChr); |
| 2546 | |
| 2547 | positionInd = 0; |
| 2548 | count = 0; |
| 2549 | uniqueCount = 0; |
| 2550 | text = ""; |
| 2551 | lastEnd = -1; |
| 2552 | |
| 2553 | //cout << "..Index for chromosome " << currentChr << ": "<< index << "\n"; |
| 2554 | |
| 2555 | if (index == NA) { |
| 2556 | cout << "skipping chromosome " << currentChr << "\n"; |
| 2557 | countChromosomesOutOfIndex ++; |
no test coverage detected