ekg/glia — pull request #1 by chapmanb (2013-12-21 18:36:19+00:00)
Title: Fixes for regional BAM re-alignment with bgzipped inputs: glia: out_of_range and tabix errors

Eric;
This fixes two issues I ran into while using glia for realignment included
called variants.

- It avoid erroring out when tabix region retrieval has no variants. The current
logic would fail both on tabix retrieval due to a return problem with vcflib
(fixed at https://github.com/ekg/vcflib/pull/28) and in regions which don't
have any variants where setRegion returns false. The fix checks the logic but
avoids erroring out, instead only iterating over variants if they are present.

- Avoids `std::out_of_range` errors from `referenceSequence.at(sp)` when an
alignment falls over the end of reference sequence. The fix counts these as
mismatches.

Here's a small reproducible test case that triggers these errors.

wget https://github.com/chapmanb/bcbio.variation.plus/raw/master/test/data/ensemble/NA12878-10.bam
wget https://raw.github.com/chapmanb/bcbio.variation.plus/master/test/data/ensemble/chr10-start.fa
wget https://s3.amazonaws.com/chapmanb/union-10_250000_400000.vcf.gz
tabix -p vcf union-10_250000_400000.vcf.gz
samtools view -bu NA12878-10.bam | glia -d -Rr -w 1000 -S 200 -Q 200 -G 4 -f chr10-start.fa -v union-10_250000_400000.vcf.gz

Thanks again for this tool. I'm excited to have a minimal test case running with
it and looking forward to exploring more.