Program: 50318
Project: 50318
Buggy source:
private Alignments.AlignmentEntry transform(final int index,int indexInReducedCollection,final Alignments.AlignmentEntry source){
  final Alignments.AlignmentEntry.Builder result=Alignments.AlignmentEntry.newBuilder(source);
  final int position=source.getPosition();
  final int targetIndex=source.getTargetIndex();
  if (index > 0 && targetIndex == previousTargetIndex) {
    result.clearPosition();
    result.clearTargetIndex();
    deltaPositions.add(position - previousPosition);
    deltaTargetIndices.add(targetIndex - previousTargetIndex);
  }
  final int queryIndex=source.getQueryIndex();
  queryIndices.add(queryIndex);
  previousPosition=position;
  previousTargetIndex=targetIndex;
  if (debug(1) && source.hasQueryLength()) {
    writtenBases+=source.getQueryAlignedLength();
  }
  result.clearQueryIndex();
  recordVariationQualitiesAndClear(result,result.getSequenceVariationsList());
  final boolean entryMatchingReverseStrand=source.getMatchingReverseStrand();
  Alignments.RelatedAlignmentEntry link=pairLinks.code(source.hasPairAlignmentLink(),entryMatchingReverseStrand,source.getPairAlignmentLink());
  if (link == null) {
    result.clearPairAlignmentLink();
  }
 else {
    result.setPairAlignmentLink(link);
  }
  link=forwardSpliceLinks.code(source.hasSplicedForwardAlignmentLink(),entryMatchingReverseStrand,source.getSplicedForwardAlignmentLink());
  if (link == null) {
    result.clearSplicedForwardAlignmentLink();
  }
 else {
    result.setSplicedForwardAlignmentLink(link);
  }
  link=backwardSpliceLinks.code(source.hasSplicedBackwardAlignmentLink(),entryMatchingReverseStrand,source.getSplicedBackwardAlignmentLink());
  if (link == null) {
    result.clearSplicedBackwardAlignmentLink();
  }
 else {
    result.setSplicedBackwardAlignmentLink(link);
  }
  final Alignments.AlignmentEntry partial=result.clone().build();
  if (previousPartial != null && indexInReducedCollection >= 1 && fastEquals(previousPartial,partial)) {
    int m=multiplicities.get(indexInReducedCollection - 1);
    multiplicities.set(indexInReducedCollection - 1,m + 1);
    countAggregatedWithMultiplicity++;
    return null;
  }
 else {
    previousPartial=partial;
    multiplicityFieldsAllMissing&=!source.hasMultiplicity();
    multiplicities.add(Math.max(1,source.getMultiplicity()));
  }
  queryLengths.add(source.hasQueryLength() ? source.getQueryLength() : MISSING_VALUE);
  mappingQualities.add(source.hasMappingQuality() ? source.getMappingQuality() : MISSING_VALUE);
  matchingReverseStrand.add(source.hasMatchingReverseStrand() ? source.getMatchingReverseStrand() ? 1 : 0 : MISSING_VALUE);
  numberOfIndels.add(source.hasNumberOfIndels() ? source.getNumberOfIndels() : MISSING_VALUE);
  numberOfMismatches.add(source.hasNumberOfMismatches() ? source.getNumberOfMismatches() : MISSING_VALUE);
  if (source.hasInsertSize()) {
    final int readPos=source.getPosition();
    final int matePos=source.getPairAlignmentLink().getPosition();
    final int length=source.getTargetAlignedLength();
    final int pos1=source.getMatchingReverseStrand() ? length + readPos : readPos + 1;
    final int pos2=EntryFlagHelper.isMateReverseStrand(source) ? length + matePos : matePos + 1;
    final int insertSize=source.getInsertSize();
    int insertSizeDiff=pos2 - pos1 - insertSize;
    if (insertSize != 0) {
    }
    if (insertSize == 0) {
      insertSizeDiff=MISSING_VALUE;
    }
    insertSizes.add(source.hasInsertSize() ? insertSizeDiff : MISSING_VALUE);
  }
 else {
    insertSizes.add(MISSING_VALUE);
  }
  queryAlignedLengths.add(source.hasQueryAlignedLength() ? source.getQueryAlignedLength() : MISSING_VALUE);
  targetAlignedLengths.add(source.hasTargetAlignedLength() ? source.getTargetAlignedLength() : MISSING_VALUE);
  fragmentIndices.add(source.hasFragmentIndex() ? source.getFragmentIndex() : MISSING_VALUE);
  variationCount.add(source.getSequenceVariationsCount());
  queryPositions.add(source.hasQueryPosition() ? source.getQueryPosition() : MISSING_VALUE);
  sampleIndices.add(source.hasSampleIndex() ? source.getSampleIndex() : MISSING_VALUE);
  readOriginIndices.add(source.hasReadOriginIndex() && storeReadOrigins ? source.getReadOriginIndex() : MISSING_VALUE);
  pairFlags.add(source.hasPairFlags() ? source.getPairFlags() : MISSING_VALUE);
  scores.add(source.hasScore() ? Float.floatToIntBits(source.getScore()) : MISSING_VALUE);
  if (source.hasReadQualityScores()) {
    final ByteString quals=source.getReadQualityScores();
    final int size=quals.size();
    numReadQualityScores.add(size);
    for (int i=0; i < size; i++) {
      allReadQualityScores.add(quals.byteAt(i));
    }
  }
 else {
    numReadQualityScores.add(0);
  }
  result.clearQueryLength();
  result.clearMappingQuality();
  result.clearMatchingReverseStrand();
  result.clearMultiplicity();
  result.clearNumberOfIndels();
  result.clearNumberOfMismatches();
  result.clearInsertSize();
  result.clearQueryAlignedLength();
  result.clearTargetAlignedLength();
  result.clearQueryPosition();
  result.clearFragmentIndex();
  result.clearReadQualityScores();
  result.clearSampleIndex();
  result.clearReadOriginIndex();
  result.clearPairFlags();
  result.clearScore();
  boolean canFullyRemoveThisOne=true;
  boolean canFullyRemoveCollection=true;
  int seqVarIndex=0;
  for (  final Alignments.SequenceVariation seqVar : result.getSequenceVariationsList()) {
    encodeVar(source.getMatchingReverseStrand(),source.getQueryLength(),seqVar);
    Alignments.SequenceVariation.Builder varBuilder=Alignments.SequenceVariation.newBuilder(seqVar);
    varBuilder.clearPosition();
    varBuilder.clearFrom();
    varBuilder.clearTo();
    varBuilder.clearToQuality();
    varBuilder.clearReadIndex();
    if (!fastEquals(EMPTY_SEQ_VAR,varBuilder.build())) {
      canFullyRemoveThisOne=false;
      canFullyRemoveCollection=false;
    }
    if (canFullyRemoveThisOne) {
      result.removeSequenceVariations(seqVarIndex);
      seqVarIndex--;
    }
    seqVarIndex++;
  }
  if (canFullyRemoveCollection) {
    result.clearSequenceVariations();
  }
  final Alignments.AlignmentEntry alignmentEntry=result.build();
  return alignmentEntry;
}

Fixed version (ground truth):
private Alignments.AlignmentEntry transform(final int index,int indexInReducedCollection,final Alignments.AlignmentEntry source){
  final Alignments.AlignmentEntry.Builder result=Alignments.AlignmentEntry.newBuilder(source);
  final int position=source.getPosition();
  final int targetIndex=source.getTargetIndex();
  if (index > 0 && targetIndex == previousTargetIndex) {
    result.clearPosition();
    result.clearTargetIndex();
    deltaPositions.add(position - previousPosition);
    deltaTargetIndices.add(targetIndex - previousTargetIndex);
  }
  final int queryIndex=source.getQueryIndex();
  queryIndices.add(queryIndex);
  previousPosition=position;
  previousTargetIndex=targetIndex;
  if (debug(1) && source.hasQueryLength()) {
    writtenBases+=source.getQueryAlignedLength();
  }
  result.clearQueryIndex();
  recordVariationQualitiesAndClear(source,result,result.getSequenceVariationsList());
  final boolean entryMatchingReverseStrand=source.getMatchingReverseStrand();
  Alignments.RelatedAlignmentEntry link=pairLinks.code(source.hasPairAlignmentLink(),entryMatchingReverseStrand,source.getPairAlignmentLink());
  if (link == null) {
    result.clearPairAlignmentLink();
  }
 else {
    result.setPairAlignmentLink(link);
  }
  link=forwardSpliceLinks.code(source.hasSplicedForwardAlignmentLink(),entryMatchingReverseStrand,source.getSplicedForwardAlignmentLink());
  if (link == null) {
    result.clearSplicedForwardAlignmentLink();
  }
 else {
    result.setSplicedForwardAlignmentLink(link);
  }
  link=backwardSpliceLinks.code(source.hasSplicedBackwardAlignmentLink(),entryMatchingReverseStrand,source.getSplicedBackwardAlignmentLink());
  if (link == null) {
    result.clearSplicedBackwardAlignmentLink();
  }
 else {
    result.setSplicedBackwardAlignmentLink(link);
  }
  final Alignments.AlignmentEntry partial=result.clone().build();
  if (previousPartial != null && indexInReducedCollection >= 1 && fastEquals(previousPartial,partial)) {
    int m=multiplicities.get(indexInReducedCollection - 1);
    multiplicities.set(indexInReducedCollection - 1,m + 1);
    countAggregatedWithMultiplicity++;
    return null;
  }
 else {
    previousPartial=partial;
    multiplicityFieldsAllMissing&=!source.hasMultiplicity();
    multiplicities.add(Math.max(1,source.getMultiplicity()));
  }
  queryLengths.add(source.hasQueryLength() ? source.getQueryLength() : MISSING_VALUE);
  mappingQualities.add(source.hasMappingQuality() ? source.getMappingQuality() : MISSING_VALUE);
  matchingReverseStrand.add(source.hasMatchingReverseStrand() ? source.getMatchingReverseStrand() ? 1 : 0 : MISSING_VALUE);
  numberOfIndels.add(source.hasNumberOfIndels() ? source.getNumberOfIndels() : MISSING_VALUE);
  numberOfMismatches.add(source.hasNumberOfMismatches() ? source.getNumberOfMismatches() : MISSING_VALUE);
  if (source.hasInsertSize()) {
    final int readPos=source.getPosition();
    final int matePos=source.getPairAlignmentLink().getPosition();
    final int length=source.getTargetAlignedLength();
    final int pos1=source.getMatchingReverseStrand() ? length + readPos : readPos + 1;
    final int pos2=EntryFlagHelper.isMateReverseStrand(source) ? length + matePos : matePos + 1;
    final int insertSize=source.getInsertSize();
    int insertSizeDiff=pos2 - pos1 - insertSize;
    if (insertSize != 0) {
    }
    if (insertSize == 0) {
      insertSizeDiff=MISSING_VALUE;
    }
    insertSizes.add(source.hasInsertSize() ? insertSizeDiff : MISSING_VALUE);
  }
 else {
    insertSizes.add(MISSING_VALUE);
  }
  queryAlignedLengths.add(source.hasQueryAlignedLength() ? source.getQueryAlignedLength() : MISSING_VALUE);
  targetAlignedLengths.add(source.hasTargetAlignedLength() ? source.getTargetAlignedLength() : MISSING_VALUE);
  fragmentIndices.add(source.hasFragmentIndex() ? source.getFragmentIndex() : MISSING_VALUE);
  variationCount.add(source.getSequenceVariationsCount());
  queryPositions.add(source.hasQueryPosition() ? source.getQueryPosition() : MISSING_VALUE);
  sampleIndices.add(source.hasSampleIndex() ? source.getSampleIndex() : MISSING_VALUE);
  readOriginIndices.add(source.hasReadOriginIndex() && storeReadOrigins ? source.getReadOriginIndex() : MISSING_VALUE);
  pairFlags.add(source.hasPairFlags() ? source.getPairFlags() : MISSING_VALUE);
  scores.add(source.hasScore() ? Float.floatToIntBits(source.getScore()) : MISSING_VALUE);
  if (source.hasReadQualityScores()) {
    final ByteString quals=source.getReadQualityScores();
    final int size=quals.size();
    numReadQualityScores.add(size);
    for (int i=0; i < size; i++) {
      allReadQualityScores.add(quals.byteAt(i));
    }
  }
 else {
    numReadQualityScores.add(0);
  }
  result.clearQueryLength();
  result.clearMappingQuality();
  result.clearMatchingReverseStrand();
  result.clearMultiplicity();
  result.clearNumberOfIndels();
  result.clearNumberOfMismatches();
  result.clearInsertSize();
  result.clearQueryAlignedLength();
  result.clearTargetAlignedLength();
  result.clearQueryPosition();
  result.clearFragmentIndex();
  result.clearReadQualityScores();
  result.clearSampleIndex();
  result.clearReadOriginIndex();
  result.clearPairFlags();
  result.clearScore();
  boolean canFullyRemoveThisOne=true;
  boolean canFullyRemoveCollection=true;
  int seqVarIndex=0;
  for (  final Alignments.SequenceVariation seqVar : result.getSequenceVariationsList()) {
    encodeVar(source.getMatchingReverseStrand(),source.getQueryLength(),seqVar);
    Alignments.SequenceVariation.Builder varBuilder=Alignments.SequenceVariation.newBuilder(seqVar);
    varBuilder.clearPosition();
    varBuilder.clearFrom();
    varBuilder.clearTo();
    varBuilder.clearToQuality();
    varBuilder.clearReadIndex();
    if (!fastEquals(EMPTY_SEQ_VAR,varBuilder.build())) {
      canFullyRemoveThisOne=false;
      canFullyRemoveCollection=false;
    }
    if (canFullyRemoveThisOne) {
      result.removeSequenceVariations(seqVarIndex);
      seqVarIndex--;
    }
    seqVarIndex++;
  }
  if (canFullyRemoveCollection) {
    result.clearSequenceVariations();
  }
  final Alignments.AlignmentEntry alignmentEntry=result.build();
  return alignmentEntry;
}