Program: 50488
Project: 50488
Buggy source:
public void merge(final List<File> inputFiles,final String outputFile) throws IOException {
  referenceIndexPermutation=new ObjectArrayList<int[]>();
  int maxNumberOfReads=0;
  if (verbose) {
    System.out.println("String_Node_Str");
    System.out.flush();
  }
  int mergedReferenceIndex=0;
  final IndexedIdentifier mergedTargetIdentifiers=new IndexedIdentifier();
  final IntSet numberOfReads=new IntArraySet();
  for (  final File inputFile : inputFiles) {
    final AlignmentReader reader=new AlignmentReader(inputFile.toString());
    reader.readHeader();
    message("String_Node_Str" + reader.getNumberOfTargets() + "String_Node_Str");
    mergedReferenceIndex=constructTargetIndexPermutations(mergedReferenceIndex,mergedTargetIdentifiers,reader);
    numberOfReads.add(reader.getNumberOfQueries());
    reader.close();
  }
  if (numberOfReads.size() != 1) {
    message("String_Node_Str" + numberOfReads);
    return;
  }
  maxNumberOfReads=numberOfReads.iterator().next();
  message("String_Node_Str" + maxNumberOfReads);
  final AbstractAlignmentEntryFilter entryFilter=getFilter(maxNumberOfReads);
  entryFilter.setHeader(mergedTargetIdentifiers);
  ProgressLogger progress=new ProgressLogger(LOG);
  progress.expectedUpdates=inputFiles.size();
  progress.start();
  float totalNumberOfLogicalEntries=0;
  message("String_Node_Str");
  int totalNumberOfEntries=0;
  for (  final File inputFile : inputFiles) {
    message("String_Node_Str" + inputFile.getName());
    final AlignmentReader reader=new AlignmentReader(inputFile.toString());
    while (reader.hasNext()) {
      final Alignments.AlignmentEntry entry=reader.next();
      entryFilter.inspectEntry(entry);
      ++totalNumberOfEntries;
      totalNumberOfLogicalEntries+=entry.getMultiplicity();
    }
    progress.update();
    reader.close();
  }
  progress.stop();
  entryFilter.postProcessing();
  message(String.format("String_Node_Str",(int)totalNumberOfLogicalEntries));
  message("String_Node_Str");
  prepareMergedTooManyHits(outputFile,maxNumberOfReads,inputFiles.toArray(new File[inputFiles.size()]));
  message("String_Node_Str");
  int wrote=0;
  int skipped=0;
  int skippedTooManyHits=0;
  int skippedNotBestScore=0;
  final AlignmentWriter writer=new AlignmentWriter(outputFile);
  progress=new ProgressLogger(LOG);
  progress.expectedUpdates=totalNumberOfEntries;
  progress.start();
  if (mergedTargetIdentifiers.size() > 0) {
    writer.setTargetIdentifiers(mergedTargetIdentifiers);
  }
  int inputFileIndex=0;
  final AlignmentTooManyHitsReader tmhReader=new AlignmentTooManyHitsReader(outputFile);
  final IntSet queriesIndicesAligned=new IntOpenHashSet();
  for (  final File inputFile : inputFiles) {
    final String basename=inputFile.toString();
    final AlignmentReader reader=new AlignmentReader(basename);
    final AlignmentTooManyHitsReader specificTmhReader=new AlignmentTooManyHitsReader(basename);
    while (reader.hasNext()) {
      final Alignments.AlignmentEntry entry=reader.next();
      progress.lightUpdate();
      if (entryFilter.shouldRetainEntry(entry)) {
        final int queryIndex=entry.getQueryIndex();
        final int matchLength=specificTmhReader.getLengthOfMatch(queryIndex);
        if (!tmhReader.isQueryAmbiguous(queryIndex,k,matchLength)) {
          final int newTargetIndex=referenceIndexPermutation.get(inputFileIndex)[entry.getTargetIndex()];
          writer.appendEntry(entry,newTargetIndex);
          wrote+=entry.getMultiplicity();
          queriesIndicesAligned.add(entry.getQueryIndex());
        }
 else {
          skipped+=entry.getMultiplicity();
          skippedTooManyHits+=entry.getMultiplicity();
        }
      }
 else {
        skipped+=entry.getMultiplicity();
        skippedNotBestScore+=entry.getMultiplicity();
      }
      if (((wrote + skipped) % 1000000) == 0) {
        printStatus((int)totalNumberOfLogicalEntries,wrote,skipped,skippedTooManyHits,skippedNotBestScore);
      }
    }
    reader.close();
    inputFileIndex++;
  }
  progress.stop();
  writer.setNumTargets(mergedReferenceIndex);
  printStatus((int)totalNumberOfLogicalEntries,wrote,skipped,skippedTooManyHits,skippedNotBestScore);
  if (verbose) {
    writer.printStats(System.out);
  }
  final float numQuerySequences=maxNumberOfReads;
  final float percentWritten=((float)wrote) * 100f / totalNumberOfLogicalEntries;
  final float skippedPercent=((float)skipped * 100f / totalNumberOfLogicalEntries);
  final float skippedTooManyHitsPercent=((float)skippedTooManyHits) * 100f / totalNumberOfLogicalEntries;
  final float skippedNotBestScorePercent=((float)skippedNotBestScore * 100f / totalNumberOfLogicalEntries);
  float percentAligned=queriesIndicesAligned.size();
  percentAligned/=numQuerySequences;
  percentAligned*=100f;
  final double percentEntriesRetained=((double)wrote) / numQuerySequences * 100d;
  writer.putStatistic("String_Node_Str",wrote);
  writer.putStatistic("String_Node_Str",percentWritten);
  writer.putStatistic("String_Node_Str",totalNumberOfLogicalEntries);
  writer.putStatistic("String_Node_Str",totalNumberOfEntries);
  writer.putStatistic("String_Node_Str",skippedPercent);
  writer.putStatistic("String_Node_Str",skippedTooManyHitsPercent);
  writer.putStatistic("String_Node_Str",skippedTooManyHits);
  writer.putStatistic("String_Node_Str",skippedNotBestScorePercent);
  writer.putStatistic("String_Node_Str",skippedNotBestScore);
  writer.putStatistic("String_Node_Str",percentEntriesRetained);
  writer.putStatistic("String_Node_Str",maxNumberOfReads);
  writer.putStatistic("String_Node_Str",mergedTargetIdentifiers.size());
  writer.putStatistic("String_Node_Str",queriesIndicesAligned.size());
  writer.putStatistic("String_Node_Str",percentAligned);
  writer.close();
  message("String_Node_Str" + percentAligned);
}

Fixed version (ground truth):
public void merge(final List<File> inputFiles,final String outputFile) throws IOException {
  referenceIndexPermutation=new ObjectArrayList<int[]>();
  int maxNumberOfReads=0;
  if (verbose) {
    System.out.println("String_Node_Str");
    System.out.flush();
  }
  int mergedReferenceIndex=0;
  final IndexedIdentifier mergedTargetIdentifiers=new IndexedIdentifier();
  final IntSet numberOfReads=new IntArraySet();
  for (  final File inputFile : inputFiles) {
    final AlignmentReader reader=new AlignmentReader(inputFile.toString());
    reader.readHeader();
    message("String_Node_Str" + reader.getNumberOfTargets() + "String_Node_Str");
    mergedReferenceIndex=constructTargetIndexPermutations(mergedReferenceIndex,mergedTargetIdentifiers,reader);
    numberOfReads.add(reader.getNumberOfQueries());
    reader.close();
  }
  if (numberOfReads.size() != 1) {
    message("String_Node_Str" + numberOfReads);
    return;
  }
  maxNumberOfReads=numberOfReads.iterator().next();
  message("String_Node_Str" + maxNumberOfReads);
  final AbstractAlignmentEntryFilter entryFilter=getFilter(maxNumberOfReads);
  entryFilter.setHeader(mergedTargetIdentifiers);
  ProgressLogger progress=new ProgressLogger(LOG);
  progress.expectedUpdates=inputFiles.size();
  progress.start();
  float totalNumberOfLogicalEntries=0;
  message("String_Node_Str");
  int totalNumberOfEntries=0;
  for (  final File inputFile : inputFiles) {
    message("String_Node_Str" + inputFile.getName());
    final AlignmentReader reader=new AlignmentReader(inputFile.toString());
    reader.readHeader();
    entryFilter.setHeader(reader.getTargetIdentifiers());
    while (reader.hasNext()) {
      final Alignments.AlignmentEntry entry=reader.next();
      entryFilter.inspectEntry(entry);
      ++totalNumberOfEntries;
      totalNumberOfLogicalEntries+=entry.getMultiplicity();
    }
    progress.update();
    reader.close();
  }
  progress.stop();
  entryFilter.postProcessing();
  message(String.format("String_Node_Str",(int)totalNumberOfLogicalEntries));
  message("String_Node_Str");
  prepareMergedTooManyHits(outputFile,maxNumberOfReads,inputFiles.toArray(new File[inputFiles.size()]));
  message("String_Node_Str");
  int wrote=0;
  int skipped=0;
  int skippedTooManyHits=0;
  int skippedNotBestScore=0;
  final AlignmentWriter writer=new AlignmentWriter(outputFile);
  progress=new ProgressLogger(LOG);
  progress.expectedUpdates=totalNumberOfEntries;
  progress.start();
  if (mergedTargetIdentifiers.size() > 0) {
    writer.setTargetIdentifiers(mergedTargetIdentifiers);
  }
  int inputFileIndex=0;
  final AlignmentTooManyHitsReader tmhReader=new AlignmentTooManyHitsReader(outputFile);
  final IntSet queriesIndicesAligned=new IntOpenHashSet();
  for (  final File inputFile : inputFiles) {
    final String basename=inputFile.toString();
    final AlignmentReader reader=new AlignmentReader(basename);
    reader.readHeader();
    entryFilter.setHeader(reader.getTargetIdentifiers());
    final AlignmentTooManyHitsReader specificTmhReader=new AlignmentTooManyHitsReader(basename);
    while (reader.hasNext()) {
      final Alignments.AlignmentEntry entry=reader.next();
      progress.lightUpdate();
      if (entryFilter.shouldRetainEntry(entry)) {
        final int queryIndex=entry.getQueryIndex();
        final int matchLength=specificTmhReader.getLengthOfMatch(queryIndex);
        if (!tmhReader.isQueryAmbiguous(queryIndex,k,matchLength)) {
          final int newTargetIndex=referenceIndexPermutation.get(inputFileIndex)[entry.getTargetIndex()];
          writer.appendEntry(entry,newTargetIndex);
          wrote+=entry.getMultiplicity();
          queriesIndicesAligned.add(entry.getQueryIndex());
        }
 else {
          skipped+=entry.getMultiplicity();
          skippedTooManyHits+=entry.getMultiplicity();
        }
      }
 else {
        skipped+=entry.getMultiplicity();
        skippedNotBestScore+=entry.getMultiplicity();
      }
      if (((wrote + skipped) % 1000000) == 0) {
        printStatus((int)wrote + skipped,wrote,skipped,skippedTooManyHits,skippedNotBestScore);
      }
    }
    reader.close();
    inputFileIndex++;
  }
  progress.stop();
  writer.setNumTargets(mergedReferenceIndex);
  printStatus((int)totalNumberOfLogicalEntries,wrote,skipped,skippedTooManyHits,skippedNotBestScore);
  if (verbose) {
    writer.printStats(System.out);
  }
  entryFilter.printStats();
  final float numQuerySequences=maxNumberOfReads;
  final float percentWritten=((float)wrote) * 100f / totalNumberOfLogicalEntries;
  final float skippedPercent=((float)skipped * 100f / totalNumberOfLogicalEntries);
  final float skippedTooManyHitsPercent=((float)skippedTooManyHits) * 100f / totalNumberOfLogicalEntries;
  final float skippedNotBestScorePercent=((float)skippedNotBestScore * 100f / totalNumberOfLogicalEntries);
  float percentAligned=queriesIndicesAligned.size();
  percentAligned/=numQuerySequences;
  percentAligned*=100f;
  final double percentEntriesRetained=((double)wrote) / numQuerySequences * 100d;
  writer.putStatistic("String_Node_Str",wrote);
  writer.putStatistic("String_Node_Str",percentWritten);
  writer.putStatistic("String_Node_Str",totalNumberOfLogicalEntries);
  writer.putStatistic("String_Node_Str",totalNumberOfEntries);
  writer.putStatistic("String_Node_Str",skippedPercent);
  writer.putStatistic("String_Node_Str",skippedTooManyHitsPercent);
  writer.putStatistic("String_Node_Str",skippedTooManyHits);
  writer.putStatistic("String_Node_Str",skippedNotBestScorePercent);
  writer.putStatistic("String_Node_Str",skippedNotBestScore);
  writer.putStatistic("String_Node_Str",percentEntriesRetained);
  writer.putStatistic("String_Node_Str",maxNumberOfReads);
  writer.putStatistic("String_Node_Str",mergedTargetIdentifiers.size());
  writer.putStatistic("String_Node_Str",queriesIndicesAligned.size());
  writer.putStatistic("String_Node_Str",percentAligned);
  writer.close();
  message("String_Node_Str" + percentAligned);
}