Skip to content

Commit

Permalink
Adding filename to stored read group ID
Browse files Browse the repository at this point in the history
  • Loading branch information
mgymrek committed Apr 10, 2016
1 parent a13e5f5 commit 068dde7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/ReadContainer.cpp
Expand Up @@ -205,6 +205,8 @@ bool ReadContainer::ParseRead(const BamTools::BamAlignment& aln,
msg << aln.Name << " Could not get read group.";
PrintMessageDieOnError(msg.str(), ERROR);
}
dummy_aligned_read.read_group += "-" + aln.Filename; // Keep track of read group as <rgid>-<filename>

// *** Alignment filters (these don't depend on which STR aligned to) *** //
if (dummy_aligned_read.mapq > max_mapq) {
filter_counter.increment(FilterCounter::MAPPING_QUALITY);
Expand Down
16 changes: 15 additions & 1 deletion src/api/internal/BamMultiReader_p.cpp
Expand Up @@ -228,14 +228,28 @@ string BamMultiReaderPrivate::GetHeaderText(void) const {
if ( reader == 0 ) return string();
SamHeader mergedHeader = reader->GetHeader();

// Add filename to read ID name so we know
// which file it came from
for (SamReadGroupIterator it = mergedHeader.ReadGroups.Begin();
it != mergedHeader.ReadGroups.End(); it++) {
it->ID = it->ID + "-" + reader->GetFilename();
}

// iterate over any remaining readers (skipping the first)
for ( size_t i = 1; i < numReaders; ++i ) {
const MergeItem& item = m_readers.at(i);
const BamReader* reader = item.Reader;
if ( reader == 0 ) continue;

// retrieve current reader's header
const SamHeader currentHeader = reader->GetHeader();
SamHeader currentHeader = reader->GetHeader();

// Add filename to read ID name so we know
// which file it came from
for (SamReadGroupIterator it = currentHeader.ReadGroups.Begin();
it != currentHeader.ReadGroups.End(); it++) {
it->ID = it->ID + "-" + reader->GetFilename();
}

// append current reader's RG entries to merged header
// N.B. - SamReadGroupDictionary handles duplicate-checking
Expand Down

0 comments on commit 068dde7

Please sign in to comment.