Program: 132255
Project: 132255
Buggy source:
/** 
 * To compare how sharded reading works vs. plain HTSJDK sequential iteration, this method implements such iteration. This makes it easier to discover errors such as reads that are somehow skipped by a sharded approach.
 */
public static Iterable<Read> readSequentiallyForTesting(Objects storageClient,String storagePath,Contig contig,ReaderOptions options) throws IOException {
  Stopwatch timer=Stopwatch.createStarted();
  SamReader samReader=BAMIO.openBAM(storageClient,storagePath,options.getStringency());
  SAMRecordIterator iterator=samReader.queryOverlapping(contig.referenceName,(int)contig.start + 1,(int)contig.end + 1);
  List<Read> reads=new ArrayList<Read>();
  int recordsBeforeStart=0;
  int recordsAfterEnd=0;
  int mismatchedSequence=0;
  int recordsProcessed=0;
  Filter filter=setupFilter(options,contig.referenceName);
  while (iterator.hasNext()) {
    SAMRecord record=iterator.next();
    final boolean passesFilter=passesFilter(record,filter,contig.referenceName);
    if (!passesFilter) {
      mismatchedSequence++;
      continue;
    }
    if (record.getAlignmentStart() < contig.start) {
      recordsBeforeStart++;
      continue;
    }
    if (record.getAlignmentStart() > contig.end) {
      recordsAfterEnd++;
      continue;
    }
    reads.add(ReadUtils.makeRead(record));
    recordsProcessed++;
  }
  timer.stop();
  LOG.info("String_Node_Str" + recordsProcessed + "String_Node_Str"+ timer+ "String_Node_Str"+ (recordsProcessed * 1000) / timer.elapsed(TimeUnit.MILLISECONDS) + "String_Node_Str" + "String_Node_Str" + mismatchedSequence + "String_Node_Str" + recordsBeforeStart + "String_Node_Str" + recordsAfterEnd);
  return reads;
}

Fixed version (ground truth):
/** 
 * To compare how sharded reading works vs. plain HTSJDK sequential iteration, this method implements such iteration. This makes it easier to discover errors such as reads that are somehow skipped by a sharded approach.
 */
public static Iterable<Read> readSequentiallyForTesting(Objects storageClient,String storagePath,Contig contig,ReaderOptions options) throws IOException {
  Stopwatch timer=Stopwatch.createStarted();
  SamReader samReader=BAMIO.openBAM(storageClient,storagePath,options.getStringency());
  SAMRecordIterator iterator=samReader.queryOverlapping(contig.referenceName,(int)contig.start + 1,(int)contig.end);
  List<Read> reads=new ArrayList<Read>();
  int recordsBeforeStart=0;
  int recordsAfterEnd=0;
  int mismatchedSequence=0;
  int recordsProcessed=0;
  Filter filter=setupFilter(options,contig.referenceName);
  while (iterator.hasNext()) {
    SAMRecord record=iterator.next();
    final boolean passesFilter=passesFilter(record,filter,contig.referenceName);
    if (!passesFilter) {
      mismatchedSequence++;
      continue;
    }
    if (record.getAlignmentStart() < contig.start) {
      recordsBeforeStart++;
      continue;
    }
    if (record.getAlignmentStart() > contig.end) {
      recordsAfterEnd++;
      continue;
    }
    reads.add(ReadUtils.makeRead(record));
    recordsProcessed++;
  }
  timer.stop();
  LOG.info("String_Node_Str" + recordsProcessed + "String_Node_Str"+ timer+ "String_Node_Str"+ (recordsProcessed * 1000) / timer.elapsed(TimeUnit.MILLISECONDS) + "String_Node_Str" + "String_Node_Str" + mismatchedSequence + "String_Node_Str" + recordsBeforeStart + "String_Node_Str" + recordsAfterEnd);
  return reads;
}