Program: 37723
Project: 37723
Buggy source:
public static List<ChangePoint> identifyConstrainedNegativeBinomialPoints(String[] ids,SAMFileReader[] sfrs,Strandedness[] strandednesses,String chr,int start,int end,int maxBins,int binSize,int minCP,boolean isNegativeStrand,double alpha_0,double beta_0,int nb_r,int r,double p,boolean constrain_decreasing,double min_fold){
  int l=end - start + 1;
  int nBins=(l + binSize - 1) / binSize;
  char strand=isNegativeStrand ? '-' : '+';
  if (nBins > maxBins) {
    nBins=maxBins;
    binSize=(l + maxBins - 1) / maxBins;
    System.out.printf("String_Node_Str",chr,start,end,strand,binSize);
  }
  List<ChangePoint> changePoints=new LinkedList<ChangePoint>();
  double[][] y=new double[sfrs.length][];
  for (int i=0; i < sfrs.length; i++) {
    int[] cov=BAMTools.binnedMaxEndCoverage(sfrs[i],chr,start,nBins,binSize,false,true,strandednesses[i],isNegativeStrand);
    y[i]=new double[nBins];
    for (int j=0; j < nBins; j++) {
      y[i][j]=cov[j];
    }
  }
  JointSegmentationResult segmentation=IdentifyConstrainedChangePoints.doubly_constrained_multi_segmentation(y,alpha_0,beta_0,nb_r,r,p,constrain_decreasing,min_fold);
  if (segmentation.n_segments > 1) {
    double[][] segment_mle=segmentation.segment_mle;
    int[] changepoints=segmentation.change_point;
    List<Integer> positions=new ArrayList<Integer>(segmentation.n_segments);
    List<double[]> before_mles=new ArrayList<double[]>(segmentation.n_segments);
    List<double[]> after_mles=new ArrayList<double[]>(segmentation.n_segments);
    StrandedGenomicIntervalTree<Map<String,Object>> segments=new StrandedGenomicIntervalTree<Map<String,Object>>();
    segments.add(chr,start,end,strand);
    for (int i=0; i < changepoints.length; i++) {
      int changepoint_i=changepoints[i];
      if (changepoints[i] > minCP && changepoints[i] < nBins - minCP - 1) {
        int position=start + (changepoint_i * binSize) + (binSize / 2);
        if (position >= start && position <= end) {
          positions.add(position);
          before_mles.add(segment_mle[i]);
          after_mles.add(segment_mle[i + 1]);
          SegmentFragmenter.fragment(segments,chr,position,strand,isNegativeStrand);
        }
      }
    }
    List<AnnotatedRegion> slist=new ArrayList<AnnotatedRegion>();
    for (    AnnotatedRegion s : segments) {
      slist.add(s);
    }
    for (int i=0; i < positions.size(); i++) {
      AnnotatedRegion before=slist.get(i);
      AnnotatedRegion after=slist.get(i + 1);
      AnnotatedRegion pos=new AnnotatedRegion("String_Node_Str",chr,positions.get(i),positions.get(i),strand);
      double[] before_mle=before_mles.get(i);
      double[] after_mle=after_mles.get(i);
      changePoints.add(new ChangePoint(pos,isNegativeStrand ? after : before,!isNegativeStrand ? after : before,ids,isNegativeStrand ? after_mle : before_mle,!isNegativeStrand ? after_mle : before_mle));
    }
  }
  return changePoints;
}

Fixed version (ground truth):
public static List<ChangePoint> identifyConstrainedNegativeBinomialPoints(String[] ids,SAMFileReader[] sfrs,Strandedness[] strandednesses,String chr,int start,int end,int maxBins,int binSize,int minCP,boolean isNegativeStrand,double alpha_0,double beta_0,int nb_r,int r,double p,boolean constrain_decreasing,double min_fold){
  int l=end - start + 1;
  int nBins=(l + binSize - 1) / binSize;
  char strand=isNegativeStrand ? '-' : '+';
  if (nBins > maxBins) {
    nBins=maxBins;
    binSize=(l + maxBins - 1) / maxBins;
    System.out.printf("String_Node_Str",chr,start,end,strand,binSize);
  }
  List<ChangePoint> changePoints=new ArrayList<ChangePoint>();
  double[][] y=new double[sfrs.length][];
  for (int i=0; i < sfrs.length; i++) {
    int[] cov=BAMTools.binnedMaxEndCoverage(sfrs[i],chr,start,nBins,binSize,false,true,strandednesses[i],isNegativeStrand);
    y[i]=new double[nBins];
    for (int j=0; j < nBins; j++) {
      y[i][j]=cov[j];
    }
  }
  JointSegmentationResult segmentation=IdentifyConstrainedChangePoints.doubly_constrained_multi_segmentation(y,alpha_0,beta_0,nb_r,r,p,constrain_decreasing,min_fold);
  if (segmentation.n_segments > 1) {
    double[][] segment_mle=segmentation.segment_mle;
    int[] changepoints=segmentation.change_point;
    List<Integer> positions=new ArrayList<Integer>(segmentation.n_segments);
    List<double[]> before_mles=new ArrayList<double[]>(segmentation.n_segments);
    List<double[]> after_mles=new ArrayList<double[]>(segmentation.n_segments);
    StrandedGenomicIntervalTree<Map<String,Object>> segments=new StrandedGenomicIntervalTree<Map<String,Object>>();
    segments.add(chr,start,end,strand);
    for (int i=0; i < changepoints.length; i++) {
      int changepoint_i=changepoints[i];
      if (changepoints[i] > minCP && changepoints[i] < nBins - minCP - 1) {
        int position=start + (changepoint_i * binSize) + (binSize / 2);
        if (position >= start && position <= end) {
          positions.add(position);
          before_mles.add(segment_mle[i]);
          after_mles.add(segment_mle[i + 1]);
          SegmentFragmenter.fragment(segments,chr,position,strand,isNegativeStrand);
        }
      }
    }
    List<AnnotatedRegion> slist=new ArrayList<AnnotatedRegion>();
    for (    AnnotatedRegion s : segments) {
      slist.add(s);
    }
    for (int i=0; i < positions.size(); i++) {
      AnnotatedRegion before=slist.get(i);
      AnnotatedRegion after=slist.get(i + 1);
      AnnotatedRegion pos=new AnnotatedRegion("String_Node_Str",chr,positions.get(i),positions.get(i),strand);
      double[] before_mle=before_mles.get(i);
      double[] after_mle=after_mles.get(i);
      changePoints.add(new ChangePoint(pos,isNegativeStrand ? after : before,!isNegativeStrand ? after : before,ids,isNegativeStrand ? after_mle : before_mle,!isNegativeStrand ? after_mle : before_mle));
    }
  }
  return changePoints;
}