walaj / SeqLib

C++ htslib/bwa-mem/fermi interface for interrogating sequence data
http://bioinformatics.oxfordjournals.org/content/early/2016/12/21/bioinformatics.btw741.full.pdf+html
Other
133 stars 36 forks source link

Apply m_cram_reference to bams #38

Closed agraubert closed 5 years ago

agraubert commented 5 years ago

See #34

The value of _Bam::m_cram_reference is never meaningfully propagated to the underlying htslib bam constructs.

If BamReader::SetCramReference is called before any crams are opened, BamReader::m_cram_reference is never passed to new bams in BamReader::Open, so the new _Bam never calls htslib::cram_load_reference.

This PR adds a single line so that m_cram_reference is passed into new bams when opened.

This PR does not fix the case where bams have already opened via BamReader::Open before setting a reference. It will probably involve copying this code segment into BamReader::SetCramReference, but I didn't want to just start duplicating code blocks in case you wanted to move that into it's own function.

walaj commented 5 years ago

Yikes, you're right, it seems my test cases first set the CRAM reference so I never noticed this. Thanks for the fix! Not an easy bug to find.