Program: 50455
Project: 50455
Buggy source:
@Test public void testIterateSortedReferenceInsertions() 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=prepareAlignmentEntryWithReferenceInsertion(0,1,100,30,false,new int[]{4,3});
  writer.appendEntry(newEntry.build());
  writer.close();
  writer.printStats(System.out);
  final Int2IntMap positionMap=new Int2IntOpenHashMap();
  IterateSortedAlignmentsListImpl iterator=new IterateSortedAlignmentsListImpl(){
    @Override public void processPositions(    int position,    ObjectArrayList<PositionBaseInfo> positionBaseInfos){
      int coverage=0;
      for (      PositionBaseInfo info : positionBaseInfos) {
        coverage+=info.to != '-' ? 1 : 0;
      }
      positionMap.put(position,coverage);
      System.out.printf("String_Node_Str",position,coverage);
    }
  }
;
  iterator.iterate(basenamePath);
  for (int i=0; i < 100; i++) {
    assertEquals("String_Node_Str" + i,0,positionMap.get(i));
  }
  for (int i=100; i < 104; i++) {
    assertEquals("String_Node_Str" + i,1,positionMap.get(i));
  }
  for (int i=104; i < 107; i++) {
    assertEquals("String_Node_Str" + i,0,positionMap.get(i));
  }
  for (int i=107; i < 137; i++) {
    assertEquals("String_Node_Str" + i,1,positionMap.get(i));
  }
  for (int i=138; i < 150; i++) {
    assertEquals("String_Node_Str" + i,0,positionMap.get(i));
  }
}

Fixed version (ground truth):
@Test public void testIterateSortedReferenceInsertions() 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=prepareAlignmentEntryWithReferenceInsertion(0,1,100,30,false,new int[]{4,3});
  writer.appendEntry(newEntry.build());
  writer.close();
  writer.printStats(System.out);
  final Int2IntMap positionMap=new Int2IntOpenHashMap();
  final IntSet variantReadIndices=new IntOpenHashSet();
  IterateSortedAlignmentsListImpl iterator=new IterateSortedAlignmentsListImpl(){
    @Override public void observeVariantBase(    ConcatSortedAlignmentReader sortedReaders,    Int2ObjectMap<ObjectArrayList<PositionBaseInfo>> positionToBases,    Alignments.SequenceVariation var,    char toChar,    char fromChar,    int currentRefPosition,    int currentReadIndex){
      variantReadIndices.add(currentReadIndex);
    }
    @Override public void processPositions(    int position,    ObjectArrayList<PositionBaseInfo> positionBaseInfos){
      int coverage=0;
      for (      PositionBaseInfo info : positionBaseInfos) {
        coverage+=info.to != '-' ? 1 : 0;
      }
      positionMap.put(position,coverage);
      System.out.printf("String_Node_Str",position,coverage);
    }
  }
;
  iterator.iterate(basenamePath);
  for (int i=0; i < 100; i++) {
    assertEquals("String_Node_Str" + i,0,positionMap.get(i));
  }
  for (int i=100; i < 103; i++) {
    assertEquals("String_Node_Str" + i,1,positionMap.get(i));
  }
  for (int i=103; i < 106; i++) {
    assertEquals("String_Node_Str" + i,0,positionMap.get(i));
  }
  for (int i=106; i < 137; i++) {
    assertEquals("String_Node_Str" + i,1,positionMap.get(i));
  }
  for (int i=138; i < 150; i++) {
    assertEquals("String_Node_Str" + i,0,positionMap.get(i));
  }
}