Fix for performance bug in extending the read with X's in cases where the read is aligned off the end of the contig.

git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@1165 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
hanna 2009-07-03 16:17:38 +00:00
parent be2f8478c0
commit 0d00823332
1 changed files with 3 additions and 5 deletions

View File

@ -4,6 +4,7 @@ import org.broadinstitute.sting.utils.GenomeLoc;
import org.broadinstitute.sting.utils.Utils;
import net.sf.picard.reference.ReferenceSequence;
import net.sf.samtools.util.StringUtil;
import net.sf.samtools.SAMSequenceRecord;
/*
* Copyright (c) 2009 The Broad Institute
*
@ -76,11 +77,8 @@ public class LocusReferenceView extends ReferenceView {
* at the end of the locus (inclusive).
*/
public char[] getReferenceBases( GenomeLoc genomeLoc ) {
long stop = genomeLoc.getStop();
long seqLength = reference.getSequence(genomeLoc.getContig()).length();
if (seqLength < genomeLoc.getStop()) {
stop = seqLength;
}
SAMSequenceRecord sequenceInfo = reference.getSequenceDictionary().getSequence(genomeLoc.getContig());
long stop = Math.min( genomeLoc.getStop(), sequenceInfo.getSequenceLength() );
ReferenceSequence subsequence = reference.getSubsequenceAt(genomeLoc.getContig(),genomeLoc.getStart(),stop);
return (StringUtil.bytesToString(subsequence.getBases()) + Utils.dupString('X', (int)(genomeLoc.getStop() - stop)) ).toCharArray();
}