Program: 50294
Project: 50294
Buggy source:
@Before public void setUp() throws IOException {
{
    outputBasename1=FilenameUtils.concat(BASE_TEST_DIR,"String_Node_Str");
    final AlignmentWriterImpl writer=new AlignmentWriterImpl(outputBasename1);
    writer.setNumAlignmentEntriesPerChunk(1000);
    writer.setAlignerName("String_Node_Str");
    writer.setAlignerVersion("String_Node_Str");
    writer.setReadOriginInfo(buildReadGroup(0,"String_Node_Str","String_Node_Str","String_Node_Str"));
    final int numQuery=10;
    int position=100;
    final int score=30;
    for (int targetIndex=0; targetIndex < numTargets; targetIndex++) {
      for (int queryIndex=0; queryIndex < numQuery; queryIndex++) {
        Alignments.AlignmentEntry.Builder newEntry=Alignments.AlignmentEntry.newBuilder();
        newEntry.setQueryIndex(queryIndex);
        newEntry.setTargetIndex(targetIndex);
        newEntry.setScore((float)score);
        newEntry.setPosition(position++);
        newEntry.setMatchingReverseStrand(false);
        newEntry.setMultiplicity(1);
        newEntry.setQueryLength(constantQueryLength);
        newEntry.setReadOriginIndex(0);
        writer.appendEntry(newEntry.build());
        numEntriesIn101++;
        count101++;
      }
    }
    numQueries101=numQuery;
    writer.close();
    AlignmentTooManyHitsWriter tmhWriter=new AlignmentTooManyHitsWriter(outputBasename1,2);
    for (int queryIndex=0; queryIndex < numQuery; queryIndex++) {
      tmhWriter.append(queryIndex,10,30);
    }
    tmhWriter.close();
  }
{
    outputBasename2=FilenameUtils.concat(BASE_TEST_DIR,"String_Node_Str");
    final AlignmentWriterImpl writer=new AlignmentWriterImpl(outputBasename2);
    writer.setAlignerName("String_Node_Str");
    writer.setAlignerVersion("String_Node_Str");
    writer.setNumAlignmentEntriesPerChunk(1000);
    writer.setReadOriginInfo(buildReadGroup(0,"String_Node_Str","String_Node_Str","String_Node_Str"));
    final int numQuery=13;
    int position=1;
    final int score=50;
    for (int targetIndex=0; targetIndex < numTargets; targetIndex++) {
      for (int queryIndex=0; queryIndex < numQuery; queryIndex++) {
        Alignments.AlignmentEntry.Builder newEntry=Alignments.AlignmentEntry.newBuilder();
        newEntry.setQueryIndex(queryIndex);
        newEntry.setTargetIndex(targetIndex);
        newEntry.setScore((float)score);
        newEntry.setPosition(position++);
        newEntry.setMatchingReverseStrand(false);
        newEntry.setMultiplicity(1);
        newEntry.setQueryLength(constantQueryLength);
        newEntry.setReadOriginIndex(0);
        writer.appendEntry(newEntry.build());
        numEntriesIn102++;
        count102++;
      }
    }
    numQueries102=numQuery;
    writer.close();
    AlignmentTooManyHitsWriter tmhWriter=new AlignmentTooManyHitsWriter(outputBasename2,2);
    for (int queryIndex=0; queryIndex < numQuery; queryIndex++) {
      tmhWriter.append(queryIndex,1,30);
    }
    tmhWriter.close();
  }
}

Fixed version (ground truth):
@Before public void setUp() throws IOException {
{
    outputBasename1=FilenameUtils.concat(BASE_TEST_DIR,"String_Node_Str");
    final AlignmentWriterImpl writer=new AlignmentWriterImpl(outputBasename1);
    writer.setNumAlignmentEntriesPerChunk(1000);
    writer.setAlignerName("String_Node_Str");
    writer.setAlignerVersion("String_Node_Str");
    writer.setReadOriginInfo(buildReadGroup(0,"String_Node_Str","String_Node_Str","String_Node_Str"));
    writer.addReadOriginInfo(buildReadGroup(1,"String_Node_Str","String_Node_Str","String_Node_Str"));
    writer.addReadOriginInfo(buildReadGroup(2,"String_Node_Str","String_Node_Str","String_Node_Str"));
    final int numQuery=10;
    int position=100;
    final int score=30;
    for (int targetIndex=0; targetIndex < numTargets; targetIndex++) {
      for (int queryIndex=0; queryIndex < numQuery; queryIndex++) {
        Alignments.AlignmentEntry.Builder newEntry=Alignments.AlignmentEntry.newBuilder();
        newEntry.setQueryIndex(queryIndex);
        newEntry.setTargetIndex(targetIndex);
        newEntry.setScore((float)score);
        newEntry.setPosition(position++);
        newEntry.setMatchingReverseStrand(false);
        newEntry.setMultiplicity(1);
        newEntry.setQueryLength(constantQueryLength);
        newEntry.setReadOriginIndex(0);
        writer.appendEntry(newEntry.build());
        numEntriesIn101++;
        count101++;
      }
    }
    numQueries101=numQuery;
    writer.close();
    AlignmentTooManyHitsWriter tmhWriter=new AlignmentTooManyHitsWriter(outputBasename1,2);
    for (int queryIndex=0; queryIndex < numQuery; queryIndex++) {
      tmhWriter.append(queryIndex,10,30);
    }
    tmhWriter.close();
  }
{
    outputBasename2=FilenameUtils.concat(BASE_TEST_DIR,"String_Node_Str");
    final AlignmentWriterImpl writer=new AlignmentWriterImpl(outputBasename2);
    writer.setAlignerName("String_Node_Str");
    writer.setAlignerVersion("String_Node_Str");
    writer.setNumAlignmentEntriesPerChunk(1000);
    writer.setReadOriginInfo(buildReadGroup(0,"String_Node_Str","String_Node_Str","String_Node_Str"));
    final int numQuery=13;
    int position=1;
    final int score=50;
    for (int targetIndex=0; targetIndex < numTargets; targetIndex++) {
      for (int queryIndex=0; queryIndex < numQuery; queryIndex++) {
        Alignments.AlignmentEntry.Builder newEntry=Alignments.AlignmentEntry.newBuilder();
        newEntry.setQueryIndex(queryIndex);
        newEntry.setTargetIndex(targetIndex);
        newEntry.setScore((float)score);
        newEntry.setPosition(position++);
        newEntry.setMatchingReverseStrand(false);
        newEntry.setMultiplicity(1);
        newEntry.setQueryLength(constantQueryLength);
        newEntry.setReadOriginIndex(0);
        writer.appendEntry(newEntry.build());
        numEntriesIn102++;
        count102++;
      }
    }
    numQueries102=numQuery;
    writer.close();
    AlignmentTooManyHitsWriter tmhWriter=new AlignmentTooManyHitsWriter(outputBasename2,2);
    for (int queryIndex=0; queryIndex < numQuery; queryIndex++) {
      tmhWriter.append(queryIndex,1,30);
    }
    tmhWriter.close();
  }
}