Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a function and constant for checking supplementary BAM alignments. #173

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/api/BamAlignment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,14 @@ bool BamAlignment::HasTag(const std::string& tag) const
return FindTag(tag, pTagData, tagDataLength, numBytesParsed);
}

/*! \fn bool BamAlignment::IsSupplementary() const
\return \c true if this read is supplementary
*/
bool BamAlignment::IsSupplementary() const
{
return ((AlignmentFlag & Constants::BAM_ALIGNMENT_SUPPLEMENTARY) != 0);
}

/*! \fn bool BamAlignment::IsDuplicate() const
\return \c true if this read is a PCR duplicate
*/
Expand Down
1 change: 1 addition & 0 deletions src/api/BamAlignment.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class API_EXPORT BamAlignment
bool IsMateMapped() const; // returns true if alignment's mate is mapped
bool IsMateReverseStrand() const; // returns true if alignment's mate mapped to reverse strand
bool IsPaired() const; // returns true if alignment part of paired-end read
bool IsSupplementary() const; // returns true if this read is supplementary
bool IsPrimaryAlignment() const; // returns true if reported position is primary alignment
bool IsProperPair()
const; // returns true if alignment is part of read that satisfied paired-end resolution
Expand Down
1 change: 1 addition & 0 deletions src/api/BamConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const int BAM_ALIGNMENT_READ_2 = 0x0080;
const int BAM_ALIGNMENT_SECONDARY = 0x0100;
const int BAM_ALIGNMENT_QC_FAILED = 0x0200;
const int BAM_ALIGNMENT_DUPLICATE = 0x0400;
const int BAM_ALIGNMENT_SUPPLEMENTARY = 0x0800;

// CIGAR constants
const char* const BAM_CIGAR_LOOKUP = "MIDNSHP=X";
Expand Down
20 changes: 20 additions & 0 deletions src/api/BamReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,26 @@ bool BamReader::OpenIndex(const std::string& indexFilename)
return d->OpenIndex(indexFilename);
}

/*! \fn bool BamReader::GetPointer()
\brief Returns the current file pointer.

Useful for going back to previous alignments with SetPointer().

\returns \c file pointer
\sa SetPointer()
*/

int64_t BamReader::GetPointer() const
{
return d->GetPointer();
}

// set the current file pointer
void BamReader::SetPointer(int64_t i)
{
d->SetPointer(i);
}

/*! \fn bool BamReader::Rewind()
\brief Returns the internal file pointer to the first alignment record.

Expand Down
6 changes: 6 additions & 0 deletions src/api/BamReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ class API_EXPORT BamReader
bool SetRegion(const int& leftRefID, const int& leftPosition, const int& rightRefID,
const int& rightPosition);

// returns current file pointer
int64_t GetPointer() const;

// set the current file pointer
void SetPointer(int64_t);

// ----------------------
// access alignment data
// ----------------------
Expand Down
10 changes: 10 additions & 0 deletions src/api/internal/bam/BamReader_p.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,16 @@ bool BamReaderPrivate::OpenIndex(const std::string& indexFilename)
}
}

int64_t BamReaderPrivate::GetPointer() const
{
return m_stream.Tell();
}

void BamReaderPrivate::SetPointer(int64_t position)
{
m_stream.Seek(position);
}

// returns BAM file pointer to beginning of alignment data
bool BamReaderPrivate::Rewind()
{
Expand Down
3 changes: 3 additions & 0 deletions src/api/internal/bam/BamReader_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ class BamReaderPrivate
bool GetNextAlignment(BamAlignment& alignment);
bool GetNextAlignmentCore(BamAlignment& alignment);

int64_t GetPointer() const;
void SetPointer(int64_t);

// access auxiliary data
std::string GetHeaderText() const;
const SamHeader& GetConstSamHeader() const;
Expand Down