Alignment and reference sequence from CIGAR and MD#110
Open
ingolia wants to merge 17 commits intorust-bio:masterfrom
Open
Alignment and reference sequence from CIGAR and MD#110ingolia wants to merge 17 commits intorust-bio:masterfrom
ingolia wants to merge 17 commits intorust-bio:masterfrom
Conversation
johanneskoester
requested changes
Sep 14, 2018
Contributor
johanneskoester
left a comment
There was a problem hiding this comment.
Thanks! I think the API could be simplified, see below.
…all other iterators & position representations. Updated record interface accordingly.
|
I would like to know if there is a function to get alignment pair now. In other similar htslib bindings, the reference sequence with the query sequence can be fetch in the same time. |
|
Is there any particular blocker for this work? I'd be happy to help get it over the line if necessary. |
johanneskoester
requested changes
Nov 12, 2024
Contributor
johanneskoester
left a comment
There was a problem hiding this comment.
Sorry for the long silence and thanks a lot! Looks good to me in principle (see below)
Comment on lines
+947
to
+972
| quick_error! { | ||
| #[derive(Debug,Clone)] | ||
| pub enum MDAlignError { | ||
| NoMD { | ||
| description("no MD aux field") | ||
| } | ||
| BadMD { | ||
| description("bad MD value") | ||
| } | ||
| MDvsCIGAR { | ||
| description("MD inconsistent with CIGAR") | ||
| } | ||
| BadSeqLen { | ||
| description("Sequence/quality length inconsistent with MD/CIGAR") | ||
| } | ||
| EmptyAlign { | ||
| description("Alignment has no positions") | ||
| } | ||
| ParseInt(err: ::std::num::ParseIntError) { | ||
| from() | ||
| } | ||
| Utf8(err: ::std::str::Utf8Error) { | ||
| from() | ||
| } | ||
| } | ||
| } |
Contributor
There was a problem hiding this comment.
We've moved to thiseeror, hence, this should be adapted and moved into errors.rs.
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.
This is a module that uses CIGAR and MD fields to construct alignments and reconstruct reference sequences from BAM records. I found myself wanting to do this repeatedly, and it isn't actually straightforward. I think these will be generally useful, based on the number of people requesting this feature in various languages.
This code features an MD field parser, a minimal alignment position type that includes only the information directly present in the CIGAR + MD fields, and more "complete" alignment types that use the read sequence to provide complete read and reference sequences directly in the alignment. These are all structured around iterators that generate individual positions, and can easily be collected into a vector if needed. I also added a function to create a bio-type Alignment.