/** ** Copyright (c) 2007-2010 Illumina, Inc. ** ** This software is covered by the "Illumina Genome Analyzer Software ** License Agreement" and the "Illumina Source Code License Agreement", ** and certain third party copyright/licenses, and any user of this ** source file is bound by the terms therein (see accompanying files ** Illumina_Genome_Analyzer_Software_License_Agreement.pdf and ** Illumina_Source_Code_License_Agreement.pdf and third party ** copyright/license notices). ** ** This file is part of the Consensus Assessment of Sequence And VAriation ** (CASAVA) software package. ** ** @file BamAlignmentReader.h ** ** @brief Provides a wrapper for bam_streamer that fills the Alignment data ** structure. ** ** @author Michael Stromberg **/ #pragma once #include #include "blt_util/bam_streamer.hh" #include "common/Alignment.hh" namespace ca { namespace variance_detection { class BamAlignmentReader { public: // constructor // if isFilterUnanchored, remove reads where both mates have SE score=0: BamAlignmentReader(const bool isFilterUnanchored); // destructor ~BamAlignmentReader(void); // closes the underlying file stream(s) void Close(void); // provides the next alignment and returns false if no more reads are available bool GetNextRead(casava::common::Alignment& al); // returns true if the underlying file stream is open bool IsOpen(void) const; // opens the underlying file stream void Open(const std::string& bamFilename, const std::string& refFilename, const char* bamRegion); private: // adds the bases from a bam_seq to an alignment string static void AddBases(const bam_seq& br, casava::common::Alignment& al, const bool onForwardStrand); // adds the base qualities from an array to an alignment string static void AddBaseQualities(const uint8_t* bq, const uint32_t numBases, casava::common::Alignment& al, const bool onForwardStrand); // adds the index sequence to an alignment string static void AddIndex(const char* indexSeq, casava::common::Alignment& al); // adds the read name into machine name, run id, etc. static void AddReadName(casava::common::Alignment& al, const char* readName, bool& useCasavaReadNameStyle); // returns true if the alignment contains supported CIGAR operations, does not fail QC, and is not a duplicate static bool IsGoodAlignment(const bam_record* pBamAlignment, const uint32_t refLen, const bool isFilterUnanchored); // toggled according to the status of the underlying file stream(s) bool mIsOpen; // our underlying input stream bam_streamer* mpInStream; // the BAM filename std::string mFilename; // the reference sequence name and bases std::string mReferenceBases; const char* mpReferenceBases; const char* mpReferenceEnd; uint32_t mReferenceLen; // uses the read name convention used by CASAVA bool mUseCasavaReadNameStyle; // remove unanchored read pairs bool mIsFilterUnanchored; }; } }