DNALength CompressedSequence<T_Sequence>::FourBitDecompressHomopolymers(int start, int end, T_Sequence &decompSeq) { decompSeq.Free(); // Free before decomp; // // first compute the length of the decoded // DNALength i; decompSeq.length = 0; for (i = start; i < end; i++ ){ unsigned char count; count = (unsigned char) seq[i]; count >>= 4; decompSeq.length += count; } decompSeq.seq = ProtectedNew<Nucleotide>(decompSeq.length); // // Now store the actual decompressed seq. // int d = 0; unsigned char mask = 0xf; for (i = start; i < end; i++ ){ unsigned char count; count = (unsigned char) seq[i]; count >>= 4; int j; for (j = 0; j < count; j++ ){ decompSeq.seq[d] = FourBitToAscii[(seq[i] & mask)]; d++; } } decompSeq.bitsPerNuc = 4; decompSeq.deleteOnExit = true; return decompSeq.length; }
int GetNext(T_Sequence &ccsSequence) { // // Read in all ccs pass data. // ccsSequence.Free(); int retVal = 0; if (this->curRead == ccsBasReader.nReads) { return 0; } if (this->curBasePos == ccsBasReader.nBases) { return 0; } try { UInt numPasses; numPassesArray.Read(this->curRead, this->curRead+1, &numPasses); if (numPasses > 0) { // Read in the ccs bases if ((retVal = ccsBasReader.GetNext((SMRTSequence&)ccsSequence)) == 0) return 0; ccsSequence.numPasses = numPasses; if (this->includedFields["AdapterHitAfter"]) { ccsSequence.adapterHitAfter.resize(ccsSequence.numPasses); adapterHitAfterArray.Read(curPassPos, curPassPos + ccsSequence.numPasses, &ccsSequence.adapterHitAfter[0]); } if (this->includedFields["AdapterHitBefore"]) { ccsSequence.adapterHitBefore.resize(ccsSequence.numPasses); adapterHitBeforeArray.Read(curPassPos, curPassPos + ccsSequence.numPasses, &ccsSequence.adapterHitBefore[0]); } if (this->includedFields["PassDirection"]) { ccsSequence.passDirection.resize(ccsSequence.numPasses); passDirectionArray.Read(curPassPos, curPassPos + ccsSequence.numPasses, &ccsSequence.passDirection[0]); } if (this->includedFields["PassNumBases"]) { ccsSequence.passNumBases.resize(ccsSequence.numPasses); passNumBasesArray.Read(curPassPos, curPassPos + ccsSequence.numPasses, &ccsSequence.passNumBases[0]); } if (this->includedFields["PassStartBase"]) { ccsSequence.passStartBase.resize(ccsSequence.numPasses); passStartBaseArray.Read(curPassPos, curPassPos + ccsSequence.numPasses, &ccsSequence.passStartBase[0]); } if (this->includedFields["PassStartPulse"]) { ccsSequence.passStartPulse.resize(ccsSequence.numPasses); passStartPulseArray.Read(curPassPos, curPassPos + ccsSequence.numPasses, &ccsSequence.passStartPulse[0]); } if (this->includedFields["PassNumPulses"]) { ccsSequence.passNumPulses.resize(ccsSequence.numPasses); passNumPulsesArray.Read(curPassPos, curPassPos + ccsSequence.numPasses, &ccsSequence.passNumPulses[0]); } curPassPos += ccsSequence.numPasses; } else { // advance a read in the ccs sequence without advancing positions. ccsBasReader.curRead++; } // // Regardless whether or not a ccs read was called, read the next // unrolled read, since an unrolled read is called for each zmw. // retVal = ((T_HDFBasReader<SMRTSequence>*)this)->GetNext(ccsSequence.unrolledRead); ccsSequence.zmwData = ccsSequence.unrolledRead.zmwData; ccsSequence.CopyTitle(ccsSequence.unrolledRead.title); string newTitle = string(ccsSequence.title) + string("/ccs"); ccsSequence.CopyTitle(newTitle.c_str()); } catch (H5::DataSetIException e) { cout << "ERROR, could not read ccs data for CCS Sequence " << ccsSequence.unrolledRead.title << endl; exit(1); } // cout << "title: " << ccsSequence.title << endl; if (retVal == 0) { return 0; } else { return 1; } }