diff --git a/java/src/org/broadinstitute/sting/utils/sam/AlignmentUtils.java b/java/src/org/broadinstitute/sting/utils/sam/AlignmentUtils.java
index 99a5bbb55..29d946410 100644
--- a/java/src/org/broadinstitute/sting/utils/sam/AlignmentUtils.java
+++ b/java/src/org/broadinstitute/sting/utils/sam/AlignmentUtils.java
@@ -70,7 +70,7 @@ public class AlignmentUtils {
* on the read of length nReadBases starting at (0-based) position readIndex.
* @param r Aligned read to count mismatches for
* @param refSeq Chunk of reference sequence that subsumes the alignment
- * @param refIndex Zero-based position on refSeq where the alighnment for the whole read starts
+ * @param refIndex Zero-based position on refSeq where the alignment for the whole read starts
* @param readIndex Zero-based position on the read, the mismatches will be counted only from this position on
* @param nReadBases Length of continuous stretch on the read, along which mismatches will be counted
* @return
@@ -491,7 +491,7 @@ public class AlignmentUtils {
if(!atDeletion) {
alignmentPos += elementLength;
} else {
- if( pos + elementLength >= pileupOffset ) {
+ if( pos + elementLength - 1 >= pileupOffset ) {
return alignmentPos + (pileupOffset - pos);
} else {
pos += elementLength;
@@ -500,7 +500,7 @@ public class AlignmentUtils {
}
break;
case M:
- if( pos + elementLength >= pileupOffset ) {
+ if( pos + elementLength - 1 >= pileupOffset ) {
return alignmentPos + (pileupOffset - pos);
} else {
pos += elementLength;
@@ -602,7 +602,7 @@ public class AlignmentUtils {
if ( r.getReadUnmappedFlag() ) return true;
// our life would be so much easier if all sam files followed the specs. In reality,
- // sam files (including those generated by maq or bwa) miss headers alltogether. When
+ // sam files (including those generated by maq or bwa) miss headers altogether. When
// reading such a SAM file, reference name is set, but since there is no sequence dictionary,
// null is always returned for referenceIndex. Let's be paranoid here, and make sure that
// we do not call the read "unmapped" when it has only reference name set with ref. index missing
@@ -624,7 +624,7 @@ public class AlignmentUtils {
if ( r.getMateUnmappedFlag() ) return true;
// our life would be so much easier if all sam files followed the specs. In reality,
- // sam files (including those generated by maq or bwa) miss headers alltogether. When
+ // sam files (including those generated by maq or bwa) miss headers altogether. When
// reading such a SAM file, reference name is set, but since there is no sequence dictionary,
// null is always returned for referenceIndex. Let's be paranoid here, and make sure that
// we do not call the read "unmapped" when it has only reference name set with ref. index missing