Program: 50256
Project: 50256
Buggy source:
private void writeAnnotationCounts(final Object2ObjectMap<String,ObjectList<Annotation>> allAnnots,final BufferedWriter writer,final String inputBasename,final DoubleIndexedIdentifier referenceIds,final AnnotationCountInterface[] algs,final IntSet referencesToProcess) throws IOException {
  if (doComparison) {
    int numberOfElements=0;
    int numberOfGenes=0;
    int numberOfExons=0;
    int numberOfIntrons=0;
    for (    final int referenceIndex : referencesToProcess) {
      final String chromosomeName=referenceIds.getId(referenceIndex).toString();
      if (!allAnnots.containsKey(chromosomeName)) {
        continue;
      }
      final ObjectList<Annotation> annots=allAnnots.get(chromosomeName);
      for (      final Annotation annot : annots) {
        final String geneID=annot.getId();
        final int numExons=annot.getSegments().size();
        final int numberIntrons=numExons - 1;
        if (includeAnnotationTypes.contains("String_Node_Str")) {
          final int index=deCalculator.defineElement(geneID,DifferentialExpressionCalculator.ElementType.GENE);
          deCalculator.defineElementLength(index,annot.getLength());
          numberOfGenes++;
          numberOfElements++;
        }
        if (includeAnnotationTypes.contains("String_Node_Str")) {
          for (int i=0; i < numExons; i++) {
            final Segment exonSegment=annot.getSegments().get(i);
            final String exonID=exonSegment.getId();
            final int index=deCalculator.defineElement(exonID,DifferentialExpressionCalculator.ElementType.EXON);
            deCalculator.defineElementLength(index,annot.getLength());
            numberOfExons++;
            numberOfElements++;
          }
        }
        if (includeAnnotationTypes.contains("String_Node_Str")) {
          for (int i=0; i < numExons; i++) {
            if (i < numberIntrons) {
              final Segment segment=annot.getSegments().get(i);
              final int intronStart=segment.getEnd() + 1;
              final Segment intronSegment=annot.getSegments().get(i + 1);
              final int intronEnd=intronSegment.getStart() - 1;
              final int intronLength=intronEnd - intronStart + 1;
              final String intronID=segment.getId() + "String_Node_Str" + intronSegment.getId();
              final int index=deCalculator.defineElement(intronID,DifferentialExpressionCalculator.ElementType.OTHER);
              deCalculator.defineElementLength(index,intronLength);
              numberOfIntrons++;
              numberOfElements++;
            }
          }
        }
      }
    }
    LOG.info(String.format("String_Node_Str",numberOfGenes,numberOfExons,numberOfIntrons,numberOfElements));
    deCalculator.reserve(numberOfElements,inputFilenames.length);
  }
  int numberOfAnnotationCountsWritten=0;
  for (  final int referenceIndex : referencesToProcess) {
    final String chromosomeName=referenceIds.getId(referenceIndex).toString();
    System.out.println("String_Node_Str" + chromosomeName);
    if (!allAnnots.containsKey(chromosomeName)) {
      continue;
    }
    final ObjectList<Annotation> annots=allAnnots.get(chromosomeName);
    algs[referenceIndex].sortReads();
    algs[referenceIndex].accumulate();
    algs[referenceIndex].baseCount();
    if (doComparison) {
      for (      final Annotation annot : annots) {
        final String geneID=annot.getId();
        deCalculator.defineElement(geneID);
      }
    }
    final String basename=FilenameUtils.getBaseName(inputBasename);
    final String sampleId=basename;
    for (    final Annotation annot : annots) {
      final String geneID=annot.getId();
      if (includeAnnotationTypes.contains("String_Node_Str")) {
        final int geneStart=annot.getStart();
        final int geneEnd=annot.getEnd();
        final int geneLength=geneEnd - geneStart + 1;
        final float geneDepth=algs[referenceIndex].averageReadsPerPosition(geneStart,geneEnd);
        final double geneOverlapReads=algs[referenceIndex].countReadsPartiallyOverlappingWithInterval(geneStart,geneEnd);
        final double geneInsideReads=algs[referenceIndex].countReadsStriclyWithinInterval(geneStart,geneEnd);
        final double geneExpression=algs[referenceIndex].geneExpressionCount(annot);
        final int numExons=annot.getSegments().size();
        final double geneRPKM=deCalculator.calculateNormalized(geneOverlapReads,annot.getLength(),deCalculator.getNumAlignedInSample(sampleId));
        if (writeAnnotationCounts) {
          writer.write(String.format("String_Node_Str",basename,geneID,"String_Node_Str","String_Node_Str",annot.getChromosome(),annot.getStrand(),geneLength,geneStart,geneEnd,geneInsideReads,geneOverlapReads,geneRPKM,log2(geneRPKM),geneExpression,numExons));
        }
        numberOfAnnotationCountsWritten++;
        if (doComparison) {
          deCalculator.observe(basename,geneID,geneExpression);
        }
      }
      final int numberExons=annot.getSegments().size();
      final int numberIntrons=numberExons - 1;
      if (includeAnnotationTypes.contains("String_Node_Str") || includeAnnotationTypes.contains("String_Node_Str")) {
        for (int i=0; i < numberExons; i++) {
          final Segment segment=annot.getSegments().get(i);
          final int exonStart=segment.getStart();
          final int exonEnd=segment.getEnd();
          final String exonStrand=segment.getStrand();
          final int exonLength=segment.getLength();
          final String exonID=segment.getId();
          final float exonDepth=algs[referenceIndex].averageReadsPerPosition(exonStart,exonEnd);
          final double exonOverlapReads=algs[referenceIndex].countReadsPartiallyOverlappingWithInterval(exonStart,exonEnd);
          final double exonInsideReads=algs[referenceIndex].countReadsStriclyWithinInterval(exonStart,exonEnd);
          final double exonRPKM=deCalculator.calculateNormalized(exonOverlapReads,segment.getLength(),deCalculator.getNumAlignedInSample(sampleId));
          if (includeAnnotationTypes.contains("String_Node_Str")) {
            if (writeAnnotationCounts) {
              writer.write(String.format("String_Node_Str",basename,geneID,exonID,"String_Node_Str",annot.getChromosome(),exonStrand,exonLength,exonStart,exonEnd,exonInsideReads,exonOverlapReads,exonRPKM,log2(exonRPKM)));
            }
            numberOfAnnotationCountsWritten++;
            if (doComparison && includeAnnotationTypes.contains("String_Node_Str")) {
              deCalculator.observe(basename,exonID,exonOverlapReads);
            }
          }
          if (i < numberIntrons) {
            final int intronStart=segment.getEnd() + 1;
            final Segment intronSegment=annot.getSegments().get(i + 1);
            final int intronEnd=intronSegment.getStart() - 1;
            final int intronLength=intronEnd - intronStart + 1;
            final String intronID=segment.getId() + "String_Node_Str" + intronSegment.getId();
            final float intronDepth=algs[referenceIndex].averageReadsPerPosition(intronStart,intronEnd);
            final double intronOverlapReads=algs[referenceIndex].countReadsPartiallyOverlappingWithInterval(intronStart,intronEnd);
            final double intronInsideReads=algs[referenceIndex].countReadsStriclyWithinInterval(intronStart,intronEnd);
            final double intronRPKM=deCalculator.calculateNormalized(intronOverlapReads,intronSegment.getLength(),deCalculator.getNumAlignedInSample(sampleId));
            if (intronLength > 0) {
              if (includeAnnotationTypes.contains("String_Node_Str")) {
                if (writeAnnotationCounts) {
                  writer.write(String.format("String_Node_Str",basename,geneID,intronID,"String_Node_Str",annot.getChromosome(),exonStrand,exonLength,exonStart,exonEnd,intronInsideReads,intronOverlapReads,intronRPKM,log2(intronRPKM)));
                }
                numberOfAnnotationCountsWritten++;
                if (doComparison && includeAnnotationTypes.contains("String_Node_Str")) {
                  deCalculator.observe(basename,intronID,intronOverlapReads);
                }
              }
            }
          }
        }
      }
    }
    algs[referenceIndex]=null;
  }
  LOG.info("String_Node_Str" + numberOfAnnotationCountsWritten + "String_Node_Str");
  if (numberOfAnnotationCountsWritten == 0) {
    LOG.warn("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
  }
}

Fixed version (ground truth):
private void writeAnnotationCounts(final Object2ObjectMap<String,ObjectList<Annotation>> allAnnots,final BufferedWriter writer,final String inputBasename,final DoubleIndexedIdentifier referenceIds,final AnnotationCountInterface[] algs,final IntSet referencesToProcess) throws IOException {
  if (doComparison) {
    int numberOfElements=0;
    int numberOfGenes=0;
    int numberOfExons=0;
    int numberOfIntrons=0;
    for (    final int referenceIndex : referencesToProcess) {
      final String chromosomeName=referenceIds.getId(referenceIndex).toString();
      if (!allAnnots.containsKey(chromosomeName)) {
        continue;
      }
      final ObjectList<Annotation> annots=allAnnots.get(chromosomeName);
      for (      final Annotation annot : annots) {
        final String geneID=annot.getId();
        final int numExons=annot.getSegments().size();
        final int numberIntrons=numExons - 1;
        if (includeAnnotationTypes.contains("String_Node_Str")) {
          final int index=deCalculator.defineElement(geneID,DifferentialExpressionCalculator.ElementType.GENE);
          deCalculator.defineElementLength(index,annot.getLength());
          numberOfGenes++;
          numberOfElements++;
        }
        if (includeAnnotationTypes.contains("String_Node_Str")) {
          for (int i=0; i < numExons; i++) {
            final Segment exonSegment=annot.getSegments().get(i);
            final String exonID=exonSegment.getId();
            final int index=deCalculator.defineElement(exonID,DifferentialExpressionCalculator.ElementType.EXON);
            deCalculator.defineElementLength(index,annot.getLength());
            numberOfExons++;
            numberOfElements++;
          }
        }
        if (includeAnnotationTypes.contains("String_Node_Str")) {
          for (int i=0; i < numExons; i++) {
            if (i < numberIntrons) {
              final Segment segment=annot.getSegments().get(i);
              final int intronStart=segment.getEnd() + 1;
              final Segment intronSegment=annot.getSegments().get(i + 1);
              final int intronEnd=intronSegment.getStart() - 1;
              final int intronLength=intronEnd - intronStart + 1;
              final String intronID=segment.getId() + "String_Node_Str" + intronSegment.getId();
              final int index=deCalculator.defineElement(intronID,DifferentialExpressionCalculator.ElementType.OTHER);
              deCalculator.defineElementLength(index,intronLength);
              numberOfIntrons++;
              numberOfElements++;
            }
          }
        }
      }
    }
    LOG.info(String.format("String_Node_Str",numberOfGenes,numberOfExons,numberOfIntrons,numberOfElements));
    deCalculator.reserve(numberOfElements,inputFilenames.length);
  }
  int numberOfAnnotationCountsWritten=0;
  for (  final int referenceIndex : referencesToProcess) {
    final String chromosomeName=referenceIds.getId(referenceIndex).toString();
    System.out.println("String_Node_Str" + chromosomeName);
    if (!allAnnots.containsKey(chromosomeName)) {
      continue;
    }
    final ObjectList<Annotation> annots=allAnnots.get(chromosomeName);
    algs[referenceIndex].sortReads();
    algs[referenceIndex].accumulate();
    algs[referenceIndex].baseCount();
    if (doComparison) {
      for (      final Annotation annot : annots) {
        final String geneID=annot.getId();
        deCalculator.defineElement(geneID);
      }
    }
    final String basename=FilenameUtils.getName(inputBasename);
    final String sampleId=inputBasename;
    for (    final Annotation annot : annots) {
      final String geneID=annot.getId();
      if (includeAnnotationTypes.contains("String_Node_Str")) {
        final int geneStart=annot.getStart();
        final int geneEnd=annot.getEnd();
        final int geneLength=geneEnd - geneStart + 1;
        final float geneDepth=algs[referenceIndex].averageReadsPerPosition(geneStart,geneEnd);
        final double geneOverlapReads=algs[referenceIndex].countReadsPartiallyOverlappingWithInterval(geneStart,geneEnd);
        final double geneInsideReads=algs[referenceIndex].countReadsStriclyWithinInterval(geneStart,geneEnd);
        final double geneExpression=algs[referenceIndex].geneExpressionCount(annot);
        final int numExons=annot.getSegments().size();
        final double geneRPKM=deCalculator.calculateNormalized(geneOverlapReads,annot.getLength(),deCalculator.getNumAlignedInSample(sampleId));
        if (writeAnnotationCounts) {
          writer.write(String.format("String_Node_Str",basename,geneID,"String_Node_Str","String_Node_Str",annot.getChromosome(),annot.getStrand(),geneLength,geneStart,geneEnd,geneInsideReads,geneOverlapReads,geneRPKM,log2(geneRPKM),geneExpression,numExons));
        }
        numberOfAnnotationCountsWritten++;
        if (doComparison) {
          deCalculator.observe(basename,geneID,geneExpression);
        }
      }
      final int numberExons=annot.getSegments().size();
      final int numberIntrons=numberExons - 1;
      if (includeAnnotationTypes.contains("String_Node_Str") || includeAnnotationTypes.contains("String_Node_Str")) {
        for (int i=0; i < numberExons; i++) {
          final Segment segment=annot.getSegments().get(i);
          final int exonStart=segment.getStart();
          final int exonEnd=segment.getEnd();
          final String exonStrand=segment.getStrand();
          final int exonLength=segment.getLength();
          final String exonID=segment.getId();
          final float exonDepth=algs[referenceIndex].averageReadsPerPosition(exonStart,exonEnd);
          final double exonOverlapReads=algs[referenceIndex].countReadsPartiallyOverlappingWithInterval(exonStart,exonEnd);
          final double exonInsideReads=algs[referenceIndex].countReadsStriclyWithinInterval(exonStart,exonEnd);
          final double exonRPKM=deCalculator.calculateNormalized(exonOverlapReads,segment.getLength(),deCalculator.getNumAlignedInSample(sampleId));
          if (includeAnnotationTypes.contains("String_Node_Str")) {
            if (writeAnnotationCounts) {
              writer.write(String.format("String_Node_Str",basename,geneID,exonID,"String_Node_Str",annot.getChromosome(),exonStrand,exonLength,exonStart,exonEnd,exonInsideReads,exonOverlapReads,exonRPKM,log2(exonRPKM)));
            }
            numberOfAnnotationCountsWritten++;
            if (doComparison && includeAnnotationTypes.contains("String_Node_Str")) {
              deCalculator.observe(basename,exonID,exonOverlapReads);
            }
          }
          if (i < numberIntrons) {
            final int intronStart=segment.getEnd() + 1;
            final Segment intronSegment=annot.getSegments().get(i + 1);
            final int intronEnd=intronSegment.getStart() - 1;
            final int intronLength=intronEnd - intronStart + 1;
            final String intronID=segment.getId() + "String_Node_Str" + intronSegment.getId();
            final float intronDepth=algs[referenceIndex].averageReadsPerPosition(intronStart,intronEnd);
            final double intronOverlapReads=algs[referenceIndex].countReadsPartiallyOverlappingWithInterval(intronStart,intronEnd);
            final double intronInsideReads=algs[referenceIndex].countReadsStriclyWithinInterval(intronStart,intronEnd);
            final double intronRPKM=deCalculator.calculateNormalized(intronOverlapReads,intronSegment.getLength(),deCalculator.getNumAlignedInSample(sampleId));
            if (intronLength > 0) {
              if (includeAnnotationTypes.contains("String_Node_Str")) {
                if (writeAnnotationCounts) {
                  writer.write(String.format("String_Node_Str",basename,geneID,intronID,"String_Node_Str",annot.getChromosome(),exonStrand,exonLength,exonStart,exonEnd,intronInsideReads,intronOverlapReads,intronRPKM,log2(intronRPKM)));
                }
                numberOfAnnotationCountsWritten++;
                if (doComparison && includeAnnotationTypes.contains("String_Node_Str")) {
                  deCalculator.observe(basename,intronID,intronOverlapReads);
                }
              }
            }
          }
        }
      }
    }
    algs[referenceIndex]=null;
  }
  LOG.info("String_Node_Str" + numberOfAnnotationCountsWritten + "String_Node_Str");
  if (numberOfAnnotationCountsWritten == 0) {
    LOG.warn("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
  }
}