Program: 37724
Project: 37724
Buggy source:
public static void filterChangePoints(SAMFileReader sfr,File spliced_exon_gtf,File intronic_exon_gtf,File acc_jnct_gtf,File changepoint_gtf,GTFWriter filtered_changepoint_writer,int sj_radius) throws FileNotFoundException {
  StrandedGenomicIntervalTree<Map<String,Object>> continuousSegments=new StrandedGenomicIntervalTree<Map<String,Object>>();
  TranscriptIterator bi=new TranscriptIterator(acc_jnct_gtf);
  StrandedGenomicIntervalTree<Map<String,Object>> sj=IntervalTools.buildRegionsTree(bi,true,false);
  StrandedGenomicIntervalTree<Map<String,Object>> sj5p=IntervalTools.buildTerminiTree(sj,true,true,false);
  StrandedGenomicIntervalTree<Map<String,Object>> sj3p=IntervalTools.buildTerminiTree(sj,false,true,false);
  for (  File gtf : Util.list(spliced_exon_gtf,intronic_exon_gtf)) {
    TranscriptIterator ti=new TranscriptIterator(gtf);
    for (    AnnotatedRegion segment : ti) {
      SegmentFragmenter.add(continuousSegments,segment.chr,segment.start,segment.end,segment.strand);
    }
  }
  StrandedGenomicIntervalTree<Map<String,Object>> ends5p=new StrandedGenomicIntervalTree<Map<String,Object>>();
  StrandedGenomicIntervalTree<Map<String,Object>> ends3p=new StrandedGenomicIntervalTree<Map<String,Object>>();
  TranscriptIterator ti=new TranscriptIterator(changepoint_gtf);
  for (  AnnotatedRegion cp : ti) {
    double before_mle=Double.parseDouble((String)cp.getAttribute("String_Node_Str"));
    double after_mle=Double.parseDouble((String)cp.getAttribute("String_Node_Str"));
    boolean isEnd5p=before_mle < after_mle ^ cp.isNegativeStrand();
    if (isEnd5p && !ends5p.contains(cp.chr,cp.start,cp.end,cp.strand) && !sj3p.overlappingRegions(cp.chr,cp.start - sj_radius,cp.end + sj_radius,cp.strand).iterator().hasNext()) {
      ends5p.add(cp.chr,cp.start,cp.end,cp.strand,cp.attributes);
    }
    if (!isEnd5p && !ends3p.contains(cp.chr,cp.start,cp.end,cp.strand) && !sj5p.overlappingRegions(cp.chr,cp.start - sj_radius,cp.end + sj_radius,cp.strand).iterator().hasNext()) {
      ends3p.add(cp.chr,cp.start,cp.end,cp.strand,cp.attributes);
    }
  }
  Comparator<AnnotatedRegion> descending_order=new Comparator<AnnotatedRegion>(){
    public int compare(    AnnotatedRegion arg0,    AnnotatedRegion arg1){
      return arg0.start < arg1.start ? 1 : arg0.start > arg1.start ? -1 : 0;
    }
  }
;
  Comparator<AnnotatedRegion> ascending_order=new Comparator<AnnotatedRegion>(){
    public int compare(    AnnotatedRegion arg0,    AnnotatedRegion arg1){
      return arg0.start < arg1.start ? -1 : arg0.start > arg1.start ? 1 : 0;
    }
  }
;
  for (  AnnotatedRegion segment : continuousSegments) {
{
      Comparator<AnnotatedRegion> c=segment.isNegativeStrand() ? ascending_order : descending_order;
      String attribute=segment.isNegativeStrand() ? "String_Node_Str" : "String_Node_Str";
      List<AnnotatedRegion> to_delete=new LinkedList<AnnotatedRegion>();
      List<AnnotatedRegion> overlapping3p=IntervalTools.OverlappingIntervals(ends3p,segment.chr,segment.start,segment.end,segment.strand);
      Collections.sort(overlapping3p,c);
      double max_mle=0;
      for (      AnnotatedRegion end : overlapping3p) {
        double mle=Double.parseDouble((String)end.getAttribute(attribute));
        if (mle > max_mle) {
          max_mle=Math.max(mle,max_mle);
        }
 else {
          to_delete.add(end);
        }
      }
      for (      AnnotatedRegion end : to_delete) {
        ends3p.remove(end.chr,end.start,end.end,end.strand);
      }
    }
{
      Comparator<AnnotatedRegion> c=segment.isNegativeStrand() ? descending_order : ascending_order;
      String attribute=segment.isNegativeStrand() ? "String_Node_Str" : "String_Node_Str";
      List<AnnotatedRegion> to_delete=new LinkedList<AnnotatedRegion>();
      List<AnnotatedRegion> overlapping5p=IntervalTools.OverlappingIntervals(ends5p,segment.chr,segment.start,segment.end,segment.strand);
      Collections.sort(overlapping5p,c);
      double max_mle=0;
      for (      AnnotatedRegion end : overlapping5p) {
        double mle=Double.parseDouble((String)end.getAttribute(attribute));
        if (mle > max_mle) {
          max_mle=Math.max(mle,max_mle);
        }
 else {
          to_delete.add(end);
        }
      }
      for (      AnnotatedRegion end : to_delete) {
        ends5p.remove(end.chr,end.start,end.end,end.strand);
      }
    }
  }
  for (  AnnotatedRegion end : ends3p) {
    filtered_changepoint_writer.write("String_Node_Str",end.chr,end.start,end.start,end.strand,AnnotatedRegion.GTFAttributeString(end.attributes));
  }
  for (  AnnotatedRegion end : ends5p) {
    filtered_changepoint_writer.write("String_Node_Str",end.chr,end.start,end.start,end.strand,AnnotatedRegion.GTFAttributeString(end.attributes));
  }
}

Fixed version (ground truth):
public static void filterChangePoints(SAMFileReader sfr,File spliced_exon_gtf,File intronic_exon_gtf,File acc_jnct_gtf,File changepoint_gtf,GTFWriter filtered_changepoint_writer,int sj_radius) throws FileNotFoundException {
  StrandedGenomicIntervalTree<Map<String,Object>> continuousSegments=new StrandedGenomicIntervalTree<Map<String,Object>>();
  TranscriptIterator bi=new TranscriptIterator(acc_jnct_gtf);
  StrandedGenomicIntervalTree<Map<String,Object>> sj=IntervalTools.buildRegionsTree(bi,true,false);
  StrandedGenomicIntervalTree<Map<String,Object>> sj5p=IntervalTools.buildTerminiTree(sj,true,true,false);
  StrandedGenomicIntervalTree<Map<String,Object>> sj3p=IntervalTools.buildTerminiTree(sj,false,true,false);
  for (  File gtf : Util.list(spliced_exon_gtf,intronic_exon_gtf)) {
    TranscriptIterator ti=new TranscriptIterator(gtf);
    for (    AnnotatedRegion segment : ti) {
      SegmentFragmenter.add(continuousSegments,segment.chr,segment.start,segment.end,segment.strand);
    }
  }
  StrandedGenomicIntervalTree<Map<String,Object>> ends5p=new StrandedGenomicIntervalTree<Map<String,Object>>();
  StrandedGenomicIntervalTree<Map<String,Object>> ends3p=new StrandedGenomicIntervalTree<Map<String,Object>>();
  TranscriptIterator ti=new TranscriptIterator(changepoint_gtf);
  for (  AnnotatedRegion cp : ti) {
    double before_mle=Double.parseDouble((String)cp.getAttribute("String_Node_Str"));
    double after_mle=Double.parseDouble((String)cp.getAttribute("String_Node_Str"));
    boolean isEnd5p=before_mle < after_mle ^ cp.isNegativeStrand();
    if (isEnd5p && !ends5p.contains(cp.chr,cp.start,cp.end,cp.strand) && !sj3p.overlappingRegions(cp.chr,cp.start - sj_radius,cp.end + sj_radius,cp.strand).iterator().hasNext()) {
      ends5p.add(cp.chr,cp.start,cp.end,cp.strand,cp.attributes);
    }
    if (!isEnd5p && !ends3p.contains(cp.chr,cp.start,cp.end,cp.strand) && !sj5p.overlappingRegions(cp.chr,cp.start - sj_radius,cp.end + sj_radius,cp.strand).iterator().hasNext()) {
      ends3p.add(cp.chr,cp.start,cp.end,cp.strand,cp.attributes);
    }
  }
  Comparator<AnnotatedRegion> descending_order=new Comparator<AnnotatedRegion>(){
    public int compare(    AnnotatedRegion arg0,    AnnotatedRegion arg1){
      return arg0.start < arg1.start ? 1 : arg0.start > arg1.start ? -1 : 0;
    }
  }
;
  Comparator<AnnotatedRegion> ascending_order=new Comparator<AnnotatedRegion>(){
    public int compare(    AnnotatedRegion arg0,    AnnotatedRegion arg1){
      return arg0.start < arg1.start ? -1 : arg0.start > arg1.start ? 1 : 0;
    }
  }
;
  for (  AnnotatedRegion segment : continuousSegments) {
{
      Comparator<AnnotatedRegion> c=segment.isNegativeStrand() ? ascending_order : descending_order;
      String attribute=segment.isNegativeStrand() ? "String_Node_Str" : "String_Node_Str";
      List<AnnotatedRegion> to_delete=new ArrayList<AnnotatedRegion>();
      List<AnnotatedRegion> overlapping3p=IntervalTools.OverlappingIntervals(ends3p,segment.chr,segment.start,segment.end,segment.strand);
      Collections.sort(overlapping3p,c);
      double max_mle=0;
      for (      AnnotatedRegion end : overlapping3p) {
        double mle=Double.parseDouble((String)end.getAttribute(attribute));
        if (mle > max_mle) {
          max_mle=Math.max(mle,max_mle);
        }
 else {
          to_delete.add(end);
        }
      }
      for (      AnnotatedRegion end : to_delete) {
        ends3p.remove(end.chr,end.start,end.end,end.strand);
      }
    }
{
      Comparator<AnnotatedRegion> c=segment.isNegativeStrand() ? descending_order : ascending_order;
      String attribute=segment.isNegativeStrand() ? "String_Node_Str" : "String_Node_Str";
      List<AnnotatedRegion> to_delete=new ArrayList<AnnotatedRegion>();
      List<AnnotatedRegion> overlapping5p=IntervalTools.OverlappingIntervals(ends5p,segment.chr,segment.start,segment.end,segment.strand);
      Collections.sort(overlapping5p,c);
      double max_mle=0;
      for (      AnnotatedRegion end : overlapping5p) {
        double mle=Double.parseDouble((String)end.getAttribute(attribute));
        if (mle > max_mle) {
          max_mle=Math.max(mle,max_mle);
        }
 else {
          to_delete.add(end);
        }
      }
      for (      AnnotatedRegion end : to_delete) {
        ends5p.remove(end.chr,end.start,end.end,end.strand);
      }
    }
  }
  for (  AnnotatedRegion end : ends3p) {
    filtered_changepoint_writer.write("String_Node_Str",end.chr,end.start,end.start,end.strand,AnnotatedRegion.GTFAttributeString(end.attributes));
  }
  for (  AnnotatedRegion end : ends5p) {
    filtered_changepoint_writer.write("String_Node_Str",end.chr,end.start,end.start,end.strand,AnnotatedRegion.GTFAttributeString(end.attributes));
  }
}