Program: 50291
Project: 50291
Buggy source:
private void buildAnnotationRecordForOutput(String chromosome,int pos,int anno){
  if (annotations.pastChosenAnnotation(anno,chromosome,pos)) {
    Annotation annoOut=annotations.getAnnotation(anno);
    FormatFieldCounter counter=counterMap.get(anno);
    StringBuilder lineToOutput=new StringBuilder("String_Node_Str");
    try {
      if (writeObservations) {
        identifiers[0]="String_Node_Str";
        identifiers[1]=annoOut.getChromosome();
        identifiers[2]=String.valueOf(annoOut.getStart());
        identifiers[3]=String.valueOf(annoOut.getEnd());
        identifiers[4]=annoOut.getId();
        obsWriter.setElementIds(identifiers);
      }
      lineToOutput.append(annoOut.getChromosome());
      lineToOutput.append("String_Node_Str");
      lineToOutput.append(String.valueOf(annoOut.getStart()));
      lineToOutput.append("String_Node_Str");
      lineToOutput.append(String.valueOf(annoOut.getEnd())).append("String_Node_Str");
      lineToOutput.append(annoOut.getId());
      if (writeCounts) {
        for (int currentContext=0; currentContext < contexts.length; currentContext++) {
          for (int sampleIndex=0; sampleIndex < numSamples; sampleIndex++) {
            lineToOutput.append("String_Node_Str");
            final int unMethylatedCCounterPerSample=counter.getUnmethylatedCCountPerSample(currentContext,sampleIndex);
            lineToOutput.append(unMethylatedCCounterPerSample);
          }
        }
        for (int currentContext=0; currentContext < contexts.length; currentContext++) {
          for (int sampleIndex=0; sampleIndex < numSamples; sampleIndex++) {
            lineToOutput.append("String_Node_Str");
            final int methylatedCCounterPerSample=counter.getMethylatedCCountPerSample(currentContext,sampleIndex);
            lineToOutput.append(methylatedCCounterPerSample);
          }
        }
      }
      for (int currentContext=0; currentContext < contexts.length; currentContext++) {
        for (int sampleIndex=0; sampleIndex < numSamples; sampleIndex++) {
          lineToOutput.append("String_Node_Str");
          final double methylationRatePerSample=counter.getMethylationRatePerSample(currentContext,sampleIndex);
          lineToOutput.append(formatDouble(methylationRatePerSample));
        }
      }
      if (writeCounts) {
        for (int currentContext=0; currentContext < contexts.length; currentContext++) {
          for (int groupIndex=0; groupIndex < numGroups; groupIndex++) {
            lineToOutput.append("String_Node_Str");
            final int unMethylatedCCounterPerGroup=counter.getUnmethylatedCcountPerGroup(currentContext,groupIndex);
            lineToOutput.append(unMethylatedCCounterPerGroup);
          }
        }
        for (int currentContext=0; currentContext < contexts.length; currentContext++) {
          for (int groupIndex=0; groupIndex < numGroups; groupIndex++) {
            lineToOutput.append("String_Node_Str");
            final int methylatedCCounterPerGroup=counter.getMethylatedCCountPerGroup(currentContext,groupIndex);
            lineToOutput.append(methylatedCCounterPerGroup);
          }
        }
      }
      for (int currentContext=0; currentContext < contexts.length; currentContext++) {
        for (int groupIndex=0; groupIndex < numGroups; groupIndex++) {
          lineToOutput.append("String_Node_Str");
          lineToOutput.append(formatDouble(counter.getMethylationRatePerGroup(currentContext,groupIndex)));
        }
      }
      if (writeNumSites) {
        for (int currentContext=0; currentContext < contexts.length; currentContext++) {
          for (int sampleIndex=0; sampleIndex < numSamples; sampleIndex++) {
            lineToOutput.append("String_Node_Str");
            final int numSitesPerSample=counter.getNumberOfSitesPerSample(currentContext,sampleIndex);
            lineToOutput.append(numSitesPerSample);
          }
        }
        for (int currentContext=0; currentContext < contexts.length; currentContext++) {
          for (int groupIndex=0; groupIndex < numGroups; groupIndex++) {
            lineToOutput.append("String_Node_Str");
            final int numSitesPerGroup=counter.getNumberOfSitesPerGroup(currentContext,groupIndex);
            lineToOutput.append(numSitesPerGroup);
          }
        }
      }
      for (int currentContext=0; currentContext < contexts.length; currentContext++) {
        for (        final GroupComparison comparison : groupComparisons) {
          final int indexGroup1=comparison.indexGroup1;
          final int indexGroup2=comparison.indexGroup2;
          double fisherP=Double.NaN;
          final boolean ok=checkCounts(counter,currentContext);
          if (ok) {
            fisherP=fisherRInstalled ? FisherExactRCalculator.getFisherPValue(counter.getUnmethylatedCcountPerGroup(currentContext,indexGroup1),counter.getMethylatedCCountPerGroup(currentContext,indexGroup1),counter.getUnmethylatedCcountPerGroup(currentContext,indexGroup2),counter.getMethylatedCCountPerGroup(currentContext,indexGroup2)) : Double.NaN;
          }
 else {
            LOG.error(String.format("String_Node_Str" + "String_Node_Str" + "String_Node_Str",counter.getUnmethylatedCcountPerGroup(currentContext,indexGroup1),counter.getMethylatedCCountPerGroup(currentContext,indexGroup1),counter.getUnmethylatedCcountPerGroup(currentContext,indexGroup2),counter.getMethylatedCCountPerGroup(currentContext,indexGroup2)));
          }
          lineToOutput.append("String_Node_Str");
          lineToOutput.append(formatDouble(fisherP));
        }
      }
      for (int currentContext=0; currentContext < contexts.length; currentContext++) {
        for (        final GroupComparison comparison : groupComparisons) {
          final int indexGroup1=comparison.indexGroup1;
          final int indexGroup2=comparison.indexGroup2;
          final double deltaMR=Math.abs(counter.getMethylationRatePerGroup(currentContext,indexGroup1) - counter.getMethylationRatePerGroup(currentContext,indexGroup2));
          lineToOutput.append("String_Node_Str");
          lineToOutput.append(formatDouble(deltaMR));
        }
      }
      if (estimateIntraGroupDifferences) {
        obsWriter.setTypeOfPair(ObservationWriter.TypeOfPair.WITHIN_GROUP_PAIR);
        for (int currentContext=0; currentContext < contexts.length; currentContext++) {
          identifiers[0]=contexts[currentContext];
          for (          final GroupComparison comparison : groupComparisons) {
            obsWriter.setNullComparison(comparison.nameGroup1);
            empiricalPValueEstimator.estimateNullDensity(currentContext,comparison.indexGroup1,counter);
            obsWriter.setNullComparison(comparison.nameGroup2);
            empiricalPValueEstimator.estimateNullDensity(currentContext,comparison.indexGroup2,counter);
          }
        }
      }
      if (estimateIntraGroupP) {
        obsWriter.setTypeOfPair(ObservationWriter.TypeOfPair.BETWEEN_GROUP_PAIR);
        for (int contextIndex=0; contextIndex < contexts.length; contextIndex++) {
          identifiers[0]=contexts[contextIndex];
          for (          final GroupComparison comparison : groupComparisons) {
            obsWriter.setComparison(comparison);
            final double p=empiricalPValueEstimator.estimateEmpiricalPValue(contextIndex,comparison,counter);
            lineToOutput.append("String_Node_Str");
            lineToOutput.append(formatDouble(p));
          }
        }
      }
      outputWriter.append(lineToOutput.toString());
      outputWriter.append("String_Node_Str");
      counterMap.remove(anno);
    }
 catch (    IOException e) {
      throw new RuntimeException(e);
    }
  }
}

Fixed version (ground truth):
private void buildAnnotationRecordForOutput(String chromosome,int pos,int anno){
  if (annotations.pastChosenAnnotation(anno,chromosome,pos)) {
    Annotation annoOut=annotations.getAnnotation(anno);
    FormatFieldCounter counter=counterMap.get(anno);
    StringBuilder lineToOutput=new StringBuilder("String_Node_Str");
    try {
      if (writeObservations) {
        identifiers[0]="String_Node_Str";
        identifiers[1]=annoOut.getChromosome();
        identifiers[2]=String.valueOf(annoOut.getStart());
        identifiers[3]=String.valueOf(annoOut.getEnd());
        identifiers[4]=annoOut.getId();
        obsWriter.setElementIds(identifiers);
      }
      lineToOutput.append(annoOut.getChromosome());
      lineToOutput.append("String_Node_Str");
      lineToOutput.append(String.valueOf(annoOut.getStart()));
      lineToOutput.append("String_Node_Str");
      lineToOutput.append(String.valueOf(annoOut.getEnd())).append("String_Node_Str");
      lineToOutput.append(annoOut.getId());
      if (writeCounts) {
        for (int currentContext=0; currentContext < contexts.length; currentContext++) {
          for (int sampleIndex=0; sampleIndex < numSamples; sampleIndex++) {
            lineToOutput.append("String_Node_Str");
            final int unMethylatedCCounterPerSample=counter.getUnmethylatedCCountPerSample(currentContext,sampleIndex);
            lineToOutput.append(unMethylatedCCounterPerSample);
          }
        }
        for (int currentContext=0; currentContext < contexts.length; currentContext++) {
          for (int sampleIndex=0; sampleIndex < numSamples; sampleIndex++) {
            lineToOutput.append("String_Node_Str");
            final int methylatedCCounterPerSample=counter.getMethylatedCCountPerSample(currentContext,sampleIndex);
            lineToOutput.append(methylatedCCounterPerSample);
          }
        }
      }
      for (int currentContext=0; currentContext < contexts.length; currentContext++) {
        for (int sampleIndex=0; sampleIndex < numSamples; sampleIndex++) {
          lineToOutput.append("String_Node_Str");
          final double methylationRatePerSample=counter.getMethylationRatePerSample(currentContext,sampleIndex);
          lineToOutput.append(formatDouble(methylationRatePerSample));
        }
      }
      if (writeCounts) {
        for (int currentContext=0; currentContext < contexts.length; currentContext++) {
          for (int groupIndex=0; groupIndex < numGroups; groupIndex++) {
            lineToOutput.append("String_Node_Str");
            final int unMethylatedCCounterPerGroup=counter.getUnmethylatedCcountPerGroup(currentContext,groupIndex);
            lineToOutput.append(unMethylatedCCounterPerGroup);
          }
        }
        for (int currentContext=0; currentContext < contexts.length; currentContext++) {
          for (int groupIndex=0; groupIndex < numGroups; groupIndex++) {
            lineToOutput.append("String_Node_Str");
            final int methylatedCCounterPerGroup=counter.getMethylatedCCountPerGroup(currentContext,groupIndex);
            lineToOutput.append(methylatedCCounterPerGroup);
          }
        }
      }
      for (int currentContext=0; currentContext < contexts.length; currentContext++) {
        for (int groupIndex=0; groupIndex < numGroups; groupIndex++) {
          lineToOutput.append("String_Node_Str");
          lineToOutput.append(formatDouble(counter.getMethylationRatePerGroup(currentContext,groupIndex)));
        }
      }
      if (writeNumSites) {
        for (int currentContext=0; currentContext < contexts.length; currentContext++) {
          for (int sampleIndex=0; sampleIndex < numSamples; sampleIndex++) {
            lineToOutput.append("String_Node_Str");
            final int numSitesPerSample=counter.getNumberOfSitesPerSample(currentContext,sampleIndex);
            lineToOutput.append(numSitesPerSample);
          }
        }
        for (int currentContext=0; currentContext < contexts.length; currentContext++) {
          for (int groupIndex=0; groupIndex < numGroups; groupIndex++) {
            lineToOutput.append("String_Node_Str");
            final int numSitesPerGroup=counter.getNumberOfSitesPerGroup(currentContext,groupIndex);
            lineToOutput.append(numSitesPerGroup);
          }
        }
      }
      for (int currentContext=0; currentContext < contexts.length; currentContext++) {
        for (        final GroupComparison comparison : groupComparisons) {
          final int indexGroup1=comparison.indexGroup1;
          final int indexGroup2=comparison.indexGroup2;
          double fisherP=Double.NaN;
          final boolean ok=checkCounts(counter,currentContext);
          if (ok) {
            fisherP=fisherRInstalled ? FisherExactRCalculator.getFisherPValue(counter.getUnmethylatedCcountPerGroup(currentContext,indexGroup1),counter.getMethylatedCCountPerGroup(currentContext,indexGroup1),counter.getUnmethylatedCcountPerGroup(currentContext,indexGroup2),counter.getMethylatedCCountPerGroup(currentContext,indexGroup2)) : Double.NaN;
          }
 else {
            LOG.error(String.format("String_Node_Str" + "String_Node_Str" + "String_Node_Str",counter.getUnmethylatedCcountPerGroup(currentContext,indexGroup1),counter.getMethylatedCCountPerGroup(currentContext,indexGroup1),counter.getUnmethylatedCcountPerGroup(currentContext,indexGroup2),counter.getMethylatedCCountPerGroup(currentContext,indexGroup2)));
          }
          lineToOutput.append("String_Node_Str");
          lineToOutput.append(formatDouble(fisherP));
        }
      }
      for (int currentContext=0; currentContext < contexts.length; currentContext++) {
        for (        final GroupComparison comparison : groupComparisons) {
          final int indexGroup1=comparison.indexGroup1;
          final int indexGroup2=comparison.indexGroup2;
          final double deltaMR=Math.abs(counter.getMethylationRatePerGroup(currentContext,indexGroup1) - counter.getMethylationRatePerGroup(currentContext,indexGroup2));
          lineToOutput.append("String_Node_Str");
          lineToOutput.append(formatDouble(deltaMR));
        }
      }
      if (estimateIntraGroupDifferences) {
        obsWriter.setTypeOfPair(ObservationWriter.TypeOfPair.WITHIN_GROUP_PAIR);
        for (int currentContext=0; currentContext < contexts.length; currentContext++) {
          identifiers[0]=contexts[currentContext];
          int groupIndex=0;
          for (          String group : groups) {
            empiricalPValueEstimator.estimateNullDensity(currentContext,groupIndex,counter);
            groupIndex++;
          }
        }
      }
      if (estimateIntraGroupP) {
        obsWriter.setTypeOfPair(ObservationWriter.TypeOfPair.BETWEEN_GROUP_PAIR);
        for (int contextIndex=0; contextIndex < contexts.length; contextIndex++) {
          identifiers[0]=contexts[contextIndex];
          for (          final GroupComparison comparison : groupComparisons) {
            obsWriter.setComparison(comparison);
            final double p=empiricalPValueEstimator.estimateEmpiricalPValue(contextIndex,comparison,counter);
            lineToOutput.append("String_Node_Str");
            lineToOutput.append(formatDouble(p));
          }
        }
      }
      outputWriter.append(lineToOutput.toString());
      outputWriter.append("String_Node_Str");
      counterMap.remove(anno);
    }
 catch (    IOException e) {
      throw new RuntimeException(e);
    }
  }
}