Program: 50324
Project: 50324
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.getQueryLength();
  }
  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);
  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);
  result.clearQueryLength();
  result.clearMappingQuality();
  result.clearMatchingReverseStrand();
  result.clearMultiplicity();
  result.clearNumberOfIndels();
  result.clearNumberOfMismatches();
  result.clearQueryAlignedLength();
  result.clearTargetAlignedLength();
  result.clearQueryPosition();
  result.clearFragmentIndex();
  boolean canFullyRemoveThisOne=true;
  boolean canFullyRemoveCollection=true;
  int seqVarIndex=0;
  for (  final Alignments.SequenceVariation seqVar : result.getSequenceVariationsList()) {
    encodeVar(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.getQueryLength();
  }
  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);
  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);
  result.clearQueryLength();
  result.clearMappingQuality();
  result.clearMatchingReverseStrand();
  result.clearMultiplicity();
  result.clearNumberOfIndels();
  result.clearNumberOfMismatches();
  result.clearQueryAlignedLength();
  result.clearTargetAlignedLength();
  result.clearQueryPosition();
  result.clearFragmentIndex();
  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;
}