Program: 50419
Project: 50419
Buggy source:
public void writeGenotypes(VCFWriter statsWriter,SampleCountInfo[] sampleCounts){
  for (int sampleIndex=0; sampleIndex < numberOfSamples; sampleIndex++) {
    alleleSet.clear();
    SampleCountInfo sci=sampleCounts[sampleIndex];
    int totalCount=0;
    for (    int sampleCount : sci.counts) {
      totalCount+=sampleCount;
    }
    statsWriter.setSampleValue(goodBaseCountFieldIndex,sampleIndex,totalCount);
    statsWriter.setSampleValue(failBaseCountFieldIndex,sampleIndex,sci.failedCount);
    int baseIndex=0;
    int genotypeCount=0;
    genotypeBuffer.setLength(0);
    char refBase='.';
    String referenceAllele="String_Node_Str";
    boolean siteObserved=false;
    for (    int count : sci.counts) {
      final char base=sci.base(baseIndex);
      if (count > 0) {
        siteObserved=true;
        alleleSet.add(base);
        if (base != sci.referenceBase) {
          statsWriter.addAlternateAllele(Character.toString(base));
          genotypeBuffer.append(String.format("String_Node_Str",base));
          genotypeCount++;
        }
 else {
          referenceAllele=Character.toString(sci.referenceBase);
          genotypeBuffer.append(String.format("String_Node_Str",base));
        }
      }
      baseIndex++;
    }
    if (siteObserved) {
      if (genotypeBuffer.length() > 1) {
        genotypeBuffer.setLength(genotypeBuffer.length() - 1);
      }
      statsWriter.setReferenceAllele(referenceAllele);
      statsWriter.setSampleValue(genotypeFieldIndex,sampleIndex,statsWriter.codeGenotype(genotypeBuffer.toString()));
      MutableString baseCountString=new MutableString();
      baseIndex=0;
      for (      int count : sci.counts) {
        final char base=sci.base(baseIndex);
        baseCountString.append(base);
        baseCountString.append('=');
        baseCountString.append(Integer.toString(count));
        baseIndex++;
        baseCountString.append(',');
      }
      baseCountString.setLength(baseCountString.length() - 1);
      statsWriter.setSampleValue(baseCountFieldIndex,sampleIndex,baseCountString);
    }
 else {
      statsWriter.setSampleValue(genotypeFieldIndex,sampleIndex,"String_Node_Str");
    }
  }
}

Fixed version (ground truth):
public void writeGenotypes(VCFWriter statsWriter,SampleCountInfo[] sampleCounts){
  for (int sampleIndex=0; sampleIndex < numberOfSamples; sampleIndex++) {
    alleleSet.clear();
    SampleCountInfo sci=sampleCounts[sampleIndex];
    int totalCount=0;
    for (    int sampleCount : sci.counts) {
      totalCount+=sampleCount;
    }
    System.out.printf("String_Node_Str",totalCount,sci.failedCount);
    statsWriter.setSampleValue(goodBaseCountFieldIndex,sampleIndex,totalCount);
    statsWriter.setSampleValue(failBaseCountFieldIndex,sampleIndex,sci.failedCount);
    int baseIndex=0;
    int genotypeCount=0;
    genotypeBuffer.setLength(0);
    char refBase='.';
    String referenceAllele="String_Node_Str";
    boolean siteObserved=false;
    for (    int count : sci.counts) {
      final char base=sci.base(baseIndex);
      if (count > 0) {
        siteObserved=true;
        alleleSet.add(base);
        if (base != sci.referenceBase) {
          statsWriter.addAlternateAllele(Character.toString(base));
          genotypeBuffer.append(String.format("String_Node_Str",base));
          genotypeCount++;
        }
 else {
          referenceAllele=Character.toString(sci.referenceBase);
          genotypeBuffer.append(String.format("String_Node_Str",base));
        }
      }
      baseIndex++;
    }
    if (siteObserved) {
      if (genotypeBuffer.length() > 1) {
        genotypeBuffer.setLength(genotypeBuffer.length() - 1);
      }
      statsWriter.setReferenceAllele(referenceAllele);
      statsWriter.setSampleValue(genotypeFieldIndex,sampleIndex,statsWriter.codeGenotype(genotypeBuffer.toString()));
      MutableString baseCountString=new MutableString();
      baseIndex=0;
      for (      int count : sci.counts) {
        final char base=sci.base(baseIndex);
        baseCountString.append(base);
        baseCountString.append('=');
        baseCountString.append(Integer.toString(count));
        baseIndex++;
        baseCountString.append(',');
      }
      baseCountString.setLength(baseCountString.length() - 1);
      statsWriter.setSampleValue(baseCountFieldIndex,sampleIndex,baseCountString);
    }
 else {
      statsWriter.setSampleValue(genotypeFieldIndex,sampleIndex,"String_Node_Str");
    }
  }
}