find RG tag correctly using BamTools API#35
Open
douglasgscofield wants to merge 1 commit intodwinter:masterfrom
Open
find RG tag correctly using BamTools API#35douglasgscofield wants to merge 1 commit intodwinter:masterfrom
douglasgscofield wants to merge 1 commit intodwinter:masterfrom
Conversation
Owner
|
Hi Douglas, Many thanks for identifying this problem and proving a PR to address it. I'll make some time to check this on a few test datasets I have here, then merge this in and make a new release. |
Author
|
Hi, I'm hoping this could get merged into the master at some point and be part of the new 0.2.2 that's been started? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
accuMUlate uses a homegrown solution to find RG tags attached to reads: using
std::string::find()to search for the literal string "\000RGZ". This only works if the previous tag fortuitously ended with \000.BAM tags containing, e.g., integer values are encoded using a type-sensitive fixed width. "XS:i:20" is encoded as "XSC\024", with the C indicating a single-byte unsigned int. In the problem case this was immediately followed by "RGZ..." encoding the tag for the read group. This is perfectly valid BAM tag encoding, however, the accuMUlate search for "\000RGZ" never found the RG tag for this read or similar reads.
The solution is to use BamTools' own API for finding tags and their values. It knows about these encodings, and searches for them robustly. A single call to
BamTools::BamAlignment::GetTag()will return a tag's value and indicate an error. The interface toReadDataVisitor::GetSampleIndex()is changed slightly and the function is simplified. The constantsReadDataVisitor::RG_TAGandReadDataVisitor::ZERO_CHARare removed as they are no longer required.