Fix for Ryan: don't pull reference sequence for the portions of reads that extend beyond the contig boundaries

git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@4551 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
ebanks 2010-10-22 14:38:26 +00:00
parent 9f76aed515
commit 181f901126
2 changed files with 5 additions and 5 deletions

View File

@ -453,9 +453,9 @@ public class UnifiedGenotyperEngine {
bitset.set(i);
}
// if a read is too long for the reference context, extend the context
// if a read is too long for the reference context, extend the context (being sure not to extend past the end of the chromosome)
if ( record.getAlignmentEnd() > refContext.getWindow().getStop() ) {
GenomeLoc window = GenomeLocParser.createGenomeLoc(refContext.getLocus().getContig(), refContext.getWindow().getStart(), record.getAlignmentEnd());
GenomeLoc window = GenomeLocParser.createGenomeLoc(refContext.getLocus().getContig(), refContext.getWindow().getStart(), Math.min(record.getAlignmentEnd(), referenceReader.getSequenceDictionary().getSequence(refContext.getLocus().getContig()).getSequenceLength()));
byte[] bases = referenceReader.getSubsequenceAt(window.getContig(), window.getStart(), window.getStop()).getBases();
StringUtil.toUpperCase(bases);
refContext = new ReferenceContext(refContext.getLocus(), window, bases);

View File

@ -285,9 +285,9 @@ public class AlignmentUtils {
if ( currentReadPos++ < readStartPos )
continue;
if ( refIndex >= refBases.length ) {
throw new IllegalStateException("When calculating mismatches, we somehow don't have enough trailing reference context for read " + read.getReadName() + " at position " + ref.getLocus());
}
// this is possible if reads extend beyond the contig end
if ( refIndex >= refBases.length )
break;
byte refChr = refBases[refIndex];
byte readChr = readBases[readIndex];