Program: 50251
Project: 50251
Buggy source:
private Alignments.AlignmentEntry realign(Alignments.AlignmentEntry entry,ObservedIndel indel,boolean shiftForward,int scoreDelta){
}

Fixed version (ground truth):
private Alignments.AlignmentEntry realign(Alignments.AlignmentEntry entry,ObservedIndel indel,boolean shiftForward,int scoreDelta){
  Alignments.AlignmentEntry.Builder builder=Alignments.AlignmentEntry.newBuilder(entry);
  builder.setScore(entry.getScore() + scoreDelta);
  final int indelLength=indel.positionSpan();
  builder.setTargetAlignedLength(builder.getTargetAlignedLength() + indelLength);
  int entryPosition=entry.getPosition();
  final int originalEntryPosition=entryPosition;
  if (!shiftForward && indel.isReadInsertion()) {
    entryPosition=entry.getPosition() - indelLength;
    builder.setPosition(entryPosition);
  }
  final int indelOffsetInAlignment=indel.getStart() - entryPosition;
  final int varCount=entry.getSequenceVariationsCount();
  final int targetIndex=entry.getTargetIndex();
  int score=0;
  final int direction=shiftForward ? 1 : -1;
  if (genome == null) {
    genomeNull.warn(LOG,"String_Node_Str");
    return entry;
  }
  IntArraySet variantPositions=new IntArraySet();
  ObjectArrayList<Alignments.SequenceVariation> rewrittenVariations=new ObjectArrayList<Alignments.SequenceVariation>();
  for (int i=0; i < varCount; i++) {
    Alignments.SequenceVariation var=entry.getSequenceVariations(i);
    final int newGenomicPosition=var.getPosition() + (direction * indelLength) + originalEntryPosition - 1;
    for (int j=0; j < var.getTo().length(); ++j) {
      final char toBase=var.getTo().charAt(j);
      final int index=newGenomicPosition + j;
      if (index < 0 || index > genome.getLength(targetIndex)) {
        score+=-10;
      }
 else {
        final boolean compatible=genome.get(targetIndex,newGenomicPosition + j) == toBase;
        if (!compatible) {
          rewrittenVariations.add(var);
        }
        variantPositions.add(var.getPosition() + entryPosition + j - 1);
      }
    }
  }
  int startAlignment=shiftForward ? entryPosition + indelOffsetInAlignment : entryPosition;
  int endAlignment=shiftForward ? entry.getTargetAlignedLength() + entryPosition : indelOffsetInAlignment + entryPosition + (direction * indelLength);
  for (int pos=startAlignment; pos < endAlignment; pos++) {
    if (!variantPositions.contains(pos)) {
      final int realignedPos=pos + (direction * indelLength);
      if (realignedPos >= 0) {
        final char fromBase=genome.get(targetIndex,realignedPos);
        final char toBase=genome.get(targetIndex,pos);
        final boolean compatible=fromBase == toBase;
        if (!compatible) {
          Alignments.SequenceVariation.Builder varBuilder=Alignments.SequenceVariation.newBuilder();
          final int varPosition=direction * (realignedPos - entryPosition) + 1;
          varBuilder.setPosition(varPosition);
          varBuilder.setFrom(Character.toString(fromBase));
          varBuilder.setTo(Character.toString(toBase));
          varBuilder.setToQuality(byteArray((byte)Byte.MAX_VALUE));
          int readIndex=entry.getMatchingReverseStrand() ? entry.getQueryLength() - indelOffsetInAlignment + (shiftForward ? 1 : indelLength) : varPosition;
          varBuilder.setReadIndex(readIndex);
          rewrittenVariations.add(varBuilder.build());
        }
      }
 else {
        LOG.warn(String.format("String_Node_Str" + "String_Node_Str" + "String_Node_Str",entry.toString(),targetIndex,genome.getReferenceName(targetIndex),pos));
        return entry;
      }
    }
  }
  Alignments.SequenceVariation.Builder varBuilder=Alignments.SequenceVariation.newBuilder();
  final int varPosition=shiftForward ? indelOffsetInAlignment + 1 : indel.getStart() - entryPosition + 1;
  varBuilder.setPosition(varPosition);
  varBuilder.setFrom(indel.from);
  varBuilder.setTo(indel.to);
  int readIndex=entry.getMatchingReverseStrand() ? entry.getQueryLength() - indelOffsetInAlignment + (shiftForward ? 1 : indelLength) : varPosition;
  varBuilder.setReadIndex(readIndex);
  rewrittenVariations.add(varBuilder.build());
  builder=builder.clearSequenceVariations();
  for (  Alignments.SequenceVariation var : rewrittenVariations) {
    builder=builder.addSequenceVariations(var);
  }
  final Alignments.AlignmentEntry alignmentEntry=builder.build();
  return alignmentEntry;
}