Program: 50414
Project: 50414
Buggy source:
private void process(DoubleList methylationRates,CharSequence segmentBases) throws IOException {
  PrintWriter writer=new PrintWriter(new FileWriter(outputFilename));
  final String trueRateFilenam=FilenameUtils.removeExtension(outputFilename) + "String_Node_Str";
  PrintWriter trueRateWriter=new PrintWriter(new FileWriter(trueRateFilenam));
  methylationForward=new Int2DoubleOpenHashMap();
  methylationReverse=new Int2DoubleOpenHashMap();
  final int segmentLength=segmentBases.length();
  DoubleIterator it=methylationRates.iterator();
  for (int i=0; i < segmentBases.length(); i++) {
    if (segmentBases.charAt(i) == 'C') {
      if (!it.hasNext()) {
        it=methylationRates.iterator();
      }
      methylationForward.put(i,it.nextDouble());
      trueRateWriter.printf("String_Node_Str",i,methylationForward.get(i));
    }
  }
  it=methylationRates.iterator();
  CharSequence reverseStrandSegment=reverseComplement(segmentBases);
  for (int i=reverseStrandSegment.length() - 1; i >= 0; i--) {
    if (reverseStrandSegment.charAt(i) == 'C') {
      if (!it.hasNext()) {
        it=methylationRates.iterator();
      }
      final int positionInSegment=i;
      methylationReverse.put(positionInSegment,it.nextDouble());
      trueRateWriter.printf("String_Node_Str",positionInSegment,methylationReverse.get(positionInSegment));
    }
  }
  for (int repeatCount=0; repeatCount < 10000; repeatCount++) {
    int startReadPosition=choose(0,segmentBases.length() - 1 - readLength);
    boolean matchedReverseStrand=random.nextBoolean();
    final CharSequence selectedReadRegion=segmentBases.subSequence(startReadPosition,startReadPosition + readLength);
    CharSequence readBases=matchedReverseStrand ? reverseComplement(selectedReadRegion) : selectedReadRegion;
    MutableString sequenceInitial=new MutableString();
    MutableString sequenceTreated=new MutableString();
    MutableString log=new MutableString();
    for (int i=0; i < readLength; i++) {
      final int basePositionInSegment=i;
      char base=readBases.charAt(basePositionInSegment);
      sequenceInitial.append(base);
      if (base == 'C') {
        boolean isBaseMethylated=random.nextDouble() < getMethylationRateAtPosition(segmentLength,matchedReverseStrand,i,startReadPosition);
        if (!isBaseMethylated) {
          base='T';
        }
 else {
          log.append("String_Node_Str");
          log.append(i + startReadPosition);
          log.append(' ');
        }
      }
      sequenceTreated.append(base);
    }
    writer.printf("String_Node_Str",repeatCount,refChoice,startReadPosition,matchedReverseStrand ? "String_Node_Str" : "String_Node_Str",log,sequenceTreated);
  }
  writer.close();
  trueRateWriter.close();
}

Fixed version (ground truth):
private void process(DoubleList methylationRates,CharSequence segmentBases,int from) throws IOException {
  PrintWriter writer=new PrintWriter(new FileWriter(outputFilename));
  final String trueRateFilename=FilenameUtils.removeExtension(outputFilename) + "String_Node_Str";
  PrintWriter trueRateWriter=new PrintWriter(new FileWriter(trueRateFilename));
  methylationForward=new Int2DoubleOpenHashMap();
  methylationReverse=new Int2DoubleOpenHashMap();
  final int segmentLength=segmentBases.length();
  DoubleIterator it=methylationRates.iterator();
  for (int i=0; i < segmentBases.length(); i++) {
    if (segmentBases.charAt(i) == 'C') {
      if (!it.hasNext()) {
        it=methylationRates.iterator();
      }
      methylationForward.put(i,it.nextDouble());
      trueRateWriter.printf("String_Node_Str",i,methylationForward.get(i),i + from);
    }
  }
  it=methylationRates.iterator();
  CharSequence reverseStrandSegment=reverseComplement(segmentBases);
  for (int i=reverseStrandSegment.length() - 1; i >= 0; i--) {
    if (reverseStrandSegment.charAt(i) == 'C') {
      if (!it.hasNext()) {
        it=methylationRates.iterator();
      }
      final int positionInSegment=i;
      methylationReverse.put(positionInSegment,it.nextDouble());
      trueRateWriter.printf("String_Node_Str",positionInSegment,methylationReverse.get(positionInSegment),i + from);
    }
  }
  for (int repeatCount=0; repeatCount < 10000; repeatCount++) {
    int startReadPosition=choose(0,segmentBases.length() - 1 - readLength);
    boolean matchedReverseStrand=random.nextBoolean();
    final CharSequence selectedReadRegion=segmentBases.subSequence(startReadPosition,startReadPosition + readLength);
    CharSequence readBases=matchedReverseStrand ? reverseComplement(selectedReadRegion) : selectedReadRegion;
    MutableString sequenceInitial=new MutableString();
    MutableString sequenceTreated=new MutableString();
    MutableString log=new MutableString();
    for (int i=0; i < readLength; i++) {
      final int basePositionInSegment=i;
      char base=readBases.charAt(basePositionInSegment);
      sequenceInitial.append(base);
      if (base == 'C') {
        final boolean b=random.nextDouble() < getMethylationRateAtPosition(segmentLength,matchedReverseStrand,i,startReadPosition);
        boolean isBaseMethylated=b;
        if (!isBaseMethylated) {
          if (bisulfiteTreatment) {
            base='T';
          }
 else {
            base='C';
          }
        }
 else {
          log.append(bisulfiteTreatment ? "String_Node_Str" : "String_Node_Str");
          log.append(i + startReadPosition + from);
          log.append(' ');
          log.append("String_Node_Str");
          log.append(matchedReverseStrand ? readLength - i : i);
          log.append(' ');
          base=matchedReverseStrand ? 'C' : 'G';
        }
      }
      sequenceTreated.append(base);
    }
    MutableString coveredPositions=new MutableString();
    MutableString qualityScores=new MutableString();
    for (int i=0; i < readLength; i++) {
      final char c=QualityEncoding.ILLUMINA.phredQualityScoreToAsciiEncoding((byte)40);
      qualityScores.append(c);
    }
    for (int i=startReadPosition + from; i < startReadPosition + from + readLength; i++) {
      coveredPositions.append(i);
      coveredPositions.append("String_Node_Str");
    }
    writer.printf("String_Node_Str",repeatCount,refChoice,startReadPosition,matchedReverseStrand ? "String_Node_Str" : "String_Node_Str",log,coveredPositions,sequenceTreated,qualityScores);
  }
  writer.close();
  trueRateWriter.close();
}