Program: 80610
Project: 80610
Buggy source:
/** 
 * canonicalize to indels
 * @param canonicalVariantList where results are saved
 * @param alleleLengthDifference
 * @param reference
 * @param alternativeAlleles
 * @param variant
 * @param currentPosition
 * @param end should we append indels to the end?
 */
private void canonicalizeToIndels(List<Variant> canonicalVariantList,int[] alleleLengthDifference,byte[] reference,byte[][] alternativeAlleles,Variant variant,int currentPosition,boolean end){
  Variant.Builder template=new Variant.Builder().chr(variant.getChr()).isPhased(true).varId(variant.getVariantId()).filter(VCFparser.DEFAULT_FILTER).refDeleted("String_Node_Str");
  if (alleleLengthDifference[0] == alleleLengthDifference[1] && alleleLengthDifference[0] != 0) {
    if (alleleLengthDifference[0] > 0) {
      if (Arrays.equals(alternativeAlleles[0],alternativeAlleles[1])) {
        byte[] phase={1,1};
        if (end) {
          Alt alt=new Alt();
          alt.setSeq(new FlexSeq(Arrays.copyOfRange(alternativeAlleles[0],0,alleleLengthDifference[0])));
          canonicalVariantList.add(template.pos(currentPosition + reference.length).referenceAlleleLength(0).ref(new byte[0]).alts(new Alt[]{alt}).phase(phase).build());
        }
 else {
          Alt alt=new Alt();
          alt.setSeq(new FlexSeq(Arrays.copyOfRange(alternativeAlleles[0],0,alleleLengthDifference[0])));
          canonicalVariantList.add(template.pos(currentPosition).referenceAlleleLength(0).ref(new byte[0]).alts(new Alt[]{alt}).phase(phase).build());
        }
      }
 else {
        byte[] phase={0,0};
        if (end) {
          phase[0]=1;
          phase[1]=0;
          Alt alt=new Alt();
          alt.setSeq(new FlexSeq(Arrays.copyOfRange(alternativeAlleles[0],0,alleleLengthDifference[0])));
          canonicalVariantList.add(template.pos(currentPosition + reference.length).referenceAlleleLength(0).ref(new byte[0]).alts(new Alt[]{alt}).phase(phase).build());
          phase[0]=0;
          phase[1]=1;
          Alt alt2=new Alt();
          alt2.setSeq(new FlexSeq(Arrays.copyOfRange(alternativeAlleles[1],0,alleleLengthDifference[1])));
          canonicalVariantList.add(template.pos(currentPosition + reference.length).referenceAlleleLength(0).ref(new byte[0]).alts(new Alt[]{alt2}).phase(phase).build());
        }
 else {
          phase[0]=1;
          phase[1]=0;
          Alt alt=new Alt();
          alt.setSeq(new FlexSeq(Arrays.copyOfRange(alternativeAlleles[0],0,alleleLengthDifference[0])));
          canonicalVariantList.add(template.pos(currentPosition).referenceAlleleLength(0).ref(new byte[0]).alts(new Alt[]{alt}).phase(phase).build());
          phase[0]=0;
          phase[1]=1;
          Alt alt2=new Alt();
          alt2.setSeq(new FlexSeq(Arrays.copyOfRange(alternativeAlleles[1],0,alleleLengthDifference[1])));
          canonicalVariantList.add(template.pos(currentPosition).referenceAlleleLength(0).ref(new byte[0]).alts(new Alt[]{alt2}).phase(phase).build());
        }
      }
    }
 else     if (alleleLengthDifference[0] < 0) {
      byte[] phase={1,1};
      if (end) {
        Alt alt=new Alt();
        alt.setSeq(new FlexSeq());
        canonicalVariantList.add(template.pos(currentPosition + alternativeAlleles[0].length).referenceAlleleLength(-alleleLengthDifference[0]).ref(Arrays.copyOfRange(reference,alternativeAlleles[0].length,alternativeAlleles[0].length - alleleLengthDifference[0])).alts(new Alt[]{alt}).phase(phase).build());
      }
 else {
        Alt alt=new Alt();
        alt.setSeq(new FlexSeq());
        canonicalVariantList.add(template.pos(currentPosition).referenceAlleleLength(-alleleLengthDifference[0]).ref(Arrays.copyOfRange(reference,0,-alleleLengthDifference[0])).alts(new Alt[]{alt}).phase(phase).build());
      }
    }
  }
 else {
    for (int a=0; a < alternativeAlleles.length; a++) {
      if (alleleLengthDifference[a] > 0) {
        byte[] phase={0,0};
        phase[a]=1;
        if (end) {
          Alt alt=new Alt();
          alt.setSeq(new FlexSeq(Arrays.copyOfRange(alternativeAlleles[a],0,alleleLengthDifference[a])));
          canonicalVariantList.add(template.pos(currentPosition + reference.length).referenceAlleleLength(0).ref(new byte[0]).alts(new Alt[]{alt}).phase(phase).build());
        }
 else {
          Alt alt=new Alt();
          alt.setSeq(new FlexSeq(Arrays.copyOfRange(alternativeAlleles[a],0,alleleLengthDifference[a])));
          canonicalVariantList.add(template.pos(currentPosition).referenceAlleleLength(0).ref(new byte[0]).alts(new Alt[]{alt}).phase(phase).build());
        }
      }
 else       if (alleleLengthDifference[a] < 0) {
        byte[] phase={0,0};
        phase[a]=1;
        if (end) {
          Alt alt=new Alt();
          alt.setSeq(new FlexSeq());
          canonicalVariantList.add(template.pos(currentPosition + alternativeAlleles[a].length).referenceAlleleLength(-alleleLengthDifference[a]).ref(Arrays.copyOfRange(reference,alternativeAlleles[a].length,alternativeAlleles[a].length - alleleLengthDifference[a])).alts(new Alt[]{alt}).phase(phase).build());
        }
 else {
          Alt alt=new Alt();
          alt.setSeq(new FlexSeq());
          canonicalVariantList.add(template.pos(currentPosition).referenceAlleleLength(-alleleLengthDifference[a]).ref(Arrays.copyOfRange(reference,0,-alleleLengthDifference[a])).alts(new Alt[]{alt}).phase(phase).build());
        }
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * canonicalize to indels
 * @param canonicalVariantList where results are saved
 * @param alleleLengthDifference
 * @param reference
 * @param alternativeAlleles
 * @param variant
 * @param currentPosition
 * @param end should we append indels to the end?
 */
private void canonicalizeToIndels(List<Variant> canonicalVariantList,int[] alleleLengthDifference,byte[] reference,byte[][] alternativeAlleles,Variant variant,int currentPosition,boolean end){
  Variant.Builder template=new Variant.Builder().chr(variant.getChr()).isPhased(true).varId(variant.getVariantId()).filter(VCFparser.DEFAULT_FILTER).refDeleted("String_Node_Str");
  if (alleleLengthDifference[0] == alleleLengthDifference[1] && alleleLengthDifference[0] != 0) {
    if (alleleLengthDifference[0] > 0) {
      if (Arrays.equals(alternativeAlleles[0],alternativeAlleles[1])) {
        byte[] phase={1,1};
        if (end) {
          Alt alt=new Alt();
          alt.setSeq(new FlexSeq(Arrays.copyOfRange(alternativeAlleles[0],0,alleleLengthDifference[0])));
          canonicalVariantList.add(template.pos(currentPosition + reference.length).referenceAlleleLength(0).ref(new byte[]{'N'}).alts(new Alt[]{alt}).phase(phase).build());
        }
 else {
          Alt alt=new Alt();
          alt.setSeq(new FlexSeq(Arrays.copyOfRange(alternativeAlleles[0],0,alleleLengthDifference[0])));
          canonicalVariantList.add(template.pos(currentPosition).referenceAlleleLength(0).ref(new byte[]{'N'}).alts(new Alt[]{alt}).phase(phase).build());
        }
      }
 else {
        byte[] phase={0,0};
        if (end) {
          phase[0]=1;
          phase[1]=0;
          Alt alt=new Alt();
          alt.setSeq(new FlexSeq(Arrays.copyOfRange(alternativeAlleles[0],0,alleleLengthDifference[0])));
          canonicalVariantList.add(template.pos(currentPosition + reference.length).referenceAlleleLength(0).ref(new byte[]{'N'}).alts(new Alt[]{alt}).phase(phase).build());
          phase[0]=0;
          phase[1]=1;
          Alt alt2=new Alt();
          alt2.setSeq(new FlexSeq(Arrays.copyOfRange(alternativeAlleles[1],0,alleleLengthDifference[1])));
          canonicalVariantList.add(template.pos(currentPosition + reference.length).referenceAlleleLength(0).ref(new byte[]{'N'}).alts(new Alt[]{alt2}).phase(phase).build());
        }
 else {
          phase[0]=1;
          phase[1]=0;
          Alt alt=new Alt();
          alt.setSeq(new FlexSeq(Arrays.copyOfRange(alternativeAlleles[0],0,alleleLengthDifference[0])));
          canonicalVariantList.add(template.pos(currentPosition).referenceAlleleLength(0).ref(new byte[]{'N'}).alts(new Alt[]{alt}).phase(phase).build());
          phase[0]=0;
          phase[1]=1;
          Alt alt2=new Alt();
          alt2.setSeq(new FlexSeq(Arrays.copyOfRange(alternativeAlleles[1],0,alleleLengthDifference[1])));
          canonicalVariantList.add(template.pos(currentPosition).referenceAlleleLength(0).ref(new byte[]{'N'}).alts(new Alt[]{alt2}).phase(phase).build());
        }
      }
    }
 else     if (alleleLengthDifference[0] < 0) {
      byte[] phase={1,1};
      if (end) {
        Alt alt=new Alt();
        alt.setSeq(new FlexSeq());
        canonicalVariantList.add(template.pos(currentPosition + alternativeAlleles[0].length).referenceAlleleLength(-alleleLengthDifference[0]).ref(Arrays.copyOfRange(reference,alternativeAlleles[0].length,alternativeAlleles[0].length - alleleLengthDifference[0])).alts(new Alt[]{alt}).phase(phase).build());
      }
 else {
        Alt alt=new Alt();
        alt.setSeq(new FlexSeq());
        canonicalVariantList.add(template.pos(currentPosition).referenceAlleleLength(-alleleLengthDifference[0]).ref(Arrays.copyOfRange(reference,0,-alleleLengthDifference[0])).alts(new Alt[]{alt}).phase(phase).build());
      }
    }
  }
 else {
    for (int a=0; a < alternativeAlleles.length; a++) {
      if (alleleLengthDifference[a] > 0) {
        byte[] phase={0,0};
        phase[a]=1;
        if (end) {
          Alt alt=new Alt();
          alt.setSeq(new FlexSeq(Arrays.copyOfRange(alternativeAlleles[a],0,alleleLengthDifference[a])));
          canonicalVariantList.add(template.pos(currentPosition + reference.length).referenceAlleleLength(0).ref(new byte[]{'N'}).alts(new Alt[]{alt}).phase(phase).build());
        }
 else {
          Alt alt=new Alt();
          alt.setSeq(new FlexSeq(Arrays.copyOfRange(alternativeAlleles[a],0,alleleLengthDifference[a])));
          canonicalVariantList.add(template.pos(currentPosition).referenceAlleleLength(0).ref(new byte[]{'N'}).alts(new Alt[]{alt}).phase(phase).build());
        }
      }
 else       if (alleleLengthDifference[a] < 0) {
        byte[] phase={0,0};
        phase[a]=1;
        if (end) {
          Alt alt=new Alt();
          alt.setSeq(new FlexSeq());
          canonicalVariantList.add(template.pos(currentPosition + alternativeAlleles[a].length).referenceAlleleLength(-alleleLengthDifference[a]).ref(Arrays.copyOfRange(reference,alternativeAlleles[a].length,alternativeAlleles[a].length - alleleLengthDifference[a])).alts(new Alt[]{alt}).phase(phase).build());
        }
 else {
          Alt alt=new Alt();
          alt.setSeq(new FlexSeq());
          canonicalVariantList.add(template.pos(currentPosition).referenceAlleleLength(-alleleLengthDifference[a]).ref(Arrays.copyOfRange(reference,0,-alleleLengthDifference[a])).alts(new Alt[]{alt}).phase(phase).build());
        }
      }
    }
  }
}