From 0d0082333222120c85afeef04a98ebf1858876a4 Mon Sep 17 00:00:00 2001 From: hanna Date: Fri, 3 Jul 2009 16:17:38 +0000 Subject: [PATCH] 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 --- .../gatk/datasources/providers/LocusReferenceView.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/java/src/org/broadinstitute/sting/gatk/datasources/providers/LocusReferenceView.java b/java/src/org/broadinstitute/sting/gatk/datasources/providers/LocusReferenceView.java index 99c72ecfa..27b40a63b 100755 --- a/java/src/org/broadinstitute/sting/gatk/datasources/providers/LocusReferenceView.java +++ b/java/src/org/broadinstitute/sting/gatk/datasources/providers/LocusReferenceView.java @@ -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(); }