Program: 132267
Project: 132267
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) throws IOException {
  Stopwatch timer=Stopwatch.createStarted();
  SamReader samReader=BAMIO.openBAM(storageClient,storagePath);
  SAMRecordIterator iterator=samReader.queryOverlapping(contig.referenceName,(int)contig.start,(int)contig.end);
  List<Read> reads=new ArrayList<Read>();
  int recordsBeforeStart=0;
  int recordsAfterEnd=0;
  int mismatchedSequence=0;
  int recordsProcessed=0;
  while (iterator.hasNext()) {
    SAMRecord record=iterator.next();
    final boolean wrongSequence=!contig.referenceName.equals(record.getReferenceName());
    if (wrongSequence) {
      mismatchedSequence++;
      continue;
    }
    if (record.getAlignmentStart() < contig.start) {
      recordsBeforeStart++;
      continue;
    }
    if (record.getAlignmentStart() > contig.end) {
      recordsAfterEnd++;
      continue;
    }
    reads.add(ReadConverter.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) throws IOException {
  Stopwatch timer=Stopwatch.createStarted();
  SamReader samReader=BAMIO.openBAM(storageClient,storagePath);
  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;
  while (iterator.hasNext()) {
    SAMRecord record=iterator.next();
    final boolean wrongSequence=!contig.referenceName.equals(record.getReferenceName()) || (!contig.referenceName.equals("String_Node_Str") && record.getReadUnmappedFlag());
    if (wrongSequence) {
      mismatchedSequence++;
      continue;
    }
    if (record.getAlignmentStart() < contig.start) {
      recordsBeforeStart++;
      continue;
    }
    if (record.getAlignmentStart() >= contig.end) {
      recordsAfterEnd++;
      continue;
    }
    reads.add(ReadConverter.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;
}