Program: 50442
Project: 50442
Buggy source:
@Test public void testIterateSortedTwoMutations() throws IOException {
  final String basename="String_Node_Str";
  final String basenamePath=FilenameUtils.concat(BASE_TEST_DIR,basename);
  final AlignmentWriter writer=new AlignmentWriter(basenamePath);
  writer.setNumAlignmentEntriesPerChunk(1);
  final int numTargets=3;
  final int[] targetLengths=new int[numTargets];
  for (int referenceIndex=0; referenceIndex < numTargets; referenceIndex++) {
    targetLengths[referenceIndex]=1000;
  }
  writer.setTargetLengths(targetLengths);
  writer.setSorted(true);
  Alignments.AlignmentEntry.Builder newEntry;
  newEntry=prepareAlignmentEntry(0,1,100,3,true,new int[]{2,31,34},35);
  writer.appendEntry(newEntry.build());
  writer.close();
  writer.printStats(System.out);
  final IntSet variantReadIndices=new IntOpenHashSet();
  final IntSet variantPositionOnRef=new IntOpenHashSet();
  IterateSortedAlignmentsListImpl iterator=new IterateSortedAlignmentsListImpl(){
    public void processPositions(    int referenceIndex,    int intermediatePosition,    ObjectArrayList<PositionBaseInfo> positionBaseInfos){
    }
    @Override public void observeVariantBase(    ConcatSortedAlignmentReader sortedReaders,    Alignments.AlignmentEntry alignmentEntry,    Int2ObjectMap<ObjectArrayList<PositionBaseInfo>> positionToBases,    Alignments.SequenceVariation var,    char toChar,    char fromChar,    int currentReferenceIndex,    int currentRefPosition,    int currentReadIndex){
      variantReadIndices.add(currentReadIndex);
      variantPositionOnRef.add(currentRefPosition);
    }
  }
;
  iterator.iterate(basenamePath);
  assertTrue(variantReadIndices.contains(34));
  assertTrue(variantReadIndices.contains(2));
  assertTrue(variantReadIndices.contains(5));
  assertTrue(variantPositionOnRef.contains(101));
  assertTrue(variantPositionOnRef.contains(130));
  assertTrue(variantPositionOnRef.contains(133));
}

Fixed version (ground truth):
@Test public void testIterateSortedTwoMutations() throws IOException {
  final String basename="String_Node_Str";
  final String basenamePath=FilenameUtils.concat(BASE_TEST_DIR,basename);
  final AlignmentWriter writer=new AlignmentWriter(basenamePath);
  writer.setNumAlignmentEntriesPerChunk(1);
  final int numTargets=3;
  final int[] targetLengths=new int[numTargets];
  for (int referenceIndex=0; referenceIndex < numTargets; referenceIndex++) {
    targetLengths[referenceIndex]=1000;
  }
  writer.setTargetLengths(targetLengths);
  writer.setSorted(true);
  Alignments.AlignmentEntry.Builder newEntry;
  newEntry=prepareAlignmentEntry(0,1,100,3,true,new int[]{2,31,34},35);
  writer.appendEntry(newEntry.build());
  writer.close();
  writer.printStats(System.out);
  final IntSet variantReadIndices=new IntOpenHashSet();
  final IntSet variantPositionOnRef=new IntOpenHashSet();
  IterateSortedAlignmentsListImpl iterator=new IterateSortedAlignmentsListImpl(){
    public void processPositions(    int referenceIndex,    int intermediatePosition,    ObjectArrayList<PositionBaseInfo> positionBaseInfos){
    }
    @Override public void observeVariantBase(    ConcatSortedAlignmentReader sortedReaders,    Alignments.AlignmentEntry alignmentEntry,    Int2ObjectMap<ObjectArrayList<IterateSortedAlignmentsListImpl.PositionBaseInfo>> positionToBases,    Alignments.SequenceVariation var,    char toChar,    char fromChar,    int currentReferenceIndex,    int currentRefPosition,    int currentReadIndex){
      variantReadIndices.add(currentReadIndex);
      variantPositionOnRef.add(currentRefPosition);
    }
  }
;
  iterator.iterate(basenamePath);
  assertTrue(variantReadIndices.contains(34));
  assertTrue(variantReadIndices.contains(2));
  assertTrue(variantReadIndices.contains(5));
  assertTrue(variantPositionOnRef.contains(101));
  assertTrue(variantPositionOnRef.contains(130));
  assertTrue(variantPositionOnRef.contains(133));
}