Program: 50425
Project: 50425
Buggy source:
public void filterBases(ObjectArrayList<PositionBaseInfo> list,SampleCountInfo[] sampleCounts,ObjectArrayList<PositionBaseInfo> filteredList){
  if (!fisherRInstalled) {
    if (firstReport) {
      System.err.println("String_Node_Str");
      firstReport=false;
    }
    return;
  }
  for (  SampleCountInfo sci : sampleCounts) {
    final ReadIndexStats stats=readIndexStats.get(sci.sampleIndex);
    ObjectArrayList<PositionBaseInfo> considered=new ObjectArrayList<PositionBaseInfo>();
    for (int baseIndex=SampleCountInfo.BASE_A_INDEX; baseIndex < SampleCountInfo.BASE_MAX_INDEX; baseIndex++) {
      considered.clear();
      int observedReferenceCount=0;
      double expectedVariationRate=0;
      int expectedVariationCount=0;
      int expectedReferenceCount=0;
      int observedVariationCount=0;
      int totalCount=0;
      for (      int count : sci.counts) {
        totalCount+=count;
      }
      observedVariationCount=sci.counts[baseIndex];
      if (observedVariationCount == 0) {
        continue;
      }
      long sum=0;
      for (      PositionBaseInfo info : list) {
        if (info.readerIndex != sci.sampleIndex)         continue;
        final int readIndex=info.readIndex;
        if (readIndex < 1 || readIndex > stats.countVariationBases.length || readIndex > stats.countReferenceBases.length) {
          continue;
        }
        long variationBases=stats.countVariationBases[readIndex - 1];
        long referenceBases=stats.countReferenceBases[readIndex - 1];
        expectedVariationRate+=variationBases;
        sum+=variationBases + referenceBases;
        if (info.to == sci.base(baseIndex)) {
          considered.add(info);
        }
      }
      expectedVariationRate/=sum;
      expectedVariationCount=(int)Math.round(expectedVariationRate * (double)(totalCount));
      expectedReferenceCount=(int)Math.round((1 - expectedVariationRate) * (double)(totalCount));
      int count00=expectedVariationCount;
      int count10=observedVariationCount;
      int count01=totalCount - count00;
      int count11=totalCount - count01;
      Double pValue;
{
        contingencyValue value=new contingencyValue(count00,count10,count01,count11);
        pValue=(Double)fisherPCache.get(value);
        if (pValue == null) {
          pValue=estimatePValue(count00,count10,count01,count11);
          fisherPCache.put(value,pValue);
        }
      }
      if (pValue > pValueThreshold) {
        int numErroneouslyCalledBases=sci.counts[baseIndex];
        sci.counts[baseIndex]=0;
        filteredList.addAll(considered);
        char base=sci.base(baseIndex);
        if (base == sci.referenceBase) {
          sci.refCount=0;
        }
 else {
          sci.varCount-=numErroneouslyCalledBases;
        }
      }
    }
  }
  numScreened+=list.size();
  numFiltered+=filteredList.size();
}

Fixed version (ground truth):
public void filterBases(ObjectArrayList<PositionBaseInfo> list,SampleCountInfo[] sampleCounts,ObjectArrayList<PositionBaseInfo> filteredList){
  if (!fisherRInstalled) {
    if (firstReport) {
      System.err.println("String_Node_Str");
      firstReport=false;
    }
    return;
  }
  initStorage(sampleCounts.length);
  resetCounters();
  for (  SampleCountInfo sci : sampleCounts) {
    final ReadIndexStats stats=readIndexStats.get(sci.sampleIndex);
    ObjectArrayList<PositionBaseInfo> considered=new ObjectArrayList<PositionBaseInfo>();
    for (int baseIndex=SampleCountInfo.BASE_A_INDEX; baseIndex < SampleCountInfo.BASE_MAX_INDEX; baseIndex++) {
      considered.clear();
      int observedReferenceCount=0;
      double expectedVariationRate=0;
      int expectedVariationCount=0;
      int expectedReferenceCount=0;
      int observedVariationCount=0;
      int totalCount=0;
      for (      int count : sci.counts) {
        totalCount+=count;
      }
      observedVariationCount=sci.counts[baseIndex];
      if (observedVariationCount == 0) {
        continue;
      }
      long sum=0;
      for (      PositionBaseInfo info : list) {
        if (info.readerIndex != sci.sampleIndex)         continue;
        final int readIndex=info.readIndex;
        if (readIndex < 1 || readIndex > stats.countVariationBases.length || readIndex > stats.countReferenceBases.length) {
          continue;
        }
        long variationBases=stats.countVariationBases[readIndex - 1];
        long referenceBases=stats.countReferenceBases[readIndex - 1];
        expectedVariationRate+=variationBases;
        sum+=variationBases + referenceBases;
        if (info.to == sci.base(baseIndex)) {
          considered.add(info);
        }
      }
      expectedVariationRate/=sum;
      expectedVariationCount=(int)Math.round(expectedVariationRate * (double)(totalCount));
      expectedReferenceCount=(int)Math.round((1 - expectedVariationRate) * (double)(totalCount));
      int count00=expectedVariationCount;
      int count10=observedVariationCount;
      int count01=totalCount - count00;
      int count11=totalCount - count01;
      Double pValue;
{
        contingencyValue value=new contingencyValue(count00,count10,count01,count11);
        pValue=(Double)fisherPCache.get(value);
        if (pValue == null) {
          pValue=estimatePValue(count00,count10,count01,count11);
          fisherPCache.put(value,pValue);
        }
      }
      if (pValue > pValueThreshold) {
        int numErroneouslyCalledBases=sci.counts[baseIndex];
        sci.counts[baseIndex]=0;
        filteredList.addAll(considered);
        char base=sci.base(baseIndex);
        int sampleIndex=sci.sampleIndex;
        if (base == sci.referenceBase) {
          refCountRemovedPerSample[sampleIndex]++;
        }
 else {
          varCountRemovedPerSample[sampleIndex]++;
        }
      }
    }
  }
  numScreened+=list.size();
  numFiltered+=filteredList.size();
  adjustRefVarCounts(sampleCounts);
}