Program: 37719
Project: 37719
Buggy source:
public static void identifyUnconstrainedNegativeBinomialPoints(SAMFileReader sfr,String chr,int start,int end,int maxBins,int binSize,int minCP,Strandedness strandedness,boolean isNegativeStrand,double alpha_0,double beta_0,int nb_r,int r,double p,double min_fold,int confidence_interval,GTFWriter gw){
  int l=end - start + 1;
  int nBins=(l + binSize - 1) / binSize;
  StrandedGenomicIntervalTree<Map<String,Object>> changePoints=new StrandedGenomicIntervalTree<Map<String,Object>>();
  char strand=isNegativeStrand ? '-' : '+';
  if (nBins > maxBins) {
    nBins=maxBins;
    binSize=(l + maxBins - 1) / maxBins;
    logger.info("String_Node_Str",chr,start,end,strand,binSize);
  }
  int[] cov=BAMTools.binnedMaxEndCoverage(sfr,chr,start,nBins,binSize,false,true,strandedness,isNegativeStrand);
  double[] y=new double[nBins];
  for (int i=0; i < nBins; i++) {
    y[i]=cov[i];
  }
  SegmentationResult segmentation=IdentifyConstrainedChangePoints.fold_constrained_segmentation(y,alpha_0,beta_0,nb_r,r,p,min_fold);
  PrefixSuffixResult prefix_suffix=IdentifyConstrainedChangePoints.prefix_suffix(y,alpha_0,beta_0,nb_r,r,p);
  ConfidenceCalculator cc=new ConfidenceCalculator(prefix_suffix);
  if (segmentation.n_segments > 1) {
    double[] segment_mle=segmentation.segment_mle;
    int[] changepoints=segmentation.change_point;
    for (int i=0; i < changepoints.length; i++) {
      int changepoint_i=changepoints[i];
      if (segment_mle[i] < segment_mle[i + 1]) {
        changepoint_i++;
      }
      if (changepoints[i] > minCP && changepoints[i] < nBins - minCP - 1) {
        int position=start + (changepoint_i * binSize) + (binSize / 2);
        if (position > start && position < end) {
          Map<String,Object> attributes=new HashMap<String,Object>();
          attributes.put("String_Node_Str",segment_mle[i]);
          attributes.put("String_Node_Str",segment_mle[i + 1]);
          attributes.put("String_Node_Str","String_Node_Str");
          ConfidenceResult cr=cc.calculateConfidence(Math.max(changepoint_i - confidence_interval,0),Math.min(changepoint_i + 1 + confidence_interval,prefix_suffix.l - 2));
          attributes.put("String_Node_Str",Util.sprintf("String_Node_Str",Math.exp(cr.log_confidence)));
          attributes.put("String_Node_Str",Util.sprintf("String_Node_Str",cr.log_odds));
          changePoints.add(chr,position,position,strand,attributes);
          gw.write("String_Node_Str",chr,position,position,strand,AnnotatedRegion.GTFAttributeString(attributes));
        }
      }
    }
  }
}

Fixed version (ground truth):
public static void identifyUnconstrainedNegativeBinomialPoints(SAMFileReader sfr,String chr,int start,int end,int maxBins,int binSize,int minCP,Strandedness strandedness,boolean isNegativeStrand,double alpha_0,double beta_0,int nb_r,int r,double p,double min_fold,GTFWriter gw){
  int l=end - start + 1;
  int nBins=(l + binSize - 1) / binSize;
  StrandedGenomicIntervalTree<Map<String,Object>> changePoints=new StrandedGenomicIntervalTree<Map<String,Object>>();
  char strand=isNegativeStrand ? '-' : '+';
  if (nBins > maxBins) {
    nBins=maxBins;
    binSize=(l + maxBins - 1) / maxBins;
    logger.info("String_Node_Str",chr,start,end,strand,binSize);
  }
  int[] cov=BAMTools.binnedMaxEndCoverage(sfr,chr,start,nBins,binSize,false,true,strandedness,isNegativeStrand);
  double[] y=new double[nBins];
  for (int i=0; i < nBins; i++) {
    y[i]=cov[i];
  }
  SegmentationResult segmentation=IdentifyConstrainedChangePoints.fold_constrained_segmentation(y,alpha_0,beta_0,nb_r,r,p,min_fold);
  PrefixSuffixResult prefix_suffix=IdentifyConstrainedChangePoints.prefix_suffix(y,alpha_0,beta_0,nb_r,r,p);
  ConfidenceCalculator cc=new ConfidenceCalculator(prefix_suffix);
  if (segmentation.n_segments > 1) {
    double[] segment_mle=segmentation.segment_mle;
    int[] changepoints=segmentation.change_point;
    for (int i=0; i < changepoints.length; i++) {
      int changepoint_i=changepoints[i];
      if (segment_mle[i] < segment_mle[i + 1]) {
        changepoint_i++;
      }
      if (changepoints[i] > minCP && changepoints[i] < nBins - minCP - 1) {
        int position=start + (changepoint_i * binSize) + (binSize / 2);
        if (position > start && position < end) {
          Map<String,Object> attributes=new HashMap<String,Object>();
          attributes.put("String_Node_Str",segment_mle[i]);
          attributes.put("String_Node_Str",segment_mle[i + 1]);
          attributes.put("String_Node_Str","String_Node_Str");
          ConfidenceResult cr=cc.calculateConfidence(changepoints[i]);
          attributes.put("String_Node_Str",Util.sprintf("String_Node_Str",Math.exp(cr.log_confidence)));
          attributes.put("String_Node_Str",Util.sprintf("String_Node_Str",cr.log_odds));
          changePoints.add(chr,position,position,strand,attributes);
          gw.write("String_Node_Str",chr,position,position,strand,AnnotatedRegion.GTFAttributeString(attributes));
        }
      }
    }
  }
}