Program: 80615
Project: 80615
Buggy source:
/** 
 * Only compares one allele at a time - don't match variants in the bitset - if match set the bitset
 * @param variant       variant we want to compare
 * @param genotype      allele of the variant to compare
 * @param validated BitSet that records the true variants that have already been validated
 * @return The maximum length of all true variants
 */
public int compareVariant(Variant variant,int genotype,BitSet validated){
  VariantType type=variant.getType(genotype);
  ChrString chr=variant.getChr();
  SimpleInterval1D intervalForCompare=variant.getVariantInterval(genotype,ignoreInsertionLength);
  int maxTrueVarianLength=0;
  if (type == VariantType.SNP) {
    Iterable<ValueInterval1D<Variant>> overlaps=trueVariantIntervalTree.getOverlaps(chr,intervalForCompare);
    if (overlaps == null) {
      return maxTrueVarianLength;
    }
    byte alternativeAlleleFirstBase=variant.getAlt(genotype).getSequence()[0];
    int numberOfSnpMatches=0;
    for (    ValueInterval1D<Variant> trueVariantInterval : overlaps) {
      Variant trueVariant=trueVariantInterval.getContent();
      boolean hasSnp=false;
      int splitVariantIndex=trueVariant.splitVariantIndex;
      int wholeVariantIndex=trueVariant.wholeVariantIndex;
      overlapComplex=trueVariant.originalType == VariantOverallType.Complex;
      if (validated.get(splitVariantIndex)) {
        continue;
      }
      for (int parent=0; parent < 2; parent++) {
        int allele=trueVariant.getAllele(parent);
        if (trueVariant.isHom() || allele > 0) {
          if (trueVariant.getType(allele) == VariantType.SNP && variant.getPos() == trueVariant.getPos()) {
            if (alternativeAlleleFirstBase == trueVariant.getAlt(allele).getSequence()[0]) {
              if (trueVariant.isHom())               homozygousMatches.add(new DualIdx(splitVariantIndex,wholeVariantIndex));
 else               heterozygousMatches.get(parent).add(new DualIdx(splitVariantIndex,wholeVariantIndex));
            }
            hasSnp=true;
          }
        }
        if (trueVariant.isHom())         break;
      }
      if (hasSnp) {
        numberOfSnpMatches++;
        maxTrueVarianLength=1;
      }
    }
    if (numberOfSnpMatches > 1) {
      log.info("String_Node_Str" + numberOfSnpMatches);
    }
  }
 else {
    SimpleInterval1D intervalForCompareWithWiggle=new SimpleInterval1D(intervalForCompare.left - wiggle,intervalForCompare.right + wiggle);
    Iterable<ValueInterval1D<Variant>> overlaps=trueVariantIntervalTree.getOverlaps(chr,intervalForCompareWithWiggle);
    if (overlaps == null) {
      return maxTrueVarianLength;
    }
    for (    ValueInterval1D<Variant> trueVariantInterval : overlaps) {
      Variant trueVariant=trueVariantInterval.getContent();
      int splitVariantIndex=trueVariant.splitVariantIndex;
      int wholeVariantIndex=trueVariant.wholeVariantIndex;
      overlapComplex=trueVariant.originalType == VariantOverallType.Complex;
      if (validated.get(splitVariantIndex)) {
        continue;
      }
      for (int parent=0; parent < 2; parent++) {
        int allele=trueVariant.getAllele(parent);
        if (allele == 0 || type != trueVariant.getType(allele)) {
          continue;
        }
        Alt.Breakend currentBreakend=variant.getAlt(allele).getBreakend();
        Alt.Breakend trueBreakend=trueVariant.getAlt(allele).getBreakend();
        boolean overlap=trueVariant.getVariantInterval(allele,ignoreInsertionLength).intersects(intervalForCompare,overlapRatio,wiggle);
        boolean breakendMatch=trueVariant.getType(allele) == VariantType.Breakend && Alt.Breakend.looseEquals(currentBreakend,trueBreakend,overlapRatio,wiggle);
        boolean matched=trueVariant.getType(allele) == VariantType.Breakend ? breakendMatch : overlap;
        if (matched) {
          if (trueVariant.isHom()) {
            homozygousMatches.add(new DualIdx(splitVariantIndex,wholeVariantIndex));
          }
 else {
            heterozygousMatches.get(parent).add(new DualIdx(splitVariantIndex,wholeVariantIndex));
          }
          maxTrueVarianLength=Math.max(trueVariant.maxLen(allele),maxTrueVarianLength);
        }
        if (trueVariant.isHom())         break;
      }
    }
  }
  return maxTrueVarianLength;
}

Fixed version (ground truth):
/** 
 * Only compares one allele at a time - don't match variants in the bitset - if match set the bitset
 * @param variant       variant we want to compare
 * @param genotype      allele of the variant to compare
 * @param validated BitSet that records the true variants that have already been validated
 * @return The maximum length of all true variants
 */
public int compareVariant(Variant variant,int genotype,BitSet validated){
  VariantType type=variant.getType(genotype);
  ChrString chr=variant.getChr();
  SimpleInterval1D intervalForCompare=variant.getVariantInterval(genotype,ignoreInsertionLength);
  int maxTrueVarianLength=0;
  if (type == VariantType.SNP) {
    Iterable<ValueInterval1D<Variant>> overlaps=trueVariantIntervalTree.getOverlaps(chr,intervalForCompare);
    if (overlaps == null) {
      return maxTrueVarianLength;
    }
    byte alternativeAlleleFirstBase=variant.getAlt(genotype).getSequence()[0];
    int numberOfSnpMatches=0;
    for (    ValueInterval1D<Variant> trueVariantInterval : overlaps) {
      Variant trueVariant=trueVariantInterval.getContent();
      boolean hasSnp=false;
      int splitVariantIndex=trueVariant.splitVariantIndex;
      int wholeVariantIndex=trueVariant.wholeVariantIndex;
      overlapComplex=trueVariant.originalType == VariantOverallType.Complex;
      if (validated.get(splitVariantIndex)) {
        continue;
      }
      for (int parent=0; parent < 2; parent++) {
        int allele=trueVariant.getAllele(parent);
        if (trueVariant.isHom() || allele > 0) {
          if (trueVariant.getType(allele) == VariantType.SNP && variant.getPos() == trueVariant.getPos()) {
            if (alternativeAlleleFirstBase == trueVariant.getAlt(allele).getSequence()[0]) {
              if (trueVariant.isHom())               homozygousMatches.add(new DualIdx(splitVariantIndex,wholeVariantIndex));
 else               heterozygousMatches.get(parent).add(new DualIdx(splitVariantIndex,wholeVariantIndex));
            }
            hasSnp=true;
          }
        }
        if (trueVariant.isHom())         break;
      }
      if (hasSnp) {
        numberOfSnpMatches++;
        maxTrueVarianLength=1;
      }
    }
    if (numberOfSnpMatches > 1) {
      log.info("String_Node_Str" + numberOfSnpMatches);
    }
  }
 else {
    SimpleInterval1D intervalForCompareWithWiggle=new SimpleInterval1D(intervalForCompare.left - wiggle,intervalForCompare.right + wiggle);
    Iterable<ValueInterval1D<Variant>> overlaps=trueVariantIntervalTree.getOverlaps(chr,intervalForCompareWithWiggle);
    if (overlaps == null) {
      return maxTrueVarianLength;
    }
    for (    ValueInterval1D<Variant> trueVariantInterval : overlaps) {
      Variant trueVariant=trueVariantInterval.getContent();
      int splitVariantIndex=trueVariant.splitVariantIndex;
      int wholeVariantIndex=trueVariant.wholeVariantIndex;
      overlapComplex=trueVariant.originalType == VariantOverallType.Complex;
      if (validated.get(splitVariantIndex)) {
        continue;
      }
      for (int parent=0; parent < 2; parent++) {
        int allele=trueVariant.getAllele(parent);
        if (allele == 0 || type != trueVariant.getType(allele) || variant.getAlt(allele) == null || trueVariant.getAlt(allele) == null) {
          continue;
        }
        Alt.Breakend currentBreakend=variant.getAlt(allele).getBreakend();
        Alt.Breakend trueBreakend=trueVariant.getAlt(allele).getBreakend();
        boolean overlap=trueVariant.getVariantInterval(allele,ignoreInsertionLength).intersects(intervalForCompare,overlapRatio,wiggle);
        boolean breakendMatch=trueVariant.getType(allele) == VariantType.Breakend && Alt.Breakend.looseEquals(currentBreakend,trueBreakend,overlapRatio,wiggle);
        boolean matched=trueVariant.getType(allele) == VariantType.Breakend ? breakendMatch : overlap;
        if (matched) {
          if (trueVariant.isHom()) {
            homozygousMatches.add(new DualIdx(splitVariantIndex,wholeVariantIndex));
          }
 else {
            heterozygousMatches.get(parent).add(new DualIdx(splitVariantIndex,wholeVariantIndex));
          }
          maxTrueVarianLength=Math.max(trueVariant.maxLen(allele),maxTrueVarianLength);
        }
        if (trueVariant.isHom())         break;
      }
    }
  }
  return maxTrueVarianLength;
}